OLD | NEW |
1 /* Code dealing with dummy stack frames, for GDB, the GNU debugger. | 1 /* Code dealing with dummy stack frames, for GDB, the GNU debugger. |
2 | 2 |
3 Copyright (C) 1986-2004, 2007-2012 Free Software Foundation, Inc. | 3 Copyright (C) 1986-2013 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GDB. | 5 This file is part of GDB. |
6 | 6 |
7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
11 | 11 |
12 This program is distributed in the hope that it will be useful, | 12 This program is distributed in the hope that it will be useful, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 GNU General Public License for more details. | 15 GNU General Public License for more details. |
16 | 16 |
17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
19 | 19 |
20 | 20 |
21 #include "defs.h" | 21 #include "defs.h" |
22 #include "dummy-frame.h" | 22 #include "dummy-frame.h" |
23 #include "regcache.h" | 23 #include "regcache.h" |
24 #include "frame.h" | 24 #include "frame.h" |
25 #include "inferior.h" | 25 #include "inferior.h" |
26 #include "gdb_assert.h" | 26 #include "gdb_assert.h" |
27 #include "frame-unwind.h" | 27 #include "frame-unwind.h" |
28 #include "command.h" | 28 #include "command.h" |
29 #include "gdbcmd.h" | 29 #include "gdbcmd.h" |
30 #include "gdb_string.h" | 30 #include <string.h> |
31 #include "observer.h" | 31 #include "observer.h" |
32 #include "gdbthread.h" | 32 #include "gdbthread.h" |
33 | 33 |
34 /* Dummy frame. This saves the processor state just prior to setting | 34 /* Dummy frame. This saves the processor state just prior to setting |
35 up the inferior function call. Older targets save the registers | 35 up the inferior function call. Older targets save the registers |
36 on the target stack (but that really slows down function calls). */ | 36 on the target stack (but that really slows down function calls). */ |
37 | 37 |
38 struct dummy_frame | 38 struct dummy_frame |
39 { | 39 { |
40 struct dummy_frame *next; | 40 struct dummy_frame *next; |
41 /* This frame's ID. Must match the value returned by | 41 /* This frame's ID. Must match the value returned by |
42 gdbarch_dummy_id. */ | 42 gdbarch_dummy_id. */ |
43 struct frame_id id; | 43 struct frame_id id; |
44 /* The caller's state prior to the call. */ | 44 /* The caller's state prior to the call. */ |
45 struct infcall_suspend_state *caller_state; | 45 struct infcall_suspend_state *caller_state; |
46 }; | 46 }; |
47 | 47 |
48 static struct dummy_frame *dummy_frame_stack = NULL; | 48 static struct dummy_frame *dummy_frame_stack = NULL; |
49 | 49 |
50 /* Function: deprecated_pc_in_call_dummy (pc) | |
51 | |
52 Return non-zero if the PC falls in a dummy frame created by gdb for | |
53 an inferior call. The code below which allows gdbarch_decr_pc_after_break | |
54 is for infrun.c, which may give the function a PC without that | |
55 subtracted out. | |
56 | |
57 FIXME: cagney/2002-11-23: This is silly. Surely "infrun.c" can | |
58 figure out what the real PC (as in the resume address) is BEFORE | |
59 calling this function. | |
60 | |
61 NOTE: cagney/2004-08-02: I'm pretty sure that, with the introduction of | |
62 infrun.c:adjust_pc_after_break (thanks), this function is now | |
63 always called with a correctly adjusted PC! | |
64 | |
65 NOTE: cagney/2004-08-02: Code should not need to call this. */ | |
66 | |
67 int | |
68 deprecated_pc_in_call_dummy (struct gdbarch *gdbarch, CORE_ADDR pc) | |
69 { | |
70 struct dummy_frame *dummyframe; | |
71 | |
72 for (dummyframe = dummy_frame_stack; | |
73 dummyframe != NULL; | |
74 dummyframe = dummyframe->next) | |
75 { | |
76 if ((pc >= dummyframe->id.code_addr) | |
77 && (pc <= dummyframe->id.code_addr | |
78 + gdbarch_decr_pc_after_break (gdbarch))) | |
79 return 1; | |
80 } | |
81 return 0; | |
82 } | |
83 | |
84 /* Push the caller's state, along with the dummy frame info, onto the | 50 /* Push the caller's state, along with the dummy frame info, onto the |
85 dummy-frame stack. */ | 51 dummy-frame stack. */ |
86 | 52 |
87 void | 53 void |
88 dummy_frame_push (struct infcall_suspend_state *caller_state, | 54 dummy_frame_push (struct infcall_suspend_state *caller_state, |
89 const struct frame_id *dummy_id) | 55 const struct frame_id *dummy_id) |
90 { | 56 { |
91 struct dummy_frame *dummy_frame; | 57 struct dummy_frame *dummy_frame; |
92 | 58 |
93 dummy_frame = XZALLOC (struct dummy_frame); | 59 dummy_frame = XZALLOC (struct dummy_frame); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 | 325 |
360 void | 326 void |
361 _initialize_dummy_frame (void) | 327 _initialize_dummy_frame (void) |
362 { | 328 { |
363 add_cmd ("dummy-frames", class_maintenance, maintenance_print_dummy_frames, | 329 add_cmd ("dummy-frames", class_maintenance, maintenance_print_dummy_frames, |
364 _("Print the contents of the internal dummy-frame stack."), | 330 _("Print the contents of the internal dummy-frame stack."), |
365 &maintenanceprintlist); | 331 &maintenanceprintlist); |
366 | 332 |
367 observer_attach_inferior_created (cleanup_dummy_frames); | 333 observer_attach_inferior_created (cleanup_dummy_frames); |
368 } | 334 } |
OLD | NEW |