[PATCH 2/9] programs/winedbg: use I width modifier for DWORD_PTR printf's args

Eric Pouech eric.pouech at gmail.com
Fri Nov 26 10:30:16 CST 2021


Signed-off-by: Eric Pouech <eric.pouech at gmail.com>

---
 programs/winedbg/break.c      |    2 +-
 programs/winedbg/expr.c       |    4 ++--
 programs/winedbg/gdbproxy.c   |    8 ++++----
 programs/winedbg/info.c       |   14 +++++++-------
 programs/winedbg/memory.c     |    4 ++--
 programs/winedbg/stack.c      |    2 +-
 programs/winedbg/symbol.c     |    8 ++++----
 programs/winedbg/tgt_active.c |    4 ++--
 programs/winedbg/types.c      |    2 +-
 programs/winedbg/winedbg.c    |    2 +-
 10 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/programs/winedbg/break.c b/programs/winedbg/break.c
index e5458c34bf9..03f7bdf5a2f 100644
--- a/programs/winedbg/break.c
+++ b/programs/winedbg/break.c
@@ -319,7 +319,7 @@ void break_add_break_from_lineno(const char *filename, int lineno, BOOL swbp)
         il.SizeOfStruct = sizeof(il);
         if (!SymGetLineFromAddr64(dbg_curr_process->handle, linear, &disp, &il))
         {
-            dbg_printf("Unable to add breakpoint (unknown address %lx)\n", linear);
+            dbg_printf("Unable to add breakpoint (unknown address %Ix)\n", linear);
             return;
         }
         filename = il.FileName;
diff --git a/programs/winedbg/expr.c b/programs/winedbg/expr.c
index 4c791e19012..842fa8e7925 100644
--- a/programs/winedbg/expr.c
+++ b/programs/winedbg/expr.c
@@ -687,10 +687,10 @@ BOOL expr_print(const struct expr* exp)
         dbg_printf("$%s", exp->un.intvar.name);
         break;
     case EXPR_TYPE_U_CONST:
-        dbg_printf("%lu", exp->un.u_const.value);
+        dbg_printf("%Iu", exp->un.u_const.value);
         break;
     case EXPR_TYPE_S_CONST:
-        dbg_printf("%ld", exp->un.s_const.value);
+        dbg_printf("%Id", exp->un.s_const.value);
         break;
     case EXPR_TYPE_STRING:
         dbg_printf("\"%s\"", exp->un.string.str);
diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c
index 37d7c8ffc66..b578ac289e1 100644
--- a/programs/winedbg/gdbproxy.c
+++ b/programs/winedbg/gdbproxy.c
@@ -1486,7 +1486,7 @@ static void packet_query_monitor_wnd_helper(struct gdb_context* gdbctx, HWND hWn
        packet_reply_open(gdbctx);
        packet_reply_add(gdbctx, "O");
        snprintf(buffer, sizeof(buffer),
-                "%*s%04lx%*s%-17.17s %08x %0*lx %.14s\n",
+                "%*s%04Ix%*s%-17.17s %08x %0*Ix %.14s\n",
                 indent, "", (ULONG_PTR)hWnd, 13 - indent, "",
                 clsName, GetWindowLongW(hWnd, GWL_STYLE),
                 addr_width(gdbctx), (ULONG_PTR)GetWindowLongPtrW(hWnd, GWLP_WNDPROC),
@@ -1613,7 +1613,7 @@ static void packet_query_monitor_mem(struct gdb_context* gdbctx, int len, const
             prot[0] = '\0';
         }
         packet_reply_open(gdbctx);
-        snprintf(buffer, sizeof(buffer), "%0*lx %0*lx %s %s %s\n",
+        snprintf(buffer, sizeof(buffer), "%0*Ix %0*Ix %s %s %s\n",
                  addr_width(gdbctx), (DWORD_PTR)addr,
                  addr_width(gdbctx), mbi.RegionSize, state, type, prot);
         packet_reply_add(gdbctx, "O");
@@ -2042,7 +2042,7 @@ static enum packet_return packet_query(struct gdb_context* gdbctx)
             char    buf[64];
 
             snprintf(buf, sizeof(buf),
-                     "Text=%08lx;Data=%08lx;Bss=%08lx",
+                     "Text=%08Ix;Data=%08Ix;Bss=%08Ix",
                      gdbctx->wine_segs[0], gdbctx->wine_segs[1],
                      gdbctx->wine_segs[2]);
             return packet_reply(gdbctx, buf);
@@ -2439,7 +2439,7 @@ static BOOL gdb_startup(struct gdb_context* gdbctx, unsigned flags, unsigned por
         if (gdbctx->sock != INVALID_SOCKET)
         {
             ret = TRUE;
-            TRACE("connected on %lu\n", gdbctx->sock);
+            TRACE("connected on %Iu\n", gdbctx->sock);
             /* don't keep our small packets too long: send them ASAP back to GDB
              * without this, GDB really crawls
              */
diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c
index b7f45086c5c..23d87bbb006 100644
--- a/programs/winedbg/info.c
+++ b/programs/winedbg/info.c
@@ -392,7 +392,7 @@ static void info_window(HWND hWnd, int indent)
         if (!GetWindowTextA(hWnd, wndName, sizeof(wndName)))
             strcpy(wndName, "-- Empty --");
 
-        dbg_printf("%*s%08lx%*s %-17.17s %08x %0*lx %08x %.14s\n",
+        dbg_printf("%*s%08Ix%*s %-17.17s %08x %0*Ix %08x %.14s\n",
                    indent, "", (DWORD_PTR)hWnd, 12 - indent, "",
                    clsName, GetWindowLongW(hWnd, GWL_STYLE),
                    ADDRWIDTH, (ULONG_PTR)GetWindowLongPtrW(hWnd, GWLP_WNDPROC),
@@ -434,7 +434,7 @@ void info_win32_window(HWND hWnd, BOOL detailed)
 
     /* FIXME missing fields: hmemTaskQ, hrgnUpdate, dce, flags, pProp, scroll */
     dbg_printf("next=%p  child=%p  parent=%p  owner=%p  class='%s'\n"
-               "inst=%p  active=%p  idmenu=%08lx\n"
+               "inst=%p  active=%p  idmenu=%08Ix\n"
                "style=0x%08x  exstyle=0x%08x  wndproc=%p  text='%s'\n"
                "client=%d,%d-%d,%d  window=%d,%d-%d,%d sysmenu=%p\n",
                GetWindow(hWnd, GW_HWNDNEXT),
@@ -791,7 +791,7 @@ void info_win32_virtual(DWORD pid)
             type = "";
             prot[0] = '\0';
         }
-        dbg_printf("%0*lx %0*lx %s %s %s\n",
+        dbg_printf("%0*Ix %0*Ix %s %s %s\n",
                    ADDRWIDTH, (DWORD_PTR)addr, ADDRWIDTH, (DWORD_PTR)addr + mbi.RegionSize - 1, state, type, prot);
         if (addr + mbi.RegionSize < addr) /* wrap around ? */
             break;
@@ -893,7 +893,7 @@ void info_win32_exception(void)
         break;
     case EXCEPTION_ACCESS_VIOLATION:
         if (rec->NumberParameters == 2)
-            dbg_printf("page fault on %s access to 0x%0*lx",
+            dbg_printf("page fault on %s access to 0x%0*Ix",
                        rec->ExceptionInformation[0] == EXCEPTION_WRITE_FAULT ? "write" :
                        rec->ExceptionInformation[0] == EXCEPTION_EXECUTE_FAULT ? "execute" : "read",
                        ADDRWIDTH, rec->ExceptionInformation[1]);
@@ -931,7 +931,7 @@ void info_win32_exception(void)
                                   (void*)rec->ExceptionInformation[1], TRUE, FALSE,
                                   name, sizeof(name));
             else
-                sprintf( name, "%ld", rec->ExceptionInformation[1] );
+                sprintf( name, "%Id", rec->ExceptionInformation[1] );
             dbg_printf("unimplemented function %s.%s called", dll, name);
         }
         break;
@@ -961,14 +961,14 @@ void info_win32_exception(void)
         break;
     case EXCEPTION_WINE_CXX_EXCEPTION:
         if(rec->NumberParameters == 3 && rec->ExceptionInformation[0] == EXCEPTION_WINE_CXX_FRAME_MAGIC)
-            dbg_printf("C++ exception(object = 0x%0*lx, type = 0x%0*lx)",
+            dbg_printf("C++ exception(object = 0x%0*Ix, type = 0x%0*Ix)",
                        ADDRWIDTH, rec->ExceptionInformation[1], ADDRWIDTH, rec->ExceptionInformation[2]);
         else if(rec->NumberParameters == 4 && rec->ExceptionInformation[0] == EXCEPTION_WINE_CXX_FRAME_MAGIC)
             dbg_printf("C++ exception(object = %p, type = %p, base = %p)",
                        (void*)rec->ExceptionInformation[1], (void*)rec->ExceptionInformation[2],
                        (void*)rec->ExceptionInformation[3]);
         else
-            dbg_printf("C++ exception with strange parameter count %d or magic 0x%0*lx",
+            dbg_printf("C++ exception with strange parameter count %d or magic 0x%0*Ix",
                        rec->NumberParameters, ADDRWIDTH, rec->ExceptionInformation[0]);
         break;
     default:
diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c
index 6cd90b236eb..2490b7cf7e2 100644
--- a/programs/winedbg/memory.c
+++ b/programs/winedbg/memory.c
@@ -219,11 +219,11 @@ void memory_examine(const struct dbg_lvalue *lvalue, int count, char format)
     case 'a':
         if (sizeof(DWORD_PTR) == 4)
         {
-            DO_DUMP(DWORD_PTR, 4, " %8.8lx");
+            DO_DUMP(DWORD_PTR, 4, " %8.8Ix");
         }
         else
         {
-            DO_DUMP(DWORD_PTR, 2, " %16.16lx");
+            DO_DUMP(DWORD_PTR, 2, " %16.16Ix");
         }
         break;
     case 'c': DO_DUMP2(char, 32, " %c", (_v < 0x20) ? ' ' : _v); break;
diff --git a/programs/winedbg/stack.c b/programs/winedbg/stack.c
index 4d2389ee345..34ca6c985be 100644
--- a/programs/winedbg/stack.c
+++ b/programs/winedbg/stack.c
@@ -409,7 +409,7 @@ static void backtrace_all(void)
                 dbg_active_wait_for_first_exception();
             }
 
-            dbg_printf("\nBacktracing for thread %04x in process %04lx (%s):\n",
+            dbg_printf("\nBacktracing for thread %04x in process %04Ix (%s):\n",
                        entry.th32ThreadID, dbg_curr_pid,
                        dbg_W2A(dbg_curr_process->imageName, -1));
             backtrace_tid(dbg_curr_process, entry.th32ThreadID);
diff --git a/programs/winedbg/symbol.c b/programs/winedbg/symbol.c
index 67be370cc5b..856cc86c8f4 100644
--- a/programs/winedbg/symbol.c
+++ b/programs/winedbg/symbol.c
@@ -87,10 +87,10 @@ static BOOL fill_sym_lvalue(const SYMBOL_INFO* sym, ULONG_PTR base,
         buffer += l;
         lvalue->cookie = DLV_TARGET;
         lvalue->addr.Offset = (ULONG64)*pval + sym->Address;
-        if ((LONG_PTR)sym->Address >= 0)
-            snprintf(buffer, sz, "+%ld]", (ULONG_PTR)sym->Address);
+        if ((LONG64)sym->Address >= 0)
+            snprintf(buffer, sz, "+%I64d]", sym->Address);
         else
-            snprintf(buffer, sz, "-%ld]", -(LONG_PTR)sym->Address);
+            snprintf(buffer, sz, "-%I64d]", -(LONG64)sym->Address);
     }
     else if (sym->Flags & SYMFLAG_VALUEPRESENT)
     {
@@ -779,7 +779,7 @@ static BOOL CALLBACK symbols_info_cb(PSYMBOL_INFO sym, ULONG size, PVOID ctx)
             mi.ModuleName[len - 5] = '\0';
     }
 
-    dbg_printf("%0*lx: %s!%s", ADDRWIDTH, (ULONG_PTR)sym->Address, mi.ModuleName, sym->Name);
+    dbg_printf("%0*I64x: %s!%s", ADDRWIDTH, sym->Address, mi.ModuleName, sym->Name);
     type.id = sym->TypeIndex;
     type.module = sym->ModBase;
 
diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c
index 66156833fc6..2fd05df39d9 100644
--- a/programs/winedbg/tgt_active.c
+++ b/programs/winedbg/tgt_active.c
@@ -536,12 +536,12 @@ static void dbg_resume_debuggee(DWORD cont)
         if (dbg_curr_thread)
         {
             if (!dbg_curr_process->be_cpu->set_context(dbg_curr_thread->handle, &dbg_context))
-                dbg_printf("Cannot set ctx on %04lx\n", dbg_curr_tid);
+                dbg_printf("Cannot set ctx on %04Ix\n", dbg_curr_tid);
         }
     }
     dbg_interactiveP = FALSE;
     if (!ContinueDebugEvent(dbg_curr_pid, dbg_curr_tid, cont))
-        dbg_printf("Cannot continue on %04lx (%08x)\n", dbg_curr_tid, cont);
+        dbg_printf("Cannot continue on %04Ix (%08x)\n", dbg_curr_tid, cont);
 }
 
 static void wait_exception(void)
diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c
index 236373858d5..c091420ed50 100644
--- a/programs/winedbg/types.c
+++ b/programs/winedbg/types.c
@@ -571,7 +571,7 @@ static BOOL CALLBACK print_types_cb(PSYMBOL_INFO sym, ULONG size, void* ctx)
     struct dbg_type     type;
     type.module = sym->ModBase;
     type.id = sym->TypeIndex;
-    dbg_printf("Mod: %0*lx ID: %08x\n", ADDRWIDTH, type.module, type.id);
+    dbg_printf("Mod: %0*Ix ID: %08x\n", ADDRWIDTH, type.module, type.id);
     types_print_type(&type, TRUE);
     dbg_printf("\n");
     return TRUE;
diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c
index 76ecea3f3ee..45a7edfb309 100644
--- a/programs/winedbg/winedbg.c
+++ b/programs/winedbg/winedbg.c
@@ -571,7 +571,7 @@ void dbg_start_interactive(HANDLE hFile)
 
     if (dbg_curr_process)
     {
-        dbg_printf("WineDbg starting on pid %04lx\n", dbg_curr_pid);
+        dbg_printf("WineDbg starting on pid %04Ix\n", dbg_curr_pid);
         if (dbg_curr_process->active_debuggee) dbg_active_wait_for_first_exception();
     }
 




More information about the wine-devel mailing list