mainly using Unicode strings in printf
Signed-off-by: Eric Pouech eric.pouech@gmail.com ---
Eric Pouech (3): programs/winedbg: get rid of dbg_outputW helper programs/winedbg: use Unicode APIs for process/thread enumeration programs/winedbg: get rid of dbg_W2A helper
programs/winedbg/debugger.h | 2 -- programs/winedbg/gdbproxy.c | 8 ++++---- programs/winedbg/info.c | 16 ++++++++-------- programs/winedbg/memory.c | 6 +----- programs/winedbg/stack.c | 5 ++--- programs/winedbg/tgt_active.c | 4 ++-- programs/winedbg/tgt_minidump.c | 4 ++-- programs/winedbg/winedbg.c | 29 ----------------------------- 8 files changed, 19 insertions(+), 55 deletions(-)
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/debugger.h | 1 - programs/winedbg/memory.c | 6 +----- programs/winedbg/winedbg.c | 7 ------- 3 files changed, 1 insertion(+), 13 deletions(-)
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 0cc2f8b7a6c..b7dcde201d8 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -501,7 +501,6 @@ extern BOOL types_is_integral_type(const struct dbg_lvalue*); extern BOOL types_is_float_type(const struct dbg_lvalue*);
/* winedbg.c */ -extern void dbg_outputW(const WCHAR* buffer, int len); extern const char* dbg_W2A(const WCHAR* buffer, unsigned len); #ifdef __GNUC__ extern int WINAPIV dbg_printf(const char* format, ...) __attribute__((format (printf,1,2))); diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index faa5ac9ddcb..208526739e2 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -641,7 +641,6 @@ void print_basic(const struct dbg_lvalue* lvalue, char format) { unsigned size; dbg_lgint_t res = types_extract_as_lgint(lvalue, &size, NULL); - WCHAR wch;
switch (format) { @@ -658,10 +657,7 @@ void print_basic(const struct dbg_lvalue* lvalue, char format) return;
case 'u': - wch = (WCHAR)(res & 0xFFFF); - dbg_printf("%d = '", wch); - dbg_outputW(&wch, 1); - dbg_printf("'"); + dbg_printf("%d = '%lc'", (WCHAR)(res & 0xFFFF), (WCHAR)(res & 0xFFFF)); return;
case 'i': diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index 89fb265fc93..dc6355be4cd 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -135,13 +135,6 @@ const char* dbg_W2A(const WCHAR* buffer, unsigned len) return ansi; }
-void dbg_outputW(const WCHAR* buffer, int len) -{ - const char* ansi = dbg_W2A(buffer, len); - if (ansi) dbg_outputA(ansi, strlen(ansi)); - /* FIXME: should CP_ACP be GetConsoleCP()? */ -} - int WINAPIV dbg_printf(const char* format, ...) { static char buf[4*1024];
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/info.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c index 2b8e377e6f4..bb933aeb455 100644 --- a/programs/winedbg/info.c +++ b/programs/winedbg/info.c @@ -565,7 +565,7 @@ void info_win32_processes(void) } }
-static BOOL get_process_name(DWORD pid, PROCESSENTRY32* entry) +static BOOL get_process_name(DWORD pid, PROCESSENTRY32W* entry) { BOOL ret = FALSE; HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); @@ -573,9 +573,9 @@ static BOOL get_process_name(DWORD pid, PROCESSENTRY32* entry) if (snap != INVALID_HANDLE_VALUE) { entry->dwSize = sizeof(*entry); - if (Process32First(snap, entry)) + if (Process32FirstW(snap, entry)) while (!(ret = (entry->th32ProcessID == pid)) && - Process32Next(snap, entry)); + Process32NextW(snap, entry)); CloseHandle(snap); } return ret; @@ -607,18 +607,18 @@ void info_win32_threads(void) */ if (entry.th32OwnerProcessID != lastProcessId) { - PROCESSENTRY32 pcs_entry; - const char* exename; + PROCESSENTRY32W pcs_entry; + const WCHAR* exename;
p = dbg_get_process(entry.th32OwnerProcessID); if (p) - exename = dbg_W2A(p->imageName, -1); + exename = p->imageName; else if (get_process_name(entry.th32OwnerProcessID, &pcs_entry)) exename = pcs_entry.szExeFile; else - exename = ""; + exename = L"";
- dbg_printf("%08lx%s %s\n", + dbg_printf("%08lx%s %ls\n", entry.th32OwnerProcessID, p ? " (D)" : "", exename); lastProcessId = entry.th32OwnerProcessID; }
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- programs/winedbg/debugger.h | 1 - programs/winedbg/gdbproxy.c | 8 ++++---- programs/winedbg/stack.c | 5 ++--- programs/winedbg/tgt_active.c | 4 ++-- programs/winedbg/tgt_minidump.c | 4 ++-- programs/winedbg/winedbg.c | 22 ---------------------- 6 files changed, 10 insertions(+), 34 deletions(-)
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index b7dcde201d8..1ae2dce4689 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -501,7 +501,6 @@ extern BOOL types_is_integral_type(const struct dbg_lvalue*); extern BOOL types_is_float_type(const struct dbg_lvalue*);
/* winedbg.c */ -extern const char* dbg_W2A(const WCHAR* buffer, unsigned len); #ifdef __GNUC__ extern int WINAPIV dbg_printf(const char* format, ...) __attribute__((format (printf,1,2))); #else diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c index 0268a288481..a63748c6ebe 100644 --- a/programs/winedbg/gdbproxy.c +++ b/programs/winedbg/gdbproxy.c @@ -538,9 +538,9 @@ static BOOL handle_debug_event(struct gdb_context* gdbctx, BOOL stop_on_dll_load QueryFullProcessImageNameW( gdbctx->process->handle, 0, u.buffer, &size ); dbg_set_process_name(gdbctx->process, u.buffer);
- fprintf(stderr, "%04lx:%04lx: create process '%s'/%p @%p (%lu<%lu>)\n", + fprintf(stderr, "%04lx:%04lx: create process '%ls'/%p @%p (%lu<%lu>)\n", de->dwProcessId, de->dwThreadId, - dbg_W2A(u.buffer, -1), + u.buffer, de->u.CreateProcessInfo.lpImageName, de->u.CreateProcessInfo.lpStartAddress, de->u.CreateProcessInfo.dwDebugInfoFileOffset, @@ -564,9 +564,9 @@ static BOOL handle_debug_event(struct gdb_context* gdbctx, BOOL stop_on_dll_load case LOAD_DLL_DEBUG_EVENT: fetch_module_name( de->u.LoadDll.lpImageName, de->u.LoadDll.lpBaseOfDll, u.buffer, ARRAY_SIZE(u.buffer) ); - fprintf(stderr, "%04lx:%04lx: loads DLL %s @%p (%lu<%lu>)\n", + fprintf(stderr, "%04lx:%04lx: loads DLL %ls @%p (%lu<%lu>)\n", de->dwProcessId, de->dwThreadId, - dbg_W2A(u.buffer, -1), + u.buffer, de->u.LoadDll.lpBaseOfDll, de->u.LoadDll.dwDebugInfoFileOffset, de->u.LoadDll.nDebugInfoSize); diff --git a/programs/winedbg/stack.c b/programs/winedbg/stack.c index 5d3504f1057..294694cf85c 100644 --- a/programs/winedbg/stack.c +++ b/programs/winedbg/stack.c @@ -407,9 +407,8 @@ static void backtrace_all(void) dbg_active_wait_for_first_exception(); }
- dbg_printf("\nBacktracing for thread %04lx in process %04lx (%s):\n", - entry.th32ThreadID, dbg_curr_pid, - dbg_W2A(dbg_curr_process->imageName, -1)); + dbg_printf("\nBacktracing for thread %04lx in process %04lx (%ls):\n", + entry.th32ThreadID, dbg_curr_pid, dbg_curr_process->imageName); backtrace_tid(dbg_curr_process, entry.th32ThreadID); } while (Thread32Next(snapshot, &entry)); diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index 2caa62206d6..c17a6f38290 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -484,8 +484,8 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de) break_set_xpoints(TRUE); if (DBG_IVAR(BreakOnDllLoad)) { - dbg_printf("Stopping on DLL %s loading at %p\n", - dbg_W2A(u.buffer, -1), de->u.LoadDll.lpBaseOfDll); + dbg_printf("Stopping on DLL %ls loading at %p\n", + u.buffer, de->u.LoadDll.lpBaseOfDll); if (dbg_fetch_context()) cont = 0; } break; diff --git a/programs/winedbg/tgt_minidump.c b/programs/winedbg/tgt_minidump.c index 6a947cbc2db..5fa615bcd45 100644 --- a/programs/winedbg/tgt_minidump.c +++ b/programs/winedbg/tgt_minidump.c @@ -307,8 +307,8 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data) str = "???"; break; } - dbg_printf(" %s was running on #%d %s CPU%s", - dbg_W2A(exec_name, -1), msi->u.s.NumberOfProcessors, str, + dbg_printf(" %ls was running on #%d %s CPU%s", + exec_name, msi->u.s.NumberOfProcessors, str, msi->u.s.NumberOfProcessors < 2 ? "" : "s"); switch (msi->MajorVersion) { diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index dc6355be4cd..d11b68ec432 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -113,28 +113,6 @@ static void dbg_outputA(const char* buffer, int len) } }
-const char* dbg_W2A(const WCHAR* buffer, unsigned len) -{ - static unsigned ansilen; - static char* ansi; - unsigned newlen; - - newlen = WideCharToMultiByte(CP_ACP, 0, buffer, len, NULL, 0, NULL, NULL); - if (newlen > ansilen) - { - static char* newansi; - if (ansi) - newansi = HeapReAlloc(GetProcessHeap(), 0, ansi, newlen); - else - newansi = HeapAlloc(GetProcessHeap(), 0, newlen); - if (!newansi) return NULL; - ansilen = newlen; - ansi = newansi; - } - WideCharToMultiByte(CP_ACP, 0, buffer, len, ansi, newlen, NULL, NULL); - return ansi; -} - int WINAPIV dbg_printf(const char* format, ...) { static char buf[4*1024];