aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-01-22 12:43:27 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2021-01-22 12:43:27 -0500
commit2189c312652ae4f66eaf55b306cb64d4c1678636 (patch)
treeca983ba85c1fff86eac62e83883f3b55c4f49cab /gdbsupport
parent02349803fc5a7941b4e23d1580bd8b600d6be1bd (diff)
downloadgdb-2189c312652ae4f66eaf55b306cb64d4c1678636.zip
gdb-2189c312652ae4f66eaf55b306cb64d4c1678636.tar.gz
gdb-2189c312652ae4f66eaf55b306cb64d4c1678636.tar.bz2
gdb: add remote_debug_printf
This is the next in the new-style debug macro series. For this one, I decided to omit the function name from the "Sending packet" / "Packet received" kind of prints, just because it's not very useful in that context and hinders readability more than anything else. This is completely arbitrary. This is with: [remote] putpkt_binary: Sending packet: $qTStatus#49... [remote] getpkt_or_notif_sane_1: Packet received: T0;tnotrun:0;tframes:0;tcreated:0;tfree:500000;tsize:500000;circular:0;disconn:0;starttime:0;stoptime:0;username:;notes:: and without: [remote] Sending packet: $qTStatus#49... [remote] Packet received: T0;tnotrun:0;tframes:0;tcreated:0;tfree:500000;tsize:500000;circular:0;disconn:0;starttime:0;stoptime:0;username:;notes:: A difference is that previously, the query packet and its reply would be printed on the same line, like this: Sending packet: $qTStatus#49...Packet received: T0;tnotrun:0;tframes:0;tcreated:0;tfree:500000;tsize:500000;circular:0;disconn:0;starttime:0;stoptime:0;username:;notes:: Now, they are printed on two lines, since each remote_debug_printf{,_nofunc} prints its own complete message including an end of line. It's probably a matter of taste, but I prefer the two-line version, it's easier to follow, especially when the query packet is long. As a result, lib/range-stepping-support.exp needs to be updated, as it currently expects the vCont packet and the reply to be on the same line. I think it's sufficient in that context to just expect the vCont packet and not the reply, since the goal is just to count how many vCont;r GDB sends. gdb/ChangeLog: * remote.h (remote_debug_printf): New. (remote_debug_printf_nofunc): New. (REMOTE_SCOPED_DEBUG_ENTER_EXIT): New. * remote.c: Use above macros throughout file. gdbsupport/ChangeLog: * common-debug.h (debug_prefixed_printf_cond_nofunc): New. * common-debug.c (debug_prefixed_vprintf): Handle a nullptr func. gdb/testsuite/ChangeLog: * lib/range-stepping-support.exp (exec_cmd_expect_vCont_count): Adjust to "set debug remote" changes. Change-Id: Ica6dead50d3f82e855c7d763f707cef74bed9fee
Diffstat (limited to 'gdbsupport')
-rw-r--r--gdbsupport/ChangeLog6
-rw-r--r--gdbsupport/common-debug.cc6
-rw-r--r--gdbsupport/common-debug.h8
3 files changed, 19 insertions, 1 deletions
diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog
index d973a6d..487107e 100644
--- a/gdbsupport/ChangeLog
+++ b/gdbsupport/ChangeLog
@@ -1,3 +1,9 @@
+2021-01-22 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * common-debug.h (debug_prefixed_printf_cond_nofunc): New.
+ * common-debug.c (debug_prefixed_vprintf): Handle a nullptr
+ func.
+
2021-01-08 Simon Marchi <simon.marchi@polymtl.ca>
PR gdb/27157
diff --git a/gdbsupport/common-debug.cc b/gdbsupport/common-debug.cc
index 0d3e919..39474c2 100644
--- a/gdbsupport/common-debug.cc
+++ b/gdbsupport/common-debug.cc
@@ -55,7 +55,11 @@ void
debug_prefixed_vprintf (const char *module, const char *func,
const char *format, va_list args)
{
- debug_printf ("%*s[%s] %s: ", debug_print_depth * 2, "", module, func);
+ if (func != nullptr)
+ debug_printf ("%*s[%s] %s: ", debug_print_depth * 2, "", module, func);
+ else
+ debug_printf ("%*s[%s] ", debug_print_depth * 2, "", module);
+
debug_vprintf (format, args);
debug_printf ("\n");
}
diff --git a/gdbsupport/common-debug.h b/gdbsupport/common-debug.h
index f313787..0536740 100644
--- a/gdbsupport/common-debug.h
+++ b/gdbsupport/common-debug.h
@@ -66,6 +66,14 @@ extern void ATTRIBUTE_PRINTF (3, 0) debug_prefixed_vprintf
} \
while (0)
+#define debug_prefixed_printf_cond_nofunc(debug_enabled_cond, module, fmt, ...) \
+ do \
+ { \
+ if (debug_enabled_cond) \
+ debug_prefixed_printf (module, nullptr, fmt, ##__VA_ARGS__); \
+ } \
+ while (0)
+
/* Nesting depth of scoped_debug_start_end objects. */
extern int debug_print_depth;