This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Regression: graceful unwind termination when we'd need unavailable/uncollect memory or registers to unwind further
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Cc: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Date: Tue, 22 Mar 2011 11:13:16 +0000
- Subject: Re: Regression: graceful unwind termination when we'd need unavailable/uncollect memory or registers to unwind further
- References: <201102221834.42413.pedro@codesourcery.com> <20110320184845.GA30084@host1.jankratochvil.net>
On Sunday 20 March 2011 18:48:45, Jan Kratochvil wrote:
> Hi Pedro,
>
> on a testfile from the Fedora patchset there is a regression, IMO a valid one:
Agreed.
> http://pkgs.fedoraproject.org/gitweb/?p=gdb.git;a=blob_plain;f=gdb-6.8-bz457187-largefile-test.patch;hb=f15/master
> = This file is included in this mail.
Thanks!
> The core file does not have accessible registers. It was not a goal of the
> testcase, it tests something else. But it has found this unrelated
> regression.
Yeah, nice test.
> (gdb) x/i 0x400078
> 0x400078: hlt
> PASS: gdb.arch/i386-biarch-core.exp: .text is readable
> ->
> (gdb) x/i 0x400078
> PC not available
> FAIL: gdb.arch/i386-biarch-core.exp: .text is readable
> I believe one should be able to evaluate PC-indepenent
> expressions even if PC is not available.
Yep, and you can. The quirk is x/i / disassemble specific. The
error is thrown while trying to decide whether to print the "==>" that
indicates the current PC.
> Even the first part is regressing (although it stays PASS->PASS):
> (gdb) core-file gdb.arch/i386-biarch-core.core
> [New LWP 6901]
> warning: Couldn't recognize general-purpose registers in core file.
> Core was generated by `./bad'.
> Program terminated with signal 11, Segmentation fault.
> warning: Couldn't recognize general-purpose registers in core file.
> #0 0x00000000 in ?? ()
> ->
> (gdb) core-file gdb.arch/i386-biarch-core.core
> [New LWP 6901]
> warning: Couldn't recognize general-purpose registers in core file.
> PC register is not available
Fixed as well. After the patch:
(...)
warning: Couldn't recognize general-purpose registers in core file.
Core was generated by `./bad'.
Program terminated with signal 11, Segmentation fault.
warning: Couldn't recognize general-purpose registers in core file.
#0 <unavailable> in ?? ()
(gdb)
and:
(gdb) x/i 0x400078
0x400078: hlt
Below's the patch. Doesn't cause regressions for me.
Did you see any other regression?
Thanks,
Pedro Alves
2011-03-27 Pedro Alves <pedro@codesourcery.com>
* infcmd.c (post_create_inferior): Ignore NOT_AVAILABLE_ERROR
errors when reading the `stop_pc'.
* printcmd.c (pc_prefix): Use get_frame_pc_if_available instead of
get_frame_pc.
---
gdb/infcmd.c | 14 ++++++++++++--
gdb/printcmd.c | 4 +---
2 files changed, 13 insertions(+), 5 deletions(-)
Index: src/gdb/infcmd.c
===================================================================
--- src.orig/gdb/infcmd.c 2011-03-15 20:15:05.000000000 +0000
+++ src/gdb/infcmd.c 2011-03-22 10:22:17.729088002 +0000
@@ -395,6 +395,8 @@ strip_bg_char (char **args)
void
post_create_inferior (struct target_ops *target, int from_tty)
{
+ volatile struct gdb_exception ex;
+
/* Be sure we own the terminal in case write operations are performed. */
target_terminal_ours ();
@@ -404,8 +406,16 @@ post_create_inferior (struct target_ops
don't need to. */
target_find_description ();
- /* Now that we know the register layout, retrieve current PC. */
- stop_pc = regcache_read_pc (get_current_regcache ());
+ /* Now that we know the register layout, retrieve current PC. But
+ if the PC is unavailable (e.g., we're opening a core file with
+ missing registers info), ignore it. */
+ stop_pc = 0;
+ TRY_CATCH (ex, RETURN_MASK_ERROR)
+ {
+ stop_pc = regcache_read_pc (get_current_regcache ());
+ }
+ if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR)
+ throw_exception (ex);
if (exec_bfd)
{
Index: src/gdb/printcmd.c
===================================================================
--- src.orig/gdb/printcmd.c 2011-03-15 20:15:34.000000000 +0000
+++ src/gdb/printcmd.c 2011-03-22 10:21:41.829088002 +0000
@@ -759,9 +759,7 @@ pc_prefix (CORE_ADDR addr)
CORE_ADDR pc;
frame = get_selected_frame (NULL);
- pc = get_frame_pc (frame);
-
- if (pc == addr)
+ if (get_frame_pc_if_available (frame, &pc) && pc == addr)
return "=> ";
}
return " ";