diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index a7336c34206..fc9a2977041 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -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 tPATH tIDENTIFIER tSTRING tINTVAR %token 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: diff --git a/programs/winedbg/debug.l b/programs/winedbg/debug.l index 0b76ba74329..dd7fb0db76f 100644 --- a/programs/winedbg/debug.l +++ b/programs/winedbg/debug.l @@ -245,6 +245,7 @@ STRING \"(\\[^\n]|[^\\"\n])*\" symbol|symbo|symb|sym { BEGIN(ASTRING_EXPECTED); return tSYMBOL; } maps|map { return tMAPS; } window|windo|wind|win|wnd { return tWND; } +system|syst|sys { return tSYSTEM; } info|inf|in { return tINFO; } type { return tTYPE; } diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index 28fb788b3c7..c65b9bfae67 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -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); diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c index 6ffcf99392a..251b92c607b 100644 --- a/programs/winedbg/info.c +++ b/programs/winedbg/info.c @@ -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(), ¤t, &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 ); + } +} diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index 7a5d71d8909..a339a586eca 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -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; }