From f612833d83f527cc3bcb394d689e93ab51c88e71 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 15 Oct 2018 17:26:56 +0200 Subject: [PATCH] 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 --- share/qtcreator/debugger/lldbbridge.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/share/qtcreator/debugger/lldbbridge.py b/share/qtcreator/debugger/lldbbridge.py index 6f8871f9777..8a6b86f1cdb 100644 --- a/share/qtcreator/debugger/lldbbridge.py +++ b/share/qtcreator/debugger/lldbbridge.py @@ -457,7 +457,7 @@ class Dumper(DumperBase): self.listMembers(value, nativeType) tdata.templateArguments = self.listTemplateParametersHelper(nativeType) elif code == lldb.eTypeClassFunction: - tdata.code = TypeCodeFunction, + tdata.code = TypeCodeFunction elif code == lldb.eTypeClassMemberPointer: tdata.code = TypeCodeMemberPointer @@ -649,6 +649,21 @@ class Dumper(DumperBase): def isMsvcTarget(self): 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): for func in self.target.FindFunctions('qVersion'): name = func.GetSymbol().GetName()