From 9c036bd836f66747ccd35f6a21a2758f0f2cb8fc Mon Sep 17 00:00:00 2001 From: Jim Kingdon Date: Tue, 17 May 1994 20:13:50 +0000 Subject: [PATCH] * utils.c (vfprintf_maybe_filtered, vfprintf_unfiltered): Call fputs_unfiltered and exit directly, rather than fatal. The latter calls vfprintf_unfiltered! * gdbtypes.h, gdbtypes.c (can_dereference): New function. * value.h, printcmd.c (print_value_flags): Move from here... * annotate.c: ...to here, and make it use can_dereference. --- gdb/ChangeLog | 10 ++++++++++ gdb/annotate.c | 13 +++++++++++++ gdb/gdbtypes.c | 11 +++++++++++ gdb/gdbtypes.h | 2 ++ gdb/printcmd.c | 13 ------------- gdb/utils.c | 10 ++++++++-- 6 files changed, 44 insertions(+), 15 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 150258b2afa..61af1ced9df 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +Tue May 17 11:08:22 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * utils.c (vfprintf_maybe_filtered, vfprintf_unfiltered): Call + fputs_unfiltered and exit directly, rather than fatal. The latter + calls vfprintf_unfiltered! + + * gdbtypes.h, gdbtypes.c (can_dereference): New function. + * value.h, printcmd.c (print_value_flags): Move from here... + * annotate.c: ...to here, and make it use can_dereference. + Sat May 14 15:13:52 1994 Stan Shebs (shebs@andros.cygnus.com) * inflow.c (job_control, attach_flag, generic_mourn_inferior): diff --git a/gdb/annotate.c b/gdb/annotate.c index 73612aa703f..4276b849d56 100644 --- a/gdb/annotate.c +++ b/gdb/annotate.c @@ -21,7 +21,20 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "annotate.h" #include "value.h" #include "target.h" +#include "gdbtypes.h" + +static void print_value_flags PARAMS ((struct type *)); +static void +print_value_flags (t) + struct type *t; +{ + if (can_dereference (t)) + printf_filtered ("*"); + else + printf_filtered ("-"); +} + void breakpoints_changed () { diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 06bada597ad..b89123738fb 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1146,6 +1146,17 @@ lookup_fundamental_type (objfile, typeid) return (*typep); } +int +can_dereference (t) + struct type *t; +{ + /* FIXME: Should we return true for references as well as pointers? */ + return + (t != NULL + && TYPE_CODE (t) == TYPE_CODE_PTR + && TYPE_CODE (TYPE_TARGET_TYPE (t)) != TYPE_CODE_VOID); +} + #if MAINTENANCE_CMDS static void diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index acd21c0dcc7..62fe1ab262a 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -726,6 +726,8 @@ extern void recursive_dump_type PARAMS ((struct type *, int)); extern void print_scalar_formatted PARAMS ((char *, struct type *, int, int, GDB_FILE *)); +extern int can_dereference PARAMS ((struct type *)); + #if MAINTENANCE_CMDS extern void maintenance_print_type PARAMS ((char *, int)); #endif diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 20600240df1..467b0ae4f62 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -88,19 +88,6 @@ int current_display_number; int inspect_it = 0; -void -print_value_flags (t) - struct type *t; -{ - /* FIXME: Should we be printing * for references as well as pointers? */ - if (t != NULL - && TYPE_CODE (t) == TYPE_CODE_PTR - && TYPE_CODE (TYPE_TARGET_TYPE (t)) != TYPE_CODE_VOID) - printf_filtered ("*"); - else - printf_filtered ("-"); -} - struct display { /* Chain link to next auto-display item. */ diff --git a/gdb/utils.c b/gdb/utils.c index 1956984d682..de02160b6e4 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1389,7 +1389,10 @@ vfprintf_maybe_filtered (stream, format, args, filter) vasprintf (&linebuffer, format, args); if (linebuffer == NULL) - fatal ("virtual memory exhausted."); + { + fputs_unfiltered ("\ngdb: virtual memory exhausted.\n", gdb_stderr); + exit (1); + } old_cleanups = make_cleanup (free, linebuffer); fputs_maybe_filtered (linebuffer, stream, filter); do_cleanups (old_cleanups); @@ -1416,7 +1419,10 @@ vfprintf_unfiltered (stream, format, args) vasprintf (&linebuffer, format, args); if (linebuffer == NULL) - fatal ("virtual memory exhausted."); + { + fputs_unfiltered ("\ngdb: virtual memory exhausted.\n", gdb_stderr); + exit (1); + } old_cleanups = make_cleanup (free, linebuffer); fputs_unfiltered (linebuffer, stream); do_cleanups (old_cleanups); -- 2.30.2