forked from qt-creator/qt-creator
Debugger: Pretty print the name of a function when using lldb
This is achieved by calling "po" on an address value casted to a simple function pointer type, regardless of the actual type of the function pointer. lldb does not complain, and reports the library where the function is defined, its name, and location in the source code if available. Change-Id: I23ccce62e33bcf213ccdcb55c9836d54333f3c86 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -457,7 +457,7 @@ class Dumper(DumperBase):
|
|||||||
self.listMembers(value, nativeType)
|
self.listMembers(value, nativeType)
|
||||||
tdata.templateArguments = self.listTemplateParametersHelper(nativeType)
|
tdata.templateArguments = self.listTemplateParametersHelper(nativeType)
|
||||||
elif code == lldb.eTypeClassFunction:
|
elif code == lldb.eTypeClassFunction:
|
||||||
tdata.code = TypeCodeFunction,
|
tdata.code = TypeCodeFunction
|
||||||
elif code == lldb.eTypeClassMemberPointer:
|
elif code == lldb.eTypeClassMemberPointer:
|
||||||
tdata.code = TypeCodeMemberPointer
|
tdata.code = TypeCodeMemberPointer
|
||||||
|
|
||||||
@@ -649,6 +649,21 @@ class Dumper(DumperBase):
|
|||||||
def isMsvcTarget(self):
|
def isMsvcTarget(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def prettySymbolByAddress(self, address):
|
||||||
|
try:
|
||||||
|
result = lldb.SBCommandReturnObject()
|
||||||
|
# Cast the address to a function pointer to get the name and location of the function.
|
||||||
|
expression = 'po (void (*)()){}'
|
||||||
|
self.debugger.GetCommandInterpreter().HandleCommand(expression.format(address), result)
|
||||||
|
output = ''
|
||||||
|
if result.Succeeded():
|
||||||
|
output = result.GetOutput().strip()
|
||||||
|
if output:
|
||||||
|
return output
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return '0x%x' % address
|
||||||
|
|
||||||
def qtVersionAndNamespace(self):
|
def qtVersionAndNamespace(self):
|
||||||
for func in self.target.FindFunctions('qVersion'):
|
for func in self.target.FindFunctions('qVersion'):
|
||||||
name = func.GetSymbol().GetName()
|
name = func.GetSymbol().GetName()
|
||||||
|
Reference in New Issue
Block a user