breakpoint::print_recreate_thread (struct ui_file *fp) const
{
if (thread != -1)
- gdb_printf (fp, " thread %d", thread);
+ {
+ struct thread_info *thr = find_thread_global_id (thread);
+ gdb_printf (fp, " thread %s", print_full_thread_id (thr));
+ }
if (task != -1)
gdb_printf (fp, " task %d", task);
circular static buffer, NUMCELLS deep. */
const char *print_thread_id (struct thread_info *thr);
+/* Like print_thread_id, but always prints the inferior-qualified form,
+ even when there is only a single inferior. */
+const char *print_full_thread_id (struct thread_info *thr);
+
/* Boolean test for an already-known ptid. */
extern bool in_thread_list (process_stratum_target *targ, ptid_t ptid);
"\[\r\n\]+\[ \t\]+printf" \
"\[\r\n\]+$disabled_row_start main at \[^\r\n\]*$srcfile:$loc_bp8" \
]
+
+# Copy the saved breakpoints file to the local machine (if necessary),
+# and then check its contents.
+if {[is_remote host]} {
+ set bps [remote_upload host bps [standard_output_file bps]]
+}
+set fh [open $bps]
+set lines [split [read $fh] "\n"]
+close $fh
+
+with_test_prefix "in bps file" {
+ gdb_assert {[lsearch -regexp $lines "break ${srcfile}:${loc_bp2}$"] != -1} \
+ "check for general breakpoint"
+ gdb_assert {[lsearch -regexp $lines "break ${srcfile}:${loc_bp3} thread 1\\.1"] != -1} \
+ "check for thread-specific breakpoint"
+}
# Check that GDB uses the correct thread-id when describing multiple
# thread specific breakpoints at the same location.
+#
+# Also check that the correct thread-ids are used in the saved
+# breakpoints file.
# The plain remote target can't do multiple inferiors.
require !use_gdb_stub
"Note: breakpoint $bpnum \\(thread 2.1\\) also set at pc $hex\\." \
"Note: breakpoint $bpnum \\(thread 2.1\\) also set at pc $hex\\." \
"Breakpoint $decimal at $hex: foo\\. \\(2 locations\\)"]
+
+# Save the breakpoints into a file.
+if {[is_remote host]} {
+ set bps bps
+} else {
+ set bps [standard_output_file bps]
+}
+
+remote_file host delete "$bps"
+gdb_test "save breakpoints $bps" "" "save breakpoint to bps"
+
+if {[is_remote host]} {
+ set bps [remote_upload host bps [standard_output_file bps]]
+}
+
+# Now dig through the saved breakpoints file and check that the
+# thread-ids were written out correctly. First open the saved
+# breakpoints and read them into a list.
+set fh [open $bps]
+set lines [split [read $fh] "\n"]
+close $fh
+
+# Except the list created from the saved breakpoints file will have a
+# blank line entry at the end, so remove it now.
+gdb_assert {[string equal [lindex $lines end] ""]} \
+ "check last item was an empty line"
+set lines [lrange $lines 0 end-1]
+
+# These are the lines we expect in the saved breakpoints file, in the
+# order that we expect them. These are strings, not regexps.
+set expected_results \
+ [list \
+ "break -qualified main" \
+ "break foo thread 2.1" \
+ "break foo thread 1.1"]
+
+# Now check that the files contents (in LINES) matches the
+# EXPECTED_RESULTS.
+gdb_assert {[llength $lines] == [llength $expected_results]} \
+ "correct number of lines in saved breakpoints file"
+foreach a $lines b $expected_results {
+ gdb_assert {[string equal $a $b]} "line '$b'"
+}
const char *
print_thread_id (struct thread_info *thr)
{
+ if (show_inferior_qualified_tids ())
+ return print_full_thread_id (thr);
+
+ char *s = get_print_cell ();
+
gdb_assert (thr != nullptr);
+ xsnprintf (s, PRINT_CELL_SIZE, "%d", thr->per_inf_num);
+ return s;
+}
+/* See gdbthread.h. */
+
+const char *
+print_full_thread_id (struct thread_info *thr)
+{
char *s = get_print_cell ();
- if (show_inferior_qualified_tids ())
- xsnprintf (s, PRINT_CELL_SIZE, "%d.%d", thr->inf->num, thr->per_inf_num);
- else
- xsnprintf (s, PRINT_CELL_SIZE, "%d", thr->per_inf_num);
+ gdb_assert (thr != nullptr);
+ xsnprintf (s, PRINT_CELL_SIZE, "%d.%d", thr->inf->num, thr->per_inf_num);
return s;
}