Commit 7ada0e22 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winedbg: Add 'info system' command.

Letting the information displayed in '--auto' mode be available as a command. Simplify a bit the --auto mode handling. Note: - the WOW64 status of the debuggee used to be printed in system information, which is a bit ackward as system info shouldn't be tied to a given process. - replaced it with supported guest machines (for the record, a 64-bit only setup incorrectly returns i386 as supported guest; I guess we shouldn't care). - now printing the wow64 status of a process when displaying an exception information instead. Signed-off-by: 's avatarEric Pouech <epouech@codeweavers.com>
parent bde06574
......@@ -53,7 +53,7 @@ static void parser(const char*);
%token tABORT tECHO
%token tCLASS tMAPS tSTACK tSEGMENTS tSYMBOL tREGS tALLREGS tWND tLOCAL tEXCEPTION
%token tPROCESS tTHREAD tEOL tEOF
%token tFRAME tSHARE tMODULE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE
%token tFRAME tSHARE tMODULE tCOND tDISPLAY tUNDISPLAY tDISASSEMBLE tSYSTEM
%token tSTEPI tNEXTI tFINISH tSHOW tDIR tWHATIS tSOURCE
%token <string> tPATH tIDENTIFIER tSTRING tINTVAR
%token <integer> tNUM tFORMAT
......@@ -292,6 +292,7 @@ info_command:
| tINFO tMAPS { info_win32_virtual(dbg_curr_pid); }
| tINFO tMAPS expr_rvalue { info_win32_virtual($3); }
| tINFO tEXCEPTION { info_win32_exception(); }
| tINFO tSYSTEM { info_win32_system(); }
;
maintenance_command:
......
......@@ -245,6 +245,7 @@ STRING \"(\\[^\n]|[^\\"\n])*\"
<INFO_CMD>symbol|symbo|symb|sym { BEGIN(ASTRING_EXPECTED); return tSYMBOL; }
<INFO_CMD>maps|map { return tMAPS; }
<INFO_CMD>window|windo|wind|win|wnd { return tWND; }
<INFO_CMD>system|syst|sys { return tSYSTEM; }
<HELP_CMD>info|inf|in { return tINFO; }
<MAINT_CMD>type { return tTYPE; }
......
......@@ -394,6 +394,7 @@ extern void info_win32_frame_exceptions(DWORD tid);
extern void info_win32_virtual(DWORD pid);
extern void info_win32_segments(DWORD start, int length);
extern void info_win32_exception(void);
extern void info_win32_system(void);
extern void info_wine_dbg_channel(BOOL add, const char* chnl, const char* name);
extern WCHAR* fetch_thread_description(DWORD tid);
......
......@@ -1078,7 +1078,8 @@ void info_win32_exception(void)
switch (addr.Mode)
{
case AddrModeFlat:
dbg_printf(" in %ld-bit code (%s)",
dbg_printf(" in %s%ld-bit code (%s)",
dbg_curr_process->is_wow64 ? "wow64 " : "",
dbg_curr_process->be_cpu->pointer_size * 8,
memory_offset_to_string(hexbuf, addr.Offset, 0));
break;
......@@ -1095,3 +1096,108 @@ void info_win32_exception(void)
}
dbg_printf(".\n");
}
static const struct
{
int type;
int platform;
int major;
int minor;
const char *str;
}
version_table[] =
{
{ 0, VER_PLATFORM_WIN32s, 2, 0, "2.0" },
{ 0, VER_PLATFORM_WIN32s, 3, 0, "3.0" },
{ 0, VER_PLATFORM_WIN32s, 3, 10, "3.1" },
{ 0, VER_PLATFORM_WIN32_WINDOWS, 4, 0, "95" },
{ 0, VER_PLATFORM_WIN32_WINDOWS, 4, 10, "98" },
{ 0, VER_PLATFORM_WIN32_WINDOWS, 4, 90, "ME" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 3, 51, "NT 3.51" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 4, 0, "NT 4.0" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 5, 0, "2000" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 5, 1, "XP" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 5, 2, "XP" },
{ VER_NT_SERVER, VER_PLATFORM_WIN32_NT, 5, 2, "Server 2003" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 6, 0, "Vista" },
{ VER_NT_SERVER, VER_PLATFORM_WIN32_NT, 6, 0, "Server 2008" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 6, 1, "7" },
{ VER_NT_SERVER, VER_PLATFORM_WIN32_NT, 6, 1, "Server 2008 R2" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 6, 2, "8" },
{ VER_NT_SERVER, VER_PLATFORM_WIN32_NT, 6, 2, "Server 2012" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 6, 3, "8.1" },
{ VER_NT_SERVER, VER_PLATFORM_WIN32_NT, 6, 3, "Server 2012 R2" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 10, 0, "10" },
};
static const char *get_windows_version(void)
{
RTL_OSVERSIONINFOEXW info = { sizeof(RTL_OSVERSIONINFOEXW) };
static char str[64];
int i;
RtlGetVersion( &info );
for (i = 0; i < ARRAY_SIZE(version_table); i++)
{
if (version_table[i].type == info.wProductType &&
version_table[i].platform == info.dwPlatformId &&
version_table[i].major == info.dwMajorVersion &&
version_table[i].minor == info.dwMinorVersion)
{
return version_table[i].str;
}
}
snprintf( str, sizeof(str), "%ld.%ld (%d)", info.dwMajorVersion,
info.dwMinorVersion, info.wProductType );
return str;
}
static BOOL is_guest(USHORT native, USHORT guest)
{
BOOLEAN supported;
return native != guest && !RtlWow64IsWowGuestMachineSupported(guest, &supported) && supported;
}
void info_win32_system(void)
{
USHORT current, native;
int i, count;
const char *(CDECL *wine_get_build_id)(void);
void (CDECL *wine_get_host_version)( const char **sysname, const char **release );
static USHORT guest_machines[] =
{
IMAGE_FILE_MACHINE_I386, IMAGE_FILE_MACHINE_ARM, IMAGE_FILE_MACHINE_ARMNT,
};
wine_get_build_id = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_build_id");
wine_get_host_version = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_host_version");
RtlWow64GetProcessMachines( GetCurrentProcess(), &current, &native );
dbg_printf( "System information:\n" );
if (wine_get_build_id) dbg_printf( " Wine build: %s\n", wine_get_build_id() );
dbg_printf( " Platform: %s", get_machine_str(native));
for (count = i = 0; i < ARRAY_SIZE(guest_machines); i++)
{
if (is_guest(native, guest_machines[i]))
{
if (!count++) dbg_printf(" (guest:");
dbg_printf(" %s", get_machine_str(guest_machines[i]));
}
}
dbg_printf("%s\n", count ? ")" : "");
dbg_printf( " Version: Windows %s\n", get_windows_version() );
if (wine_get_host_version)
{
const char *sysname, *release;
wine_get_host_version( &sysname, &release );
dbg_printf( " Host system: %s\n", sysname );
dbg_printf( " Host version: %s\n", release );
}
}
......@@ -796,96 +796,6 @@ static HANDLE create_temp_file(void)
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, 0 );
}
static const struct
{
int type;
int platform;
int major;
int minor;
const char *str;
}
version_table[] =
{
{ 0, VER_PLATFORM_WIN32s, 2, 0, "2.0" },
{ 0, VER_PLATFORM_WIN32s, 3, 0, "3.0" },
{ 0, VER_PLATFORM_WIN32s, 3, 10, "3.1" },
{ 0, VER_PLATFORM_WIN32_WINDOWS, 4, 0, "95" },
{ 0, VER_PLATFORM_WIN32_WINDOWS, 4, 10, "98" },
{ 0, VER_PLATFORM_WIN32_WINDOWS, 4, 90, "ME" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 3, 51, "NT 3.51" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 4, 0, "NT 4.0" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 5, 0, "2000" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 5, 1, "XP" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 5, 2, "XP" },
{ VER_NT_SERVER, VER_PLATFORM_WIN32_NT, 5, 2, "Server 2003" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 6, 0, "Vista" },
{ VER_NT_SERVER, VER_PLATFORM_WIN32_NT, 6, 0, "Server 2008" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 6, 1, "7" },
{ VER_NT_SERVER, VER_PLATFORM_WIN32_NT, 6, 1, "Server 2008 R2" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 6, 2, "8" },
{ VER_NT_SERVER, VER_PLATFORM_WIN32_NT, 6, 2, "Server 2012" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 6, 3, "8.1" },
{ VER_NT_SERVER, VER_PLATFORM_WIN32_NT, 6, 3, "Server 2012 R2" },
{ VER_NT_WORKSTATION, VER_PLATFORM_WIN32_NT, 10, 0, "10" },
};
static const char *get_windows_version(void)
{
RTL_OSVERSIONINFOEXW info = { sizeof(RTL_OSVERSIONINFOEXW) };
static char str[64];
int i;
RtlGetVersion( &info );
for (i = 0; i < ARRAY_SIZE(version_table); i++)
{
if (version_table[i].type == info.wProductType &&
version_table[i].platform == info.dwPlatformId &&
version_table[i].major == info.dwMajorVersion &&
version_table[i].minor == info.dwMinorVersion)
{
return version_table[i].str;
}
}
snprintf( str, sizeof(str), "%ld.%ld (%d)", info.dwMajorVersion,
info.dwMinorVersion, info.wProductType );
return str;
}
static void output_system_info(void)
{
#ifdef __i386__
static const char platform[] = "i386";
#elif defined(__x86_64__)
static const char platform[] = "x86_64";
#elif defined(__arm__)
static const char platform[] = "arm";
#elif defined(__aarch64__)
static const char platform[] = "arm64";
#else
# error CPU unknown
#endif
const char *(CDECL *wine_get_build_id)(void);
void (CDECL *wine_get_host_version)( const char **sysname, const char **release );
wine_get_build_id = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_build_id");
wine_get_host_version = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_host_version");
dbg_printf( "System information:\n" );
if (wine_get_build_id) dbg_printf( " Wine build: %s\n", wine_get_build_id() );
dbg_printf( " Platform: %s%s\n", platform, dbg_curr_process->is_wow64 ? " (WOW64)" : "" );
dbg_printf( " Version: Windows %s\n", get_windows_version() );
if (wine_get_host_version)
{
const char *sysname, *release;
wine_get_host_version( &sysname, &release );
dbg_printf( " Host system: %s\n", sysname );
dbg_printf( " Host version: %s\n", release );
}
}
/******************************************************************
* dbg_active_attach
*
......@@ -978,7 +888,10 @@ enum dbg_start dbg_active_auto(int argc, char* argv[])
}
input = parser_generate_command_file("echo Modules:", "info share",
"echo Threads:", "info threads", NULL);
"echo Threads:", "info threads",
"info system",
"detach",
NULL);
if (input == INVALID_HANDLE_VALUE) return start_error_parse;
if (dbg_curr_process->active_debuggee)
......@@ -986,7 +899,6 @@ enum dbg_start dbg_active_auto(int argc, char* argv[])
dbg_interactiveP = TRUE;
parser_handle(NULL, input);
output_system_info();
if (output != INVALID_HANDLE_VALUE)
{
......@@ -998,7 +910,6 @@ enum dbg_start dbg_active_auto(int argc, char* argv[])
}
CloseHandle( input );
dbg_curr_process->process_io->close_process(dbg_curr_process, TRUE);
return start_ok;
}
......
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