1 """Test that lldb can create a stack-only corefile, and load the main binary."""
8 from lldbsuite
.test
.decorators
import *
9 from lldbsuite
.test
.lldbtest
import *
10 from lldbsuite
.test
import lldbutil
13 class TestStackCorefile(TestBase
):
14 @skipIfOutOfTreeDebugserver # newer debugserver required for these qMemoryRegionInfo types
19 corefile
= self
.getBuildArtifact("process.core")
21 (target
, process
, thread
, bkpt
) = lldbutil
.run_to_source_breakpoint(
22 self
, "// break here", lldb
.SBFileSpec("main.c")
25 frame
= thread
.GetFrameAtIndex(0)
26 stack_int
= frame
.GetValueForVariablePath("stack_int")
27 heap_int
= frame
.GetValueForVariablePath("*heap_int")
28 stack_str
= frame
.GetValueForVariablePath("stack_str")
29 heap_str
= frame
.GetValueForVariablePath("heap_str")
30 self
.assertEqual(stack_int
.GetValueAsUnsigned(), 5)
31 self
.assertEqual(heap_int
.GetValueAsUnsigned(), 10)
32 self
.assertEqual(stack_str
.summary
, '"stack string"')
33 self
.assertEqual(heap_str
.summary
, '"heap string"')
35 self
.runCmd("process save-core -s stack " + corefile
)
37 self
.dbg
.DeleteTarget(target
)
39 # Now load the corefile
40 target
= self
.dbg
.CreateTarget("")
41 process
= target
.LoadCore(corefile
)
42 thread
= process
.GetSelectedThread()
43 self
.assertTrue(process
.IsValid())
44 self
.assertTrue(process
.GetSelectedThread().IsValid())
46 self
.runCmd("image list")
49 num_modules
= target
.GetNumModules()
50 # We should only have the a.out binary and possibly
51 # the libdyld.dylib. Extra libraries loaded means
52 # extra LC_NOTE and unnecessarily large corefile.
53 self
.assertTrue(num_modules
== 1 or num_modules
== 2)
55 # The heap variables should be unavailable now.
56 frame
= thread
.GetFrameAtIndex(0)
57 stack_int
= frame
.GetValueForVariablePath("stack_int")
58 heap_int
= frame
.GetValueForVariablePath("*heap_int")
59 stack_str
= frame
.GetValueForVariablePath("stack_str")
60 heap_str
= frame
.GetValueForVariablePath("heap_str")
62 ## The heap SBValues both come back as IsValid()==true,
63 ## which I'm not so sure is a great/correct thing --
64 ## it hides the memory read error that actually happened,
65 ## and we don't have a real value.
66 self
.assertEqual(stack_int
.GetValueAsUnsigned(), 5)
67 self
.assertEqual(heap_int
.GetValueAsUnsigned(), 0)
68 self
.assertEqual(stack_str
.summary
, '"stack string"')
69 self
.assertEqual(heap_str
.summary
, '""')