From ce406537179aa72cf126062f938ceed5eae0de4c Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 22 Mar 2011 14:39:40 +0000 Subject: [PATCH] * 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/ChangeLog | 7 +++++++ gdb/infcmd.c | 14 ++++++++++++-- gdb/printcmd.c | 4 +--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9e4c43af780..98d6456bda3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2011-03-22 Pedro Alves + + * 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. + 2011-03-22 Phil Muldoon * NEWS: Document gdb.Write stream keyword. diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 8a85915fb11..3dc13e3816f 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -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 *target, int from_tty) 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) { diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 81360ada90c..f1ebb7e9e01 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -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 " "; -- 2.30.2