aboutsummaryrefslogtreecommitdiff
path: root/gdb/stack.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2013-09-17 18:26:41 +0000
committerPedro Alves <palves@redhat.com>2013-09-17 18:26:41 +0000
commit08d72866c0af5242ab28e61727cd9ae9703810d8 (patch)
treef0c3e42be6cc2c1bf57d1e3ccd9d9c0c7e36585d /gdb/stack.c
parenta7ea61cf67933d71a4451665cf979afcb259221f (diff)
downloadgdb-08d72866c0af5242ab28e61727cd9ae9703810d8.zip
gdb-08d72866c0af5242ab28e61727cd9ae9703810d8.tar.gz
gdb-08d72866c0af5242ab28e61727cd9ae9703810d8.tar.bz2
PR gdb/15911: "info threads" changes the default source and line (for "break", "list")
"info threads" changes the default source for "break" and "list", to whatever the location of the first/bottom thread in the thread list is... (gdb) b start (gdb) c ... (gdb) list *lists "start"* (gdb) b 23 Breakpoint 3 at 0x400614: file test.c, line 23. (gdb) info threads Id Target Id Frame * 2 Thread 0x7ffff7fcb700 (LWP 1760) "test" start (arg=0x0) at test.c:23 1 Thread 0x7ffff7fcc740 (LWP 1748) "test" 0x000000323dc08e60 in pthread_join (threadid=140737353922304, thread_return=0x0) at pthread_join.c:93 (gdb) b 23 Breakpoint 4 at 0x323dc08d90: file pthread_join.c, line 23. ^^^^^^^^^^^^^^^ (gdb) list 93 lll_wait_tid (pd->tid); 94 95 96 /* Restore cancellation mode. */ 97 CANCEL_RESET (oldtype); 98 99 /* Remove the handler. */ 100 pthread_cleanup_pop (0); 101 102 The issue is that print_stack_frame always sets the current sal to the frame's sal. print_frame_info (which print_stack_frame calls to do most of the work) also sets the last displayed sal, but only if print_what isn't LOCATION. Now the call in question, from within thread.c:print_thread_info, does pass in LOCATION as print_what, but print_stack_frame doesn't have the same check print_frame_info has. We could consider adding it, but setting these globals depending on print_what isn't very clean, IMO. What we have is two logically distinct operations mixed in the same function(s): #1 - print frame, in the format specified by {print_what, print_level and print_args}. #2 - We're displaying a frame to the user, and I want the default sal to point here, because the program stopped here, or the user did some context-changing command (up, down, etc.). So I added a new parameter to print_stack_frame & friends for point #2, and went through all calls in the tree adjusting as necessary. Tested on x86_64 Fedora 17. gdb/ 2013-09-17 Pedro Alves <palves@redhat.com> PR gdb/15911 * ada-tasks.c (task_command_1): Adjust call to print_stack_frame. * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd, bsd_kvm_pcb_cmd): * corelow.c (core_open): * frame.h (print_stack_frame, print_frame_info): New 'set_current_sal' parameter. * infcmd.c (finish_command, kill_command): Adjust call to print_stack_frame. * inferior.c (inferior_command): Likewise. * infrun.c (normal_stop): Likewise. * linux-fork.c (linux_fork_context): Likewise. * record-full.c (record_full_goto_entry, record_full_restore): Likewise. * remote-mips.c (common_open): Likewise. * stack.c (print_stack_frame): New 'set_current_sal' parameter. Use it. (print_frame_info): New 'set_current_sal' parameter. Set the last displayed sal depending on the new paremeter instead of looking at print_what. (backtrace_command_1, select_and_print_frame, frame_command) (current_frame_command, up_command, down_command): Adjust call to print_stack_frame. * thread.c (print_thread_info, restore_selected_frame) (do_captured_thread_select): Adjust call to print_stack_frame. * tracepoint.c (tfind_1): Likewise. * mi/mi-cmd-stack.c (mi_cmd_stack_list_frames) (mi_cmd_stack_info_frame): Likewise. * mi/mi-interp.c (mi_on_normal_stop): Likewise. * mi/mi-main.c (mi_cmd_exec_return, mi_cmd_trace_find): Likewise. gdb/testsuite/ * gdb.threads/info-threads-cur-sal-2.c: New file. * gdb.threads/info-threads-cur-sal.c: New file. * gdb.threads/info-threads-cur-sal.exp: New file.
Diffstat (limited to 'gdb/stack.c')
-rw-r--r--gdb/stack.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/gdb/stack.c b/gdb/stack.c
index 16a03eb..cd4ac7a 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -154,7 +154,8 @@ frame_show_address (struct frame_info *frame,
void
print_stack_frame (struct frame_info *frame, int print_level,
- enum print_what print_what)
+ enum print_what print_what,
+ int set_current_sal)
{
volatile struct gdb_exception e;
@@ -166,8 +167,10 @@ print_stack_frame (struct frame_info *frame, int print_level,
{
int center = (print_what == SRC_LINE || print_what == SRC_AND_LOC);
- print_frame_info (frame, print_level, print_what, 1 /* print_args */);
- set_current_sal_from_frame (frame, center);
+ print_frame_info (frame, print_level, print_what, 1 /* print_args */,
+ set_current_sal);
+ if (set_current_sal)
+ set_current_sal_from_frame (frame, center);
}
}
@@ -780,7 +783,8 @@ do_gdb_disassembly (struct gdbarch *gdbarch,
void
print_frame_info (struct frame_info *frame, int print_level,
- enum print_what print_what, int print_args)
+ enum print_what print_what, int print_args,
+ int set_current_sal)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
struct symtab_and_line sal;
@@ -905,7 +909,7 @@ print_frame_info (struct frame_info *frame, int print_level,
do_gdb_disassembly (get_frame_arch (frame), -1, sal.pc, sal.end);
}
- if (print_what != LOCATION)
+ if (set_current_sal)
{
CORE_ADDR pc;
@@ -1787,7 +1791,7 @@ backtrace_command_1 (char *count_exp, int show_locals, int no_filters,
hand, perhaps the code does or could be fixed to make sure
the frame->prev field gets set to NULL in that case). */
- print_frame_info (fi, 1, LOCATION, 1);
+ print_frame_info (fi, 1, LOCATION, 1, 0);
if (show_locals)
{
struct frame_id frame_id = get_frame_id (fi);
@@ -2184,7 +2188,7 @@ select_and_print_frame (struct frame_info *frame)
{
select_frame (frame);
if (frame)
- print_stack_frame (frame, 1, SRC_AND_LOC);
+ print_stack_frame (frame, 1, SRC_AND_LOC, 1);
}
/* Return the symbol-block in which the selected frame is executing.
@@ -2262,7 +2266,7 @@ static void
frame_command (char *level_exp, int from_tty)
{
select_frame_command (level_exp, from_tty);
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
/* The XDB Compatibility command to print the current frame. */
@@ -2270,7 +2274,7 @@ frame_command (char *level_exp, int from_tty)
static void
current_frame_command (char *level_exp, int from_tty)
{
- print_stack_frame (get_selected_frame (_("No stack.")), 1, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (_("No stack.")), 1, SRC_AND_LOC, 1);
}
/* Select the frame up one or COUNT_EXP stack levels from the
@@ -2301,7 +2305,7 @@ static void
up_command (char *count_exp, int from_tty)
{
up_silently_base (count_exp);
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
/* Select the frame down one or COUNT_EXP stack levels from the previously
@@ -2340,7 +2344,7 @@ static void
down_command (char *count_exp, int from_tty)
{
down_silently_base (count_exp);
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}