Skip to content

Commit

Permalink
i#2127: Add further Windows version info to diagnostics (#2160)
Browse files Browse the repository at this point in the history
Updates DR to fae84d17 to retrieve the Windows build number, edition, and
release identifier.

Prints the new version information in the following places:
+ crash messages;
+ the win10 message about auto-generating syscall info for a new version;
+ results.txt;
+ global logfile.

Suppresses extra printing of DR Windows version warnings in debug build
from the frontend's use of DR standalone mode.

Asks the user to run "-debug -dr_debug" in release build crash messages.

Fixes #2127
  • Loading branch information
derekbruening authored Mar 4, 2019
1 parent f7eb0ad commit 0db6537
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ else ()
endif ()

# when updating this, also update the git submodule
set(DynamoRIO_VERSION_REQUIRED "7.1.17952")
set(DynamoRIO_VERSION_REQUIRED "7.1.17958")

set(DR_install_dir "dynamorio")

Expand Down
17 changes: 16 additions & 1 deletion common/utils.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2011-2018 Google, Inc. All rights reserved.
* Copyright (c) 2011-2019 Google, Inc. All rights reserved.
* Copyright (c) 2007-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -905,6 +905,10 @@ init_os_version(void)
os_version.version = DR_WINDOWS_VERSION_10_1803;
os_version.service_pack_major = 1;
os_version.service_pack_minor = 0;
/* Make it clear we don't know these fields: */
os_version.build_number = 0;
os_version.release_id[0] = '\0';
os_version.edition[0] = '\0';
}
}

Expand Down Expand Up @@ -941,6 +945,17 @@ get_windows_version(void)
return os_version.version;
}

void
get_windows_version_string(char *buf OUT, size_t bufsz)
{
if (os_version.version == 0)
init_os_version();
dr_snprintf(buf, bufsz, "WinVer=%u;Rel=%s;Build=%u;Edition=%s",
os_version.version, os_version.release_id, os_version.build_number,
os_version.edition);
buf[bufsz - 1] = '\0';
}

GET_NTDLL(NtQuerySystemInformation, (IN SYSTEM_INFORMATION_CLASS info_class,
OUT PVOID info,
IN ULONG info_size,
Expand Down
11 changes: 9 additions & 2 deletions common/utils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2010-2018 Google, Inc. All rights reserved.
* Copyright (c) 2010-2019 Google, Inc. All rights reserved.
* Copyright (c) 2007-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -30,7 +30,11 @@ extern "C" {
#ifdef WINDOWS
/* DRi#1424: avoid pulling in features from recent versions to keep compatibility */
# ifndef _WIN32_WINNT
# define _WIN32_WINNT _WIN32_WINNT_WIN2K
# ifdef X64
# define _WIN32_WINNT _WIN32_WINNT_WIN2003
# else
# define _WIN32_WINNT _WIN32_WINNT_WINXP
# endif
# endif
#endif

Expand Down Expand Up @@ -927,6 +931,9 @@ running_on_Vista_or_later(void);
dr_os_version_t
get_windows_version(void);

void
get_windows_version_string(char *buf OUT, size_t bufsz);

app_pc
get_highest_user_address(void);

Expand Down
26 changes: 18 additions & 8 deletions drmemory/drmemory.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2010-2017 Google, Inc. All rights reserved.
* Copyright (c) 2010-2019 Google, Inc. All rights reserved.
* Copyright (c) 2007-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -1819,18 +1819,24 @@ dr_init(client_id_t id)
#endif
module_data_t *data;
const char *opstr;
char tool_ver[64];
char tool_ver[128];
char os_ver[96];

dr_set_client_name("Dr. Memory", "http://drmemory.org/issues");
dr_set_client_name("Dr. Memory", "http://drmemory.org/issues"
/* Try to get more info from users. */
IF_DEBUG_ELSE("", " along with the results of running "
"'-debug -dr_debug'"));

utils_early_init();

#ifdef WINDOWS
get_windows_version_string(os_ver, BUFFER_SIZE_ELEMENTS(os_ver));
#else
os_ver[0] = '\0';
#endif
dr_snprintf(tool_ver, BUFFER_SIZE_ELEMENTS(tool_ver),
/* we include the date to distinguish RC and custom builds */
"%s-%d-(%s)%s%d", VERSION_STRING, BUILD_NUMBER, build_date,
/* we include the Windows version here for convenience */
IF_WINDOWS_ELSE(" win",""),
IF_WINDOWS_ELSE(get_windows_version(),0));
"%s-%d-(%s) %s", VERSION_STRING, BUILD_NUMBER, build_date, os_ver);
NULL_TERMINATE_BUFFER(tool_ver);
dr_set_client_version_string(tool_ver);

Expand Down Expand Up @@ -1907,7 +1913,11 @@ dr_init(client_id_t id)
"redzone size not large enough to store size");

create_global_logfile();
LOG(0, "options are \"%s\"\n", opstr);
#ifdef WINDOWS
LOG(0, "Windows version: %s\n", os_ver);
ELOGF(0, f_results, "Windows version: %s" NL, os_ver);
#endif
LOG(0, "Options are \"%s\"\n", opstr);

/* delayed from getting app_path, etc. until have logfile and ops */
ASSERT(app_base != NULL, "internal error finding executable base");
Expand Down
7 changes: 7 additions & 0 deletions drmemory/frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,13 @@ _tmain(int argc, TCHAR *targv[])

#ifdef WINDOWS
time_t start_time, end_time;
# ifdef DEBUG
/* Avoid stderr printing in debug build from version init on new win10
* (otherwise we get 2 prints, one here and in the client).
*/
if (!SetEnvironmentVariable(L"DYNAMORIO_OPTIONS", L"-stderr_mask 0"))
info("Failed to quiet frontend DR messages");
# endif
#endif

drfront_status_t sc;
Expand Down
9 changes: 6 additions & 3 deletions drmemory/syscall.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2010-2018 Google, Inc. All rights reserved.
* Copyright (c) 2010-2019 Google, Inc. All rights reserved.
* Copyright (c) 2007-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -698,8 +698,11 @@ syscall_init(void *drcontext _IF_WINDOWS(app_pc ntdll_base))
res = drsys_init(client_id, &ops);
#ifdef WINDOWS
if (res == DRMF_WARNING_UNSUPPORTED_KERNEL) {
NOTIFY_ERROR("Running on an unsupported operating system version."
"%s" NL, options.ignore_kernel ? "" :
char os_ver[96];
get_windows_version_string(os_ver, BUFFER_SIZE_ELEMENTS(os_ver));
NOTIFY_ERROR("Running on an unsupported operating system version: %s."
"%s" NL, os_ver,
options.ignore_kernel ? "" :
" Exiting to trigger auto-generation of system call information."
" Re-run with -ignore_kernel to attempt to continue instead.");
if (options.ignore_kernel)
Expand Down
2 changes: 1 addition & 1 deletion dynamorio
Submodule dynamorio updated 167 files

0 comments on commit 0db6537

Please sign in to comment.