public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed] Fix the Windows build
@ 2021-07-26 13:35 Tom Tromey
  2021-07-26 13:49 ` Simon Marchi
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2021-07-26 13:35 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The gdb build was broken on Windows after the patch to change
get_inferior_cwd.  This patch fixes the build.
---
 gdb/windows-nat.c      | 20 +++++++++++---------
 gdbserver/win32-low.cc |  6 +++---
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 9526149311b..0c2d55ef67b 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2553,14 +2553,16 @@ windows_nat_target::create_inferior (const char *exec_file,
   PROCESS_INFORMATION pi;
   BOOL ret;
   DWORD flags = 0;
-  const char *inferior_tty = current_inferior ()->tty ();
+  const std::string &inferior_tty = current_inferior ()->tty ();
 
   if (!exec_file)
     error (_("No executable specified, use `target exec'."));
 
-  const char *inferior_cwd = current_inferior ()->cwd ();
+  const char *inferior_cwd = current_inferior ()->cwd ().c_str ();
   std::string expanded_infcwd;
-  if (inferior_cwd != NULL)
+  if (*inferior_cwd == '\0')
+    inferior_cwd = nullptr;
+  else
     {
       expanded_infcwd = gdb_tilde_expand (inferior_cwd);
       /* Mirror slashes on inferior's cwd.  */
@@ -2652,14 +2654,14 @@ windows_nat_target::create_inferior (const char *exec_file,
       w32_env = NULL;
     }
 
-  if (inferior_tty == nullptr)
+  if (inferior_tty.empty ())
     tty = ostdin = ostdout = ostderr = -1;
   else
     {
-      tty = open (inferior_tty, O_RDWR | O_NOCTTY);
+      tty = open (inferior_tty.c_str (), O_RDWR | O_NOCTTY);
       if (tty < 0)
 	{
-	  print_sys_errmsg (inferior_tty, errno);
+	  print_sys_errmsg (inferior_tty.c_str (), errno);
 	  ostdin = ostdout = ostderr = -1;
 	}
       else
@@ -2725,18 +2727,18 @@ windows_nat_target::create_inferior (const char *exec_file,
     }
   /* If not all the standard streams are redirected by the command
      line, use INFERIOR_TTY for those which aren't.  */
-  if (inferior_tty != nullptr
+  if (!inferior_tty.empty ()
       && !(fd_inp >= 0 && fd_out >= 0 && fd_err >= 0))
     {
       SECURITY_ATTRIBUTES sa;
       sa.nLength = sizeof(sa);
       sa.lpSecurityDescriptor = 0;
       sa.bInheritHandle = TRUE;
-      tty = CreateFileA (inferior_tty, GENERIC_READ | GENERIC_WRITE,
+      tty = CreateFileA (inferior_tty.c_str (), GENERIC_READ | GENERIC_WRITE,
 			 0, &sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
       if (tty == INVALID_HANDLE_VALUE)
 	warning (_("Warning: Failed to open TTY %s, error %#x."),
-		 inferior_tty, (unsigned) GetLastError ());
+		 inferior_tty.c_str (), (unsigned) GetLastError ());
     }
   if (redirected || tty != INVALID_HANDLE_VALUE)
     {
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 5c7946bd33a..1e97f91d954 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -559,7 +559,7 @@ static BOOL
 create_process (const char *program, char *args,
 		DWORD flags, PROCESS_INFORMATION *pi)
 {
-  const char *inferior_cwd = get_inferior_cwd ();
+  const std::string &inferior_cwd = get_inferior_cwd ();
   BOOL ret;
   size_t argslen, proglen;
 
@@ -580,9 +580,9 @@ create_process (const char *program, char *args,
 			flags,             /* start flags */
 			NULL,              /* environment */
 			/* current directory */
-			(inferior_cwd == NULL
+			(inferior_cwd.empty ()
 			 ? NULL
-			 : gdb_tilde_expand (inferior_cwd).c_str()),
+			 : gdb_tilde_expand (inferior_cwd.c_str ()).c_str()),
 			&si,               /* start info */
 			pi);               /* proc info */
 
-- 
2.26.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [pushed] Fix the Windows build
  2021-07-26 13:35 [pushed] Fix the Windows build Tom Tromey
@ 2021-07-26 13:49 ` Simon Marchi
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2021-07-26 13:49 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2021-07-26 9:35 a.m., Tom Tromey wrote:
> The gdb build was broken on Windows after the patch to change
> get_inferior_cwd.  This patch fixes the build.

Ah, thanks for doing this, I forgot to build with mingw.

Simon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-26 13:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-26 13:35 [pushed] Fix the Windows build Tom Tromey
2021-07-26 13:49 ` Simon Marchi

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).