aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2022-08-05 08:09:57 +0200
committerTom de Vries <tdevries@suse.de>2022-08-05 08:09:57 +0200
commit731d2cc1d5106c077584bd83e96dbba4f7e11118 (patch)
treef76ffb66c77d08c5ac0840ac459435fa7b69a4d9 /gdb
parent701821154b110230f52a0367e120ecc51f490e56 (diff)
downloadgdb-731d2cc1d5106c077584bd83e96dbba4f7e11118.zip
gdb-731d2cc1d5106c077584bd83e96dbba4f7e11118.tar.gz
gdb-731d2cc1d5106c077584bd83e96dbba4f7e11118.tar.bz2
[gdb] Add debug_{exp,val}
When debugging cc1 I heavily rely on simple one-parameter debug functions that allow me to inspect a variable of a common type, like: - debug_generic_expr - debug_gimple_stmt - debug_rtx and I miss similar functions in gdb. Add functions to dump variables of types 'value' and 'expression': - debug_exp, and - debug_val. Tested on x86_64-linux, by breaking on varobj_create, and doing: ... (gdb) call debug_exp (var->root->exp.get ()) &"Operation: OP_VAR_VALUE\n" &" Block symbol:\n" &" Symbol: aaa\n" &" Block: 0x2d064f0\n" (gdb) ... and: ... (gdb) call debug_val (value) &"5" (gdb) ...
Diffstat (limited to 'gdb')
-rw-r--r--gdb/expprint.c13
-rw-r--r--gdb/valprint.c12
2 files changed, 25 insertions, 0 deletions
diff --git a/gdb/expprint.c b/gdb/expprint.c
index cef6ffb..8534d2a 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -65,6 +65,19 @@ dump_prefix_expression (struct expression *exp, struct ui_file *stream)
exp->op->dump (stream, 0);
}
+/* Meant to be used in debug sessions, so don't export it in a header file. */
+extern void ATTRIBUTE_USED debug_exp (struct expression *exp);
+
+/* Print EXP. */
+
+void
+ATTRIBUTE_USED
+debug_exp (struct expression *exp)
+{
+ exp->op->dump (gdb_stdlog, 0);
+ gdb_flush (gdb_stdlog);
+}
+
namespace expr
{
diff --git a/gdb/valprint.c b/gdb/valprint.c
index f873e12..3ad4c0c 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1190,6 +1190,18 @@ value_print (struct value *val, struct ui_file *stream,
current_language->value_print (val, stream, options);
}
+/* Meant to be used in debug sessions, so don't export it in a header file. */
+extern void ATTRIBUTE_UNUSED debug_val (struct value *val);
+
+/* Print VAL. */
+
+void ATTRIBUTE_UNUSED
+debug_val (struct value *val)
+{
+ value_print (val, gdb_stdlog, &user_print_options);
+ gdb_flush (gdb_stdlog);
+}
+
static void
val_print_type_code_flags (struct type *type, struct value *original_value,
int embedded_offset, struct ui_file *stream)