From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id 9F1EF3AAA07B for ; Fri, 13 Mar 2020 19:09:02 +0000 (GMT) Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 98D76561B7; Fri, 13 Mar 2020 15:09:02 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id vQlpqQcIiR4q; Fri, 13 Mar 2020 15:09:02 -0400 (EDT) Received: from murgatroyd.Home (184-96-250-69.hlrn.qwest.net [184.96.250.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 56227561B0; Fri, 13 Mar 2020 15:09:02 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v3 17/29] Normalize handle_output_debug_string API Date: Fri, 13 Mar 2020 13:08:43 -0600 Message-Id: <20200313190855.28662-18-tromey@adacore.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200313190855.28662-1-tromey@adacore.com> References: <20200313190855.28662-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-25.0 required=5.0 tests=GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2020 19:09:03 -0000 This changes gdbserver's implementation of handle_output_debug_string to have the same calling convention as that of gdb. This allows for sharing some more code in a subsequent patch. gdb/ChangeLog 2020-03-13 Tom Tromey * windows-nat.c (windows_nat::handle_output_debug_string): Rename. No longer static. * nat/windows-nat.h (handle_output_debug_string): Declare. gdbserver/ChangeLog 2020-03-13 Tom Tromey * win32-low.c (handle_output_debug_string): Add parameter. Change return type. (win32_kill, get_child_debug_event): Update. --- gdb/ChangeLog | 6 ++++++ gdb/nat/windows-nat.h | 11 +++++++++++ gdb/windows-nat.c | 9 ++++----- gdbserver/ChangeLog | 6 ++++++ gdbserver/win32-low.cc | 21 ++++++++++++--------- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h index 501147b2c90..f438befbc94 100644 --- a/gdb/nat/windows-nat.h +++ b/gdb/nat/windows-nat.h @@ -114,6 +114,17 @@ enum thread_disposition_type extern windows_thread_info *thread_rec (ptid_t ptid, thread_disposition_type disposition); + +/* Handle OUTPUT_DEBUG_STRING_EVENT from child process. Updates + OURSTATUS and returns the thread id if this represents a thread + change (this is specific to Cygwin), otherwise 0. + + Cygwin prepends its messages with a "cygwin:". Interpret this as + a Cygwin signal. Otherwise just print the string as a warning. + + This function must be supplied by the embedding application. */ +extern int handle_output_debug_string (struct target_waitstatus *ourstatus); + /* Currently executing process */ extern HANDLE current_process_handle; extern DWORD current_process_id; diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 74b852ca603..370e7bc1ae5 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1004,11 +1004,10 @@ signal_event_command (const char *args, int from_tty) CloseHandle ((HANDLE) event_id); } -/* Handle DEBUG_STRING output from child process. - Cygwin prepends its messages with a "cygwin:". Interpret this as - a Cygwin signal. Otherwise just print the string as a warning. */ -static int -handle_output_debug_string (struct target_waitstatus *ourstatus) +/* See nat/windows-nat.h. */ + +int +windows_nat::handle_output_debug_string (struct target_waitstatus *ourstatus) { gdb::unique_xmalloc_ptr s; int retval = 0; diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc index 7060b6d1527..2130366747c 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -733,9 +733,10 @@ win32_process_target::attach (unsigned long pid) (int) err, strwinerror (err)); } -/* Handle OUTPUT_DEBUG_STRING_EVENT from child process. */ -static void -handle_output_debug_string (void) +/* See nat/windows-nat.h. */ + +int +windows_nat::handle_output_debug_string (struct target_waitstatus *ourstatus) { #define READ_BUFFER_LEN 1024 CORE_ADDR addr; @@ -743,7 +744,7 @@ handle_output_debug_string (void) DWORD nbytes = current_event.u.DebugString.nDebugStringLength; if (nbytes == 0) - return; + return 0; if (nbytes > READ_BUFFER_LEN) nbytes = READ_BUFFER_LEN; @@ -756,13 +757,13 @@ handle_output_debug_string (void) in Unicode. */ WCHAR buffer[(READ_BUFFER_LEN + 1) / sizeof (WCHAR)] = { 0 }; if (read_inferior_memory (addr, (unsigned char *) buffer, nbytes) != 0) - return; + return 0; wcstombs (s, buffer, (nbytes + 1) / sizeof (WCHAR)); } else { if (read_inferior_memory (addr, (unsigned char *) s, nbytes) != 0) - return; + return 0; } if (!startswith (s, "cYg")) @@ -770,12 +771,14 @@ handle_output_debug_string (void) if (!server_waiting) { OUTMSG2(("%s", s)); - return; + return 0; } monitor_output (s); } #undef READ_BUFFER_LEN + + return 0; } static void @@ -804,7 +807,7 @@ win32_process_target::kill (process_info *process) if (current_event.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT) break; else if (current_event.dwDebugEventCode == OUTPUT_DEBUG_STRING_EVENT) - handle_output_debug_string (); + handle_output_debug_string (nullptr); } win32_clear_inferiors (); @@ -1504,7 +1507,7 @@ get_child_debug_event (struct target_waitstatus *ourstatus) "for pid=%u tid=%x\n", (unsigned) current_event.dwProcessId, (unsigned) current_event.dwThreadId)); - handle_output_debug_string (); + handle_output_debug_string (nullptr); break; default: -- 2.21.1