[lldb-dev] How to get function name without arguments type/value/name?

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Thu Apr 21 14:49:02 PDT 2016


The difference is how the debug info is emitted in the DWARF. Functions that come from C++ will have mangled names. These mangled names contain the arguments. If a function has a mangled name we will demangle it and display that. You can easily strip this if you want to by looking for the first "(" character and stripping the contents. We don't do anything like this. The main issue you will run into is if you have code like:


int foo(int f)
{
    return f*2; // Break here...
}

float foo(float d)
{
    return (float)foo((int)d);
}

int main(int argc, const char **argv)
{
    float f = float(2.3);
    return 0;
}


If you set a breakpoint at "Break here" and run you will currently get:

foo(int) + 16
foo(float) + 23
main + 25 

But you are saying you would rather see:

foo + 16
foo + 23
main + 25 

Or:

foo(...) + 16
foo(...) + 23
main + 25 

"main" is funny because C++ compilers will often 'extern "C"' the function auto magically. This will stop it from getting a mangled name and stop us from showing "main(int, const char **)" as the function name.

The other reason you might not want to strip anything from the actual name is what happens when you are debugging another language? If you strip any text between "(" and ")", you might ruin a stack frame for the "q" language that has a function name like "foo.bar.baz{int (hello)}" and display this as "foo.bar.baz{int ()}". So any stripping you do, you will want to only do this for specific languages. We do have "const char * SBFunction::GetDisplayName()", but we currently only do something different for Swift (the new Apple language). You can't change the output of that for C++.

Personally I like to see all of the arguments that uniquely identify each function, but that is me. So anything you do in your debugger, you will want to make that configurable.

Greg


> On Apr 21, 2016, at 1:45 PM, Jeffrey Tan via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> Hi,
> 
> I call SBFrame.name to get function name and display in our debugger callstack window. However, this seems to include arguments types sometimes.(Btw: why it includes arguments types for subFunction but not main() in screenshot?)
> 
> <Screen Shot 2016-04-21 at 1.40.55 PM.png>
> 
> This is fine for small function, but can be really long if the function has a lot of arguments and the arguments are of template type.
> 
> Is there any way to only get the function name without arguments types?
> 
> I have tried ""settings set frame-format [..]" " which seems to only apply to "bt" command. 
> I have tried SBFrame.function.name the same result.
> 
> Did I miss anything?
> Jeffrey
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev



More information about the lldb-dev mailing list