From f00150c95d261f2fac4fbab21d60eceb2ccb7d3e Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Sun, 1 Feb 2009 23:31:03 +0000 Subject: [PATCH] * target.h (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New function. Copied from debug_to_wait. Add missing entries for TARGET_WAITKIND_SYSCALL_ENTRY, TARGET_WAITKIND_SYSCALL_RETURN, TARGET_WAITKIND_IGNORE, TARGET_WAITKIND_NO_HISTORY. (debug_to_wait): Call it. * infrun.c (wait_for_inferior): If debug_infrun, print result of target_wait. (fetch_inferior_event): Ditto. --- gdb/ChangeLog | 12 ++++++++ gdb/infrun.c | 20 +++++++++++++ gdb/target.c | 81 ++++++++++++++++++++++++++++++--------------------- gdb/target.h | 4 +++ 4 files changed, 83 insertions(+), 34 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index add82e4907..416b389681 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2009-02-01 Doug Evans + + * target.h (target_waitstatus_to_string): Declare. + * target.c (target_waitstatus_to_string): New function. Copied from + debug_to_wait. Add missing entries for TARGET_WAITKIND_SYSCALL_ENTRY, + TARGET_WAITKIND_SYSCALL_RETURN, TARGET_WAITKIND_IGNORE, + TARGET_WAITKIND_NO_HISTORY. + (debug_to_wait): Call it. + * infrun.c (wait_for_inferior): If debug_infrun, print result of + target_wait. + (fetch_inferior_event): Ditto. + 2009-01-30 Tom Tromey * Makefile.in (HFILES_NO_SRCDIR): Remove i386-cygwin-tdep.h. diff --git a/gdb/infrun.c b/gdb/infrun.c index 2b74beb604..3a67ac5400 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1789,6 +1789,16 @@ wait_for_inferior (int treat_exec_as_sigtrap) else ecs->ptid = target_wait (waiton_ptid, &ecs->ws); + if (debug_infrun) + { + char *status_string = target_waitstatus_to_string (&ecs->ws); + fprintf_unfiltered (gdb_stdlog, + "infrun: target_wait (%d, status) = %d, %s\n", + PIDGET (waiton_ptid), PIDGET (ecs->ptid), + status_string); + xfree (status_string); + } + if (treat_exec_as_sigtrap && ecs->ws.kind == TARGET_WAITKIND_EXECD) { xfree (ecs->ws.value.execd_pathname); @@ -1864,6 +1874,16 @@ fetch_inferior_event (void *client_data) else ecs->ptid = target_wait (waiton_ptid, &ecs->ws); + if (debug_infrun) + { + char *status_string = target_waitstatus_to_string (&ecs->ws); + fprintf_unfiltered (gdb_stdlog, + "infrun: target_wait (%d, status) = %d, %s\n", + PIDGET (waiton_ptid), PIDGET (ecs->ptid), + status_string); + xfree (status_string); + } + if (non_stop && ecs->ws.kind != TARGET_WAITKIND_IGNORE && ecs->ws.kind != TARGET_WAITKIND_EXITED diff --git a/gdb/target.c b/gdb/target.c index 78a0a1b0af..a289e896f7 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -2603,50 +2603,63 @@ debug_to_resume (ptid_t ptid, int step, enum target_signal siggnal) target_signal_to_name (siggnal)); } +/* Return a pretty printed form of target_waitstatus. + Space for the result is malloc'd, caller must free. */ + +char * +target_waitstatus_to_string (const struct target_waitstatus *ws) +{ + const char *kind_str = "status->kind = "; + + switch (ws->kind) + { + case TARGET_WAITKIND_EXITED: + return xstrprintf ("%sexited, status = %d", + kind_str, ws->value.integer); + case TARGET_WAITKIND_STOPPED: + return xstrprintf ("%sstopped, signal = %s", + kind_str, target_signal_to_name (ws->value.sig)); + case TARGET_WAITKIND_SIGNALLED: + return xstrprintf ("%ssignalled, signal = %s", + kind_str, target_signal_to_name (ws->value.sig)); + case TARGET_WAITKIND_LOADED: + return xstrprintf ("%sloaded", kind_str); + case TARGET_WAITKIND_FORKED: + return xstrprintf ("%sforked", kind_str); + case TARGET_WAITKIND_VFORKED: + return xstrprintf ("%svforked", kind_str); + case TARGET_WAITKIND_EXECD: + return xstrprintf ("%sexecd", kind_str); + case TARGET_WAITKIND_SYSCALL_ENTRY: + return xstrprintf ("%ssyscall-entry", kind_str); + case TARGET_WAITKIND_SYSCALL_RETURN: + return xstrprintf ("%ssyscall-return", kind_str); + case TARGET_WAITKIND_SPURIOUS: + return xstrprintf ("%sspurious", kind_str); + case TARGET_WAITKIND_IGNORE: + return xstrprintf ("%signore", kind_str); + case TARGET_WAITKIND_NO_HISTORY: + return xstrprintf ("%sno-history", kind_str); + default: + return xstrprintf ("%sunknown???", kind_str); + } +} + static ptid_t debug_to_wait (ptid_t ptid, struct target_waitstatus *status) { ptid_t retval; + char *status_string; retval = debug_target.to_wait (ptid, status); fprintf_unfiltered (gdb_stdlog, "target_wait (%d, status) = %d, ", PIDGET (ptid), PIDGET (retval)); - fprintf_unfiltered (gdb_stdlog, "status->kind = "); - switch (status->kind) - { - case TARGET_WAITKIND_EXITED: - fprintf_unfiltered (gdb_stdlog, "exited, status = %d\n", - status->value.integer); - break; - case TARGET_WAITKIND_STOPPED: - fprintf_unfiltered (gdb_stdlog, "stopped, signal = %s\n", - target_signal_to_name (status->value.sig)); - break; - case TARGET_WAITKIND_SIGNALLED: - fprintf_unfiltered (gdb_stdlog, "signalled, signal = %s\n", - target_signal_to_name (status->value.sig)); - break; - case TARGET_WAITKIND_LOADED: - fprintf_unfiltered (gdb_stdlog, "loaded\n"); - break; - case TARGET_WAITKIND_FORKED: - fprintf_unfiltered (gdb_stdlog, "forked\n"); - break; - case TARGET_WAITKIND_VFORKED: - fprintf_unfiltered (gdb_stdlog, "vforked\n"); - break; - case TARGET_WAITKIND_EXECD: - fprintf_unfiltered (gdb_stdlog, "execd\n"); - break; - case TARGET_WAITKIND_SPURIOUS: - fprintf_unfiltered (gdb_stdlog, "spurious\n"); - break; - default: - fprintf_unfiltered (gdb_stdlog, "unknown???\n"); - break; - } + + status_string = target_waitstatus_to_string (status); + fprintf_unfiltered (gdb_stdlog, "%s\n", status_string); + xfree (status_string); return retval; } diff --git a/gdb/target.h b/gdb/target.h index 188c9a4f95..7cdd81e4e8 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -151,6 +151,10 @@ struct target_waitstatus value; }; +/* Return a pretty printed form of target_waitstatus. + Space for the result is malloc'd, caller must free. */ +extern char *target_waitstatus_to_string (const struct target_waitstatus *); + /* Possible types of events that the inferior handler will have to deal with. */ enum inferior_event_type