winedbg: Build with msvcrt.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-10-04 15:19:20 +02:00
parent 13125b51cd
commit 0ea9fe999c
19 changed files with 36 additions and 75 deletions

View File

@ -2,7 +2,7 @@ MODULE = winedbg.exe
IMPORTS = dbghelp advapi32 IMPORTS = dbghelp advapi32
DELAYIMPORTS = comdlg32 shell32 comctl32 user32 gdi32 ws2_32 DELAYIMPORTS = comdlg32 shell32 comctl32 user32 gdi32 ws2_32
EXTRADLLFLAGS = -mconsole -mcygwin EXTRADLLFLAGS = -mconsole
C_SRCS = \ C_SRCS = \
be_arm.c \ be_arm.c \

View File

@ -20,7 +20,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include "debugger.h" #include "debugger.h"
#include "wine/debug.h" #include "wine/debug.h"

View File

@ -26,8 +26,6 @@
#include "shellapi.h" #include "shellapi.h"
#include "psapi.h" #include "psapi.h"
#include "wine/unicode.h"
#include "resource.h" #include "resource.h"
#define MAX_PROGRAM_NAME_LENGTH 80 #define MAX_PROGRAM_NAME_LENGTH 80
@ -79,7 +77,7 @@ static WCHAR *get_program_name(HANDLE hProcess)
return unidentified; return unidentified;
} }
programname = strrchrW(image_name, '\\'); programname = wcsrchr(image_name, '\\');
if (programname != NULL) if (programname != NULL)
programname++; programname++;
else else
@ -89,7 +87,7 @@ static WCHAR *get_program_name(HANDLE hProcess)
* user-friendly program name */ * user-friendly program name */
/* don't display a too long string to the user */ /* don't display a too long string to the user */
if (strlenW(programname) >= MAX_PROGRAM_NAME_LENGTH) if (lstrlenW(programname) >= MAX_PROGRAM_NAME_LENGTH)
{ {
programname[MAX_PROGRAM_NAME_LENGTH - 4] = '.'; programname[MAX_PROGRAM_NAME_LENGTH - 4] = '.';
programname[MAX_PROGRAM_NAME_LENGTH - 3] = '.'; programname[MAX_PROGRAM_NAME_LENGTH - 3] = '.';
@ -382,7 +380,7 @@ int display_crash_dialog(void)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dbg_curr_pid); hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dbg_curr_pid);
g_ProgramName = get_program_name(hProcess); g_ProgramName = get_program_name(hProcess);
CloseHandle(hProcess); CloseHandle(hProcess);
if (!strcmpW( g_ProgramName, winedeviceW )) return TRUE; if (!wcscmp( g_ProgramName, winedeviceW )) return TRUE;
InitCommonControlsEx( &init ); InitCommonControlsEx( &init );
return DialogBoxW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(IDD_CRASH_DLG), NULL, crash_dlg_proc); return DialogBoxW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(IDD_CRASH_DLG), NULL, crash_dlg_proc);
} }

View File

@ -33,12 +33,12 @@
#include "debugger.h" #include "debugger.h"
#if defined(__GNUC__) && (__GNUC__ >= 3) #if defined(__GNUC__) && (__GNUC__ >= 3)
static int (*db_printf)(const char* format, ...) __attribute__((format (printf,1,2))); static int WINAPIV (*db_printf)(const char* format, ...) __attribute__((format (printf,1,2)));
#else #else
static int (*db_printf)(const char* format, ...); static int WINAPIV (*db_printf)(const char* format, ...);
#endif #endif
static int no_printf(const char* format, ...) {return 0;} static int WINAPIV no_printf(const char* format, ...) {return 0;}
typedef DWORD_PTR db_addr_t; typedef DWORD_PTR db_addr_t;
typedef BOOL boolean_t; typedef BOOL boolean_t;

View File

@ -21,9 +21,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include "wine/port.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -22,7 +22,6 @@
%option noinput nounput always-interactive 8bit prefix="dbg_" %option noinput nounput always-interactive 8bit prefix="dbg_"
%{ %{
#include "config.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>

View File

@ -447,9 +447,9 @@ extern struct dbg_type types_find_type(DWORD64 linear, const char* name, enum S
extern void dbg_outputW(const WCHAR* buffer, int len); extern void dbg_outputW(const WCHAR* buffer, int len);
extern const char* dbg_W2A(const WCHAR* buffer, unsigned len); extern const char* dbg_W2A(const WCHAR* buffer, unsigned len);
#ifdef __GNUC__ #ifdef __GNUC__
extern int dbg_printf(const char* format, ...) __attribute__((format (printf,1,2))); extern int WINAPIV dbg_printf(const char* format, ...) __attribute__((format (printf,1,2)));
#else #else
extern int dbg_printf(const char* format, ...); extern int WINAPIV dbg_printf(const char* format, ...);
#endif #endif
extern const struct dbg_internal_var* dbg_get_internal_var(const char*); extern const struct dbg_internal_var* dbg_get_internal_var(const char*);
extern BOOL dbg_interrupt_debuggee(void); extern BOOL dbg_interrupt_debuggee(void);

View File

@ -18,8 +18,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>

View File

@ -24,27 +24,20 @@
* http://sources.redhat.com/gdb/onlinedocs/gdb/Maintenance-Commands.html * http://sources.redhat.com/gdb/onlinedocs/gdb/Maintenance-Commands.html
*/ */
#include "config.h"
#define NONAMELESSUNION #define NONAMELESSUNION
#define NONAMELESSSTRUCT #define NONAMELESSSTRUCT
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "winsock2.h"
#include <assert.h> #include <assert.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "debugger.h" #include "debugger.h"
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winsock2.h"
#include "tlhelp32.h" #include "tlhelp32.h"
#include "wine/exception.h" #include "wine/exception.h"
#include "wine/debug.h" #include "wine/debug.h"
@ -1283,15 +1276,15 @@ static enum packet_return packet_read_register(struct gdb_context* gdbctx)
if (!backend->get_context(thread->handle, &ctx)) if (!backend->get_context(thread->handle, &ctx))
return packet_error; return packet_error;
if (sscanf(gdbctx->in_packet, "%zx", &reg) != 1) if (sscanf(gdbctx->in_packet, "%Ix", &reg) != 1)
return packet_error; return packet_error;
if (reg >= backend->gdb_num_regs) if (reg >= backend->gdb_num_regs)
{ {
WARN("Unhandled register %zu\n", reg); WARN("Unhandled register %Iu\n", reg);
return packet_error; return packet_error;
} }
TRACE("%zu => %s\n", reg, wine_dbgstr_longlong(cpu_register(gdbctx, &ctx, reg))); TRACE("%Iu => %s\n", reg, wine_dbgstr_longlong(cpu_register(gdbctx, &ctx, reg)));
packet_reply_open(gdbctx); packet_reply_open(gdbctx);
packet_reply_register_hex_to(gdbctx, &ctx, reg); packet_reply_register_hex_to(gdbctx, &ctx, reg);
@ -1318,18 +1311,18 @@ static enum packet_return packet_write_register(struct gdb_context* gdbctx)
return packet_error; return packet_error;
*ptr++ = '\0'; *ptr++ = '\0';
if (sscanf(gdbctx->in_packet, "%zx", &reg) != 1) if (sscanf(gdbctx->in_packet, "%Ix", &reg) != 1)
return packet_error; return packet_error;
if (reg >= backend->gdb_num_regs) if (reg >= backend->gdb_num_regs)
{ {
/* FIXME: if just the reg is above cpu_num_regs, don't tell gdb /* FIXME: if just the reg is above cpu_num_regs, don't tell gdb
* it wouldn't matter too much, and it fakes our support for all regs * it wouldn't matter too much, and it fakes our support for all regs
*/ */
WARN("Unhandled register %zu\n", reg); WARN("Unhandled register %Iu\n", reg);
return packet_ok; return packet_ok;
} }
TRACE("%zu <= %s\n", reg, debugstr_an(ptr, (int)(gdbctx->in_packet_len - (ptr - gdbctx->in_packet)))); TRACE("%Iu <= %s\n", reg, debugstr_an(ptr, (int)(gdbctx->in_packet_len - (ptr - gdbctx->in_packet))));
cpu_register_hex_from(gdbctx, &ctx, reg, (const char**)&ptr); cpu_register_hex_from(gdbctx, &ctx, reg, (const char**)&ptr);
if (!backend->set_context(thread->handle, &ctx)) if (!backend->set_context(thread->handle, &ctx))
@ -1747,7 +1740,7 @@ static void packet_query_target_xml(struct gdb_context* gdbctx, struct backend_c
"</flags>"); "</flags>");
} }
snprintf(buffer, ARRAY_SIZE(buffer), "<reg name=\"%s\" bitsize=\"%zu\"", snprintf(buffer, ARRAY_SIZE(buffer), "<reg name=\"%s\" bitsize=\"%Iu\"",
cpu->gdb_register_map[i].name, 8 * cpu->gdb_register_map[i].length); cpu->gdb_register_map[i].name, 8 * cpu->gdb_register_map[i].length);
packet_reply_add(gdbctx, buffer); packet_reply_add(gdbctx, buffer);
@ -2111,19 +2104,17 @@ static int fetch_data(struct gdb_context* gdbctx)
static BOOL gdb_exec(unsigned port, unsigned flags) static BOOL gdb_exec(unsigned port, unsigned flags)
{ {
char buf[MAX_PATH]; WCHAR tmp[MAX_PATH], buf[MAX_PATH];
int fd;
const char *gdb_path, *tmp_path;
FILE* f;
const char *argv[6]; const char *argv[6];
char *unix_tmp;
const char *gdb_path;
FILE* f;
if (!(gdb_path = getenv("WINE_GDB"))) gdb_path = "gdb"; if (!(gdb_path = getenv("WINE_GDB"))) gdb_path = "gdb";
if (!(tmp_path = getenv("TMPDIR"))) tmp_path = "/tmp"; GetTempPathW( MAX_PATH, buf );
strcpy(buf, tmp_path); GetTempFileNameW( buf, L"gdb", 0, tmp );
strcat(buf, "/winegdb.XXXXXX"); if ((f = _wfopen( tmp, L"w+" )) == NULL) return FALSE;
fd = mkstemps(buf, 0); unix_tmp = wine_get_unix_file_name( tmp );
if (fd == -1) return FALSE;
if ((f = fdopen(fd, "w+")) == NULL) return FALSE;
fprintf(f, "target remote localhost:%d\n", ntohs(port)); fprintf(f, "target remote localhost:%d\n", ntohs(port));
fprintf(f, "set prompt Wine-gdb>\\ \n"); fprintf(f, "set prompt Wine-gdb>\\ \n");
/* gdb 5.1 seems to require it, won't hurt anyway */ /* gdb 5.1 seems to require it, won't hurt anyway */
@ -2137,18 +2128,19 @@ static BOOL gdb_exec(unsigned port, unsigned flags)
*/ */
fprintf(f, "set step-mode on\n"); fprintf(f, "set step-mode on\n");
/* tell gdb to delete this file when done handling it... */ /* tell gdb to delete this file when done handling it... */
fprintf(f, "shell rm -f \"%s\"\n", buf); fprintf(f, "shell rm -f \"%s\"\n", unix_tmp);
fclose(f); fclose(f);
argv[0] = "xterm"; argv[0] = "xterm";
argv[1] = "-e"; argv[1] = "-e";
argv[2] = gdb_path; argv[2] = gdb_path;
argv[3] = "-x"; argv[3] = "-x";
argv[4] = buf; argv[4] = unix_tmp;
argv[5] = NULL; argv[5] = NULL;
if (flags & FLAG_WITH_XTERM) if (flags & FLAG_WITH_XTERM)
__wine_unix_spawnvp( (char **)argv, FALSE ); __wine_unix_spawnvp( (char **)argv, FALSE );
else else
__wine_unix_spawnvp( (char **)argv + 2, FALSE ); __wine_unix_spawnvp( (char **)argv + 2, FALSE );
HeapFree( GetProcessHeap(), 0, unix_tmp );
return TRUE; return TRUE;
} }

View File

@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -177,7 +175,7 @@ static void module_print_info(const struct info_module *module, BOOL is_embedded
is_embedded ? "\\" : get_symtype_str(&module->mi), module->name); is_embedded ? "\\" : get_symtype_str(&module->mi), module->name);
} }
static int module_compare(const void* p1, const void* p2) static int __cdecl module_compare(const void* p1, const void* p2)
{ {
struct info_module *left = (struct info_module *)p1; struct info_module *left = (struct info_module *)p1;
struct info_module *right = (struct info_module *)p2; struct info_module *right = (struct info_module *)p2;

View File

@ -20,16 +20,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include "wine/port.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "debugger.h" #include "debugger.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(winedbg); WINE_DEFAULT_DEBUG_CHANNEL(winedbg);

View File

@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -20,8 +20,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>

View File

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>

View File

@ -18,8 +18,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -31,7 +29,6 @@
#include "winternl.h" #include "winternl.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/exception.h" #include "wine/exception.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(winedbg); WINE_DEFAULT_DEBUG_CHANNEL(winedbg);
@ -308,11 +305,11 @@ void fetch_module_name(void* name_addr, void* mod_addr, WCHAR* buffer, size_t bu
/* FIXME: proper NT->Dos conversion */ /* FIXME: proper NT->Dos conversion */
static const WCHAR nt_prefixW[] = {'\\','?','?','\\'}; static const WCHAR nt_prefixW[] = {'\\','?','?','\\'};
if (!strncmpW( buffer, nt_prefixW, 4 )) if (!wcsncmp( buffer, nt_prefixW, 4 ))
memmove( buffer, buffer + 4, (lstrlenW(buffer + 4) + 1) * sizeof(WCHAR) ); memmove( buffer, buffer + 4, (lstrlenW(buffer + 4) + 1) * sizeof(WCHAR) );
} }
else else
snprintfW(buffer, bufsz, dlladdr, (ULONG_PTR)mod_addr); swprintf(buffer, bufsz, dlladdr, (ULONG_PTR)mod_addr);
} }
} }
@ -376,7 +373,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
if (!QueryFullProcessImageNameW( dbg_curr_process->handle, 0, u.buffer, &size )) if (!QueryFullProcessImageNameW( dbg_curr_process->handle, 0, u.buffer, &size ))
{ {
static const WCHAR pcspid[] = {'P','r','o','c','e','s','s','_','%','0','8','x',0}; static const WCHAR pcspid[] = {'P','r','o','c','e','s','s','_','%','0','8','x',0};
snprintfW( u.buffer, ARRAY_SIZE(u.buffer), pcspid, dbg_curr_pid); swprintf( u.buffer, ARRAY_SIZE(u.buffer), pcspid, dbg_curr_pid);
} }
WINE_TRACE("%04x:%04x: create process '%s'/%p @%p (%u<%u>)\n", WINE_TRACE("%04x:%04x: create process '%s'/%p @%p (%u<%u>)\n",

View File

@ -21,9 +21,6 @@
#define NONAMELESSUNION #define NONAMELESSUNION
#define NONAMELESSSTRUCT #define NONAMELESSSTRUCT
#include "config.h"
#include "wine/port.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>

View File

@ -18,8 +18,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>

View File

@ -21,7 +21,6 @@
* upon which full support for datatype handling will eventually be built. * upon which full support for datatype handling will eventually be built.
*/ */
#include "config.h"
#include <stdlib.h> #include <stdlib.h>
#include "debugger.h" #include "debugger.h"

View File

@ -17,9 +17,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include "wine/port.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -149,15 +146,15 @@ void dbg_outputW(const WCHAR* buffer, int len)
/* FIXME: should CP_ACP be GetConsoleCP()? */ /* FIXME: should CP_ACP be GetConsoleCP()? */
} }
int dbg_printf(const char* format, ...) int WINAPIV dbg_printf(const char* format, ...)
{ {
static char buf[4*1024]; static char buf[4*1024];
va_list valist; __ms_va_list valist;
int len; int len;
va_start(valist, format); __ms_va_start(valist, format);
len = vsnprintf(buf, sizeof(buf), format, valist); len = vsnprintf(buf, sizeof(buf), format, valist);
va_end(valist); __ms_va_end(valist);
if (len <= -1 || len >= sizeof(buf)) if (len <= -1 || len >= sizeof(buf))
{ {