minidump: Create memory regions from the sections of loaded modules
Summary:
Not all minidumps contain information about memory permissions. However,
it is still important to know which regions of memory contain
potentially executable code. This is particularly important for
unwinding on win32, as the default unwind method there relies on
scanning the stack for things which "look like" code pointers.
This patch enables ProcessMinidump to reconstruct the likely permissions
of memory regions using the sections of loaded object files. It only
does this if we don't have a better source (memory info list stream, or
linux /proc/maps) for this information, and only if the information in
the object files does not conflict with the information in the minidump.
Theoretically that last bit could be improved, since the permissions
obtained from the MemoryList streams is also only a very rough guess,
but it did not seem worthwhile to complicate the implementation because
of that because there will generally be no overlap in practice as the
MemoryList will contain the stack contents and not any module data.
The patch adds a test checking that the module section permissions are
entered into the memory region list, and also a test which demonstrate
that now the unwinder is able to correctly find return addresses even in
minidumps without memory info list streams.
There's one TODO left in this patch, which is that the "memory region"
output does not give any indication about the "don't know" values of
memory region permissions (it just prints them as if they permission bit
was set). I address this in a follow up.
Reviewers: amccarth, clayborg
Subscribers: mgrang, lldb-commits
Differential Revision: https://reviews.llvm.org/D69105
2019-10-16 16:38:10 +08:00
|
|
|
# Check that memory region parsing works correctly, with a particular emphasis
|
|
|
|
# on the boundary conditions.
|
|
|
|
|
|
|
|
# RUN: yaml2obj --docnum=1 %s > %t1.dmp
|
|
|
|
# RUN: yaml2obj --docnum=2 %s > %t2.dmp
|
|
|
|
# RUN: yaml2obj %S/Inputs/basic-elf.yaml >%T/memory-region-from-module.exe
|
|
|
|
|
|
|
|
# RUN: %lldb -b -c %t1.dmp %T/memory-region-from-module.exe \
|
|
|
|
# RUN: -o "memory region 0" -o "memory region 0x4000" \
|
|
|
|
# RUN: -o "memory region 0x5000" -o "memory region 0x6000" \
|
|
|
|
# RUN: | FileCheck --check-prefix=ALL --check-prefix=CHECK1 %s
|
|
|
|
|
|
|
|
# RUN: %lldb -b -c %t2.dmp %T/memory-region-from-module.exe \
|
|
|
|
# RUN: -o "memory region 0" -o "memory region 0x4000" \
|
|
|
|
# RUN: -o "memory region 0x5000" -o "memory region 0x6000" \
|
|
|
|
# RUN: | FileCheck --check-prefix=ALL --check-prefix=CHECK2 %s
|
|
|
|
|
|
|
|
# ALL-LABEL: (lldb) memory region 0
|
|
|
|
# ALL: [0x0000000000000000-0x0000000000004000) ---
|
|
|
|
# ALL-LABEL: (lldb) memory region 0x4000
|
|
|
|
# CHECK1: [0x0000000000004000-0x00000000000040b0) r-x {{.*}}memory-region-from-module.exe PT_LOAD[0]
|
2019-10-16 21:29:20 +08:00
|
|
|
# CHECK2: [0x0000000000004000-0x0000000000004010) r??
|
minidump: Create memory regions from the sections of loaded modules
Summary:
Not all minidumps contain information about memory permissions. However,
it is still important to know which regions of memory contain
potentially executable code. This is particularly important for
unwinding on win32, as the default unwind method there relies on
scanning the stack for things which "look like" code pointers.
This patch enables ProcessMinidump to reconstruct the likely permissions
of memory regions using the sections of loaded object files. It only
does this if we don't have a better source (memory info list stream, or
linux /proc/maps) for this information, and only if the information in
the object files does not conflict with the information in the minidump.
Theoretically that last bit could be improved, since the permissions
obtained from the MemoryList streams is also only a very rough guess,
but it did not seem worthwhile to complicate the implementation because
of that because there will generally be no overlap in practice as the
MemoryList will contain the stack contents and not any module data.
The patch adds a test checking that the module section permissions are
entered into the memory region list, and also a test which demonstrate
that now the unwinder is able to correctly find return addresses even in
minidumps without memory info list streams.
There's one TODO left in this patch, which is that the "memory region"
output does not give any indication about the "don't know" values of
memory region permissions (it just prints them as if they permission bit
was set). I address this in a follow up.
Reviewers: amccarth, clayborg
Subscribers: mgrang, lldb-commits
Differential Revision: https://reviews.llvm.org/D69105
2019-10-16 16:38:10 +08:00
|
|
|
# ALL-LABEL: (lldb) memory region 0x5000
|
|
|
|
# ALL: [0x0000000000005000-0x000000000000505c) rw- {{.*}}memory-region-from-module.exe PT_LOAD[1]
|
|
|
|
# ALL-LABEL: (lldb) memory region 0x6000
|
|
|
|
# ALL: [0x000000000000505c-0xffffffffffffffff) ---
|
|
|
|
|
|
|
|
--- !minidump
|
|
|
|
Streams:
|
|
|
|
- Type: ModuleList
|
|
|
|
Modules:
|
|
|
|
- Base of Image: 0x0000000000004000
|
|
|
|
Size of Image: 0x00002000
|
|
|
|
Module Name: 'memory-region-from-module.exe'
|
|
|
|
CodeView Record: 4C457042DEADBEEFBAADF00D
|
|
|
|
|
|
|
|
- Type: SystemInfo
|
|
|
|
Processor Arch: AMD64
|
|
|
|
Platform ID: Linux
|
|
|
|
CPU:
|
|
|
|
Vendor ID: GenuineIntel
|
|
|
|
Version Info: 0x00000000
|
|
|
|
Feature Info: 0x00000000
|
|
|
|
- Type: LinuxProcStatus
|
|
|
|
Text: |
|
|
|
|
Name: memory-region-from-module.exe
|
|
|
|
State: t (tracing stop)
|
|
|
|
Tgid: 29939
|
|
|
|
Ngid: 0
|
|
|
|
Pid: 29939
|
|
|
|
PPid: 29370
|
|
|
|
TracerPid: 29940
|
|
|
|
Uid: 1001 1001 1001 1001
|
|
|
|
Gid: 1001 1001 1001 1001
|
|
|
|
|
|
|
|
...
|
|
|
|
|
|
|
|
--- !minidump
|
|
|
|
Streams:
|
|
|
|
- Type: MemoryList
|
|
|
|
Memory Ranges:
|
|
|
|
- Start of Memory Range: 0x0000000000004000
|
|
|
|
Content: 30044000000000000000000000000000
|
|
|
|
- Type: ModuleList
|
|
|
|
Modules:
|
|
|
|
- Base of Image: 0x0000000000004000
|
|
|
|
Size of Image: 0x00002000
|
|
|
|
Module Name: 'memory-region-from-module.exe'
|
|
|
|
CodeView Record: 4C457042DEADBEEFBAADF00D
|
|
|
|
|
|
|
|
- Type: SystemInfo
|
|
|
|
Processor Arch: AMD64
|
|
|
|
Platform ID: Linux
|
|
|
|
CPU:
|
|
|
|
Vendor ID: GenuineIntel
|
|
|
|
Version Info: 0x00000000
|
|
|
|
Feature Info: 0x00000000
|
|
|
|
- Type: LinuxProcStatus
|
|
|
|
Text: |
|
|
|
|
Name: memory-region-from-module.exe
|
|
|
|
State: t (tracing stop)
|
|
|
|
Tgid: 29939
|
|
|
|
Ngid: 0
|
|
|
|
Pid: 29939
|
|
|
|
PPid: 29370
|
|
|
|
TracerPid: 29940
|
|
|
|
Uid: 1001 1001 1001 1001
|
|
|
|
Gid: 1001 1001 1001 1001
|
|
|
|
|
|
|
|
...
|