It's useful to be able to put a breakpoint on the *emission* of
a diagnostic (without having to step past all of the warnings
that are suppressed because of command-line options).
The invocation:
(gdb) break diagnostic_show_locus
has been my approach for this for a while (it even works in
the presence of -fno-diagnostics-show-caret).
This patch adds a pre-canned gdb command for adding this
breakpoint.
Not sure if I can self-approve this, but it's been very useful;
it works nicely with tab-completion. I guess I'll commit it
in a few days, unless people here can suggest improvements.
gcc/ChangeLog:
* gdbinit.in (break-on-diagnostic): New command.
---
gcc/gdbinit.in | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/gcc/gdbinit.in b/gcc/gdbinit.in
index 3e1279e..ebdeaf0 100644
--- a/gcc/gdbinit.in
+++ b/gcc/gdbinit.in
@@ -208,6 +208,16 @@ document pcfun
Print current function.
end
+define break-on-diagnostic
+break diagnostic_show_locus
+end
+
+document break-on-diagnostic
+Put a breakpoint on diagnostic_show_locus, called whenever a diagnostic
+is emitted (as opposed to those warnings that are suppressed by
+command-line options).
+end
+
# Define some macros helpful to gdb when it is expanding macros.
macro define __FILE__ "gdb"
macro define __LINE__ 1
--
1.8.5.3