Skip to content

Commit 5961e8e

Browse files
committed
Find the # that was preventing the extension from being included! Switch over to type byte size
1 parent 7edd450 commit 5961e8e

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

lldb/bindings/interface/SBSaveCoreOptionsExtensions.i

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11

22
%extend lldb::SBSaveCoreOptions {
33
#ifdef SWIGPYTHON
4-
%pythoncode %{
4+
%pythoncode%{
55
def save_thread_with_heaps(self, thread, num_pointers_deep = 3):
66
self.AddThread(thread)
77
frame = thread.GetFrameAtIndex(0)
88
process = thread.GetProcess()
99
queue = []
1010
for var in frame.locals:
11-
if var.TypeIsPointerType():
11+
type = var.GetType()
12+
if type.IsPointerType() or type.IsReferenceType():
1213
queue.append(var.Dereference())
1314

1415
while (num_pointers_deep > 0 and len(queue) > 0):
1516
queue_size = len(queue)
1617
for i in range(0, queue_size):
1718
var = queue.pop(0)
18-
memory_region = lldb.SBMemoryRegionInfo()
19-
process.GetMemoryRegionInfo(var.GetAddress().GetOffset(), memory_region)
19+
var_type = var.GetType()
20+
addr = var.GetAddress().GetOffset()
21+
memory_region = lldb.SBMemoryRegionInfo(None, addr, addr + var_type.GetByteSize(), False)
2022
self.AddMemoryRegionToSave(memory_region)
21-
/*
22-
We only check for direct pointer children T*, should probably scan
23-
internal to the children themselves.
24-
*/
23+
# We only check for direct pointer children T*, should probably scan
24+
# internal to the children themselves.
2525
for x in var.children:
2626
if x.TypeIsPointerType():
2727
queue.append(x.Dereference())

lldb/bindings/interfaces.swig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
%include "./interface/SBProcessExtensions.i"
201201
%include "./interface/SBProcessInfoListExtensions.i"
202202
%include "./interface/SBQueueItemExtensions.i"
203-
#include "./interface/SBSaveCoreOptionsExtensions.i"
203+
%include "./interface/SBSaveCoreOptionsExtensions.i"
204204
%include "./interface/SBScriptObjectExtensions.i"
205205
%include "./interface/SBSectionExtensions.i"
206206
%include "./interface/SBStreamExtensions.i"

lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ def test_save_core_one_thread_one_heap(self):
489489
options.SetPluginName("minidump")
490490
options.SetStyle(lldb.eSaveCoreCustomOnly)
491491
thread = process.GetThreadAtIndex(0)
492-
options.save_thread_with_heaps(thread)
492+
options.save_thread_with_heaps(thread, 1)
493493

494494
error = process.SaveCore(options)
495495
self.assertTrue(error.Success())
@@ -498,6 +498,24 @@ def test_save_core_one_thread_one_heap(self):
498498
# proc/pid maps prevent us from checking the number of regions, but
499499
# this is mostly a smoke test for the extension.
500500
self.assertEqual(core_proc.GetNumThreads(), 1)
501+
addr = (
502+
process.GetThreadAtIndex(0)
503+
.GetFrameAtIndex(0)
504+
.FindVariable("str")
505+
.Dereference()
506+
.GetAddress()
507+
.GetOffset()
508+
)
509+
core_addr = (
510+
core_proc.GetThreadAtIndex(0)
511+
.GetFrameAtIndex(0)
512+
.FindVariable("str")
513+
.Dereference()
514+
.GetAddress()
515+
.GetOffset()
516+
)
517+
self.assertEqual(addr, core_addr)
518+
501519
finally:
502520
if os.path.isfile(custom_file):
503521
os.unlink(custom_file)

lldb/test/API/functionalities/process_save_core_minidump/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ size_t h() {
1818

1919
int main() {
2020
std::thread t1(f);
21-
21+
char *str = new char[10];
2222
size_t x = h();
2323

2424
t1.join();

0 commit comments

Comments
 (0)