1
- """Test corefiles with "main bin spec"/"load binary" with only addrs work ."""
1
+ """Test corefiles with "main bin spec"/"load binary" with only vmaddrs works ."""
2
2
3
3
4
4
import os
@@ -35,41 +35,28 @@ def initial_setup(self):
35
35
self .libtwo_exe ,
36
36
self .libtwo_slide ,
37
37
)
38
+ if self .TraceOn ():
39
+ print ("Creating corefile with command %s" )
38
40
call (cmd , shell = True )
39
41
40
42
def load_corefile_and_test (self ):
41
43
target = self .dbg .CreateTarget ("" )
42
44
err = lldb .SBError ()
43
45
if self .TraceOn ():
44
- self . runCmd ( "script print(' loading corefile %s') " % self .corefile )
46
+ print (" loading corefile %s" % self .corefile )
45
47
process = target .LoadCore (self .corefile )
46
48
self .assertEqual (process .IsValid (), True )
47
49
if self .TraceOn ():
48
- self . runCmd ( "script print(' image list after loading corefile:') " )
50
+ print (" image list after loading corefile:" )
49
51
self .runCmd ("image list" )
50
52
51
- self .assertEqual (target .GetNumModules (), 3 )
53
+ ## We don't have libone.dylib in the global module cache or from
54
+ ## dsymForUUID, and lldb will not read the binary out of memory.
55
+ self .assertEqual (target .GetNumModules (), 2 )
52
56
fspec = target .GetModuleAtIndex (0 ).GetFileSpec ()
53
57
self .assertEqual (fspec .GetFilename (), self .aout_exe_basename )
54
58
55
- # libone.dylib was never loaded into lldb, see that we added a memory module.
56
59
fspec = target .GetModuleAtIndex (1 ).GetFileSpec ()
57
- self .assertIn ("memory-image" , fspec .GetFilename ())
58
-
59
- dwarfdump_uuid_regex = re .compile ("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*" )
60
- dwarfdump_cmd_output = subprocess .check_output (
61
- ('/usr/bin/dwarfdump --uuid "%s"' % self .libone_exe ), shell = True
62
- ).decode ("utf-8" )
63
- libone_uuid = None
64
- for line in dwarfdump_cmd_output .splitlines ():
65
- match = dwarfdump_uuid_regex .search (line )
66
- if match :
67
- libone_uuid = match .group (1 )
68
-
69
- memory_image_uuid = target .GetModuleAtIndex (1 ).GetUUIDString ()
70
- self .assertEqual (libone_uuid , memory_image_uuid )
71
-
72
- fspec = target .GetModuleAtIndex (2 ).GetFileSpec ()
73
60
self .assertEqual (fspec .GetFilename (), self .libtwo_exe_basename )
74
61
75
62
# Executables "always" have this base address
@@ -80,17 +67,9 @@ def load_corefile_and_test(self):
80
67
)
81
68
self .assertEqual (aout_load , 0x100000000 + self .aout_slide )
82
69
83
- # Value from Makefile
84
- libone_load = (
85
- target .GetModuleAtIndex (1 )
86
- .GetObjectFileHeaderAddress ()
87
- .GetLoadAddress (target )
88
- )
89
- self .assertEqual (libone_load , self .libone_slide )
90
-
91
70
# Value from Makefile
92
71
libtwo_load = (
93
- target .GetModuleAtIndex (2 )
72
+ target .GetModuleAtIndex (1 )
94
73
.GetObjectFileHeaderAddress ()
95
74
.GetLoadAddress (target )
96
75
)
@@ -140,6 +119,15 @@ def test_corefile_binaries_dsymforuuid(self):
140
119
self .assertNotEqual (
141
120
libtwo_uuid , None , "Could not get uuid of built libtwo.dylib"
142
121
)
122
+ dwarfdump_cmd_output = subprocess .check_output (
123
+ ('/usr/bin/dwarfdump --uuid "%s"' % self .aout_exe ), shell = True
124
+ ).decode ("utf-8" )
125
+ aout_uuid = None
126
+ for line in dwarfdump_cmd_output .splitlines ():
127
+ match = dwarfdump_uuid_regex .search (line )
128
+ if match :
129
+ aout_uuid = match .group (1 )
130
+ self .assertNotEqual (aout_uuid , None , "Could not get uuid of built a.out" )
143
131
144
132
### Create our dsym-for-uuid shell script which returns aout_exe
145
133
shell_cmds = [
@@ -149,27 +137,47 @@ def test_corefile_binaries_dsymforuuid(self):
149
137
"do" ,
150
138
" shift" ,
151
139
"done" ,
152
- "ret=0" ,
153
140
'echo "<?xml version=\\ "1.0\\ " encoding=\\ "UTF-8\\ "?>"' ,
154
141
'echo "<!DOCTYPE plist PUBLIC \\ "-//Apple//DTD PLIST 1.0//EN\\ " \\ "http://www.apple.com/DTDs/PropertyList-1.0.dtd\\ ">"' ,
155
142
'echo "<plist version=\\ "1.0\\ ">"' ,
143
+ 'echo " <dict>"' ,
144
+ 'echo " <key>$1</key>"' ,
145
+ 'echo " <dict>"' ,
156
146
"" ,
157
- 'if [ "$1" != "%s" ]' % (libtwo_uuid ),
147
+ 'if [ "$1" != "%s" -a "$1" != "%s" ]' % (libtwo_uuid , aout_uuid ),
158
148
"then" ,
159
- ' echo "<key>DBGError</key><string>not found</string>"' ,
149
+ ' echo " <key>DBGError</key>"' ,
150
+ ' echo " <string>not found by $0</string>"' ,
151
+ ' echo " </dict>"' ,
152
+ ' echo " </dict>"' ,
160
153
' echo "</plist>"' ,
161
- " exit 1 " ,
154
+ " exit 0 " ,
162
155
"fi" ,
156
+ # UUID matches libtwo.dylib
157
+ 'if [ "$1" = "%s" ]' % (libtwo_uuid ),
158
+ "then" ,
163
159
" uuid=%s" % libtwo_uuid ,
164
160
" bin=%s" % self .libtwo_exe ,
165
161
" dsym=%s.dSYM/Contents/Resources/DWARF/%s"
166
162
% (self .libtwo_exe , os .path .basename (self .libtwo_exe )),
167
- 'echo "<dict><key>$uuid</key><dict>"' ,
163
+ "fi" ,
164
+ # UUID matches a.out
165
+ 'if [ "$1" = "%s" ]' % (aout_uuid ),
166
+ "then" ,
167
+ " uuid=%s" % aout_uuid ,
168
+ " bin=%s" % self .aout_exe ,
169
+ " dsym=%s.dSYM/Contents/Resources/DWARF/%s"
170
+ % (self .aout_exe , os .path .basename (self .aout_exe )),
171
+ "fi" ,
168
172
"" ,
169
- 'echo "<key>DBGDSYMPath</key><string>$dsym</string>"' ,
170
- 'echo "<key>DBGSymbolRichExecutable</key><string>$bin</string>"' ,
171
- 'echo "</dict></dict></plist>"' ,
172
- "exit $ret" ,
173
+ 'echo " <key>DBGDSYMPath</key>"' ,
174
+ 'echo " <string>$dsym</string>"' ,
175
+ 'echo " <key>DBGSymbolRichExecutable</key>"' ,
176
+ 'echo " <string>$bin</string>"' ,
177
+ 'echo " </dict>"' ,
178
+ 'echo " </dict>"' ,
179
+ 'echo "</plist>"' ,
180
+ "exit 0" ,
173
181
]
174
182
175
183
with open (dsym_for_uuid , "w" ) as writer :
@@ -183,7 +191,7 @@ def test_corefile_binaries_dsymforuuid(self):
183
191
self .dbg .DeleteTarget (target )
184
192
185
193
if self .TraceOn ():
186
- self . runCmd ( "script print(' Global image list, before loading corefile:') " )
194
+ print (" Global image list, before loading corefile:" )
187
195
self .runCmd ("image list -g" )
188
196
189
197
self .load_corefile_and_test ()
@@ -206,7 +214,7 @@ def test_corefile_binaries_preloaded(self):
206
214
self .dbg .DeleteTarget (target )
207
215
208
216
if self .TraceOn ():
209
- self . runCmd ( "script print(' Global image list, before loading corefile:') " )
217
+ print (" Global image list, before loading corefile:" )
210
218
self .runCmd ("image list -g" )
211
219
212
220
self .load_corefile_and_test ()
0 commit comments