Re: [FYI] Inlining support, rough patch

Daniel Jacobowitz
2008-07-02T19:15:04Z

[-- Attachment #1: Type: text/plain, Size: 834 bytes --]

On Mon, Jun 23, 2008 at 01:54:22PM +0200, Jan Kratochvil wrote:
> Hi,
>
> here are some fixes on top of it. I find now your patch useful on top of CVS
> HEAD. I expect some of its problems were probably due to the patch separation
> from the CodeSourcery patchset.
>
> On x86+x86_64+ppc64 with gcc-4.3.1-2 (Fedora) there are no regressions.
> On x86+x86_64 with gcc-4.3.1-2 (Fedora) the provided tests PASS.
> (On ppc64 the tests FAIL as multi-PC breakpoints do not work there.)

Thanks for the patches. Here's a copy of your diff minus the parts
I've merged (or solved differently). I'm not planning to put in any
of these parts yet, but we can talk about them if you have examples
where they help.

Let's wait on that until the rest of the patch is ready, though.
I'm making good progress.

--
Daniel Jacobowitz
CodeSourcery

[-- Attachment #2: gdb-inline-works3.patch.left --]
[-- Type: text/plain, Size: 6003 bytes --]

diff -up -u -X /home/jkratoch/.diffi.list -rupxCVS sources-codesourceryinline-gdb/breakpoint.c sources/gdb/breakpoint.c
--- sources-codesourceryinline-gdb/breakpoint.c 2008-06-20 15:59:08.000000000 +0200
+++ sources/gdb/breakpoint.c 2008-06-22 23:45:57.000000000 +0200
@@ -3076,6 +3076,11 @@ bpstat_stop_status (CORE_ADDR bp_addr, p
bs->print = 0;
}
bs->commands = copy_command_lines (bs->commands);
+
+ /* We display the innermost inlined frame at a breakpont as it gives to
+ most of the available information. */
+ if (b->type != bp_until && b->type != bp_finish)
+ set_skipped_inline_frames (0);
}

/* Print nothing for this entry if we dont stop or if we dont print. */
diff -up -u -X /home/jkratoch/.diffi.list -rupxCVS sources-codesourceryinline-gdb/frame.c sources/gdb/frame.c
--- sources-codesourceryinline-gdb/frame.c 2008-06-20 15:59:09.000000000 +0200
+++ sources/gdb/frame.c 2008-06-22 18:01:02.000000000 +0200
@@ -422,12 +422,12 @@ frame_id_inner (struct gdbarch *gdbarch,
if (!l.stack_addr_p || !r.stack_addr_p)
/* Like NaN, any operation involving an invalid ID always fails. */
inner = 0;
- else if (l.inline_depth > r.inline_depth
+ else if (l.inline_depth < r.inline_depth
&& l.stack_addr == r.stack_addr
&& l.code_addr_p == r.code_addr_p
- && l.code_addr == r.code_addr
+ && (!l.code_addr_p || l.code_addr == r.code_addr)
&& l.special_addr_p == r.special_addr_p
- && l.special_addr == r.special_addr)
+ && (!l.special_addr_p || l.special_addr == r.special_addr))
{
/* Same function, different inlined functions. */
struct block *lb, *rb;
@@ -1697,7 +1697,7 @@ find_frame_sal (struct frame_info *frame
sym = inline_skipped_symbol ();

init_sal (sal);
- if (SYMBOL_LINE (sym) != 0)
+ if (sym && SYMBOL_LINE (sym) != 0)
{
sal->symtab = SYMBOL_SYMTAB (sym);
sal->line = SYMBOL_LINE (sym);
diff -up -u -X /home/jkratoch/.diffi.list -rupxCVS sources-codesourceryinline-gdb/infcmd.c sources/gdb/infcmd.c
--- sources-codesourceryinline-gdb/infcmd.c 2008-06-20 15:59:09.000000000 +0200
+++ sources/gdb/infcmd.c 2008-06-17 20:57:03.000000000 +0200
@@ -758,7 +758,13 @@ step_1 (int skip_subroutines, int single
if (!target_can_async_p ())
{
for (; count > 0; count--)
- step_once (skip_subroutines, single_inst, count, thread);
+ {
+ step_once (skip_subroutines, single_inst, count, thread);
+
+ /* Unexpected breakpoint terminates our multistepping. */
+ if (!stop_step)
+ break;
+ }

do_cleanups (cleanups);
}
diff -up -u -X /home/jkratoch/.diffi.list -rupxCVS sources-codesourceryinline-gdb/inline-frame.c sources/gdb/inline-frame.c
--- sources-codesourceryinline-gdb/inline-frame.c 2008-06-20 15:59:09.000000000 +0200
+++ sources/gdb/inline-frame.c 2008-06-23 00:54:53.000000000 +0200
@@ -90,7 +130,12 @@ inline_frame_sniffer (const struct frame
frame_block = block_for_pc (this_pc);
if (frame_block == NULL)
return 0;

+ /* INLINE_SKIP_SYMBOL does not need to be set for each specific frame. But
+ * it needs to be recalculated after STEP_INTO_INLINE_FRAME according to new
+ * INLINE_SKIP_FRAMES - therefore SET_SKIPPED_INLINE_FRAMES is too early. */
+ inline_skip_symbol = NULL;
+
/* Calculate DEPTH, the number of inlined functions at this
location. */
depth = 0;
@@ -104,7 +154,9 @@ inline_frame_sniffer (const struct frame
{
if (block_inlined_p (cur_block))
depth++;
+ if (depth == inline_skip_frames && inline_skip_symbol == NULL)
+ inline_skip_symbol = BLOCK_FUNCTION (cur_block);

cur_block = BLOCK_SUPERBLOCK (cur_block);
}

@@ -189,7 +247,6 @@ set_skipped_inline_frames (int skip_ok)
{
CORE_ADDR this_pc;
struct block *frame_block, *cur_block;
- struct symbol *last_sym = NULL;
int skip_count = 0;

if (!skip_ok)
@@ -219,19 +276,23 @@ set_skipped_inline_frames (int skip_ok)
of BLOCK_START. */
if (BLOCK_START (cur_block) == this_pc
|| block_starting_point_at (this_pc, cur_block))
+ skip_count++;
+ else
{
- skip_count++;
- last_sym = BLOCK_FUNCTION (cur_block);
+ /* Here we will stop at any possible inlining after we
+ already crossed any first non-inlined function. We could
+ possibly detect such functions generating NORMAL_FRAME
+ by `!block_inlined_p && BLOCK_FUNCTION' (as
+ `!block_inlined_p && !BLOCK_FUNCTION' are just anonymous
+ local { ... } blocks). */
+ break;
}
- else
- break;
}
cur_block = BLOCK_SUPERBLOCK (cur_block);
}
}

inline_skip_pc = this_pc;
- inline_skip_symbol = last_sym;

if (inline_skip_frames != skip_count)
{
diff -up -u -X /home/jkratoch/.diffi.list -rupxCVS sources-codesourceryinline-gdb/testsuite/gdb.cp/annota2.exp sources/gdb/testsuite/gdb.cp/annota2.exp
--- sources-codesourceryinline-gdb/testsuite/gdb.cp/annota2.exp 2008-06-20 15:58:04.000000000 +0200
+++ sources/gdb/testsuite/gdb.cp/annota2.exp 2008-06-18 18:44:11.000000000 +0200
@@ -119,13 +119,14 @@ gdb_expect {
# continue until exit
# this will test:
# annotate-exited
+# `a.x is 1' is asynchronous regarding to `frames-invalid'.
#
send_gdb "continue\n"
gdb_expect {
- -re "\r\n\032\032post-prompt\r\nContinuing.\r\n\r\n\032\032starting\r\n\r\n\032\032frames-invalid\r\na.x is 1\r\n\r\n\032\032exited 0\r\n\r\nProgram exited normally.\r\n\r\n\032\032stopped\r\n$gdb_prompt$" \
+ -re "\r\n\032\032post-prompt\r\nContinuing.\r\n\r\n\032\032starting\r\n(\r\n\032\032frames-invalid\r\n)*a.x is 1\r\n(\r\n\032\032frames-invalid\r\n)*\r\n\032\032exited 0\r\n\r\nProgram exited normally.\r\n\r\n\032\032stopped\r\n$gdb_prompt$" \
{ pass "continue until exit" }
- -re ".*$gdb_prompt$" { fail "continue to exit" }
- timeout { fail "continue to exit (timeout)" }
+ -re ".*$gdb_prompt$" { fail "continue until exit" }
+ timeout { fail "continue until exit (timeout)" }
}

#