aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/expop.h5
-rw-r--r--gdb/testsuite/gdb.rust/expr.exp21
2 files changed, 25 insertions, 1 deletions
diff --git a/gdb/expop.h b/gdb/expop.h
index 854945c..a9da11c 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -314,7 +314,10 @@ static inline void
dump_for_expression (struct ui_file *stream, int depth,
const operation_up &op)
{
- op->dump (stream, depth);
+ if (op == nullptr)
+ gdb_printf (stream, _("%*snullptr\n"), depth, "");
+ else
+ op->dump (stream, depth);
}
extern void dump_for_expression (struct ui_file *stream, int depth,
diff --git a/gdb/testsuite/gdb.rust/expr.exp b/gdb/testsuite/gdb.rust/expr.exp
index 908d1a3..ce2cce2 100644
--- a/gdb/testsuite/gdb.rust/expr.exp
+++ b/gdb/testsuite/gdb.rust/expr.exp
@@ -148,3 +148,24 @@ gdb_test "print r#" "No symbol 'r' in current context"
gdb_test "printf \"%d %d\\n\", 23+1, 23-1" "24 22"
gdb_test "print 5," "Syntax error near ','"
+
+# Check expression debug works for strings.
+gdb_test "with debug expression 1 -- print \"foo\"" \
+ [multi_line \
+ "Operation: OP_AGGREGATE" \
+ " Type: &str" \
+ " nullptr" \
+ " Vector:" \
+ " String: data_ptr" \
+ " Operation: UNOP_ADDR" \
+ " Operation: OP_STRING" \
+ " String: foo" \
+ " String: length" \
+ " Operation: OP_LONG" \
+ " Type: usize" \
+ " Constant: 3" \
+ "Operation: OP_LONG" \
+ " Type: i32" \
+ " Constant: 0" \
+ "evaluation of this expression requires the target program to be active"] \
+ "print a string with expression debug turned on"