aboutsummaryrefslogtreecommitdiff
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
parent Fix ChangeLog entry missing a ':' char. (diff)
downloadbinutils-gdb-08d72866c0af5242ab28e61727cd9ae9703810d8.tar.gz
binutils-gdb-08d72866c0af5242ab28e61727cd9ae9703810d8.tar.bz2
binutils-gdb-08d72866c0af5242ab28e61727cd9ae9703810d8.zip
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.
-rw-r--r--gdb/ChangeLog32
-rw-r--r--gdb/ada-tasks.c2
-rw-r--r--gdb/bsd-kvm.c6
-rw-r--r--gdb/corelow.c2
-rw-r--r--gdb/frame.h6
-rw-r--r--gdb/infcmd.c6
-rw-r--r--gdb/inferior.c2
-rw-r--r--gdb/infrun.c2
-rw-r--r--gdb/linux-fork.c2
-rw-r--r--gdb/mi/mi-cmd-stack.c4
-rw-r--r--gdb/mi/mi-interp.c2
-rw-r--r--gdb/mi/mi-main.c4
-rw-r--r--gdb/record-full.c4
-rw-r--r--gdb/remote-mips.c2
-rw-r--r--gdb/stack.c26
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.threads/info-threads-cur-sal-2.c23
-rw-r--r--gdb/testsuite/gdb.threads/info-threads-cur-sal.c33
-rw-r--r--gdb/testsuite/gdb.threads/info-threads-cur-sal.exp57
-rw-r--r--gdb/thread.c6
-rw-r--r--gdb/tracepoint.c2
21 files changed, 194 insertions, 36 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 27d82936485..cf0ff4470e2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,35 @@
+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.
+
2013-09-16 Sergio Durigan Junior <sergiodj@redhat.com>
* value.c (isvoid_internal_fn): Replace "parameter" with
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 3aa66675a46..dfb6719c090 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -1311,7 +1311,7 @@ task_command_1 (char *taskno_str, int from_tty, struct inferior *inf)
printf_filtered (_("[Switching to task %d]\n"), taskno);
print_stack_frame (get_selected_frame (NULL),
frame_relative_level (get_selected_frame (NULL)),
- SRC_AND_LOC);
+ SRC_AND_LOC, 1);
}
diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c
index b47578b269c..d1e7ca84851 100644
--- a/gdb/bsd-kvm.c
+++ b/gdb/bsd-kvm.c
@@ -100,7 +100,7 @@ bsd_kvm_open (char *filename, int from_tty)
target_fetch_registers (get_current_regcache (), -1);
reinit_frame_cache ();
- print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
}
static void
@@ -286,7 +286,7 @@ bsd_kvm_proc_cmd (char *arg, int fromtty)
target_fetch_registers (get_current_regcache (), -1);
reinit_frame_cache ();
- print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
}
#endif
@@ -306,7 +306,7 @@ bsd_kvm_pcb_cmd (char *arg, int fromtty)
target_fetch_registers (get_current_regcache (), -1);
reinit_frame_cache ();
- print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
}
static int
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 8371b58b2b9..7a5aaabf7c6 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -453,7 +453,7 @@ core_open (char *filename, int from_tty)
/* Now, set up the frame cache, and print the top of stack. */
reinit_frame_cache ();
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
static void
diff --git a/gdb/frame.h b/gdb/frame.h
index 5e2400da374..a5e1629f984 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -660,10 +660,12 @@ extern CORE_ADDR get_pc_function_start (CORE_ADDR);
extern struct frame_info *find_relative_frame (struct frame_info *, int *);
extern void print_stack_frame (struct frame_info *, int print_level,
- enum print_what print_what);
+ enum print_what print_what,
+ int set_current_sal);
extern void print_frame_info (struct frame_info *, int print_level,
- enum print_what print_what, int args);
+ enum print_what print_what, int args,
+ int set_current_sal);
extern struct frame_info *block_innermost_frame (const struct block *);
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 154cde25068..242aac11584 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1765,7 +1765,7 @@ finish_command (char *arg, int from_tty)
if (from_tty)
{
printf_filtered (_("Run till exit from "));
- print_stack_frame (get_selected_frame (NULL), 1, LOCATION);
+ print_stack_frame (get_selected_frame (NULL), 1, LOCATION, 0);
}
proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT, 1);
@@ -1790,7 +1790,7 @@ finish_command (char *arg, int from_tty)
else
printf_filtered (_("Run till exit from "));
- print_stack_frame (get_selected_frame (NULL), 1, LOCATION);
+ print_stack_frame (get_selected_frame (NULL), 1, LOCATION, 0);
}
if (execution_direction == EXEC_REVERSE)
@@ -2334,7 +2334,7 @@ kill_command (char *arg, int from_tty)
if (target_has_stack)
{
printf_filtered (_("In %s,\n"), target_longname);
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
}
bfd_cache_close_all ();
diff --git a/gdb/inferior.c b/gdb/inferior.c
index d5866e1f20c..28a520052cc 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -739,7 +739,7 @@ inferior_command (char *args, int from_tty)
else if (inf->pid != 0)
{
ui_out_text (current_uiout, "\n");
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
}
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 57618ae981f..9e4323c72e2 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -6102,7 +6102,7 @@ normal_stop (void)
LOCATION: Print only location
SRC_AND_LOC: Print location and source line. */
if (do_frame_printing)
- print_stack_frame (get_selected_frame (NULL), 0, source_flag);
+ print_stack_frame (get_selected_frame (NULL), 0, source_flag, 1);
/* Display the auto-display expressions. */
do_displays ();
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 4100cb13f66..3774a7fdb5f 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -731,7 +731,7 @@ linux_fork_context (struct fork_info *newfp, int from_tty)
printf_filtered (_("Switching to %s\n"),
target_pid_to_str (inferior_ptid));
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
/* Switch inferior process (checkpoint) context, by checkpoint id. */
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 7bf9ab82d88..6101341020f 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -159,7 +159,7 @@ mi_cmd_stack_list_frames (char *command, char **argv, int argc)
QUIT;
/* Print the location and the address always, even for level 0.
If args is 0, don't print the arguments. */
- print_frame_info (fi, 1, LOC_AND_ADDRESS, 0 /* args */ );
+ print_frame_info (fi, 1, LOC_AND_ADDRESS, 0 /* args */, 0);
}
}
@@ -691,5 +691,5 @@ mi_cmd_stack_info_frame (char *command, char **argv, int argc)
if (argc > 0)
error (_("-stack-info-frame: No arguments allowed"));
- print_frame_info (get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 0);
+ print_frame_info (get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 0, 1);
}
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 038132f32a9..80cc0055a44 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -448,7 +448,7 @@ mi_on_normal_stop (struct bpstats *bs, int print_frame)
get_last_target_status (&last_ptid, &last);
bpstat_print (bs, last.kind);
- print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
current_uiout = saved_uiout;
}
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index e6e98b6e18a..e8c4744c64c 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -194,7 +194,7 @@ mi_cmd_exec_return (char *command, char **argv, int argc)
/* Because we have called return_command with from_tty = 0, we need
to print the frame here. */
- print_stack_frame (get_selected_frame (NULL), 1, LOC_AND_ADDRESS);
+ print_stack_frame (get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 1);
}
void
@@ -2484,7 +2484,7 @@ mi_cmd_trace_find (char *command, char **argv, int argc)
error (_("Invalid mode '%s'"), mode);
if (has_stack_frames () || get_traceframe_number () >= 0)
- print_stack_frame (get_selected_frame (NULL), 1, LOC_AND_ADDRESS);
+ print_stack_frame (get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 1);
}
void
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 1c4e68bcd23..f9af408e8d3 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -2004,7 +2004,7 @@ record_full_goto_entry (struct record_full_entry *p)
registers_changed ();
reinit_frame_cache ();
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
/* The "to_goto_record_begin" target method. */
@@ -2590,7 +2590,7 @@ record_full_restore (void)
printf_filtered (_("Restored records from core file %s.\n"),
bfd_get_filename (core_bfd));
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
/* bfdcore_write -- write bytes into a core file section. */
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index 081fbd06aa7..bf6cce5357a 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -1661,7 +1661,7 @@ seen from the board via TFTP, specify that name as the third parameter.\n"));
reinit_frame_cache ();
registers_changed ();
stop_pc = regcache_read_pc (get_current_regcache ());
- print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
xfree (serial_port_name);
do_cleanups (cleanup);
diff --git a/gdb/stack.c b/gdb/stack.c
index 16a03eb1e3f..cd4ac7a24f6 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);
}
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 8d34fb892af..446768d818f 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2013-09-17 Pedro Alves <palves@redhat.com>
+
+ PR gdb/15911
+ * 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.
+
2013-09-17 Yao Qi <yao@codesourcery.com>
* gdb.base/catch-load.c: Remove the include of "dlfcn.h".
diff --git a/gdb/testsuite/gdb.threads/info-threads-cur-sal-2.c b/gdb/testsuite/gdb.threads/info-threads-cur-sal-2.c
new file mode 100644
index 00000000000..2c29686988d
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/info-threads-cur-sal-2.c
@@ -0,0 +1,23 @@
+/* Copyright 2013 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 <stddef.h>
+
+void *
+start (void *arg)
+{
+ /* "list" should show this line. */
+ return NULL;
+}
diff --git a/gdb/testsuite/gdb.threads/info-threads-cur-sal.c b/gdb/testsuite/gdb.threads/info-threads-cur-sal.c
new file mode 100644
index 00000000000..8a8c8b9d88d
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/info-threads-cur-sal.c
@@ -0,0 +1,33 @@
+/* Copyright 2007-2013 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 <pthread.h>
+#include <assert.h>
+#include <unistd.h>
+
+extern void *start (void *arg);
+
+int
+main (void)
+{
+ pthread_t thread;
+ int i;
+
+ i = pthread_create (&thread, NULL, start, NULL);
+ assert (i == 0);
+ pthread_join (thread, NULL);
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp b/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp
new file mode 100644
index 00000000000..f18ae0c3023
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp
@@ -0,0 +1,57 @@
+# Copyright (C) 2013 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/>.
+
+standard_testfile info-threads-cur-sal.c info-threads-cur-sal-2.c
+
+set executable ${testfile}
+
+if {[gdb_compile_pthreads \
+ "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile2}" \
+ "${binfile}" executable {debug}] != "" } {
+ return -1
+}
+
+clean_restart ${executable}
+
+if ![runto_main] {
+ return -1
+}
+
+gdb_breakpoint "start"
+gdb_continue_to_breakpoint "start"
+
+set line [gdb_get_line_number "should show this line" "${srcfile2}"]
+
+gdb_test "list $line" \
+ "\"list\" should show this line.*" \
+ "list before info threads"
+
+# There used to be a bug where "info threads" would set the current
+# SAL to the location of the last thread displayed.
+gdb_test "info threads" \
+ "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*\r\n 1 *Thread \[^\r\n\]* .* \[^\r\n\]*" \
+ "info threads before break"
+
+# Check that "break" is still operating on the same file by default.
+gdb_test "break $line" ".*${srcfile2}.*" "break on line"
+
+gdb_test "info threads" \
+ "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*\r\n 1 *Thread \[^\r\n\]* .* \[^\r\n\]*" \
+ "info threads before list"
+
+# And that so is "list".
+gdb_test "list $line" \
+ "\"list\" should show this line.*" \
+ "list after info threads"
diff --git a/gdb/thread.c b/gdb/thread.c
index 52626ff0989..498e547aad0 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -929,7 +929,7 @@ print_thread_info (struct ui_out *uiout, char *requested_threads, int pid)
print_stack_frame (get_selected_frame (NULL),
/* For MI output, print frame level. */
ui_out_is_mi_like_p (uiout),
- LOCATION);
+ LOCATION, 0);
}
if (ui_out_is_mi_like_p (uiout))
@@ -1082,7 +1082,7 @@ restore_selected_frame (struct frame_id a_frame_id, int frame_level)
/* For MI, we should probably have a notification about
current frame change. But this error is not very
likely, so don't bother for now. */
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
}
@@ -1467,7 +1467,7 @@ do_captured_thread_select (struct ui_out *uiout, void *tidstr)
else
{
ui_out_text (uiout, "\n");
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
/* Since the current thread may have changed, see if there is any
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 7dbe54b2753..c086587ca7e 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2444,7 +2444,7 @@ tfind_1 (enum trace_find_type type, int num,
else
print_what = SRC_AND_LOC;
- print_stack_frame (get_selected_frame (NULL), 1, print_what);
+ print_stack_frame (get_selected_frame (NULL), 1, print_what, 1);
do_displays ();
}
}