]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Normalize handle_output_debug_string API
authorTom Tromey <tromey@adacore.com>
Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 8 Apr 2020 20:47:58 +0000 (14:47 -0600)
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-04-08  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.

gdbserver/ChangeLog
2020-04-08  Tom Tromey  <tromey@adacore.com>

* win32-low.c (handle_output_debug_string): Add parameter.  Change
return type.
(win32_kill, get_child_debug_event): Update.

gdb/ChangeLog
gdb/nat/windows-nat.h
gdb/windows-nat.c
gdbserver/ChangeLog
gdbserver/win32-low.cc

index caf72cf296a0f09422538cb8b4e1a84a9cd69d07..aeab1ffa85631cd77bd7d0a2027c7e400a9a6485 100644 (file)
@@ -1,3 +1,9 @@
+2020-04-08  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.
+
 2020-04-08  Tom Tromey  <tromey@adacore.com>
 
        * windows-nat.c (current_process_handle, current_process_id)
index 501147b2c901dfd4b1ec4fee62b128b3f54b5168..f438befbc940c58a46c683db6b41aa0e07ae91f3 100644 (file)
@@ -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;
index 83bf3394237b1c7b46336043b178df7b57c2ef96..7ccd124ac29bdf5068e5b1d9b4d962600b7f262f 100644 (file)
@@ -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<char> s;
   int retval = 0;
index ce547c13e408b109c6155e86c66ad29e0cea80e4..c6aceced1912703f94518dfc71bbc730f9a421e1 100644 (file)
@@ -1,3 +1,9 @@
+2020-04-08  Tom Tromey  <tromey@adacore.com>
+
+       * win32-low.c (handle_output_debug_string): Add parameter.  Change
+       return type.
+       (win32_kill, get_child_debug_event): Update.
+
 2020-04-08  Tom Tromey  <tromey@adacore.com>
 
        * win32-low.c (current_process_handle, current_process_id)
index 7060b6d152723b57d79e5ace2dbb311622212f9e..2130366747c91aa0c02d9784627acd831eb4ed6e 100644 (file)
@@ -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: