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

common/BackTrace: demangle on FreeBSD also #12992

Merged
merged 1 commit into from Jan 25, 2017

Conversation

Projects
None yet
3 participants
@tchaikov
Contributor

tchaikov commented Jan 19, 2017

the output on FreeBSD/clang looks like:

1: 0x44bfb3 <_Z3foov+0x413> at /usr/srcs/Ceph/work/ceph/build/bin/unittest_back_trace
2: 0x44c23e <_ZN20BackTrace_Basic_Test8TestBodyEv+0x1e> at /usr/srcs/Ceph/work/ceph/build/bin/unittest_back_trace
3: 0x4d068a <_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc+0x7a> at /usr/srcs/Ceph/work/ceph/build/bin/unittest_back_trace
4: 0x4b5977 <_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc+0x77> at /usr/srcs/Ceph/work/ceph/build/bin/unittest_back_trace
...

and update the test accordingly, as FreeBSD/clang uses '<>' to enclose
the mangled function and offset.

Signed-off-by: Kefu Chai kchai@redhat.com

@wjwithagen

This comment has been minimized.

Contributor

wjwithagen commented Jan 20, 2017

@tchaikov

I've run this thru FreeBSD, and the expression that worked for me:

  boost::regex e{"\\s+1:\\s+"
#ifdef __FreeBSD__
                 "(0x[[:xdigit:]]+\\s)?"
                 "\\s*<.*foo.*>"
#else
                 "\\(foo.*\\)\\s"
                 "\\[0x[[:xdigit:]]+\\]"
#endif
                ".*$"
                };

Which is a lot more liberal on white space, which is good.
And it'll match 2 versions: with debug info, and fully stripped.

@tchaikov

This comment has been minimized.

Contributor

tchaikov commented Jan 22, 2017

@wjwithagen as the comment put, i was trying to demangle function symbol name. the regex you have here is more tolerant but is less helpful to verify the demangled result. i just fixed it and tested the updated patch on clang 3.9.1 and FreeBSD 12.0-CURRENT.

could you give a try again? thanks.

common/BackTrace: demangle on FreeBSD also
the output on FreeBSD/clang looks like:

1: 0x44bfb3 <_Z3foov+0x413> at /usr/srcs/Ceph/work/ceph/build/bin/unittest_back_trace
2: 0x44c23e <_ZN20BackTrace_Basic_Test8TestBodyEv+0x1e> at /usr/srcs/Ceph/work/ceph/build/bin/unittest_back_trace
3: 0x4d068a <_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc+0x7a> at /usr/srcs/Ceph/work/ceph/build/bin/unittest_back_trace
4: 0x4b5977 <_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc+0x77> at /usr/srcs/Ceph/work/ceph/build/bin/unittest_back_trace
...

and update the test accordingly, as FreeBSD/clang uses '<>' to enclose
the mangled function and offset.

also, only demangle the C++ mangled names. those names always start with
"_Z". on FreeBSD, after demangling, "main" is turned into "unsigned
long", which does not make sense.

Signed-off-by: Kefu Chai <kchai@redhat.com>
@wjwithagen

This comment has been minimized.

Contributor

wjwithagen commented Jan 22, 2017

@tchaikov
It sort of depends on the compilation/link/strip/debug options.
I did have as bactrace:
1: 0x44bfb3 <_Z3foov+0x413> at /usr/srcs/Ceph/work/ceph/build/bin/unittest_back_trace
but also:
1: <foo(void)+0x413> at /usr/srcs/Ceph/work/ceph/build/bin/unittest_back_trace
Currently you RE only matches the last one.

For debugging purposes I would also just always print line 1.
That makes analysis after an error a bit easier.

@tchaikov

This comment has been minimized.

Contributor

tchaikov commented Jan 22, 2017

@wjwithagen

It sort of depends on the compilation/link/strip/debug options.

could you elaborate this a little bit?

under what condition do you have

1: 0x44bfb3 <_Z3foov+0x413> at /usr/srcs/Ceph/work/ceph/build/bin/unittest_back_trace

?

"_Z3foov" should be demangled to "foo(void)" if the BackTrace class works as expected.

For debugging purposes I would also just always print line 1.

what is line 1?

@wjwithagen

This comment has been minimized.

Contributor

wjwithagen commented Jan 23, 2017

@tchaikov
Yup, that is a good question....
First time I ran into an error on the unittest, I printed bt and got the
1: 0x44bfb3 <_Z3foov+0x413> at /usr/srcs/Ceph/work/ceph/build/bin/unittest_back_trace
But since then I have not been able to reproduce the conditions.
The full traceback does show that it did not get demangled.

HOWEVER it could be that that output was from before you fixed common/BackTrace.cc.
what I am missing is the "delete" for the hex-address, but that is due to you skipping over everything until you find an OPEN-symbol.

So I guess that this is just an unlucky flow of patching and my misunderstanding the full impact of the code.

Line 1 is the line against which you are running the RE backtrace matching.

@wjwithagen

This comment has been minimized.

Contributor

wjwithagen commented Jan 23, 2017

LGTM

@liewegas liewegas merged commit 07cb98e into ceph:master Jan 25, 2017

3 checks passed

Signed-off-by all commits in this PR are signed
Details
Unmodifed Submodules submodules for project are unmodified
Details
default Build finished.
Details

@tchaikov tchaikov deleted the tchaikov:wip-demangle-on-freebsd branch Jan 25, 2017

@tchaikov

This comment has been minimized.

Contributor

tchaikov commented Feb 8, 2017

@alfredodeza the "Unmodifed Submodules" check passed in PR, but it did bring in an unexpected change of rocksdb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment