public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix stepping in rtld without debug symbol
@ 2022-11-04 18:26 Lancelot SIX
  2022-11-07  9:43 ` Bruno Larsen
  2022-11-09 16:22 ` Kevin Buettner
  0 siblings, 2 replies; 5+ messages in thread
From: Lancelot SIX @ 2022-11-04 18:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: kevinb, lsix, Lancelot SIX

Commit be6276e0aed "Allow debugging of runtime loader / dynamic linker"
introduced a small regression when stepping into the runtime loader /
dynamic linker from function we do not have debug information for.  This
is reported in PR/29747.

This can be shown by the following example (given by Simon Marchi in
buzilla bug report):

    $ cat test.c
    #include <stdio.h>

    int main()
    {
      printf("Hi\n");
      return 0;
    }
    $ gcc test.c -O0 -o test
    $ ./gdb -q -nx --data-directory=data-directory test -ex start -ex s
    Reading symbols from test...
    (No debugging symbols found in test)
    Temporary breakpoint 1 at 0x1151
    Starting program: .../binutils-gdb/gdb/test
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

    Temporary breakpoint 1, 0x0000555555555151 in main ()
    Single stepping until exit from function main,
    which has no line number information.
    /home/smarchi/src/binutils-gdb/gdb/infrun.c:6960:64: runtime error: member call on null pointer of type 'struct symbol'

    The crash happens here:

    #0  __sanitizer::Die () at ../../../../src/libsanitizer/sanitizer_common/sanitizer_termination.cpp:50
    #1  0x00007ffff5dd7128 in __ubsan::__ubsan_handle_type_mismatch_v1_abort (Data=<optimized out>, Pointer=<optimized out>) at ../../../../src/libsanitizer/ubsan/ubsan_handlers.cpp:148
    #2  0x000055556183e1a7 in process_event_stop_test (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:6960
    #3  0x0000555561838ea4 in handle_signal_stop (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:6615
    #4  0x000055556182f77b in handle_inferior_event (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:5866

When evaluating:

    6956   if (execution_direction != EXEC_REVERSE
    6957       && ecs->event_thread->control.step_over_calls == STEP_OVER_UNDEBUGGABLE
    6958       && in_solib_dynsym_resolve_code (ecs->event_thread->stop_pc ())
    6959       && !in_solib_dynsym_resolve_code (
    6961          ecs->event_thread->control.step_start_function->value_block ()
    6962              ->entry_pc ()))

we dereference, ecs->event_thread->control.step_start_function which is
nullptr.

This patch changes this condition so it evaluates to true if
ecs->event_thread->control.step_start_function is nullptr since this
matches the behaviour before be6276e0aed.

Tested on ubuntu-22.04 x86_64.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29747
---
 gdb/infrun.c                                  |  7 +++--
 gdb/testsuite/gdb.base/rtld-step-nodebugsym.c | 25 +++++++++++++++
 .../gdb.base/rtld-step-nodebugsym.exp         | 31 +++++++++++++++++++
 3 files changed, 60 insertions(+), 3 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/rtld-step-nodebugsym.c
 create mode 100644 gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 5ff0dc44d03..6da46b75ac7 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -6956,9 +6956,10 @@ process_event_stop_test (struct execution_control_state *ecs)
   if (execution_direction != EXEC_REVERSE
       && ecs->event_thread->control.step_over_calls == STEP_OVER_UNDEBUGGABLE
       && in_solib_dynsym_resolve_code (ecs->event_thread->stop_pc ())
-      && !in_solib_dynsym_resolve_code (
-	  ecs->event_thread->control.step_start_function->value_block ()
-	      ->entry_pc ()))
+      && (ecs->event_thread->control.step_start_function == nullptr
+	  || !in_solib_dynsym_resolve_code (
+	       ecs->event_thread->control.step_start_function->value_block ()
+		->entry_pc ())))
     {
       CORE_ADDR pc_after_resolver =
 	gdbarch_skip_solib_resolver (gdbarch, ecs->event_thread->stop_pc ());
diff --git a/gdb/testsuite/gdb.base/rtld-step-nodebugsym.c b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.c
new file mode 100644
index 00000000000..4ad96db1445
--- /dev/null
+++ b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.c
@@ -0,0 +1,25 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2022 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+
+int
+main (void)
+{
+  printf ("hello wolrd");
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp
new file mode 100644
index 00000000000..3bc6929102c
--- /dev/null
+++ b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp
@@ -0,0 +1,31 @@
+# Copyright 2022 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test stepping through a runtime loader / dynamic linker (RTLD) without
+# debug info.
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} [list]] } {
+    return
+}
+
+if { ![runto_main] } {
+    return
+}
+
+gdb_test "step" "Single stepping until exit from function.*"
+
+gdb_continue_to_end "" continue 1

base-commit: b0119424d19afcf80997ad5f3128d7ec68e1fafa
-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix stepping in rtld without debug symbol
  2022-11-04 18:26 [PATCH] Fix stepping in rtld without debug symbol Lancelot SIX
@ 2022-11-07  9:43 ` Bruno Larsen
  2022-11-07 10:21   ` Lancelot SIX
  2022-11-09 16:22 ` Kevin Buettner
  1 sibling, 1 reply; 5+ messages in thread
From: Bruno Larsen @ 2022-11-07  9:43 UTC (permalink / raw)
  To: Lancelot SIX, gdb-patches; +Cc: lsix

On 04/11/2022 19:26, Lancelot SIX via Gdb-patches wrote:
> Commit be6276e0aed "Allow debugging of runtime loader / dynamic linker"
> introduced a small regression when stepping into the runtime loader /
> dynamic linker from function we do not have debug information for.  This
> is reported in PR/29747.
>
> This can be shown by the following example (given by Simon Marchi in
> buzilla bug report):
>
>      $ cat test.c
>      #include <stdio.h>
>
>      int main()
>      {
>        printf("Hi\n");
>        return 0;
>      }
>      $ gcc test.c -O0 -o test
>      $ ./gdb -q -nx --data-directory=data-directory test -ex start -ex s
>      Reading symbols from test...
>      (No debugging symbols found in test)
>      Temporary breakpoint 1 at 0x1151
>      Starting program: .../binutils-gdb/gdb/test
>      [Thread debugging using libthread_db enabled]
>      Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
>
>      Temporary breakpoint 1, 0x0000555555555151 in main ()
>      Single stepping until exit from function main,
>      which has no line number information.
>      /home/smarchi/src/binutils-gdb/gdb/infrun.c:6960:64: runtime error: member call on null pointer of type 'struct symbol'
>
>      The crash happens here:
>
>      #0  __sanitizer::Die () at ../../../../src/libsanitizer/sanitizer_common/sanitizer_termination.cpp:50
>      #1  0x00007ffff5dd7128 in __ubsan::__ubsan_handle_type_mismatch_v1_abort (Data=<optimized out>, Pointer=<optimized out>) at ../../../../src/libsanitizer/ubsan/ubsan_handlers.cpp:148
>      #2  0x000055556183e1a7 in process_event_stop_test (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:6960
>      #3  0x0000555561838ea4 in handle_signal_stop (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:6615
>      #4  0x000055556182f77b in handle_inferior_event (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:5866
>
> When evaluating:
>
>      6956   if (execution_direction != EXEC_REVERSE
>      6957       && ecs->event_thread->control.step_over_calls == STEP_OVER_UNDEBUGGABLE
>      6958       && in_solib_dynsym_resolve_code (ecs->event_thread->stop_pc ())
>      6959       && !in_solib_dynsym_resolve_code (
>      6961          ecs->event_thread->control.step_start_function->value_block ()
>      6962              ->entry_pc ()))
>
> we dereference, ecs->event_thread->control.step_start_function which is
> nullptr.
>
> This patch changes this condition so it evaluates to true if
> ecs->event_thread->control.step_start_function is nullptr since this
> matches the behaviour before be6276e0aed.
>
> Tested on ubuntu-22.04 x86_64.
>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29747
Patch looks alright, I just have one nit inlined.
> ---
>   gdb/infrun.c                                  |  7 +++--
>   gdb/testsuite/gdb.base/rtld-step-nodebugsym.c | 25 +++++++++++++++
>   .../gdb.base/rtld-step-nodebugsym.exp         | 31 +++++++++++++++++++
>   3 files changed, 60 insertions(+), 3 deletions(-)
>   create mode 100644 gdb/testsuite/gdb.base/rtld-step-nodebugsym.c
>   create mode 100644 gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp
>
> diff --git a/gdb/infrun.c b/gdb/infrun.c
> index 5ff0dc44d03..6da46b75ac7 100644
> --- a/gdb/infrun.c
> +++ b/gdb/infrun.c
> @@ -6956,9 +6956,10 @@ process_event_stop_test (struct execution_control_state *ecs)
>     if (execution_direction != EXEC_REVERSE
>         && ecs->event_thread->control.step_over_calls == STEP_OVER_UNDEBUGGABLE
>         && in_solib_dynsym_resolve_code (ecs->event_thread->stop_pc ())
> -      && !in_solib_dynsym_resolve_code (
> -	  ecs->event_thread->control.step_start_function->value_block ()
> -	      ->entry_pc ()))
> +      && (ecs->event_thread->control.step_start_function == nullptr
> +	  || !in_solib_dynsym_resolve_code (
> +	       ecs->event_thread->control.step_start_function->value_block ()
> +		->entry_pc ())))
>       {
>         CORE_ADDR pc_after_resolver =
>   	gdbarch_skip_solib_resolver (gdbarch, ecs->event_thread->stop_pc ());
> diff --git a/gdb/testsuite/gdb.base/rtld-step-nodebugsym.c b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.c
> new file mode 100644
> index 00000000000..4ad96db1445
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.c
> @@ -0,0 +1,25 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> +   Copyright 2022 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +#include <stdio.h>
> +
> +int
> +main (void)
> +{
> +  printf ("hello wolrd");
> +  return 0;
> +}
> diff --git a/gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp
> new file mode 100644
> index 00000000000..3bc6929102c
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp
> @@ -0,0 +1,31 @@
> +# Copyright 2022 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# Test stepping through a runtime loader / dynamic linker (RTLD) without
> +# debug info.
> +
> +standard_testfile
> +
> +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} [list]] } {

I think explicitly saying {nodebug} instead of [list] would make this 
test clearer.

With this fixed, you get my

Reviewed-By: Bruno Larsen <blarsen@redhat.com>

Cheers,
Bruno

> +    return
> +}
> +
> +if { ![runto_main] } {
> +    return
> +}
> +
> +gdb_test "step" "Single stepping until exit from function.*"
> +
> +gdb_continue_to_end "" continue 1
>
> base-commit: b0119424d19afcf80997ad5f3128d7ec68e1fafa


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix stepping in rtld without debug symbol
  2022-11-07  9:43 ` Bruno Larsen
@ 2022-11-07 10:21   ` Lancelot SIX
  0 siblings, 0 replies; 5+ messages in thread
From: Lancelot SIX @ 2022-11-07 10:21 UTC (permalink / raw)
  To: Bruno Larsen, gdb-patches; +Cc: lsix


>> +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} 
>> [list]] } {
> 
> I think explicitly saying {nodebug} instead of [list] would make this
> test clearer.

You are absolutely right! I have done this change locally.

Best,
Lancelot.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix stepping in rtld without debug symbol
  2022-11-04 18:26 [PATCH] Fix stepping in rtld without debug symbol Lancelot SIX
  2022-11-07  9:43 ` Bruno Larsen
@ 2022-11-09 16:22 ` Kevin Buettner
  2022-11-09 18:43   ` Lancelot SIX
  1 sibling, 1 reply; 5+ messages in thread
From: Kevin Buettner @ 2022-11-09 16:22 UTC (permalink / raw)
  To: Lancelot SIX; +Cc: gdb-patches, lsix

On Fri, 4 Nov 2022 18:26:34 +0000
Lancelot SIX <lancelot.six@amd.com> wrote:

> Commit be6276e0aed "Allow debugging of runtime loader / dynamic linker"
> introduced a small regression when stepping into the runtime loader /
> dynamic linker from function we do not have debug information for.  This
> is reported in PR/29747.
> 
> This can be shown by the following example (given by Simon Marchi in
> buzilla bug report):
> 
>     $ cat test.c
>     #include <stdio.h>
> 
>     int main()
>     {
>       printf("Hi\n");
>       return 0;
>     }
>     $ gcc test.c -O0 -o test
>     $ ./gdb -q -nx --data-directory=data-directory test -ex start -ex s
>     Reading symbols from test...
>     (No debugging symbols found in test)
>     Temporary breakpoint 1 at 0x1151
>     Starting program: .../binutils-gdb/gdb/test
>     [Thread debugging using libthread_db enabled]
>     Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
> 
>     Temporary breakpoint 1, 0x0000555555555151 in main ()
>     Single stepping until exit from function main,
>     which has no line number information.
>     /home/smarchi/src/binutils-gdb/gdb/infrun.c:6960:64: runtime error: member call on null pointer of type 'struct symbol'
> 
>     The crash happens here:
> 
>     #0  __sanitizer::Die () at ../../../../src/libsanitizer/sanitizer_common/sanitizer_termination.cpp:50
>     #1  0x00007ffff5dd7128 in __ubsan::__ubsan_handle_type_mismatch_v1_abort (Data=<optimized out>, Pointer=<optimized out>) at ../../../../src/libsanitizer/ubsan/ubsan_handlers.cpp:148
>     #2  0x000055556183e1a7 in process_event_stop_test (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:6960
>     #3  0x0000555561838ea4 in handle_signal_stop (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:6615
>     #4  0x000055556182f77b in handle_inferior_event (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:5866
> 
> When evaluating:
> 
>     6956   if (execution_direction != EXEC_REVERSE
>     6957       && ecs->event_thread->control.step_over_calls == STEP_OVER_UNDEBUGGABLE
>     6958       && in_solib_dynsym_resolve_code (ecs->event_thread->stop_pc ())
>     6959       && !in_solib_dynsym_resolve_code (
>     6961          ecs->event_thread->control.step_start_function->value_block ()
>     6962              ->entry_pc ()))
> 
> we dereference, ecs->event_thread->control.step_start_function which is
> nullptr.
> 
> This patch changes this condition so it evaluates to true if
> ecs->event_thread->control.step_start_function is nullptr since this
> matches the behaviour before be6276e0aed.

Thanks for fixing this!

I see that Bruno has asked for the test case to be tweaked and your
reply that you've fixed it in your local sources.  That being the
case...

Approved-By: Kevin Buettner <kevinb@redhat.com>

Kevin


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix stepping in rtld without debug symbol
  2022-11-09 16:22 ` Kevin Buettner
@ 2022-11-09 18:43   ` Lancelot SIX
  0 siblings, 0 replies; 5+ messages in thread
From: Lancelot SIX @ 2022-11-09 18:43 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: gdb-patches, lsix, Bruno Larsen

[-- Attachment #1: Type: text/plain, Size: 382 bytes --]

> Thanks for fixing this!
> 
> I see that Bruno has asked for the test case to be tweaked and your
> reply that you've fixed it in your local sources.  That being the
> case...
> 
> Approved-By: Kevin Buettner <kevinb@redhat.com>
> 
> Kevin
> 

Thanks for the review.

I'll push this shortly, including the change requested by Bruno and a 
typo fix in the testcase.

Best,
Lancelot.

[-- Attachment #2: 0001-Fix-stepping-in-rtld-without-debug-symbol.patch --]
[-- Type: text/x-patch, Size: 6516 bytes --]

From 6eae8b305b6985a48722ae11f18c52aa88ecd5c6 Mon Sep 17 00:00:00 2001
From: Lancelot SIX <lancelot.six@amd.com>
Date: Fri, 4 Nov 2022 15:14:38 +0000
Subject: [PATCH] Fix stepping in rtld without debug symbol

Commit be6276e0aed "Allow debugging of runtime loader / dynamic linker"
introduced a small regression when stepping into the runtime loader /
dynamic linker from function we do not have debug information for.  This
is reported in PR/29747.

This can be shown by the following example (given by Simon Marchi in
buzilla bug report):

    $ cat test.c
    #include <stdio.h>

    int main()
    {
      printf("Hi\n");
      return 0;
    }
    $ gcc test.c -O0 -o test
    $ ./gdb -q -nx --data-directory=data-directory test -ex start -ex s
    Reading symbols from test...
    (No debugging symbols found in test)
    Temporary breakpoint 1 at 0x1151
    Starting program: .../binutils-gdb/gdb/test
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

    Temporary breakpoint 1, 0x0000555555555151 in main ()
    Single stepping until exit from function main,
    which has no line number information.
    /home/smarchi/src/binutils-gdb/gdb/infrun.c:6960:64: runtime error: member call on null pointer of type 'struct symbol'

    The crash happens here:

    #0  __sanitizer::Die () at ../../../../src/libsanitizer/sanitizer_common/sanitizer_termination.cpp:50
    #1  0x00007ffff5dd7128 in __ubsan::__ubsan_handle_type_mismatch_v1_abort (Data=<optimized out>, Pointer=<optimized out>) at ../../../../src/libsanitizer/ubsan/ubsan_handlers.cpp:148
    #2  0x000055556183e1a7 in process_event_stop_test (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:6960
    #3  0x0000555561838ea4 in handle_signal_stop (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:6615
    #4  0x000055556182f77b in handle_inferior_event (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:5866

When evaluating:

    6956   if (execution_direction != EXEC_REVERSE
    6957       && ecs->event_thread->control.step_over_calls == STEP_OVER_UNDEBUGGABLE
    6958       && in_solib_dynsym_resolve_code (ecs->event_thread->stop_pc ())
    6959       && !in_solib_dynsym_resolve_code (
    6961          ecs->event_thread->control.step_start_function->value_block ()
    6962              ->entry_pc ()))

we dereference, ecs->event_thread->control.step_start_function which is
nullptr.

This patch changes this condition so it evaluates to true if
ecs->event_thread->control.step_start_function is nullptr since this
matches the behaviour before be6276e0aed.

Tested on ubuntu-22.04 x86_64.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29747
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
Approved-By: Kevin Buettner <kevinb@redhat.com>
---
 gdb/infrun.c                                  |  7 ++--
 gdb/testsuite/gdb.base/rtld-step-nodebugsym.c | 25 +++++++++++++++
 .../gdb.base/rtld-step-nodebugsym.exp         | 32 +++++++++++++++++++
 3 files changed, 61 insertions(+), 3 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/rtld-step-nodebugsym.c
 create mode 100644 gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 5ff0dc44d03..6da46b75ac7 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -6956,9 +6956,10 @@ process_event_stop_test (struct execution_control_state *ecs)
   if (execution_direction != EXEC_REVERSE
       && ecs->event_thread->control.step_over_calls == STEP_OVER_UNDEBUGGABLE
       && in_solib_dynsym_resolve_code (ecs->event_thread->stop_pc ())
-      && !in_solib_dynsym_resolve_code (
-	  ecs->event_thread->control.step_start_function->value_block ()
-	      ->entry_pc ()))
+      && (ecs->event_thread->control.step_start_function == nullptr
+	  || !in_solib_dynsym_resolve_code (
+	       ecs->event_thread->control.step_start_function->value_block ()
+		->entry_pc ())))
     {
       CORE_ADDR pc_after_resolver =
 	gdbarch_skip_solib_resolver (gdbarch, ecs->event_thread->stop_pc ());
diff --git a/gdb/testsuite/gdb.base/rtld-step-nodebugsym.c b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.c
new file mode 100644
index 00000000000..2e01da65699
--- /dev/null
+++ b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.c
@@ -0,0 +1,25 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2022 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+
+int
+main (void)
+{
+  printf ("hello world");
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp
new file mode 100644
index 00000000000..1c8fa478cb8
--- /dev/null
+++ b/gdb/testsuite/gdb.base/rtld-step-nodebugsym.exp
@@ -0,0 +1,32 @@
+# Copyright 2022 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test stepping through a runtime loader / dynamic linker (RTLD) without
+# debug info.
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
+       {nodebug}] } {
+    return
+}
+
+if { ![runto_main] } {
+    return
+}
+
+gdb_test "step" "Single stepping until exit from function.*"
+
+gdb_continue_to_end "" continue 1

base-commit: 8263b346fa07e3f679b05a8b369d491af51e6de8
-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-09 18:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-04 18:26 [PATCH] Fix stepping in rtld without debug symbol Lancelot SIX
2022-11-07  9:43 ` Bruno Larsen
2022-11-07 10:21   ` Lancelot SIX
2022-11-09 16:22 ` Kevin Buettner
2022-11-09 18:43   ` Lancelot SIX

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).