1 infcall.c <unwind_on_signal_p>:
2 Revert the change of: gdb-6.8-inlining.patch
3 causing: FAIL: gdb.base/unwindonsignal.exp: unwindonsignal, stack unwound
5 resume() -> target_resume() move of clear_inline_frame_state() is for:
6 gdb.mi/mi-nsmoribund.exp
8 Index: gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-bt.c
9 ===================================================================
10 --- gdb-6.8.91.20090917.orig/gdb/testsuite/gdb.opt/inline-bt.c 2009-06-28 02:20:24.000000000 +0200
11 +++ gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-bt.c 2009-09-17 12:49:01.000000000 +0200
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 +/* VOLATILE forces all the inlining to happen as otherwise the whole program
18 + gets optimized by CSE to just simple assignments of the results. */
23 +inline void bar(void)
25 + x += y; /* set breakpoint 1 here */
29 inline int func1(void)
31 Index: gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-cmds.c
32 ===================================================================
33 --- gdb-6.8.91.20090917.orig/gdb/testsuite/gdb.opt/inline-cmds.c 2009-06-28 02:20:24.000000000 +0200
34 +++ gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-cmds.c 2009-09-17 12:49:01.000000000 +0200
36 You should have received a copy of the GNU General Public License
37 along with this program. If not, see <http://www.gnu.org/licenses/>. */
40 +/* VOLATILE forces all the inlining to happen as otherwise the whole program
41 + gets optimized by CSE to just simple assignments of the results. */
49 +inline void bar(void)
51 + x += y; /* set breakpoint 1 here */
54 inline int func1(void)
57 Index: gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-cmds.exp
58 ===================================================================
59 --- gdb-6.8.91.20090917.orig/gdb/testsuite/gdb.opt/inline-cmds.exp 2009-06-28 02:20:24.000000000 +0200
60 +++ gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-cmds.exp 2009-09-17 12:49:01.000000000 +0200
61 @@ -230,7 +230,7 @@ set line3 [gdb_get_line_number "set brea
63 gdb_continue_to_breakpoint "consecutive func1"
65 -gdb_test "next" ".*func1 .*first call.*" "next to first func1"
66 +gdb_test "next" "func1 .*first call.*" "next to first func1"
67 set msg "next to second func1"
68 gdb_test_multiple "next" $msg {
69 -re ".*func1 .*second call.*$gdb_prompt $" {
70 @@ -253,16 +253,16 @@ set line4 [gdb_get_line_number "set brea
72 gdb_continue_to_breakpoint "func1 then func3"
74 -gdb_test "next" ".*func1 \\\(\\\);" "next to func1 before func3"
75 -gdb_test "next" ".*func3 \\\(\\\);" "next to func3"
76 +gdb_test "next" "func1 \\\(\\\);" "next to func1 before func3"
77 +gdb_test "next" "func3 \\\(\\\);" "next to func3"
79 # Test finishing out of one thing and into another.
80 set line5 [gdb_get_line_number "set breakpoint 5 here"]
82 gdb_continue_to_breakpoint "finish into func1"
84 -gdb_test "next" ".*marker \\\(\\\);" "next to finish marker"
85 -gdb_test "step" ".*set breakpoint 2 here.*" "step into finish marker"
86 +gdb_test "next" "marker \\\(\\\);" "next to finish marker"
87 +gdb_test "step" "set breakpoint 2 here.*" "step into finish marker"
88 gdb_test "finish" "func1 \\\(\\\);" "finish from marker to func1"
90 gdb_test "step" "bar \\\(\\\);" "step into func1 for finish"
91 @@ -297,12 +297,12 @@ gdb_test "step" "noinline \\\(\\\) at .*
92 gdb_test "bt" "#0 noinline.*#1 .*outer_inline1.*#2 .*outer_inline2.*#3 main.*" "backtrace at noinline from outer_inline1"
93 gdb_test "step" "inlined_fn \\\(\\\) at .*" "enter inlined_fn from noinline"
94 gdb_test "bt" "#0 inlined_fn.*#1 noinline.*#2 .*outer_inline1.*#3 .*outer_inline2.*#4 main.*" "backtrace at inlined_fn from noinline"
95 -gdb_test "info frame" ".*inlined into frame.*" "inlined_fn from noinline inlined"
96 -gdb_test "up" "#1 noinline.*" "up to noinline"
97 -gdb_test "info frame" ".*\n called by frame.*" "noinline from outer_inline1 not inlined"
98 -gdb_test "up" "#2 .*outer_inline1.*" "up to outer_inline1"
99 -gdb_test "info frame" ".*inlined into frame.*" "outer_inline1 inlined"
100 -gdb_test "up" "#3 .*outer_inline2.*" "up to outer_inline2"
101 -gdb_test "info frame" ".*inlined into frame.*" "outer_inline2 inlined"
102 -gdb_test "up" "#4 main.*" "up from outer_inline2"
103 -gdb_test "info frame" ".*\n caller of frame.*" "main not inlined"
104 +gdb_test "info frame" "inlined into frame.*" "inlined_fn from noinline inlined"
105 +gdb_test "fini" "" "up to noinline"
106 +gdb_test "info frame" "\n called by frame.*" "noinline from outer_inline1 not inlined"
107 +gdb_test "fini" "" "up to outer_inline1"
108 +gdb_test "info frame" "inlined into frame.*" "outer_inline1 inlined"
109 +gdb_test "fini" "" "up to outer_inline2"
110 +gdb_test "info frame" "inlined into frame.*" "outer_inline2 inlined"
111 +gdb_test "fini" "" "up from outer_inline2"
112 +gdb_test "info frame" " in main \[^\n\]*\n source language.*" "main not inlined"
113 Index: gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-locals.c
114 ===================================================================
115 --- gdb-6.8.91.20090917.orig/gdb/testsuite/gdb.opt/inline-locals.c 2009-06-28 02:20:24.000000000 +0200
116 +++ gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-locals.c 2009-09-17 12:49:01.000000000 +0200
118 You should have received a copy of the GNU General Public License
119 along with this program. If not, see <http://www.gnu.org/licenses/>. */
122 +/* VOLATILE forces all the inlining to happen as otherwise the whole program
123 + gets optimized by CSE to just simple assignments of the results. */
126 volatile int *array_p;
129 +inline void bar(void)
131 + x += y; /* set breakpoint 1 here */
134 inline int func1(int arg1)
136 Index: gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-locals.exp
137 ===================================================================
138 --- gdb-6.8.91.20090917.orig/gdb/testsuite/gdb.opt/inline-locals.exp 2009-06-30 17:50:27.000000000 +0200
139 +++ gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-locals.exp 2009-09-17 12:49:01.000000000 +0200
140 @@ -77,6 +77,9 @@ if { ! $no_frames } {
142 # Make sure that locals on the stack are found. This is an array to
143 # prevent it from living in a register.
144 +if [test_compiler_info "gcc-4-3-*"] {
145 + setup_kfail *-*-* "gcc/debug.optimization"
147 gdb_test "print array\[0\]" "\\\$$decimal = 0" "print local (2)"
149 if { ! $no_frames } {
150 @@ -115,4 +118,7 @@ if { ! $no_frames } {
151 gdb_test "info locals" ".*arg2 = 184.*" "info locals above bar (3b)"
154 +if [test_compiler_info "gcc-4-3-*"] {
155 + setup_kfail *-*-* "gcc/debug.optimization"
157 gdb_test "print array\[0\]" "\\\$$decimal = 184" "print local (3)"
158 Index: gdb-6.8.91.20090917/gdb/frame.c
159 ===================================================================
160 --- gdb-6.8.91.20090917.orig/gdb/frame.c 2009-09-17 12:48:49.000000000 +0200
161 +++ gdb-6.8.91.20090917/gdb/frame.c 2009-09-17 12:49:01.000000000 +0200
162 @@ -310,7 +310,7 @@ fprint_frame (struct ui_file *file, stru
163 static struct frame_info *
164 skip_inlined_frames (struct frame_info *frame)
166 - while (get_frame_type (frame) == INLINE_FRAME)
167 + while (frame && get_frame_type (frame) == INLINE_FRAME)
168 frame = get_prev_frame (frame);
171 @@ -1778,6 +1778,7 @@ get_frame_address_in_block (struct frame
173 /* A draft address. */
174 CORE_ADDR pc = get_frame_pc (this_frame);
175 + struct thread_info *tp = inferior_thread ();
177 struct frame_info *next_frame = this_frame->next;
179 @@ -1820,6 +1821,9 @@ get_frame_address_in_block (struct frame
180 while in an inlined function, then the code address of the
181 "calling" normal function should not be adjusted either. */
183 + if (tp->current_pc_is_notcurrent)
186 while (get_frame_type (next_frame) == INLINE_FRAME)
187 next_frame = next_frame->next;
189 @@ -1851,7 +1855,7 @@ find_frame_sal (struct frame_info *frame
190 sym = inline_skipped_symbol (inferior_ptid);
193 - if (SYMBOL_LINE (sym) != 0)
194 + if (sym != NULL && SYMBOL_LINE (sym) != 0)
196 sal->symtab = SYMBOL_SYMTAB (sym);
197 sal->line = SYMBOL_LINE (sym);
198 Index: gdb-6.8.91.20090917/gdb/breakpoint.c
199 ===================================================================
200 --- gdb-6.8.91.20090917.orig/gdb/breakpoint.c 2009-09-17 12:48:51.000000000 +0200
201 +++ gdb-6.8.91.20090917/gdb/breakpoint.c 2009-09-17 12:49:12.000000000 +0200
204 #include "xml-syscall.h"
205 #include "parser-defs.h"
206 +#include "inline-frame.h"
208 /* readline include files */
209 #include "readline/readline.h"
210 @@ -3220,10 +3221,24 @@ bpstat_check_breakpoint_conditions (bpst
211 const struct bp_location *bl = bs->breakpoint_at;
212 struct breakpoint *b = bl->owner;
214 - if (frame_id_p (b->frame_id)
215 - && !frame_id_eq (b->frame_id, get_stack_frame_id (get_current_frame ())))
218 + if (frame_id_p (b->frame_id))
220 + struct frame_info *b_frame, *frame;
221 + struct frame_id b_frame_id, current_frame_id;
223 + b_frame = frame_find_by_id (b->frame_id);
225 + /* get_stack_frame_id normalizes the id to the real non-inlined function
226 + by skip_inlined_frames. */
227 + b_frame_id = get_stack_frame_id (b_frame);
228 + current_frame_id = get_stack_frame_id (get_current_frame ());
230 + /* Completely different (inlining notwithstanding) frames? */
231 + if (!frame_id_eq (b_frame_id, current_frame_id))
237 int value_is_zero = 0;
239 @@ -3383,6 +3398,12 @@ bpstat_stop_status (CORE_ADDR bp_addr, p
242 bs->commands = copy_command_lines (bs->commands);
244 + /* Display the innermost inlined frame at a breakpont as it gives to
245 + most of the available information. */
246 + if (b->type != bp_until && b->type != bp_finish)
247 + while (inline_skipped_frames (ptid))
248 + step_into_inline_frame (ptid);
251 /* Print nothing for this entry if we dont stop or if we dont print. */
252 @@ -5572,9 +5593,9 @@ set_momentary_breakpoint (struct gdbarch
254 struct breakpoint *b;
256 - /* If FRAME_ID is valid, it should be a real frame, not an inlined
258 - gdb_assert (!frame_id_inlined_p (frame_id));
259 + /* We can be returning even into an inline frame. While finish_command will
260 + shortcut the case of returning _from_ an inline frame we still may be
261 + returning from non-inlined frame _to_ an inlined frame. */
263 b = set_raw_breakpoint (gdbarch, sal, type);
264 b->enable_state = bp_enabled;
265 Index: gdb-6.8.91.20090917/gdb/inline-frame.c
266 ===================================================================
267 --- gdb-6.8.91.20090917.orig/gdb/inline-frame.c 2009-09-13 18:28:28.000000000 +0200
268 +++ gdb-6.8.91.20090917/gdb/inline-frame.c 2009-09-17 12:49:01.000000000 +0200
269 @@ -199,6 +199,12 @@ inline_frame_sniffer (const struct frame
270 if (frame_block == NULL)
273 + /* For >=2 inlined functions SKIPPED_SYMBOL needs to be different after each
274 + step_into_inline_frame call. But skip_inline_frames is called only once
275 + and thus SKIPPED_SYMBOL needs to be calculated by INLINE_FRAME_SNIFFER. */
277 + state->skipped_symbol = NULL;
279 /* Calculate DEPTH, the number of inlined functions at this
282 @@ -208,6 +214,10 @@ inline_frame_sniffer (const struct frame
283 if (block_inlined_p (cur_block))
286 + if (state && depth == state->skipped_frames
287 + && state->skipped_symbol == NULL)
288 + state->skipped_symbol = BLOCK_FUNCTION (cur_block);
290 cur_block = BLOCK_SUPERBLOCK (cur_block);
293 @@ -291,7 +301,6 @@ skip_inline_frames (ptid_t ptid)
296 struct block *frame_block, *cur_block;
297 - struct symbol *last_sym = NULL;
299 struct inline_state *state;
301 @@ -312,10 +321,7 @@ skip_inline_frames (ptid_t ptid)
303 if (BLOCK_START (cur_block) == this_pc
304 || block_starting_point_at (this_pc, cur_block))
307 - last_sym = BLOCK_FUNCTION (cur_block);
313 @@ -327,7 +333,6 @@ skip_inline_frames (ptid_t ptid)
314 state = allocate_inline_frame_state (ptid);
315 state->skipped_frames = skip_count;
316 state->saved_pc = this_pc;
317 - state->skipped_symbol = last_sym;
320 reinit_frame_cache ();
321 @@ -345,6 +350,23 @@ step_into_inline_frame (ptid_t ptid)
322 reinit_frame_cache ();
325 +/* Step out of an inlined function by hiding it. */
328 +step_out_of_inline_frame (ptid_t ptid)
330 + struct inline_state *state = find_inline_frame_state (ptid);
332 + gdb_assert (state != NULL);
334 + /* Simulate the caller adjustment. */
335 + if (state->skipped_frames == 0)
338 + state->skipped_frames++;
339 + reinit_frame_cache ();
342 /* Return the number of hidden functions inlined into the current
345 Index: gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-markers.c
346 ===================================================================
347 --- gdb-6.8.91.20090917.orig/gdb/testsuite/gdb.opt/inline-markers.c 2009-06-28 02:20:24.000000000 +0200
348 +++ gdb-6.8.91.20090917/gdb/testsuite/gdb.opt/inline-markers.c 2009-09-17 12:49:01.000000000 +0200
355 - x += y; /* set breakpoint 1 here */
360 x += y; /* set breakpoint 2 here */
361 Index: gdb-6.8.91.20090917/gdb/gdbthread.h
362 ===================================================================
363 --- gdb-6.8.91.20090917.orig/gdb/gdbthread.h 2009-09-17 12:47:07.000000000 +0200
364 +++ gdb-6.8.91.20090917/gdb/gdbthread.h 2009-09-17 12:49:01.000000000 +0200
365 @@ -191,6 +191,12 @@ struct thread_info
367 /* Private data used by the target vector implementation. */
368 struct private_thread_info *private;
370 + /* Nonzero if the current frame PC should be unwound as the caller. It is
371 + used to keep the backtrace upper levels existing after finish_command into
372 + an inlined frame if the current inlined function/block was ending at the
374 + int current_pc_is_notcurrent;
377 /* Create an empty thread list, or empty the existing one. */
378 Index: gdb-6.8.91.20090917/gdb/infcmd.c
379 ===================================================================
380 --- gdb-6.8.91.20090917.orig/gdb/infcmd.c 2009-09-17 12:47:07.000000000 +0200
381 +++ gdb-6.8.91.20090917/gdb/infcmd.c 2009-09-17 12:49:01.000000000 +0200
382 @@ -1434,11 +1434,11 @@ finish_command_continuation (void *arg)
383 struct type *value_type;
385 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (a->function));
387 + if (!SYMBOL_INLINED (a->function) && !value_type)
388 internal_error (__FILE__, __LINE__,
389 _("finish_command: function has no target type"));
391 - if (TYPE_CODE (value_type) != TYPE_CODE_VOID)
392 + if (value_type && TYPE_CODE (value_type) != TYPE_CODE_VOID)
393 print_return_value (SYMBOL_TYPE (a->function), value_type);
396 @@ -1546,6 +1546,16 @@ finish_forward (struct symbol *function,
397 tp->initiating_frame = get_frame_id (frame);
398 make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
400 + /* We should _always_ set CURRENT_PC_IS_NOTCURRENT here to always see the
401 + calling line with the message `Value returned is ...'. Currently it is
402 + seen only if at least one instruction is on that source line after the
403 + call instruction. We would also need to hook step_once and only clear
404 + CURRENT_PC_IS_NOTCURRENT on the first step. But it would be a change of
405 + general non-inlining behavior against upstream. */
407 + if (get_frame_type (frame) == INLINE_FRAME)
408 + tp->current_pc_is_notcurrent = 1;
410 tp->proceed_to_finish = 1; /* We want stop_registers, please... */
411 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
413 @@ -1567,7 +1577,9 @@ finish_forward (struct symbol *function,
415 finish_command (char *arg, int from_tty)
417 - struct frame_info *frame;
418 + /* FIXME: Rename `current_frame' to `frame' upon a merge. */
419 + struct frame_info *current_frame, *prev_frame;
420 + CORE_ADDR frame_pc;
421 struct symbol *function;
424 @@ -1598,45 +1610,63 @@ finish_command (char *arg, int from_tty)
425 if (!target_has_execution)
426 error (_("The program is not running."));
428 - frame = get_prev_frame (get_selected_frame (_("No selected frame.")));
430 + current_frame = get_selected_frame (_("No selected frame."));
431 + frame_pc = get_frame_pc (current_frame);
432 + prev_frame = get_prev_frame (current_frame);
433 + if (prev_frame == 0)
434 error (_("\"finish\" not meaningful in the outermost frame."));
436 - clear_proceed_status ();
438 /* Finishing from an inline frame is completely different. We don't
439 try to show the "return value" - no way to locate it. So we do
440 not need a completion. */
441 - if (get_frame_type (get_selected_frame (_("No selected frame.")))
443 + if (get_frame_type (current_frame) == INLINE_FRAME)
445 - /* Claim we are stepping in the calling frame. An empty step
446 - range means that we will stop once we aren't in a function
447 - called by that frame. We don't use the magic "1" value for
448 - step_range_end, because then infrun will think this is nexti,
449 - and not step over the rest of this inlined function call. */
450 struct thread_info *tp = inferior_thread ();
451 struct symtab_and_line empty_sal;
452 - init_sal (&empty_sal);
453 - set_step_info (frame, empty_sal);
454 - tp->step_range_start = tp->step_range_end = get_frame_pc (frame);
455 - tp->step_over_calls = STEP_OVER_ALL;
456 + struct block *frame_block;
458 /* Print info on the selected frame, including level number but not
462 printf_filtered (_("Run till exit from "));
463 - print_stack_frame (get_selected_frame (NULL), 1, LOCATION);
464 + print_stack_frame (current_frame, 1, LOCATION);
467 + /* Even just a single stepi would get us out of the caller function PC
470 + frame_block = get_frame_block (current_frame, NULL);
472 + /* FRAME_BLOCK must be initialized and also the frame printing above must
473 + be done still with the original CURRENT_PC_IS_NOTCURRENT setting. */
474 + clear_proceed_status ();
476 + if (frame_block && BLOCK_END (frame_block) == frame_pc)
478 + step_out_of_inline_frame (tp->ptid);
479 + tp->current_pc_is_notcurrent = 1;
484 + /* Claim we are stepping in the calling frame. An empty step
485 + range means that we will stop once we aren't in a function
486 + called by that frame. We don't use the magic "1" value for
487 + step_range_end, because then infrun will think this is nexti,
488 + and not step over the rest of this inlined function call. */
489 + init_sal (&empty_sal);
490 + set_step_info (prev_frame, empty_sal);
491 + tp->step_range_start = tp->step_range_end = get_frame_pc (prev_frame);
492 + tp->step_over_calls = STEP_OVER_ALL;
494 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
498 /* Find the function we will return from. */
500 - function = find_pc_function (get_frame_pc (get_selected_frame (NULL)));
501 + function = find_pc_function (frame_pc);
503 /* Print info on the selected frame, including level number but not
505 @@ -1650,10 +1680,14 @@ finish_command (char *arg, int from_tty)
506 print_stack_frame (get_selected_frame (NULL), 1, LOCATION);
509 + /* Frames printing above must be done still with the original
510 + CURRENT_PC_IS_NOTCURRENT setting. */
511 + clear_proceed_status ();
513 if (execution_direction == EXEC_REVERSE)
514 finish_backward (function);
516 - finish_forward (function, frame);
517 + finish_forward (function, prev_frame);
521 Index: gdb-6.8.91.20090917/gdb/target.c
522 ===================================================================
523 --- gdb-6.8.91.20090917.orig/gdb/target.c 2009-09-17 12:48:49.000000000 +0200
524 +++ gdb-6.8.91.20090917/gdb/target.c 2009-09-17 12:49:01.000000000 +0200
525 @@ -2187,6 +2187,7 @@ target_resume (ptid_t ptid, int step, en
527 struct target_ops *t;
529 + clear_inline_frame_state (ptid);
530 target_dcache_invalidate ();
532 for (t = current_target.beneath; t != NULL; t = t->beneath)
533 Index: gdb-6.8.91.20090917/gdb/inline-frame.h
534 ===================================================================
535 --- gdb-6.8.91.20090917.orig/gdb/inline-frame.h 2009-06-28 02:20:22.000000000 +0200
536 +++ gdb-6.8.91.20090917/gdb/inline-frame.h 2009-09-17 12:49:01.000000000 +0200
537 @@ -43,6 +43,10 @@ void clear_inline_frame_state (ptid_t pt
539 void step_into_inline_frame (ptid_t ptid);
541 +/* Step out of an inlined function by hiding it. */
543 +void step_out_of_inline_frame (ptid_t ptid);
545 /* Return the number of hidden functions inlined into the current
548 Index: gdb-6.8.91.20090917/gdb/dwarf2read.c
549 ===================================================================
550 --- gdb-6.8.91.20090917.orig/gdb/dwarf2read.c 2009-09-17 12:48:51.000000000 +0200
551 +++ gdb-6.8.91.20090917/gdb/dwarf2read.c 2009-09-17 12:49:01.000000000 +0200
552 @@ -4128,6 +4128,7 @@ read_func_scope (struct die_info *die, s
554 unsigned die_children = 0;
555 int inlined_func = (die->tag == DW_TAG_inlined_subroutine);
560 @@ -4169,7 +4170,10 @@ read_func_scope (struct die_info *die, s
561 add_to_cu_func_list (name, lowpc, highpc, cu);
563 new = push_context (0, lowpc);
564 - new->name = new_symbol (die, read_type_die (die, cu), cu);
565 + type = read_type_die (die, cu);
566 + gdb_assert (type != NULL);
567 + new->name = new_symbol (die, type, cu);
568 + gdb_assert (TYPE_CODE (SYMBOL_TYPE (new->name)) == TYPE_CODE_FUNC);
570 /* If there is a location expression for DW_AT_frame_base, record