aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-valprint.c
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>1994-07-15 23:53:04 +0000
committerStan Shebs <shebs@codesourcery.com>1994-07-15 23:53:04 +0000
commit0568ccb0acb963d00f5bc283b7389d2b397c6364 (patch)
treeb211934d7f8f750d403ce613e4b288883d5c96d8 /gdb/c-valprint.c
parent14c11f44828bad1a48e3753f77fc1962a2bc5feb (diff)
downloadgdb-0568ccb0acb963d00f5bc283b7389d2b397c6364.zip
gdb-0568ccb0acb963d00f5bc283b7389d2b397c6364.tar.gz
gdb-0568ccb0acb963d00f5bc283b7389d2b397c6364.tar.bz2
Stop printing at null char option, from Oliver Meyer
(omeyer@i3.informatik.rwth-aachen.de). * valprint.h, valprint.c (stop_print_at_null): New global. * valprint.c (_initialize_valprint): New print set subcommand "null-stop". * c-valprint.c (c_val_print): If stop_print_at_null is on, and printing a char array, adjust the number of chars to print.
Diffstat (limited to 'gdb/c-valprint.c')
-rw-r--r--gdb/c-valprint.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index b776237..ee98fc4 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -1,6 +1,6 @@
/* Support for printing C values for GDB, the GNU debugger.
Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994
- Free Software Foundation, Inc.
+ Free Software Foundation, Inc.
This file is part of GDB.
@@ -109,9 +109,26 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
print_spaces_filtered (2 + 2 * recurse, stream);
}
/* For an array of chars, print with string syntax. */
- if (eltlen == 1 && TYPE_CODE (elttype) == TYPE_CODE_INT
+ if (eltlen == 1 &&
+ ((TYPE_CODE (elttype) == TYPE_CODE_INT)
+ || ((current_language->la_language == language_m2)
+ && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
&& (format == 0 || format == 's'))
{
+ /* If requested, look for the first null char and only print
+ elements up to it. */
+ if (stop_print_at_null)
+ {
+ int temp_len;
+
+ /* Look for a NULL char. */
+ for (temp_len = 0;
+ valaddr[temp_len]
+ && temp_len < len && temp_len < print_max;
+ temp_len++);
+ len = temp_len;
+ }
+
LA_PRINT_STRING (stream, valaddr, len, 0);
i = len;
}