Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: gdb/target-descriptions.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/target-descriptions.h ('k') | gdb/target-memory.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
None
OLDNEW
1 /* Target description support for GDB. 1 /* Target description support for GDB.
2 2
3 Copyright (C) 2006-2012 Free Software Foundation, Inc. 3 Copyright (C) 2006-2013 Free Software Foundation, Inc.
4 4
5 Contributed by CodeSourcery. 5 Contributed by CodeSourcery.
6 6
7 This file is part of GDB. 7 This file is part of GDB.
8 8
9 This program is free software; you can redistribute it and/or modify 9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or 11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version. 12 (at your option) any later version.
13 13
(...skipping 13 matching lines...) Expand all
27 #include "target.h" 27 #include "target.h"
28 #include "target-descriptions.h" 28 #include "target-descriptions.h"
29 #include "vec.h" 29 #include "vec.h"
30 #include "xml-support.h" 30 #include "xml-support.h"
31 #include "xml-tdesc.h" 31 #include "xml-tdesc.h"
32 #include "osabi.h" 32 #include "osabi.h"
33 33
34 #include "gdb_assert.h" 34 #include "gdb_assert.h"
35 #include "gdb_obstack.h" 35 #include "gdb_obstack.h"
36 #include "hashtab.h" 36 #include "hashtab.h"
37 #include "inferior.h"
37 38
38 /* Types. */ 39 /* Types. */
39 40
40 typedef struct property 41 typedef struct property
41 { 42 {
42 char *key; 43 char *key;
43 char *value; 44 char *value;
44 } property_s; 45 } property_s;
45 DEF_VEC_O(property_s); 46 DEF_VEC_O(property_s);
46 47
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 numbering). */ 225 numbering). */
225 VEC(tdesc_arch_reg) *arch_regs; 226 VEC(tdesc_arch_reg) *arch_regs;
226 227
227 /* Functions which report the register name, type, and reggroups for 228 /* Functions which report the register name, type, and reggroups for
228 pseudo-registers. */ 229 pseudo-registers. */
229 gdbarch_register_name_ftype *pseudo_register_name; 230 gdbarch_register_name_ftype *pseudo_register_name;
230 gdbarch_register_type_ftype *pseudo_register_type; 231 gdbarch_register_type_ftype *pseudo_register_type;
231 gdbarch_register_reggroup_p_ftype *pseudo_register_reggroup_p; 232 gdbarch_register_reggroup_p_ftype *pseudo_register_reggroup_p;
232 }; 233 };
233 234
234 /* Global state. These variables are associated with the current 235 /* Info about an inferior's target description. There's one of these
235 target; if GDB adds support for multiple simultaneous targets, then 236 for each inferior. */
236 these variables should become target-specific data. */
237 237
238 /* A flag indicating that a description has already been fetched from 238 struct target_desc_info
239 the current target, so it should not be queried again. */ 239 {
240 /* A flag indicating that a description has already been fetched
241 from the target, so it should not be queried again. */
240 242
241 static int target_desc_fetched; 243 int fetched;
242 244
243 /* The description fetched from the current target, or NULL if the 245 /* The description fetched from the target, or NULL if the target
244 current target did not supply any description. Only valid when 246 did not supply any description. Only valid when
245 target_desc_fetched is set. Only the description initialization 247 target_desc_fetched is set. Only the description initialization
246 code should access this; normally, the description should be 248 code should access this; normally, the description should be
247 accessed through the gdbarch object. */ 249 accessed through the gdbarch object. */
248 250
249 static const struct target_desc *current_target_desc; 251 const struct target_desc *tdesc;
250 252
251 /* Other global variables. */ 253 /* The filename to read a target description from, as set by "set
254 tdesc filename ..." */
252 255
253 /* The filename to read a target description from. */ 256 char *filename;
257 };
254 258
255 static char *target_description_filename; 259 /* Get the inferior INF's target description info, allocating one on
260 the stop if necessary. */
261
262 static struct target_desc_info *
263 get_tdesc_info (struct inferior *inf)
264 {
265 if (inf->tdesc_info == NULL)
266 inf->tdesc_info = XCNEW (struct target_desc_info);
267 return inf->tdesc_info;
268 }
256 269
257 /* A handle for architecture-specific data associated with the 270 /* A handle for architecture-specific data associated with the
258 target description (see struct tdesc_arch_data). */ 271 target description (see struct tdesc_arch_data). */
259 272
260 static struct gdbarch_data *tdesc_data; 273 static struct gdbarch_data *tdesc_data;
261 274
275 /* See target-descriptions.h. */
276
277 int
278 target_desc_info_from_user_p (struct target_desc_info *info)
279 {
280 return info != NULL && info->filename != NULL;
281 }
282
283 /* See target-descriptions.h. */
284
285 void
286 copy_inferior_target_desc_info (struct inferior *destinf, struct inferior *srcin f)
287 {
288 struct target_desc_info *src = get_tdesc_info (srcinf);
289 struct target_desc_info *dest = get_tdesc_info (destinf);
290
291 dest->fetched = src->fetched;
292 dest->tdesc = src->tdesc;
293 dest->filename = src->filename != NULL ? xstrdup (src->filename) : NULL;
294 }
295
296 /* See target-descriptions.h. */
297
298 void
299 target_desc_info_free (struct target_desc_info *tdesc_info)
300 {
301 if (tdesc_info != NULL)
302 {
303 xfree (tdesc_info->filename);
304 xfree (tdesc_info);
305 }
306 }
307
308 /* Convenience helper macros. */
309
310 #define target_desc_fetched \
311 get_tdesc_info (current_inferior ())->fetched
312 #define current_target_desc \
313 get_tdesc_info (current_inferior ())->tdesc
314 #define target_description_filename \
315 get_tdesc_info (current_inferior ())->filename
316
317 /* The string manipulated by the "set tdesc filename ..." command. */
318
319 static char *tdesc_filename_cmd_string;
320
262 /* Fetch the current target's description, and switch the current 321 /* Fetch the current target's description, and switch the current
263 architecture to one which incorporates that description. */ 322 architecture to one which incorporates that description. */
264 323
265 void 324 void
266 target_find_description (void) 325 target_find_description (void)
267 { 326 {
268 /* If we've already fetched a description from the target, don't do 327 /* If we've already fetched a description from the target, don't do
269 it again. This allows a target to fetch the description early, 328 it again. This allows a target to fetch the description early,
270 during its to_open or to_create_inferior, if it needs extra 329 during its to_open or to_create_inferior, if it needs extra
271 information about the target to initialize. */ 330 information about the target to initialize. */
272 if (target_desc_fetched) 331 if (target_desc_fetched)
273 return; 332 return;
274 333
275 /* The current architecture should not have any target description 334 /* The current architecture should not have any target description
276 specified. It should have been cleared, e.g. when we 335 specified. It should have been cleared, e.g. when we
277 disconnected from the previous target. */ 336 disconnected from the previous target. */
278 gdb_assert (gdbarch_target_desc (target_gdbarch) == NULL); 337 gdb_assert (gdbarch_target_desc (target_gdbarch ()) == NULL);
279 338
280 /* First try to fetch an XML description from the user-specified 339 /* First try to fetch an XML description from the user-specified
281 file. */ 340 file. */
282 current_target_desc = NULL; 341 current_target_desc = NULL;
283 if (target_description_filename != NULL 342 if (target_description_filename != NULL
284 && *target_description_filename != '\0') 343 && *target_description_filename != '\0')
285 current_target_desc 344 current_target_desc
286 = file_read_description_xml (target_description_filename); 345 = file_read_description_xml (target_description_filename);
287 346
288 /* Next try to read the description from the current target using 347 /* Next try to read the description from the current target using
(...skipping 12 matching lines...) Expand all
301 struct gdbarch_info info; 360 struct gdbarch_info info;
302 361
303 gdbarch_info_init (&info); 362 gdbarch_info_init (&info);
304 info.target_desc = current_target_desc; 363 info.target_desc = current_target_desc;
305 if (!gdbarch_update_p (info)) 364 if (!gdbarch_update_p (info))
306 warning (_("Architecture rejected target-supplied description")); 365 warning (_("Architecture rejected target-supplied description"));
307 else 366 else
308 { 367 {
309 struct tdesc_arch_data *data; 368 struct tdesc_arch_data *data;
310 369
311 » data = gdbarch_data (target_gdbarch, tdesc_data); 370 » data = gdbarch_data (target_gdbarch (), tdesc_data);
312 if (tdesc_has_registers (current_target_desc) 371 if (tdesc_has_registers (current_target_desc)
313 && data->arch_regs == NULL) 372 && data->arch_regs == NULL)
314 warning (_("Target-supplied registers are not supported " 373 warning (_("Target-supplied registers are not supported "
315 "by the current architecture")); 374 "by the current architecture"));
316 } 375 }
317 } 376 }
318 377
319 /* Now that we know this description is usable, record that we 378 /* Now that we know this description is usable, record that we
320 fetched it. */ 379 fetched it. */
321 target_desc_fetched = 1; 380 target_desc_fetched = 1;
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 } 1559 }
1501 1560
1502 static void 1561 static void
1503 show_tdesc_cmd (char *args, int from_tty) 1562 show_tdesc_cmd (char *args, int from_tty)
1504 { 1563 {
1505 cmd_show_list (tdesc_show_cmdlist, from_tty, ""); 1564 cmd_show_list (tdesc_show_cmdlist, from_tty, "");
1506 } 1565 }
1507 1566
1508 static void 1567 static void
1509 unset_tdesc_cmd (char *args, int from_tty) 1568 unset_tdesc_cmd (char *args, int from_tty)

error: old chunk mismatch

OLDNEW
« no previous file with comments | « gdb/target-descriptions.h ('k') | gdb/target-memory.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698