[pushed] Change inline frame breakpoint skipping logic (fix gdb.gdb/selftest.exp)

Joel Brobecker brobecker@adacore.com
Mon Jun 25 21:04:00 GMT 2018


Hello,

> gdb/ChangeLog:
> 2018-06-19  Pedro Alves  <palves@redhat.com>
>
> 	* inline-frame.c (stopped_by_user_bp_inline_frame): Replace PC
> 	parameter with a block parameter.  Compare location's block symbol
> 	with the frame's block instead of addresses.
> 	(skip_inline_frames): Pass the current block instead of the
> 	frame's address.  Break out as soon as we determine the frame
> 	should not be skipped.
>
> gdb/testsuite/ChangeLog:
> 2018-06-19  Pedro Alves  <palves@redhat.com>
>
> 	* gdb.opt/inline-break.c (func_inline_callee, func_inline_caller)
> 	(func_extern_caller): New.
> 	(main): Call func_extern_caller.
> 	* gdb.opt/inline-break.exp: Add tests for inline frame skipping
> 	logic change.

it looks like this patch is causing a crash with the following
example program:

    $ cat -n r.h
         1	/* r.h */
         2	int counter = 42;
         3
         4	inline void
         5	callee () {
         6	  counter = 0;  /* break here */
         7	}
    $ cat -n r.c
         1	/* r.c */
         2	#include "r.h"
         3
         4	int
         5	main ()
         6	{
         7	  callee ();
         8	}

I compiled it using the following commands:

    $ gcc -c -g -O2 r.c
    $ gcc -o r r.o

Then, trying to put a breakpoint on r.h:6 (inside "callee") causes
a SEGV for me:

    $ gdb -q r
    Reading symbols from r...done.
    (gdb) b r.h:6
    Breakpoint 1 at 0x4003c0: file r.h, line 6.
    (gdb) run
    Starting program: /[...]/r
    [1]    75618 segmentation fault  /[...]/gdb -q r

Prior to this commit, the behavior is the following for the "run"
command:

    (gdb) run
    Starting program: /[...]/r

    Breakpoint 1, callee () at r.h:6
    6	  counter = 0;  /* break here */

The problem occurs because we apparently assume that a bp_location's
symbols is not NULL:

    Program received signal SIGSEGV, Segmentation fault.
    0x00000000006f42bb in stopped_by_user_bp_inline_frame (
        stop_chain=<optimized out>, frame_block=<optimized out>)
        at /homes/brobecke/act/gdb/gdb-head/gdb/inline-frame.c:305
    305		      && frame_block == SYMBOL_BLOCK_VALUE (loc->symbol))
    (gdb) p loc->symbol
    $1 = (const symbol *) 0x0

I don't know yet whether that's a valid assumption or something
occurred earlier in the process. Any thoughts on this before I start
looking deeper?

I'm using a version of GCC 7.3.1 on x86_64-linux if anyone wants to
reproduce.

-- 
Joel



More information about the Gdb-patches mailing list