* [review] Normalize handle_output_debug_string API
@ 2019-11-26 17:12 Tom Tromey (Code Review)
2019-11-29 19:52 ` Pedro Alves (Code Review)
0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-26 17:12 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/711
......................................................................
Normalize handle_output_debug_string API
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
2019-11-26 Tom Tromey <tromey@adacore.com>
* windows-nat.c (windows_nat::handle_output_debug_string):
Rename. No longer static.
* nat/windows-nat.h (handle_output_debug_string): Declare.
gdb/gdbserver/ChangeLog
2019-11-26 Tom Tromey <tromey@adacore.com>
* win32-low.c (handle_output_debug_string): Add parameter. Change
return type.
(win32_kill, get_child_debug_event): Update.
Change-Id: I1fd6e593c561a39799d005843ae56564d4114a17
---
M gdb/ChangeLog
M gdb/gdbserver/ChangeLog
M gdb/gdbserver/win32-low.c
M gdb/nat/windows-nat.h
M gdb/windows-nat.c
5 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b0921f9..976c19a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2019-11-26 Tom Tromey <tromey@adacore.com>
+ * windows-nat.c (windows_nat::handle_output_debug_string):
+ Rename. No longer static.
+ * nat/windows-nat.h (handle_output_debug_string): Declare.
+
+2019-11-26 Tom Tromey <tromey@adacore.com>
+
* windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 8349b8d..bd20f14 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,11 @@
2019-11-26 Tom Tromey <tromey@adacore.com>
+ * win32-low.c (handle_output_debug_string): Add parameter. Change
+ return type.
+ (win32_kill, get_child_debug_event): Update.
+
+2019-11-26 Tom Tromey <tromey@adacore.com>
+
* win32-low.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event): Move to
nat/windows-nat.c.
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 4cf60b2..7825630 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -722,9 +722,10 @@
(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;
@@ -732,7 +733,7 @@
DWORD nbytes = current_event.u.DebugString.nDebugStringLength;
if (nbytes == 0)
- return;
+ return 0;
if (nbytes > READ_BUFFER_LEN)
nbytes = READ_BUFFER_LEN;
@@ -745,13 +746,13 @@
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"))
@@ -759,12 +760,14 @@
if (!server_waiting)
{
OUTMSG2(("%s", s));
- return;
+ return 0;
}
monitor_output (s);
}
#undef READ_BUFFER_LEN
+
+ return 0;
}
static void
@@ -792,7 +795,7 @@
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 ();
@@ -1473,7 +1476,7 @@
"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:
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index de53f2f..01c647e 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -107,6 +107,14 @@
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.
+
+ 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 fad3952..083e05b 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -900,11 +900,10 @@
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<char> s;
int retval = 0;
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I1fd6e593c561a39799d005843ae56564d4114a17
Gerrit-Change-Number: 711
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newchange
^ permalink raw reply [flat|nested] 4+ messages in thread
* [review] Normalize handle_output_debug_string API
2019-11-26 17:12 [review] Normalize handle_output_debug_string API Tom Tromey (Code Review)
@ 2019-11-29 19:52 ` Pedro Alves (Code Review)
0 siblings, 0 replies; 4+ messages in thread
From: Pedro Alves (Code Review) @ 2019-11-29 19:52 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
Pedro Alves has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/711
......................................................................
Patch Set 1: Code-Review+2
(1 comment)
LGTM other the losing one comment.
| --- gdb/windows-nat.c
| +++ gdb/windows-nat.c
| @@ -894,17 +894,16 @@ signal_event_command (const char *args, int from_tty)
|
| if ((errno == ERANGE) || (event_id == 0) || (event_id > UINTPTR_MAX) ||
| ((HANDLE) event_id == INVALID_HANDLE_VALUE))
| error (_("Failed to convert `%s' to event id"), args);
|
| SetEvent ((HANDLE) event_id);
| 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. */
PS1, Line 905:
I think that we're losing this concise description of how Cygwin
messages are interpreted.
| -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<char> s;
| int retval = 0;
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I1fd6e593c561a39799d005843ae56564d4114a17
Gerrit-Change-Number: 711
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Comment-Date: Fri, 29 Nov 2019 19:51:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 4+ messages in thread
* [review] Normalize handle_output_debug_string API
2019-10-29 17:58 Tom Tromey (Code Review)
@ 2019-11-27 0:02 ` Luis Machado (Code Review)
0 siblings, 0 replies; 4+ messages in thread
From: Luis Machado (Code Review) @ 2019-11-27 0:02 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
Luis Machado has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/420
......................................................................
Patch Set 1: Code-Review+1
LGTM
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I7ce60462781ff2d4fc9e5cb6f7bbd6d390c6826b
Gerrit-Change-Number: 420
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Luis Machado <luis.machado@linaro.org>
Gerrit-Comment-Date: Wed, 27 Nov 2019 00:02:45 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 4+ messages in thread
* [review] Normalize handle_output_debug_string API
@ 2019-10-29 17:58 Tom Tromey (Code Review)
2019-11-27 0:02 ` Luis Machado (Code Review)
0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey (Code Review) @ 2019-10-29 17:58 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/420
......................................................................
Normalize handle_output_debug_string API
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.
Change-Id: I1fd6e593c561a39799d005843ae56564d4114a17
gdb/ChangeLog
2019-10-29 Tom Tromey <tromey@adacore.com>
* windows-nat.c (windows_nat::handle_output_debug_string):
Rename. No longer static.
* nat/windows-nat.h (handle_output_debug_string): Declare.
gdb/gdbserver/ChangeLog
2019-10-29 Tom Tromey <tromey@adacore.com>
* win32-low.c (handle_output_debug_string): Add parameter. Change
return type.
(win32_kill, get_child_debug_event): Update.
Change-Id: I7ce60462781ff2d4fc9e5cb6f7bbd6d390c6826b
---
M gdb/ChangeLog
M gdb/gdbserver/ChangeLog
M gdb/gdbserver/win32-low.c
M gdb/nat/windows-nat.h
M gdb/windows-nat.c
5 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4434f9a..81c52ca 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2019-10-29 Tom Tromey <tromey@adacore.com>
+ * windows-nat.c (windows_nat::handle_output_debug_string):
+ Rename. No longer static.
+ * nat/windows-nat.h (handle_output_debug_string): Declare.
+
+2019-10-29 Tom Tromey <tromey@adacore.com>
+
* windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 646ca7f..72418f8 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,11 @@
2019-10-29 Tom Tromey <tromey@adacore.com>
+ * win32-low.c (handle_output_debug_string): Add parameter. Change
+ return type.
+ (win32_kill, get_child_debug_event): Update.
+
+2019-10-29 Tom Tromey <tromey@adacore.com>
+
* win32-low.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event): Move to
nat/windows-nat.c.
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 4cf60b2..7825630 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -722,9 +722,10 @@
(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;
@@ -732,7 +733,7 @@
DWORD nbytes = current_event.u.DebugString.nDebugStringLength;
if (nbytes == 0)
- return;
+ return 0;
if (nbytes > READ_BUFFER_LEN)
nbytes = READ_BUFFER_LEN;
@@ -745,13 +746,13 @@
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"))
@@ -759,12 +760,14 @@
if (!server_waiting)
{
OUTMSG2(("%s", s));
- return;
+ return 0;
}
monitor_output (s);
}
#undef READ_BUFFER_LEN
+
+ return 0;
}
static void
@@ -792,7 +795,7 @@
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 ();
@@ -1473,7 +1476,7 @@
"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:
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index c497d73..5eedb54 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -103,6 +103,14 @@
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.
+
+ 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 3762af3..38b3828 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -875,11 +875,10 @@
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<char> s;
int retval = 0;
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I7ce60462781ff2d4fc9e5cb6f7bbd6d390c6826b
Gerrit-Change-Number: 420
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newchange
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-29 19:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-26 17:12 [review] Normalize handle_output_debug_string API Tom Tromey (Code Review)
2019-11-29 19:52 ` Pedro Alves (Code Review)
-- strict thread matches above, loose matches on Subject: below --
2019-10-29 17:58 Tom Tromey (Code Review)
2019-11-27 0:02 ` Luis Machado (Code Review)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).