MCPcopy
hub / github.com/DerekSelander/LLDB / getSymbolsForSection

Function getSymbolsForSection

lldb_commands/ds.py:235–288  ·  view source on GitHub ↗
(section, outputCount, shouldFilterDataOnly = True)

Source from the content-addressed store, hash-verified

233 return output
234
235def getSymbolsForSection(section, outputCount, shouldFilterDataOnly = True):
236 # Grab all the DATA related symbols
237 module = section.addr.module
238 target = getTarget()
239 section_load_addr = section.GetLoadAddress(target)
240
241 if shouldFilterDataOnly:
242 symbols = [i for i in module.symbols if i.type == 4]
243 else:
244 symbols = module.symbols
245 indeces = []
246 symbolList = []
247 descriptions = []
248
249 process = target.GetProcess()
250
251
252 # error = lldb.SBError()
253 # ptr = process.ReadPointerFromMemory(loadAddr + i * ptrsize, error)
254 # if error.success == True:
255
256 # sec = target.ResolveLoadAddress(ptr).section
257 # if sec.IsValid():
258 # if sec.name == "__stub_helper":
259 # descriptions.append("-")
260 # else:
261 # descriptions.append("+")
262 # else:
263 # descriptions.append(None)
264
265
266 # stringList.append(retstr)
267 err = lldb.SBError()
268 for symbol in symbols:
269 if symbol.GetStartAddress().GetSection() == section:
270 symbolList.append(symbol.name)
271 symbol_load_address = symbol.GetStartAddress().GetLoadAddress(target)
272 symbol_end_address = symbol.GetEndAddress().GetLoadAddress(target)
273
274 size = symbol_end_address-symbol_load_address
275 indeces.append((symbol_load_address - section_load_addr, size))
276
277 if size % 4 != 0 or size > 8:
278 descriptions.append(None)
279 continue
280
281 read_memory = "{0:#0{1}x}".format(process.ReadUnsignedFromMemory(symbol_load_address, size, err), size *2)
282 if err.success == True:
283 descriptions.append(read_memory)
284 else:
285 print("error parsing memory {}, {}".format(symbol_load_address, size))
286 descriptions.append(None)
287
288 return (indeces, symbolList, descriptions)
289
290def getIvars(section, outputCount):
291 target = getTarget()

Callers 1

formatFromDataFunction · 0.85

Calls 1

getTargetFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…