gdb: add infrun_debug_printf macro

Introduce this macro to print debug statements in the infrun.c file,
same idea as what was done in 9327494e0eeb ("gdb: add
linux_nat_debug_printf macro").

Although in this case, there are places outside infrun.c that print
debug statements if debug_infrun is set.  So the macro has to be
declared in the header file, so that it can be used in these other
files.

Note one special case.  In stop_all_threads, I've used an explicit

    if (debug_infrun)
      infrun_debug_printf_1 ("stop_all_threads", "done");

for the message in the SCOPE_EXIT.  Otherwise, the message appears like
this:

  [infrun] operator(): done

Until we find a better solution for extracting a meaningful function
name for lambda functions, I think it's fine to handle these special
cases manually, they are quite rare.

Some tests need to be updated, because they rely on some infrun debug
statements.

gdb/ChangeLog:

	* infrun.h (infrun_debug_printf_1): New function declaration.
	(infrun_debug_printf): New macro.
	* infrun.c (infrun_debug_printf_1): Use infrun_debug_printf
	throughout.
	(infrun_debug_printf): New function.
	* breakpoint.c (should_be_inserted): Use infrun_debug_printf.
	(handle_jit_event): Likewise.

gdb/testsuite/ChangeLog:

	* gdb.base/gdb-sigterm.exp (do_test): Update expected regexp.
	* gdb.threads/signal-while-stepping-over-bp-other-thread.exp:
	Likewise.
	* gdb.threads/stepi-random-signal.exp: Likewise.

Change-Id: I66433c8a9caa64c8525ab57c593022b9d1956d5c
This commit is contained in:
Simon Marchi 2020-08-24 15:49:46 -04:00 committed by Simon Marchi
parent 0f55320bc4
commit 1eb8556f5a
8 changed files with 298 additions and 533 deletions

View File

@ -1,3 +1,13 @@
2020-08-24 Simon Marchi <simon.marchi@efficios.com>
* infrun.h (infrun_debug_printf_1): New function declaration.
(infrun_debug_printf): New macro.
* infrun.c (infrun_debug_printf_1): Use infrun_debug_printf
throughout.
(infrun_debug_printf): New function.
* breakpoint.c (should_be_inserted): Use infrun_debug_printf.
(handle_jit_event): Likewise.
2020-08-21 Mark Wielaard <mark@klomp.org>
* ada-lex.l: Extend register warnings diagnostics comment for g++.

View File

@ -2035,13 +2035,8 @@ should_be_inserted (struct bp_location *bl)
&& !(bl->owner->type == bp_single_step
&& thread_is_stepping_over_breakpoint (bl->owner->thread)))
{
if (debug_infrun)
{
fprintf_unfiltered (gdb_stdlog,
"infrun: skipping breakpoint: "
"stepping past insn at: %s\n",
paddress (bl->gdbarch, bl->address));
}
infrun_debug_printf ("skipping breakpoint: stepping past insn at: %s",
paddress (bl->gdbarch, bl->address));
return 0;
}
@ -2050,14 +2045,9 @@ should_be_inserted (struct bp_location *bl)
if ((bl->loc_type == bp_loc_hardware_watchpoint)
&& stepping_past_nonsteppable_watchpoint ())
{
if (debug_infrun)
{
fprintf_unfiltered (gdb_stdlog,
"infrun: stepping past non-steppable watchpoint. "
"skipping watchpoint at %s:%d\n",
paddress (bl->gdbarch, bl->address),
bl->length);
}
infrun_debug_printf ("stepping past non-steppable watchpoint. "
"skipping watchpoint at %s:%d\n",
paddress (bl->gdbarch, bl->address), bl->length);
return 0;
}
@ -5446,8 +5436,7 @@ handle_jit_event (void)
struct frame_info *frame;
struct gdbarch *gdbarch;
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, "handling bp_jit_event\n");
infrun_debug_printf ("handling bp_jit_event");
/* Switch terminal for any messages produced by
breakpoint_re_set. */

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,17 @@ struct thread_info;
/* True if we are debugging run control. */
extern unsigned int debug_infrun;
/* Print an "infrun" debug statement. Should be used through
infrun_debug_printf. */
void ATTRIBUTE_PRINTF (2, 3) infrun_debug_printf_1
(const char *func_name, const char *fmt, ...);
#define infrun_debug_printf(fmt, ...) \
do { \
if (debug_infrun) \
infrun_debug_printf_1 (__func__, fmt, ##__VA_ARGS__); \
} while (0)
/* True if we are debugging displaced stepping. */
extern bool debug_displaced;

View File

@ -1,3 +1,10 @@
2020-08-24 Simon Marchi <simon.marchi@efficios.com>
* gdb.base/gdb-sigterm.exp (do_test): Update expected regexp.
* gdb.threads/signal-while-stepping-over-bp-other-thread.exp:
Likewise.
* gdb.threads/stepi-random-signal.exp: Likewise.
2020-08-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.base/print-file-var.exp: Fix typo "breapoint".

View File

@ -53,7 +53,7 @@ proc do_test { pass } {
set test "run a bit #$pass"
set abort 1
gdb_test_multiple "step" $test {
-re "infrun: stepping inside range" {
-re {\[infrun\] process_event_stop_test: stepping inside range} {
# Suppress pass $test
verbose -log "$pf_prefix $test: ran"
set abort 0
@ -78,7 +78,7 @@ proc do_test { pass } {
verbose -log "$pf_prefix $test: got eof"
set abort 0
}
-re "infrun: stepping inside range" {
-re "infrun: process_event_stop_test: stepping inside range" {
incr stepping
exp_continue
}

View File

@ -104,7 +104,7 @@ gdb_test "set debug infrun 1"
set test "step"
gdb_test_sequence $test $test {
"need to step-over"
"resume \\(step=1"
"resume_1: step=1,"
"signal arrived while stepping over breakpoint"
"stepped to a different line"
"callme"

View File

@ -87,7 +87,7 @@ set seen 0
set test "stepi"
if {[gdb_test_multiple "stepi" "$test" {
-re "infrun: random signal" {
-re "infrun: handle_signal_stop: random signal" {
set seen 1
exp_continue
}