From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17044 invoked by alias); 26 Feb 2009 18:41:22 -0000 Received: (qmail 17035 invoked by uid 22791); 26 Feb 2009 18:41:21 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 26 Feb 2009 18:41:12 +0000 Received: from spaceape11.eur.corp.google.com (spaceape11.eur.corp.google.com [172.28.16.145]) by smtp-out.google.com with ESMTP id n1QIf9xu030324 for ; Thu, 26 Feb 2009 18:41:09 GMT Received: from localhost (ruffy.mtv.corp.google.com [172.18.118.116]) by spaceape11.eur.corp.google.com with ESMTP id n1QIf7a4027758 for ; Thu, 26 Feb 2009 10:41:08 -0800 Received: by localhost (Postfix, from userid 67641) id B00611C78A7; Thu, 26 Feb 2009 10:41:07 -0800 (PST) To: gdb-patches@sourceware.org Subject: [RFA] Include thread ID in target_wait debugging output. Message-Id: <20090226184107.B00611C78A7@localhost> Date: Thu, 26 Feb 2009 19:22:00 -0000 From: dje@google.com (Doug Evans) X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-02/txt/msg00488.txt.bz2 Hi. Printing the result of target_wait when "set debug infrun 1" is great, but I've found I've needed the thread ID. The output line was getting a bit long, so I split it up. There are other ways to split it up, but this works for me. Ok to check in? 2009-02-26 Doug Evans Include thread ID in target_wait debugging output. * infrun.c (print_target_wait_results): New function. (wait_for_inferior,fetch_inferior_event): Call it. Index: infrun.c =================================================================== RCS file: /cvs/src/src/gdb/infrun.c,v retrieving revision 1.360 diff -u -p -r1.360 infrun.c --- infrun.c 25 Feb 2009 02:14:22 -0000 1.360 +++ infrun.c 26 Feb 2009 18:34:57 -0000 @@ -1737,6 +1737,30 @@ delete_step_thread_step_resume_breakpoin delete_step_thread_step_resume_breakpoint (); } +/* Pretty print the results of target_wait, for debugging purposes. */ + +static void +print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid, + const struct target_waitstatus *ws) +{ + char *status_string = target_waitstatus_to_string (ws); + + fprintf_unfiltered (gdb_stdlog, + "infrun: target_wait (%d", PIDGET (waiton_ptid)); + if (PIDGET (waiton_ptid) != -1) + fprintf_unfiltered (gdb_stdlog, + " [%s]", target_pid_to_str (waiton_ptid)); + fprintf_unfiltered (gdb_stdlog, ", status) =\n"); + fprintf_unfiltered (gdb_stdlog, + "infrun: %d [%s],\n", + PIDGET (result_ptid), target_pid_to_str (result_ptid)); + fprintf_unfiltered (gdb_stdlog, + "infrun: %s\n", + status_string); + + xfree (status_string); +} + /* Wait for control to return from inferior to debugger. If TREAT_EXEC_AS_SIGTRAP is non-zero, then handle EXEC signals @@ -1790,14 +1814,7 @@ wait_for_inferior (int treat_exec_as_sig 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); - } + print_target_wait_results (waiton_ptid, ecs->ptid, &ecs->ws); if (treat_exec_as_sigtrap && ecs->ws.kind == TARGET_WAITKIND_EXECD) { @@ -1875,14 +1892,7 @@ fetch_inferior_event (void *client_data) 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); - } + print_target_wait_results (waiton_ptid, ecs->ptid, &ecs->ws); if (non_stop && ecs->ws.kind != TARGET_WAITKIND_IGNORE