From: Corinna Vinschen <vinschen@redhat.com>
To: gdb-patches@sourceware.org
Subject: [patch]: Replace stryoul call to fetch address
Date: Wed, 27 Feb 2013 16:44:00 -0000 [thread overview]
Message-ID: <20130227164419.GA16975@calimero.vinschen.de> (raw)
Hi,
here's a small patch which will help along building GDB on the (not
yet finished) x86_64 Cygwin.
Mostly these are just a few casts, and tweaks to the printf format
strings, so that the argument and the format matches all three cases:
- i686
- x86_64 LLP (Mingw, native Windows)
- x86_64 LP (Cygwin)
The most important part of the patch is in handle_output_debug_string,
though. The address for the context information is read from the string
using the strtoul function. This works fine for a 32 bit GDB, and it
also works fine for a 64 bit Cygwin GDB. It does not work for a 64 bit
Mingw GDB debugging a 64 bit Cygwin application, though. Therefore I
replaced the strtoul with a call to string_to_core_addr.
Apart from that there's more required to get GDB working on Cygwin,
apparently, but I thought the below patch is simple enough to go in
already.
Ok to apply?
Thanks,
Corinna
* windows-nat.c: Throughout, fix format strings and casts of
printf-like functions to avoid type related warnings on all
platforms.
(handle_output_debug_string): Fetch context information address
from debug string using string_to_core_addr.
Index: windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.240
diff -u -p -r1.240 windows-nat.c
--- windows-nat.c 19 Feb 2013 15:46:32 -0000 1.240
+++ windows-nat.c 27 Feb 2013 16:42:42 -0000
@@ -289,8 +289,8 @@ static void
check (BOOL ok, const char *file, int line)
{
if (!ok)
- printf_filtered ("error return %s:%d was %lu\n", file, line,
- GetLastError ());
+ printf_filtered ("error return %s:%d was %u\n", file, line,
+ (unsigned) GetLastError ());
}
/* Find a thread record given a thread id. If GET_CONTEXT is not 0,
@@ -311,7 +311,7 @@ thread_rec (DWORD id, int get_context)
if (SuspendThread (th->h) == (DWORD) -1)
{
DWORD err = GetLastError ();
- warning (_("SuspendThread failed. (winerr %d)"),
+ warning (_("SuspendThread failed. (winerr %u)"),
(int) err);
return NULL;
}
@@ -576,7 +576,8 @@ get_module_name (LPVOID base_address, ch
len = GetModuleFileNameEx (current_process_handle,
DllHandle[i], pathbuf, __PMAX);
if (len == 0)
- error (_("Error getting dll name: %lu."), GetLastError ());
+ error (_("Error getting dll name: %u."),
+ (unsigned) GetLastError ());
if (cygwin_conv_path (CCP_WIN_W_TO_POSIX, pathbuf, dll_name_ret,
__PMAX) < 0)
error (_("Error converting dll name to POSIX: %d."), errno);
@@ -977,7 +978,7 @@ handle_output_debug_string (struct targe
retval = strtoul (p, &p, 0);
if (!retval)
retval = main_thread_id;
- else if ((x = (LPCVOID) strtoul (p, &p, 0))
+ else if ((x = (LPCVOID) string_to_core_addr (p))
&& ReadProcessMemory (current_process_handle, x,
&saved_context,
__COPY_CONTEXT_SIZE, &n)
@@ -1000,7 +1001,7 @@ display_selector (HANDLE thread, DWORD s
if (GetThreadSelectorEntry (thread, sel, &info))
{
int base, limit;
- printf_filtered ("0x%03lx: ", sel);
+ printf_filtered ("0x%03x: ", (unsigned) sel);
if (!info.HighWord.Bits.Pres)
{
puts_filtered ("Segment not present\n");
@@ -1064,7 +1065,7 @@ display_selector (HANDLE thread, DWORD s
if (err == ERROR_NOT_SUPPORTED)
printf_filtered ("Function not supported\n");
else
- printf_filtered ("Invalid selector 0x%lx.\n",sel);
+ printf_filtered ("Invalid selector 0x%x.\n", (unsigned) sel);
return 0;
}
}
@@ -1228,8 +1229,8 @@ handle_exception (struct target_waitstat
/* Treat unhandled first chance exceptions specially. */
if (current_event.u.Exception.dwFirstChance)
return -1;
- printf_unfiltered ("gdb: unknown target exception 0x%08lx at %s\n",
- current_event.u.Exception.ExceptionRecord.ExceptionCode,
+ printf_unfiltered ("gdb: unknown target exception 0x%08x at %s\n",
+ (unsigned) current_event.u.Exception.ExceptionRecord.ExceptionCode,
host_address_to_string (
current_event.u.Exception.ExceptionRecord.ExceptionAddress));
ourstatus->value.sig = GDB_SIGNAL_UNKNOWN;
@@ -1249,8 +1250,9 @@ windows_continue (DWORD continue_status,
thread_info *th;
BOOL res;
- DEBUG_EVENTS (("ContinueDebugEvent (cpid=%ld, ctid=%lx, %s);\n",
- current_event.dwProcessId, current_event.dwThreadId,
+ DEBUG_EVENTS (("ContinueDebugEvent (cpid=%d, ctid=%x, %s);\n",
+ (unsigned) current_event.dwProcessId,
+ (unsigned) current_event.dwThreadId,
continue_status == DBG_CONTINUE ?
"DBG_CONTINUE" : "DBG_EXCEPTION_NOT_HANDLED"));
@@ -1297,8 +1299,8 @@ fake_create_process (void)
open_process_used = 1;
else
{
- error (_("OpenProcess call failed, GetLastError = %lud"),
- GetLastError ());
+ error (_("OpenProcess call failed, GetLastError = %u"),
+ (unsigned) GetLastError ());
/* We can not debug anything in that case. */
}
main_thread_id = current_event.dwThreadId;
@@ -1457,7 +1459,7 @@ get_windows_debug_event (struct target_o
switch (event_code)
{
case CREATE_THREAD_DEBUG_EVENT:
- DEBUG_EVENTS (("gdb: kernel event for pid=%d tid=%x code=%s)\n",
+ DEBUG_EVENTS (("gdb: kernel event for pid=%u tid=%x code=%s)\n",
(unsigned) current_event.dwProcessId,
(unsigned) current_event.dwThreadId,
"CREATE_THREAD_DEBUG_EVENT"));
@@ -1486,7 +1488,7 @@ get_windows_debug_event (struct target_o
break;
case EXIT_THREAD_DEBUG_EVENT:
- DEBUG_EVENTS (("gdb: kernel event for pid=%d tid=%x code=%s)\n",
+ DEBUG_EVENTS (("gdb: kernel event for pid=%u tid=%x code=%s)\n",
(unsigned) current_event.dwProcessId,
(unsigned) current_event.dwThreadId,
"EXIT_THREAD_DEBUG_EVENT"));
@@ -1500,7 +1502,7 @@ get_windows_debug_event (struct target_o
break;
case CREATE_PROCESS_DEBUG_EVENT:
- DEBUG_EVENTS (("gdb: kernel event for pid=%d tid=%x code=%s)\n",
+ DEBUG_EVENTS (("gdb: kernel event for pid=%u tid=%x code=%s)\n",
(unsigned) current_event.dwProcessId,
(unsigned) current_event.dwThreadId,
"CREATE_PROCESS_DEBUG_EVENT"));
@@ -1522,7 +1524,7 @@ get_windows_debug_event (struct target_o
break;
case EXIT_PROCESS_DEBUG_EVENT:
- DEBUG_EVENTS (("gdb: kernel event for pid=%d tid=%x code=%s)\n",
+ DEBUG_EVENTS (("gdb: kernel event for pid=%u tid=%x code=%s)\n",
(unsigned) current_event.dwProcessId,
(unsigned) current_event.dwThreadId,
"EXIT_PROCESS_DEBUG_EVENT"));
@@ -1542,7 +1544,7 @@ get_windows_debug_event (struct target_o
break;
case LOAD_DLL_DEBUG_EVENT:
- DEBUG_EVENTS (("gdb: kernel event for pid=%d tid=%x code=%s)\n",
+ DEBUG_EVENTS (("gdb: kernel event for pid=%u tid=%x code=%s)\n",
(unsigned) current_event.dwProcessId,
(unsigned) current_event.dwThreadId,
"LOAD_DLL_DEBUG_EVENT"));
@@ -1556,7 +1558,7 @@ get_windows_debug_event (struct target_o
break;
case UNLOAD_DLL_DEBUG_EVENT:
- DEBUG_EVENTS (("gdb: kernel event for pid=%d tid=%x code=%s)\n",
+ DEBUG_EVENTS (("gdb: kernel event for pid=%u tid=%x code=%s)\n",
(unsigned) current_event.dwProcessId,
(unsigned) current_event.dwThreadId,
"UNLOAD_DLL_DEBUG_EVENT"));
@@ -1569,7 +1571,7 @@ get_windows_debug_event (struct target_o
break;
case EXCEPTION_DEBUG_EVENT:
- DEBUG_EVENTS (("gdb: kernel event for pid=%d tid=%x code=%s)\n",
+ DEBUG_EVENTS (("gdb: kernel event for pid=%u tid=%x code=%s)\n",
(unsigned) current_event.dwProcessId,
(unsigned) current_event.dwThreadId,
"EXCEPTION_DEBUG_EVENT"));
@@ -1591,7 +1593,7 @@ get_windows_debug_event (struct target_o
break;
case OUTPUT_DEBUG_STRING_EVENT: /* Message from the kernel. */
- DEBUG_EVENTS (("gdb: kernel event for pid=%d tid=%x code=%s)\n",
+ DEBUG_EVENTS (("gdb: kernel event for pid=%u tid=%x code=%s)\n",
(unsigned) current_event.dwProcessId,
(unsigned) current_event.dwThreadId,
"OUTPUT_DEBUG_STRING_EVENT"));
@@ -1603,11 +1605,11 @@ get_windows_debug_event (struct target_o
default:
if (saw_create != 1)
break;
- printf_unfiltered ("gdb: kernel event for pid=%ld tid=%ld\n",
- (DWORD) current_event.dwProcessId,
- (DWORD) current_event.dwThreadId);
- printf_unfiltered (" unknown event code %ld\n",
- current_event.dwDebugEventCode);
+ printf_unfiltered ("gdb: kernel event for pid=%u tid=%x\n",
+ (unsigned) current_event.dwProcessId,
+ (unsigned) current_event.dwThreadId);
+ printf_unfiltered (" unknown event code %u\n",
+ (unsigned) current_event.dwDebugEventCode);
break;
}
@@ -1865,8 +1867,8 @@ windows_detach (struct target_ops *ops,
if (!DebugActiveProcessStop (current_event.dwProcessId))
{
- error (_("Can't detach process %lu (error %lu)"),
- current_event.dwProcessId, GetLastError ());
+ error (_("Can't detach process %u (error %u)"),
+ (unsigned) current_event.dwProcessId, (unsigned) GetLastError ());
detached = 0;
}
DebugSetProcessKillOnExit (FALSE);
@@ -1876,8 +1878,8 @@ windows_detach (struct target_ops *ops,
char *exec_file = get_exec_file (0);
if (exec_file == 0)
exec_file = "";
- printf_unfiltered ("Detaching from program: %s, Pid %lu\n", exec_file,
- current_event.dwProcessId);
+ printf_unfiltered ("Detaching from program: %s, Pid %u\n", exec_file,
+ (unsigned) current_event.dwProcessId);
gdb_flush (gdb_stdout);
}
@@ -2264,7 +2266,7 @@ windows_create_inferior (struct target_o
#endif
if (!ret)
- error (_("Error creating process %s, (error %d)."),
+ error (_("Error creating process %s, (error %u)."),
exec_file, (unsigned) GetLastError ());
CloseHandle (pi.hThread);
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
next reply other threads:[~2013-02-27 16:44 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-27 16:44 Corinna Vinschen [this message]
2013-02-27 17:20 ` Pedro Alves
2013-02-27 18:47 ` Corinna Vinschen
2013-02-27 19:40 ` Pedro Alves
2013-02-27 19:53 ` Corinna Vinschen
2013-02-27 20:03 ` [patch] gdbserver/win32-low.c: Fix printf-like formatting (was Re: [patch]: Replace stryoul call to fetch address) Corinna Vinschen
2013-02-27 21:05 ` Eli Zaretskii
2013-02-27 21:25 ` Corinna Vinschen
2013-02-27 21:30 ` Eli Zaretskii
2013-02-28 9:19 ` Corinna Vinschen
2013-02-28 16:20 ` Eli Zaretskii
2013-02-27 21:50 ` Pedro Alves
2013-02-28 11:01 ` Corinna Vinschen
2013-02-28 0:44 ` [patch]: Replace stryoul call to fetch address Pedro Alves
2013-02-28 10:02 ` Corinna Vinschen
2013-02-28 16:33 ` Corinna Vinschen
2013-02-28 16:48 ` Corinna Vinschen
2013-02-28 17:04 ` Pedro Alves
2013-02-27 20:24 ` Christopher Faylor
2013-02-27 20:29 ` Christopher Faylor
2013-02-28 0:33 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130227164419.GA16975@calimero.vinschen.de \
--to=vinschen@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox