Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to demangle C++ symbols #638

Merged
merged 1 commit into from
Jul 31, 2016
Merged

Try to demangle C++ symbols #638

merged 1 commit into from
Jul 31, 2016

Conversation

palmtenor
Copy link
Member

For C++ programs, this would make outputted stack traces look nicer.
Example: http:https://pastebin.com/LqT0nP67

def _demangle(name):
if name not in BPF._demangle_caches:
try:
pipe = subprocess.Popen(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice and useful, but can we do it on c++ side just calling a function instead of a process from python?

@palmtenor
Copy link
Member Author

Do the demangling in C++ side instead.
I have little knowledge about Lua so I will leave that part untouched for now...
@4ast: I don't know what would be the effect if I change the bcc_symbol->name in-place, so I added a new field.

bool res = mod.find_addr(addr, sym);
if (sym->name) {
sym->demangle_name = abi::__cxa_demangle(
sym->name, nullptr, nullptr, nullptr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the coding style looks a bit odd... why not in the same line? other than that it looks great!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have hard 80-char limit marker on my editor :P

@4ast
Copy link
Member

4ast commented Jul 30, 2016

LGTM

@@ -101,6 +101,7 @@ void perf_reader_set_fd(struct perf_reader *reader, int fd);
ffi.cdef[[
struct bcc_symbol {
const char *name;
const char *demangle_name;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation :)

@markdrayton
Copy link
Contributor

As far as I can tell you also need to change

return ffi.string(sym[0].name), sym[0].offset
to make the Lua side use the demangled name.

@markdrayton
Copy link
Contributor

Also thanks for doings this :)

@palmtenor
Copy link
Member Author

Thanks @markdrayton! Changed according to comment. Didn't locally verify Lua builds though, hoping the tests would cover:)

@4ast
Copy link
Member

4ast commented Jul 31, 2016

can you please squash all of the commits into one?
github will preserve the discussion/comments and git history will be less noisy.
Thanks!

Added a field `demangle_name` in the `bcc_symbol` struct. Calculate its value whenever possible. For C++ programs, this would make outputted stack traces look nicer.
Example: http:https://pastebin.com/LqT0nP67
@palmtenor palmtenor changed the title Try to demangle C++ symbols in BPF.sym() Try to demangle C++ symbols Jul 31, 2016
@palmtenor
Copy link
Member Author

Done:)

@4ast 4ast merged commit 4ba5238 into iovisor:master Jul 31, 2016
@4ast
Copy link
Member

4ast commented Jul 31, 2016

Thanks!

@palmtenor palmtenor deleted the demangle branch August 1, 2016 06:02
chantra pushed a commit to chantra/bcc that referenced this pull request Sep 16, 2016
Added a field `demangle_name` in the `bcc_symbol` struct. Calculate its value whenever possible. For C++ programs, this would make outputted stack traces look nicer.
Example: http:https://pastebin.com/LqT0nP67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants