winedbg format strings use the wrong type on armhf
authorMichael Gilbert <mgilbert@debian.org>
Wed, 6 Jul 2022 00:44:32 +0000 (01:44 +0100)
committerMichael Gilbert <mgilbert@debian.org>
Wed, 6 Jul 2022 00:44:32 +0000 (01:44 +0100)
Gbp-Pq: Topic armhf
Gbp-Pq: Name format-strings.patch

programs/winedbg/break.c
programs/winedbg/db_disasm64.c
programs/winedbg/expr.c
programs/winedbg/info.c
programs/winedbg/memory.c
programs/winedbg/stack.c
programs/winedbg/symbol.c
programs/winedbg/types.c

index 27a11a00d3337d75341a06289bdc547477b82a3a..2e652836841fd9b25192339602057629b06319a1 100644 (file)
@@ -319,7 +319,11 @@ 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))
         {
+#ifdef __arm__
+            dbg_printf("Unable to add breakpoint (unknown address %Ild)\n", linear);
+#else
             dbg_printf("Unable to add breakpoint (unknown address %Ix)\n", linear);
+#endif
             return;
         }
         filename = il.FileName;
@@ -402,7 +406,11 @@ static void break_add_watch(const struct dbg_lvalue* lvalue, BOOL is_write)
             {
             case 4: case 2: case 1: break;
             default:
+#ifdef __arm__
+                dbg_printf("Unsupported length (%I64lld) for watch-points, defaulting to 4\n", l);
+#else
                 dbg_printf("Unsupported length (%I64x) for watch-points, defaulting to 4\n", l);
+#endif
                 break;
             }
         }
@@ -751,7 +759,11 @@ BOOL break_should_continue(ADDRESS64* addr, DWORD code)
         case be_xpoint_watch_write:
             dbg_printf("Stopped on watchpoint %d at ", dbg_curr_thread->stopped_xpoint);
             print_address(addr, TRUE);
+#ifdef __arm__
+            dbg_printf(" new value %I64lld\n",
+#else
             dbg_printf(" new value %I64x\n",
+#endif
                        dbg_curr_process->bp[dbg_curr_thread->stopped_xpoint].w.oldval);
         }
         return FALSE;
index 3c0d55ee218d57874aa228b0d15eabd1d7410fa8..fdc024862987d1b730e4a5f444011af86d68eb81 100644 (file)
@@ -1603,7 +1603,11 @@ db_disasm(db_addr_t loc, boolean_t altfmt)
                case Ilq:
                    len = db_lengths[rex & REX_W ? QUAD : LONG];
                    get_value_inc(imm64, loc, len, FALSE);
+#ifdef __arm__
+                    db_printf("$%I64lld", imm64);
+#else
                     db_printf("$%#I64x", imm64);
+#endif
                    break;
 
                case O:
index 5d9ef30ad130d4e7cf30a31f3f1999a593a0645c..aed60eac7c7a36120b327f2d11c99a6dda7cb2f6 100644 (file)
@@ -661,10 +661,18 @@ BOOL expr_print(const struct expr* exp)
         dbg_printf("$%s", exp->un.intvar.name);
         break;
     case EXPR_TYPE_U_CONST:
+#ifdef __arm__
+        dbg_printf("%I64llu", exp->un.u_const.value);
+#else
         dbg_printf("%I64u", exp->un.u_const.value);
+#endif
         break;
     case EXPR_TYPE_S_CONST:
+#ifdef __arm__
+        dbg_printf("%I64lld", exp->un.s_const.value);
+#else
         dbg_printf("%I64d", exp->un.s_const.value);
+#endif
         break;
     case EXPR_TYPE_STRING:
         dbg_printf("\"%s\"", exp->un.string.str);
index 07b2a5acc8b8495906be7a15bce050a07bd0c5ab..69217207fdabff547a587fd016d14c5af4e36426 100644 (file)
@@ -168,7 +168,11 @@ struct info_modules
 
 static void module_print_info(const struct info_module *module, BOOL is_embedded)
 {
+#ifdef __arm__
+    dbg_printf("%x_%x_%I64lld-%x_%x_%I64lld\t%-16s%s\n",
+#else
     dbg_printf("%*.*I64x-%*.*I64x\t%-16s%s\n",
+#endif
                ADDRWIDTH, ADDRWIDTH, module->mi.BaseOfImage,
                ADDRWIDTH, ADDRWIDTH, module->mi.BaseOfImage + module->mi.ImageSize,
                is_embedded ? "\\" : get_symtype_str(&module->mi), module->name);
@@ -284,7 +288,11 @@ void info_win32_module(DWORD64 base)
     HeapFree(GetProcessHeap(), 0, im.modules);
 
     if (base && !num_printed)
+#ifdef __arm__
+        dbg_printf("'%x 0x%I64lld' is not a valid module address\n", ADDRWIDTH, base);
+#else
         dbg_printf("'0x%0*I64x' is not a valid module address\n", ADDRWIDTH, base);
+#endif
 }
 
 struct class_walker
@@ -392,7 +400,11 @@ static void info_window(HWND hWnd, int indent)
         if (!GetWindowTextA(hWnd, wndName, sizeof(wndName)))
             strcpy(wndName, "-- Empty --");
 
+#ifdef __arm__
+        dbg_printf("%x %s %Ild %x %s %-17.17s %08x %x %Ild %08x %.14s\n",
+#else
         dbg_printf("%*s%08Ix%*s %-17.17s %08x %0*Ix %08x %.14s\n",
+#endif
                    indent, "", (DWORD_PTR)hWnd, 12 - indent, "",
                    clsName, GetWindowLongW(hWnd, GWL_STYLE),
                    ADDRWIDTH, (ULONG_PTR)GetWindowLongPtrW(hWnd, GWLP_WNDPROC),
@@ -434,7 +446,11 @@ 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"
+#ifdef __arm__
+               "inst=%p  active=%p  idmenu=%Ild\n"
+#else
                "inst=%p  active=%p  idmenu=%08Ix\n"
+#endif
                "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 +807,11 @@ void info_win32_virtual(DWORD pid)
             type = "";
             prot[0] = '\0';
         }
+#ifdef __arm__
+        dbg_printf("%x %Ild %x %Ild %s %s %s\n",
+#else
         dbg_printf("%0*Ix %0*Ix %s %s %s\n",
+#endif
                    ADDRWIDTH, (DWORD_PTR)addr, ADDRWIDTH, (DWORD_PTR)addr + mbi.RegionSize - 1, state, type, prot);
         if (addr + mbi.RegionSize < addr) /* wrap around ? */
             break;
@@ -893,7 +913,11 @@ void info_win32_exception(void)
         break;
     case EXCEPTION_ACCESS_VIOLATION:
         if (rec->NumberParameters == 2)
+#ifdef __arm__
+            dbg_printf("page fault on %s access to %x 0x%Ild",
+#else
             dbg_printf("page fault on %s access to 0x%0*Ix",
+#endif
                        rec->ExceptionInformation[0] == EXCEPTION_WRITE_FAULT ? "write" :
                        rec->ExceptionInformation[0] == EXCEPTION_EXECUTE_FAULT ? "execute" : "read",
                        ADDRWIDTH, rec->ExceptionInformation[1]);
@@ -961,14 +985,22 @@ void info_win32_exception(void)
         break;
     case EXCEPTION_WINE_CXX_EXCEPTION:
         if(rec->NumberParameters == 3 && rec->ExceptionInformation[0] == EXCEPTION_WINE_CXX_FRAME_MAGIC)
+#ifdef __arm__
+            dbg_printf("C++ exception(object = %x 0x%Ild, type = %x 0x%Ild)",
+#else
             dbg_printf("C++ exception(object = 0x%0*Ix, type = 0x%0*Ix)",
+#endif
                        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
+#ifdef __arm__
+            dbg_printf("C++ exception with strange parameter count %d or magic %x 0x%0Ild",
+#else
             dbg_printf("C++ exception with strange parameter count %d or magic 0x%0*Ix",
+#endif
                        rec->NumberParameters, ADDRWIDTH, rec->ExceptionInformation[0]);
         break;
     default:
index 0c8e1ee0d19ded62dfb4855260c3f4ef934a67b6..41894eb94bafca89d6a8ed10fa1cf02dd9fb26bc 100644 (file)
@@ -250,11 +250,19 @@ void memory_examine(const struct dbg_lvalue *lvalue, int count, char format)
     case 'a':
         if (sizeof(DWORD_PTR) == 4)
         {
+#ifdef __arm__
+            DO_DUMP(DWORD_PTR, 4, " %Ild");
+#else
             DO_DUMP(DWORD_PTR, 4, " %8.8Ix");
+#endif
         }
         else
         {
+#ifdef __arm__
+            DO_DUMP(DWORD_PTR, 2, " %Ild");
+#else
             DO_DUMP(DWORD_PTR, 2, " %16.16Ix");
+#endif
         }
         break;
     case 'c': DO_DUMP2(char, 32, " %c", (_v < 0x20) ? ' ' : _v); break;
@@ -460,7 +468,11 @@ char* memory_offset_to_string(char *str, DWORD64 offset, unsigned mode)
 
 static void dbg_print_sdecimal(dbg_lgint_t sv)
 {
+#ifdef __arm__
+    dbg_printf("%I64lld", sv);
+#else
     dbg_printf("%I64d", sv);
+#endif
 }
 
 static void dbg_print_hex(DWORD size, dbg_lgint_t sv)
@@ -469,7 +481,11 @@ static void dbg_print_hex(DWORD size, dbg_lgint_t sv)
         dbg_printf("0");
     else
         /* clear unneeded high bits, esp. sign extension */
+#ifdef __arm__
+        dbg_printf("%I64lld", sv & (~(dbg_lguint_t)0 >> (8 * (sizeof(dbg_lgint_t) - size))));
+#else
         dbg_printf("%#I64x", sv & (~(dbg_lguint_t)0 >> (8 * (sizeof(dbg_lgint_t) - size))));
+#endif
 }
 
 static void print_typed_basic(const struct dbg_lvalue* lvalue)
@@ -723,7 +739,11 @@ void print_address(const ADDRESS64* addr, BOOLEAN with_line)
     if (SymFromAddr(dbg_curr_process->handle, lin, &disp64, si) && disp64 < si->Size)
     {
         dbg_printf(" %s", si->Name);
+#ifdef __arm__
+        if (disp64) dbg_printf("+0x%I64lld", disp64);
+#else
         if (disp64) dbg_printf("+0x%I64x", disp64);
+#endif
     }
     else
     {
@@ -731,7 +751,11 @@ void print_address(const ADDRESS64* addr, BOOLEAN with_line)
         if (!SymGetModuleInfo(dbg_curr_process->handle, lin, &im)) return;
         dbg_printf(" %s", im.ModuleName);
         if (lin > im.BaseOfImage)
+#ifdef __arm__
+            dbg_printf("+0x%Ild", lin - im.BaseOfImage);
+#else
             dbg_printf("+0x%Ix", lin - im.BaseOfImage);
+#endif
     }
     if (with_line)
     {
index c8352d8a994a82b0f4f23fb8807358ee22d13f37..50bef288a0adb1fbdeaa3ec0427bf267c2f13e41 100644 (file)
@@ -276,7 +276,11 @@ static void stack_print_addr_and_args(void)
         DWORD           disp;
 
         dbg_printf(" %s", si->Name);
+#ifdef __arm__
+        if (disp64) dbg_printf("+0x%I64lld", disp64);
+#else
         if (disp64) dbg_printf("+0x%I64x", disp64);
+#endif
 
         stack_set_local_scope();
         se.first = TRUE;
@@ -291,7 +295,11 @@ static void stack_print_addr_and_args(void)
             dbg_printf(" [%s:%u]", il.FileName, il.LineNumber);
         dbg_printf(" in %s", im.ModuleName);
     }
+#ifdef __arm__
+    else dbg_printf(" in %s (+0x%Ild)", im.ModuleName, frm->linear_pc - im.BaseOfImage);
+#else
     else dbg_printf(" in %s (+0x%Ix)", im.ModuleName, frm->linear_pc - im.BaseOfImage);
+#endif
 }
 
 /******************************************************************
index 08e0317154ea6193f95e75cd9a4e0716cbacaa7f..9d0df52bc83e51a1c10c4d0295985f53c4f03e89 100644 (file)
@@ -749,7 +749,11 @@ BOOL symbol_info_locals(void)
     addr.Mode = AddrModeFlat;
     addr.Offset = frm->linear_pc;
     print_address(&addr, FALSE);
+#ifdef __arm__
+    dbg_printf(": %x (%Ild)\n", ADDRWIDTH, frm->linear_frame);
+#else
     dbg_printf(": (%0*Ix)\n", ADDRWIDTH, frm->linear_frame);
+#endif
     SymEnumSymbols(dbg_curr_process->handle, 0, NULL, info_locals_cb, (void*)frm->linear_frame);
 
     return TRUE;
@@ -771,7 +775,11 @@ static BOOL CALLBACK symbols_info_cb(PSYMBOL_INFO sym, ULONG size, PVOID ctx)
             mi.ModuleName[len - 5] = '\0';
     }
 
+#ifdef __arm__
+    dbg_printf("%x %I64lld: %s!%s", ADDRWIDTH, sym->Address, mi.ModuleName, sym->Name);
+#else
     dbg_printf("%0*I64x: %s!%s", ADDRWIDTH, sym->Address, mi.ModuleName, sym->Name);
+#endif
     type.id = sym->TypeIndex;
     type.module = sym->ModBase;
 
index 1383f0254301af13b713ad9c621e9ec93fa41062..1d3995e1250b77f7d17d2e350289cb5c64388372 100644 (file)
@@ -555,7 +555,11 @@ 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;
+#ifdef __arm__
+    dbg_printf("Mod: %x %Ild ID: %08x\n", ADDRWIDTH, type.module, type.id);
+#else
     dbg_printf("Mod: %0*Ix ID: %08x\n", ADDRWIDTH, type.module, type.id);
+#endif
     types_print_type(&type, TRUE);
     dbg_printf("\n");
     return TRUE;