This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC]Enable to set breakpoint on line which includes inlined function call


Hi there,

This patch intends to enable setting breakpoint on source line that has
inlined function call as shown in below case:

$ ../install-x86-upstream/bin/gdb a.out
GNU gdb (GDB) 7.8.50.20141117-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...done.
(gdb) !cat -n g.c
     1  volatile int x;
     2
     3  static inline void foo(int f)
     4  {
     5    volatile int y;
     6    y = f;
     7  }
     8
     9  __attribute__( ( always_inline ) ) static inline void bar(int b)
    10  {
    11    volatile int y;
    12    y = b;
    13  }
    14
    15  int main(void) {
    16
    17      x= 42;
    18
    19      if (x)
    20        foo(16);
    21      else
    22        foo(18);
    23
    24      while (1)
    25        {
    26          bar(10);
    27        }
    28
    29      return 0 ;
    30  }
    31
(gdb) b g.c:20
No line 20 in file "g.c".
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb)

Please use recent gcc 5.0 to build the case. Command is "gcc -O2 -g g.c".

The idea is to find functions that are inlined at specified line number and
then set breakpoint at first inlined function instruction, when we couldn't
find an instruction for specified line number. Tested with GDB regression
test on x86_64, no regression. Any comments?

BR,
Terry

Attachment: gdb-bp-inline-v1.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]