Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Pedro Alves <palves@redhat.com>
Cc: Tom de Vries <tdevries@suse.de>,
	gdb-patches@sourceware.org,	Keith Seitz <keiths@redhat.com>
Subject: Re: [pushed] Change inline frame breakpoint skipping logic (fix gdb.gdb/selftest.exp)
Date: Mon, 25 Jun 2018 21:04:00 -0000	[thread overview]
Message-ID: <20180625210436.GA11382@adacore.com> (raw)
In-Reply-To: <8c7ace90-f0b8-56f0-0033-5b7827796037@redhat.com>

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


  parent reply	other threads:[~2018-06-25 21:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12 15:06 [PATCH] Ensure captured_main has unique address Tom de Vries
2018-06-12 17:38 ` Change inline frame breakpoint skipping logic (Re: [PATCH] Ensure captured_main has unique address) Pedro Alves
2018-06-14 13:22   ` Tom de Vries
     [not found]     ` <8c7ace90-f0b8-56f0-0033-5b7827796037@redhat.com>
2018-06-25 21:04       ` Joel Brobecker [this message]
2018-06-26 19:02         ` [pushed] Change inline frame breakpoint skipping logic (fix gdb.gdb/selftest.exp) Pedro Alves
2018-06-26 22:02           ` Joel Brobecker
2018-06-27 16:28             ` Pedro Alves
2018-06-28 14:48               ` Pedro Alves
2018-06-28 14:50                 ` [PATCH 1/2] Fix running to breakpoint set in inline function by lineno/address Pedro Alves
2018-06-28 17:32                   ` Joel Brobecker
2018-06-28 14:50                 ` [PATCH 2/2] "break LINENO/*ADDRESS", inline functions and "info break" output Pedro Alves
2018-06-28 17:42                   ` Joel Brobecker
2018-06-29 18:43                     ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180625210436.GA11382@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    --cc=palves@redhat.com \
    --cc=tdevries@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox