Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Fix debugging on OS X Sierra (#10078) (#10205)
Browse files Browse the repository at this point in the history
Issue #9730

The output of the vmmap changed between OS X versions. Changed the sscanf formatting to deal with both old/new formats.
  • Loading branch information
mikem8361 authored Mar 16, 2017
1 parent a59b790 commit f4579b2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pal/src/thread/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2666,6 +2666,12 @@ CreateProcessModules(
// VM_ALLOCATE 0000000105bac000-0000000105bad000 [ 4K] r--/rw- SM=SHM
// MALLOC (admin) 0000000105bad000-0000000105bae000 [ 4K] r--/rwx SM=ZER
// MALLOC 0000000105bae000-0000000105baf000 [ 4K] rw-/rwx SM=ZER

// OS X Sierra (10.12.4 Beta)
// REGION TYPE START - END [ VSIZE RSDNT DIRTY SWAP] PRT/MAX SHRMOD PURGE REGION DETAIL
// Stack 00007fff5a930000-00007fff5b130000 [ 8192K 32K 32K 0K] rw-/rwx SM=PRV thread 0
// __TEXT 00007fffa4a0b000-00007fffa4a0d000 [ 8K 8K 0K 0K] r-x/r-x SM=COW /usr/lib/libSystem.B.dylib
// __TEXT 00007fffa4bbe000-00007fffa4c15000 [ 348K 348K 0K 0K] r-x/r-x SM=COW /usr/lib/libc++.1.dylib
char *line = NULL;
size_t lineLen = 0;
int count = 0;
Expand All @@ -2686,9 +2692,8 @@ CreateProcessModules(
{
void *startAddress, *endAddress;
char moduleName[PATH_MAX];
int size;

if (sscanf(line, "__TEXT %p-%p [ %dK] %*[-/rwxsp] SM=%*[A-Z] %s\n", &startAddress, &endAddress, &size, moduleName) == 4)
if (sscanf_s(line, "__TEXT %p-%p [ %*[0-9K ]] %*[-/rwxsp] SM=%*[A-Z] %s\n", &startAddress, &endAddress, moduleName, _countof(moduleName)) == 3)
{
bool dup = false;
for (ProcessModules *entry = listHead; entry != NULL; entry = entry->Next)
Expand Down

0 comments on commit f4579b2

Please sign in to comment.