public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Willgerodt, Felix" <felix.willgerodt@intel.com>
To: Pedro Alves <pedro@palves.net>
Cc: Bruno Larsen <blarsen@redhat.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH 1/1] gdb: Avoid warning for the jump command inside an inline function.
Date: Tue, 11 Apr 2023 13:08:40 +0000	[thread overview]
Message-ID: <MN2PR11MB4566195B19C9FDAF2BEDAFA28E9A9@MN2PR11MB4566.namprd11.prod.outlook.com> (raw)
In-Reply-To: <3619ffc8-1050-c586-3da4-e98dc0649754@redhat.com>

Hi Pedro,

Sorry for pinging you directly, but could you help us shed some light on
this question?

Thanks a lot,
Felix

> -----Original Message-----
> From: Willgerodt, Felix
> Sent: Dienstag, 21. März 2023 15:05
> To: Bruno Larsen <blarsen@redhat.com>; gdb-patches@sourceware.org
> Cc: Pedro Alves <pedro@palves.net>
> Subject: RE: [PATCH 1/1] gdb: Avoid warning for the jump command inside an
> inline function.
> 
> > -----Original Message-----
> > From: Bruno Larsen <blarsen@redhat.com>
> > Sent: Freitag, 17. März 2023 14:34
> > To: Willgerodt, Felix <felix.willgerodt@intel.com>; gdb-
> > patches@sourceware.org
> > Subject: Re: [PATCH 1/1] gdb: Avoid warning for the jump command inside
> > an inline function.
> >
> > On 17/03/2023 13:56, Willgerodt, Felix wrote:
> > >> -----Original Message-----
> > >> From: Bruno Larsen <blarsen@redhat.com>
> > >> Sent: Freitag, 17. März 2023 11:14
> > >> To: Willgerodt, Felix <felix.willgerodt@intel.com>; gdb-
> > >> patches@sourceware.org
> > >> Cc: Cristian Sandu <cristian.sandu@intel.com>
> > >> Subject: Re: [PATCH 1/1] gdb: Avoid warning for the jump command
> > inside
> > >> an inline function.
> > >>
> > >> On 24/01/2023 16:19, Felix Willgerodt via Gdb-patches wrote:
> > >>> When stopped inside an inline function, trying to jump to a different
> line
> > >>> of the same function currently results in a warning about jumping to
> > >> another
> > >>> function.  Fix this by taking inline functions into account.
> > >>>
> > >>> Before:
> > >>>     Breakpoint 1, function_inline (x=510) at jump-inline.cpp:22
> > >>>     22        a = a + x;             /* inline-funct */
> > >>>     (gdb) j 21
> > >>>     Line 21 is not in `function_inline(int)'.  Jump anyway? (y or n)
> > >>>
> > >>> After:
> > >>>     Breakpoint 2, function_inline (x=510) at jump-inline.cpp:22
> > >>>     22        a = a + x;            /* inline-funct */
> > >>>     (gdb) j 21
> > >>>     Continuing at 0x400679.
> > >>>
> > >>>     Breakpoint 1, function_inline (x=510) at jump-inline.cpp:21
> > >>>     21        a += 1020 + a;                /* increment-funct */
> > >>>
> > >>> This was regression-tested on X86-64 Linux.
> > >>>
> > >>> Co-Authored-by: Cristian Sandu <cristian.sandu@intel.com>
> > >>> ---
> > >>>    gdb/infcmd.c                           |  3 +-
> > >>>    gdb/testsuite/gdb.base/jump-inline.c   | 30 +++++++++++++++++
> > >>>    gdb/testsuite/gdb.base/jump-inline.exp | 45
> > >> ++++++++++++++++++++++++++
> > >>>    3 files changed, 77 insertions(+), 1 deletion(-)
> > >>>    create mode 100644 gdb/testsuite/gdb.base/jump-inline.c
> > >>>    create mode 100644 gdb/testsuite/gdb.base/jump-inline.exp
> > >>>
> > >>> diff --git a/gdb/infcmd.c b/gdb/infcmd.c
> > >>> index fd88b8ca328..40414bc9260 100644
> > >>> --- a/gdb/infcmd.c
> > >>> +++ b/gdb/infcmd.c
> > >>> @@ -1091,7 +1091,8 @@ jump_command (const char *arg, int
> from_tty)
> > >>>
> > >>>      /* See if we are trying to jump to another function.  */
> > >>>      fn = get_frame_function (get_current_frame ());
> > >>> -  sfn = find_pc_function (sal.pc);
> > >>> +  sfn = find_pc_sect_containing_function (sal.pc,
> > >>> +					  find_pc_mapped_section (sal.pc));
> > >> Hi Felix,
> > >>
> > >> Thanks for doing this, it is a good improvement, but I don't know if
> > >> this is the best way to go about it. Is there a reason why
> > >> find_pc_function should not return inlined functions?
> > >>
> > >> I feel like most of the time we want to know the function, knowing if
> > >> we're in an inlined one would be desirable, but I might be wrong. Does
> > >> anyone know?
> > >>
> > > Hi Bruno,
> > >
> > > I don't know the details, but the comments in symtab.h are rather explicit
> > > about it, so I assume there is a reason:
> > >
> > >
> > > /* lookup the function symbol corresponding to the address.  The
> > >     return value will not be an inlined function; the containing
> > >     function will be returned instead.  */
> > >
> > > extern struct symbol *find_pc_function (CORE_ADDR);
> > >
> > > /* lookup the function symbol corresponding to the address and
> > >     section.  The return value will be the closest enclosing function,
> > >     which might be an inline function.  */
> > >
> > > extern struct symbol *find_pc_sect_containing_function
> > >    (CORE_ADDR pc, struct obj_section *section);
> >
> > Hi Felix,
> >
> > I thought it was mostly a descriptive comment, rather than prescriptive.
> > I tested changing find_pc_function locally and there were only 2
> > regressions, which might just be broken assumptions, but our testsuite
> > is probably not very comprehensive on inlined functions, so I don't know
> > how representative this test actually is.
> >
> 
> Hi Bruno,
> 
> Could you share what changes you have done locally?
> Did you basically just change find_pc_function to call
> find_pc_sec_containing_function?
> 
> I saw that there is another comment in blockframe.c about
> "backwards compatibility", but that has been in the code for ages and
> I couldn't find anything interesting related to it.
> 
> When git blaming the comments in symtab.h, I saw they were added
> by Pedro a couple years ago:
> https://sourceware.org/git/?p=binutils-
> gdb.git;a=commit;f=gdb/symtab.h;h=cd2bb709940d33668fe6dbe8d4ffee0ed
> 44c25e6
> Maybe he can help shed some light on this?
> 
> Thanks,
> Felix
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

  parent reply	other threads:[~2023-04-11 13:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-24 15:19 Felix Willgerodt
2023-02-20 12:50 ` [PING] " Willgerodt, Felix
2023-03-06  9:03 ` Willgerodt, Felix
2023-03-16 15:08 ` Willgerodt, Felix
2023-03-17 10:13 ` Bruno Larsen
2023-03-17 12:56   ` Willgerodt, Felix
2023-03-17 13:33     ` Bruno Larsen
2023-03-21 14:05       ` Willgerodt, Felix
2023-03-21 14:44         ` Bruno Larsen
2023-04-11 13:08       ` Willgerodt, Felix [this message]
2023-04-24 14:28 ` [PING] " Willgerodt, Felix
2023-04-25 14:09 ` Andrew Burgess
2023-04-25 14:40   ` Willgerodt, Felix
2023-05-04  8:10   ` Willgerodt, Felix
2023-05-05 16:21     ` Andrew Burgess
2023-05-08  7:22       ` Willgerodt, Felix

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=MN2PR11MB4566195B19C9FDAF2BEDAFA28E9A9@MN2PR11MB4566.namprd11.prod.outlook.com \
    --to=felix.willgerodt@intel.com \
    --cc=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).