OLD | NEW |
1 /* Copyright (C) 2008-2012 Free Software Foundation, Inc. | 1 /* Copyright (C) 2008-2012 Free Software Foundation, Inc. |
2 | 2 |
3 This file is part of GDB. | 3 This file is part of GDB. |
4 | 4 |
5 This program is free software; you can redistribute it and/or modify | 5 This program is free software; you can redistribute it and/or modify |
6 it under the terms of the GNU General Public License as published by | 6 it under the terms of the GNU General Public License as published by |
7 the Free Software Foundation; either version 3 of the License, or | 7 the Free Software Foundation; either version 3 of the License, or |
8 (at your option) any later version. | 8 (at your option) any later version. |
9 | 9 |
10 This program is distributed in the hope that it will be useful, | 10 This program is distributed in the hope that it will be useful, |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 GNU General Public License for more details. | 13 GNU General Public License for more details. |
14 | 14 |
15 You should have received a copy of the GNU General Public License | 15 You should have received a copy of the GNU General Public License |
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
17 | 17 |
18 #include "defs.h" | 18 #include "defs.h" |
19 #include "windows-tdep.h" | 19 #include "windows-tdep.h" |
20 #include "gdb_obstack.h" | 20 #include "gdb_obstack.h" |
21 #include "xml-support.h" | 21 #include "xml-support.h" |
22 #include "gdbarch.h" | 22 #include "gdbarch.h" |
23 #include "target.h" | 23 #include "target.h" |
24 #include "value.h" | 24 #include "value.h" |
25 #include "inferior.h" | 25 #include "inferior.h" |
26 #include "command.h" | 26 #include "command.h" |
27 #include "gdbcmd.h" | 27 #include "gdbcmd.h" |
28 #include "gdbthread.h" | 28 #include "gdbthread.h" |
| 29 #include "objfiles.h" |
29 | 30 |
30 struct cmd_list_element *info_w32_cmdlist; | 31 struct cmd_list_element *info_w32_cmdlist; |
31 | 32 |
32 typedef struct thread_information_block_32 | 33 typedef struct thread_information_block_32 |
33 { | 34 { |
34 uint32_t current_seh; /* %fs:0x0000 */ | 35 uint32_t current_seh; /* %fs:0x0000 */ |
35 uint32_t current_top_of_stack; /* %fs:0x0004 */ | 36 uint32_t current_top_of_stack; /* %fs:0x0004 */ |
36 uint32_t current_bottom_of_stack; /* %fs:0x0008 */ | 37 uint32_t current_bottom_of_stack; /* %fs:0x0008 */ |
37 uint32_t sub_system_tib; /* %fs:0x000c */ | 38 uint32_t sub_system_tib; /* %fs:0x000c */ |
38 uint32_t fiber_data; /* %fs:0x0010 */ | 39 uint32_t fiber_data; /* %fs:0x0010 */ |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 tlb_value_read, | 262 tlb_value_read, |
262 tlb_value_write | 263 tlb_value_write |
263 }; | 264 }; |
264 | 265 |
265 | 266 |
266 /* Return a new value with the correct type for the tlb object of | 267 /* Return a new value with the correct type for the tlb object of |
267 the current thread using architecture GDBARCH. Return a void value | 268 the current thread using architecture GDBARCH. Return a void value |
268 if there's no object available. */ | 269 if there's no object available. */ |
269 | 270 |
270 static struct value * | 271 static struct value * |
271 tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var) | 272 tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var, void *ignore) |
272 { | 273 { |
273 if (target_has_stack && !ptid_equal (inferior_ptid, null_ptid)) | 274 if (target_has_stack && !ptid_equal (inferior_ptid, null_ptid)) |
274 { | 275 { |
275 struct type *type = windows_get_tlb_type (gdbarch); | 276 struct type *type = windows_get_tlb_type (gdbarch); |
276 return allocate_computed_value (type, &tlb_value_funcs, NULL); | 277 return allocate_computed_value (type, &tlb_value_funcs, NULL); |
277 } | 278 } |
278 | 279 |
279 return allocate_value (builtin_type (gdbarch)->builtin_void); | 280 return allocate_value (builtin_type (gdbarch)->builtin_void); |
280 } | 281 } |
281 | 282 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 obstack_grow_str (obstack, p); | 392 obstack_grow_str (obstack, p); |
392 xfree (p); | 393 xfree (p); |
393 obstack_grow_str (obstack, "\"><segment address=\""); | 394 obstack_grow_str (obstack, "\"><segment address=\""); |
394 /* The symbols in a dll are offset by 0x1000, which is the | 395 /* The symbols in a dll are offset by 0x1000, which is the |
395 offset from 0 of the first byte in an image - because of the file | 396 offset from 0 of the first byte in an image - because of the file |
396 header and the section alignment. */ | 397 header and the section alignment. */ |
397 obstack_grow_str (obstack, paddress (gdbarch, load_addr + 0x1000)); | 398 obstack_grow_str (obstack, paddress (gdbarch, load_addr + 0x1000)); |
398 obstack_grow_str (obstack, "\"/></library>"); | 399 obstack_grow_str (obstack, "\"/></library>"); |
399 } | 400 } |
400 | 401 |
| 402 /* Implement the "iterate_over_objfiles_in_search_order" gdbarch |
| 403 method. It searches all objfiles, starting with CURRENT_OBJFILE |
| 404 first (if not NULL). |
| 405 |
| 406 On Windows, the system behaves a little differently when two |
| 407 objfiles each define a global symbol using the same name, compared |
| 408 to other platforms such as GNU/Linux for instance. On GNU/Linux, |
| 409 all instances of the symbol effectively get merged into a single |
| 410 one, but on Windows, they remain distinct. |
| 411 |
| 412 As a result, it usually makes sense to start global symbol searches |
| 413 with the current objfile before expanding it to all other objfiles. |
| 414 This helps for instance when a user debugs some code in a DLL that |
| 415 refers to a global variable defined inside that DLL. When trying |
| 416 to print the value of that global variable, it would be unhelpful |
| 417 to print the value of another global variable defined with the same |
| 418 name, but in a different DLL. */ |
| 419 |
| 420 void |
| 421 windows_iterate_over_objfiles_in_search_order |
| 422 (struct gdbarch *gdbarch, |
| 423 iterate_over_objfiles_in_search_order_cb_ftype *cb, |
| 424 void *cb_data, struct objfile *current_objfile) |
| 425 { |
| 426 int stop; |
| 427 struct objfile *objfile; |
| 428 |
| 429 if (current_objfile) |
| 430 { |
| 431 stop = cb (current_objfile, cb_data); |
| 432 if (stop) |
| 433 return; |
| 434 } |
| 435 |
| 436 ALL_OBJFILES (objfile) |
| 437 { |
| 438 if (objfile != current_objfile) |
| 439 { |
| 440 stop = cb (objfile, cb_data); |
| 441 if (stop) |
| 442 return; |
| 443 } |
| 444 } |
| 445 } |
| 446 |
401 static void | 447 static void |
402 show_maint_show_all_tib (struct ui_file *file, int from_tty, | 448 show_maint_show_all_tib (struct ui_file *file, int from_tty, |
403 struct cmd_list_element *c, const char *value) | 449 struct cmd_list_element *c, const char *value) |
404 { | 450 { |
405 fprintf_filtered (file, _("Show all non-zero elements of " | 451 fprintf_filtered (file, _("Show all non-zero elements of " |
406 "Thread Information Block is %s.\n"), value); | 452 "Thread Information Block is %s.\n"), value); |
407 } | 453 } |
408 | 454 |
409 static void | 455 static void |
410 info_w32_command (char *args, int from_tty) | 456 info_w32_command (char *args, int from_tty) |
411 { | 457 { |
412 help_list (info_w32_cmdlist, "info w32 ", class_info, gdb_stdout); | 458 help_list (info_w32_cmdlist, "info w32 ", class_info, gdb_stdout); |
413 } | 459 } |
414 | 460 |
415 static int w32_prefix_command_valid = 0; | 461 static int w32_prefix_command_valid = 0; |
416 void | 462 void |
417 init_w32_command_list (void) | 463 init_w32_command_list (void) |
418 { | 464 { |
419 if (!w32_prefix_command_valid) | 465 if (!w32_prefix_command_valid) |
420 { | 466 { |
421 add_prefix_cmd ("w32", class_info, info_w32_command, | 467 add_prefix_cmd ("w32", class_info, info_w32_command, |
422 _("Print information specific to Win32 debugging."), | 468 _("Print information specific to Win32 debugging."), |
423 &info_w32_cmdlist, "info w32 ", 0, &infolist); | 469 &info_w32_cmdlist, "info w32 ", 0, &infolist); |
424 w32_prefix_command_valid = 1; | 470 w32_prefix_command_valid = 1; |
425 } | 471 } |
426 } | 472 } |
427 | 473 |
| 474 /* Provide a prototype to silence -Wmissing-prototypes. */ |
| 475 extern initialize_file_ftype _initialize_windows_tdep; |
| 476 |
| 477 /* Implementation of `tlb' variable. */ |
| 478 |
| 479 static const struct internalvar_funcs tlb_funcs = |
| 480 { |
| 481 tlb_make_value, |
| 482 NULL, |
| 483 NULL |
| 484 }; |
| 485 |
428 void | 486 void |
429 _initialize_windows_tdep (void) | 487 _initialize_windows_tdep (void) |
430 { | 488 { |
431 init_w32_command_list (); | 489 init_w32_command_list (); |
432 add_cmd ("thread-information-block", class_info, display_tib, | 490 add_cmd ("thread-information-block", class_info, display_tib, |
433 _("Display thread information block."), | 491 _("Display thread information block."), |
434 &info_w32_cmdlist); | 492 &info_w32_cmdlist); |
435 add_alias_cmd ("tib", "thread-information-block", class_info, 1, | 493 add_alias_cmd ("tib", "thread-information-block", class_info, 1, |
436 &info_w32_cmdlist); | 494 &info_w32_cmdlist); |
437 | 495 |
438 add_setshow_boolean_cmd ("show-all-tib", class_maintenance, | 496 add_setshow_boolean_cmd ("show-all-tib", class_maintenance, |
439 &maint_display_all_tib, _("\ | 497 &maint_display_all_tib, _("\ |
440 Set whether to display all non-zero fields of thread information block."), _("\ | 498 Set whether to display all non-zero fields of thread information block."), _("\ |
441 Show whether to display all non-zero fields of thread information block."), _("\ | 499 Show whether to display all non-zero fields of thread information block."), _("\ |
442 Use \"on\" to enable, \"off\" to disable.\n\ | 500 Use \"on\" to enable, \"off\" to disable.\n\ |
443 If enabled, all non-zero fields of thread information block are displayed,\n\ | 501 If enabled, all non-zero fields of thread information block are displayed,\n\ |
444 even if their meaning is unknown."), | 502 even if their meaning is unknown."), |
445 NULL, | 503 NULL, |
446 show_maint_show_all_tib, | 504 show_maint_show_all_tib, |
447 &maintenance_set_cmdlist, | 505 &maintenance_set_cmdlist, |
448 &maintenance_show_cmdlist); | 506 &maintenance_show_cmdlist); |
449 | 507 |
450 /* Explicitly create without lookup, since that tries to create a | 508 /* Explicitly create without lookup, since that tries to create a |
451 value with a void typed value, and when we get here, gdbarch | 509 value with a void typed value, and when we get here, gdbarch |
452 isn't initialized yet. At this point, we're quite sure there | 510 isn't initialized yet. At this point, we're quite sure there |
453 isn't another convenience variable of the same name. */ | 511 isn't another convenience variable of the same name. */ |
454 create_internalvar_type_lazy ("_tlb", tlb_make_value); | 512 create_internalvar_type_lazy ("_tlb", &tlb_funcs, NULL); |
455 } | 513 } |
OLD | NEW |