Commit facae70c authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winedump: Add helpers to print DWORD64 integers.

parent 4baada41
...@@ -133,6 +133,29 @@ void dump_unicode_str( const WCHAR *str, int len ) ...@@ -133,6 +133,29 @@ void dump_unicode_str( const WCHAR *str, int len )
printf( "\"" ); printf( "\"" );
} }
const char *get_hexint64_str( DWORD64 l )
{
char *buf = dump_want_n(2 + 16 + 1);
if (sizeof(l) > sizeof(unsigned long) && l >> 32)
sprintf(buf, "%#lx%08lx", (unsigned long)(l >> 32), (unsigned long)l);
else
sprintf(buf, "%#lx", (unsigned long)l);
assert(strlen(buf) <= 18);
return buf;
}
const char *get_uint64_str( DWORD64 l )
{
char *buf = dump_want_n( 32 );
char *ptr = buf + 31;
*ptr = '\0';
for ( ; l; l /= 10)
*--ptr = '0' + (l % 10);
if (ptr == buf + 31) *--ptr = '0';
assert(ptr >= buf);
return ptr;
}
const char* get_symbol_str(const char* symname) const char* get_symbol_str(const char* symname)
{ {
const char* ret = NULL; const char* ret = NULL;
......
...@@ -53,30 +53,6 @@ enum FileSig get_kind_mdmp(void) ...@@ -53,30 +53,6 @@ enum FileSig get_kind_mdmp(void)
return SIG_UNKNOWN; return SIG_UNKNOWN;
} }
static inline void print_longlong(const char *title, ULONG64 value)
{
printf("%s: 0x", title);
if (sizeof(value) > sizeof(unsigned long) && value >> 32)
printf("%lx%08lx\n", (unsigned long)(value >> 32), (unsigned long)value);
else
printf("%lx\n", (unsigned long)value);
}
static inline void print_longlong_range(const char *title, ULONG64 start, ULONG64 length)
{
ULONG64 value = start;
printf("%s: 0x", title);
if (sizeof(value) > sizeof(unsigned long) && value >> 32)
printf("%lx%08lx-", (unsigned long)(value >> 32), (unsigned long)value);
else
printf("%lx-", (unsigned long)value);
value = start + length;
if (sizeof(value) > sizeof(unsigned long) && value >> 32)
printf("0x%lx%08lx\n", (unsigned long)(value >> 32), (unsigned long)value);
else
printf("0x%lx\n", (unsigned long)value);
}
void mdmp_dump(void) void mdmp_dump(void)
{ {
const MINIDUMP_HEADER* hdr = PRD(0, sizeof(MINIDUMP_HEADER)); const MINIDUMP_HEADER* hdr = PRD(0, sizeof(MINIDUMP_HEADER));
...@@ -97,7 +73,7 @@ void mdmp_dump(void) ...@@ -97,7 +73,7 @@ void mdmp_dump(void)
printf("StreamDirectoryRva: %u\n", (UINT)hdr->StreamDirectoryRva); printf("StreamDirectoryRva: %u\n", (UINT)hdr->StreamDirectoryRva);
printf("CheckSum: %#x (%u)\n", hdr->CheckSum, hdr->CheckSum); printf("CheckSum: %#x (%u)\n", hdr->CheckSum, hdr->CheckSum);
printf("TimeDateStamp: %s\n", get_time_str(hdr->TimeDateStamp)); printf("TimeDateStamp: %s\n", get_time_str(hdr->TimeDateStamp));
print_longlong("Flags", hdr->Flags); printf("Flags: %s\n", get_hexint64_str(hdr->Flags));
for (idx = 0; idx < hdr->NumberOfStreams; ++idx) for (idx = 0; idx < hdr->NumberOfStreams; ++idx)
{ {
...@@ -122,8 +98,8 @@ void mdmp_dump(void) ...@@ -122,8 +98,8 @@ void mdmp_dump(void)
printf(" SuspendCount: %u\n", mt->SuspendCount); printf(" SuspendCount: %u\n", mt->SuspendCount);
printf(" PriorityClass: %u\n", mt->PriorityClass); printf(" PriorityClass: %u\n", mt->PriorityClass);
printf(" Priority: %u\n", mt->Priority); printf(" Priority: %u\n", mt->Priority);
print_longlong(" Teb", mt->Teb); printf(" Teb: %s\n", get_hexint64_str(mt->Teb));
print_longlong_range(" Stack", mt->Stack.StartOfMemoryRange, mt->Stack.Memory.DataSize); printf(" Stack: %s +%#x\n", get_hexint64_str(mt->Stack.StartOfMemoryRange), mt->Stack.Memory.DataSize);
dump_mdmp_data(&mt->Stack.Memory, " "); dump_mdmp_data(&mt->Stack.Memory, " ");
printf(" ThreadContext:\n"); printf(" ThreadContext:\n");
dump_mdmp_data(&mt->ThreadContext, " "); dump_mdmp_data(&mt->ThreadContext, " ");
...@@ -144,7 +120,7 @@ void mdmp_dump(void) ...@@ -144,7 +120,7 @@ void mdmp_dump(void)
for (i = 0; i < mml->NumberOfModules; i++, mm++) for (i = 0; i < mml->NumberOfModules; i++, mm++)
{ {
printf(" Module #%d:\n", i); printf(" Module #%d:\n", i);
print_longlong(" BaseOfImage", mm->BaseOfImage); printf(" BaseOfImage: %s\n", get_hexint64_str(mm->BaseOfImage));
printf(" SizeOfImage: %#x (%u)\n", mm->SizeOfImage, mm->SizeOfImage); printf(" SizeOfImage: %#x (%u)\n", mm->SizeOfImage, mm->SizeOfImage);
printf(" CheckSum: %#x (%u)\n", mm->CheckSum, mm->CheckSum); printf(" CheckSum: %#x (%u)\n", mm->CheckSum, mm->CheckSum);
printf(" TimeDateStamp: %s\n", get_time_str(mm->TimeDateStamp)); printf(" TimeDateStamp: %s\n", get_time_str(mm->TimeDateStamp));
...@@ -214,8 +190,8 @@ void mdmp_dump(void) ...@@ -214,8 +190,8 @@ void mdmp_dump(void)
dump_mdmp_data(&mm->CvRecord, " "); dump_mdmp_data(&mm->CvRecord, " ");
printf(" MiscRecord: <%u>\n", (UINT)mm->MiscRecord.DataSize); printf(" MiscRecord: <%u>\n", (UINT)mm->MiscRecord.DataSize);
dump_mdmp_data(&mm->MiscRecord, " "); dump_mdmp_data(&mm->MiscRecord, " ");
print_longlong(" Reserved0", mm->Reserved0); printf(" Reserved0: %s\n", get_hexint64_str(mm->Reserved0));
print_longlong(" Reserved1", mm->Reserved1); printf(" Reserved1: %s\n", get_hexint64_str(mm->Reserved1));
} }
} }
break; break;
...@@ -228,7 +204,7 @@ void mdmp_dump(void) ...@@ -228,7 +204,7 @@ void mdmp_dump(void)
for (i = 0; i < mml->NumberOfMemoryRanges; i++, mmd++) for (i = 0; i < mml->NumberOfMemoryRanges; i++, mmd++)
{ {
printf(" Memory Range #%d:\n", i); printf(" Memory Range #%d:\n", i);
print_longlong_range(" Range", mmd->StartOfMemoryRange, mmd->Memory.DataSize); printf(" Range: %s +%#x\n", get_hexint64_str(mmd->StartOfMemoryRange), mmd->Memory.DataSize);
dump_mdmp_data(&mmd->Memory, " "); dump_mdmp_data(&mmd->Memory, " ");
} }
} }
...@@ -423,13 +399,12 @@ void mdmp_dump(void) ...@@ -423,13 +399,12 @@ void mdmp_dump(void)
printf(" ExceptionRecord:\n"); printf(" ExceptionRecord:\n");
printf(" ExceptionCode: %#x\n", mes->ExceptionRecord.ExceptionCode); printf(" ExceptionCode: %#x\n", mes->ExceptionRecord.ExceptionCode);
printf(" ExceptionFlags: %#x\n", mes->ExceptionRecord.ExceptionFlags); printf(" ExceptionFlags: %#x\n", mes->ExceptionRecord.ExceptionFlags);
print_longlong(" ExceptionRecord", mes->ExceptionRecord.ExceptionRecord); printf(" ExceptionRecord: %s\n", get_hexint64_str( mes->ExceptionRecord.ExceptionRecord));
print_longlong(" ExceptionAddress", mes->ExceptionRecord.ExceptionAddress); printf(" ExceptionAddress: %s\n", get_hexint64_str( mes->ExceptionRecord.ExceptionAddress));
printf(" ExceptionNumberParameters: %u\n", mes->ExceptionRecord.NumberParameters); printf(" ExceptionNumberParameters: %u\n", mes->ExceptionRecord.NumberParameters);
for (i = 0; i < mes->ExceptionRecord.NumberParameters; i++) for (i = 0; i < mes->ExceptionRecord.NumberParameters; i++)
{ {
printf(" [%d]", i); printf(" [%d] %s\n", i, get_hexint64_str(mes->ExceptionRecord.ExceptionInformation[i]));
print_longlong(" ", mes->ExceptionRecord.ExceptionInformation[i]);
} }
printf(" ThreadContext:\n"); printf(" ThreadContext:\n");
dump_mdmp_data(&mes->ThreadContext, " "); dump_mdmp_data(&mes->ThreadContext, " ");
...@@ -450,7 +425,7 @@ void mdmp_dump(void) ...@@ -450,7 +425,7 @@ void mdmp_dump(void)
const MINIDUMP_HANDLE_DESCRIPTOR_2 *hd = (void *)ptr; const MINIDUMP_HANDLE_DESCRIPTOR_2 *hd = (void *)ptr;
printf(" Handle [%u]:\n", i); printf(" Handle [%u]:\n", i);
print_longlong(" Handle", hd->Handle); printf(" Handle: %s\n", get_hexint64_str(hd->Handle));
printf(" TypeName: "); printf(" TypeName: ");
dump_mdmp_string(hd->TypeNameRva); dump_mdmp_string(hd->TypeNameRva);
printf("\n"); printf("\n");
...@@ -493,12 +468,12 @@ void mdmp_dump(void) ...@@ -493,12 +468,12 @@ void mdmp_dump(void)
printf(" DumpFlags: %#x\n", ti->DumpFlags); printf(" DumpFlags: %#x\n", ti->DumpFlags);
printf(" DumpError: %u\n", ti->DumpError); printf(" DumpError: %u\n", ti->DumpError);
printf(" ExitStatus: %u\n", ti->ExitStatus); printf(" ExitStatus: %u\n", ti->ExitStatus);
print_longlong(" CreateTime", ti->CreateTime); printf(" CreateTime: %s\n", get_uint64_str(ti->CreateTime));
print_longlong(" ExitTime", ti->ExitTime); printf(" ExitTime: %s\n", get_hexint64_str(ti->ExitTime));
print_longlong(" KernelTime", ti->KernelTime); printf(" KernelTime: %s\n", get_uint64_str(ti->KernelTime));
print_longlong(" UserTime", ti->UserTime); printf(" UserTime: %s\n", get_uint64_str(ti->UserTime));
print_longlong(" StartAddress", ti->StartAddress); printf(" StartAddress: %s\n", get_hexint64_str(ti->StartAddress));
print_longlong(" Affinity", ti->Affinity); printf(" Affinity: %s\n", get_uint64_str(ti->Affinity));
ptr += til->SizeOfEntry; ptr += til->SizeOfEntry;
} }
...@@ -520,7 +495,7 @@ void mdmp_dump(void) ...@@ -520,7 +495,7 @@ void mdmp_dump(void)
const MINIDUMP_UNLOADED_MODULE *mod = (void *)ptr; const MINIDUMP_UNLOADED_MODULE *mod = (void *)ptr;
printf(" Module [%u]:\n", i); printf(" Module [%u]:\n", i);
print_longlong(" BaseOfImage", mod->BaseOfImage); printf(" BaseOfImage: %s\n", get_hexint64_str(mod->BaseOfImage));
printf(" SizeOfImage: %u\n", mod->SizeOfImage); printf(" SizeOfImage: %u\n", mod->SizeOfImage);
printf(" CheckSum: %#x\n", mod->CheckSum); printf(" CheckSum: %#x\n", mod->CheckSum);
printf(" TimeDateStamp: %s\n", get_time_str(mod->TimeDateStamp)); printf(" TimeDateStamp: %s\n", get_time_str(mod->TimeDateStamp));
......
...@@ -229,6 +229,8 @@ void dump_data( const unsigned char *ptr, unsigned int size, const ch ...@@ -229,6 +229,8 @@ void dump_data( const unsigned char *ptr, unsigned int size, const ch
const char* get_time_str( unsigned long ); const char* get_time_str( unsigned long );
unsigned int strlenW( const unsigned short *str ); unsigned int strlenW( const unsigned short *str );
void dump_unicode_str( const unsigned short *str, int len ); void dump_unicode_str( const unsigned short *str, int len );
const char* get_hexint64_str( DWORD64 l );
const char* get_uint64_str( DWORD64 l );
const char* get_guid_str(const GUID* guid); const char* get_guid_str(const GUID* guid);
const char* get_unicode_str( const WCHAR *str, int len ); const char* get_unicode_str( const WCHAR *str, int len );
const char* get_symbol_str(const char* symname); const char* get_symbol_str(const char* symname);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment