gdb: Avoid warning for the jump command inside an inline function.

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>
Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
Felix Willgerodt
2021-11-04 15:46:45 +01:00
parent f35cc0decd
commit c239019c9f
3 changed files with 76 additions and 1 deletions

View File

@@ -1081,7 +1081,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));
if (fn != nullptr && sfn != fn)
{
if (!query (_("Line %d is not in `%s'. Jump anyway? "), sal.line,