-
Notifications
You must be signed in to change notification settings - Fork 478
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
extract argspec from DWARF debug info #174
Comments
Pushed an premature implementation to review/dwarf-argspec-v1. Note:
|
Thanks for doing this work but I've got the below message if I don't install
We may be able to provide better message when |
Hm.. It doesn't seem to be working on my system.
|
I've checked it again but found that I should have to run |
It shows strange output for return value display:
And it crashes if I run it as follows:
|
For your reference, this feature also works in my system.
After setting the test environment,
If I find some problems from other test cases, I'll report it 😄 |
@honggyukim retval is not supported yet, sorry. @Taeung thanks for testing! |
@namhyung I found the case that segfault occurs like below:
So, I retest it with
You can download the error.log file. |
Hmm.. it should count floating-point argument separately. Will fix, thanks. |
Pushed review/dwarf-argspec-v2. Changelog:
|
It's working fine even for python interpreter as follows:
I think we need to change the description from |
I want to test this feature.
Then recompile uftrace, go test right? |
I think you need to checkout |
I'm interesting in this issue and want to know more about Is there any references or |
🖐 I tried a few set of patches, also a name of a function pointer can be traced with
It is original feature of uftrace in
But for this, I picked only 2 commits, 1e2dc9f and 0b29291, involved with
I cannot resolve the conflicts.. |
@flavono123 thanks for working on this. I need to rebase this branch on top of the current master (with auto-args merged). But I have some more work before doing that. Did you make all pointers to function pointer? It works for the current implementation but not sure it's the right thing as it involves unnecessary symbol resolution for other type of characters. |
And for your information, it needs a lot more testing for C++ programs which have many subtleties.. |
@namhyung Right. I do that following the current implementation(commits i picked). You mean more work gonna be on the It is sorry for that I have no idea about C++ now 😅 |
No need to be sorry. :) I'm working on 'enum' type support for auto-args. After that DWARF can generate more detailed arg info automatically. |
@namhyung Is it possible to make it work for binaries compiled with |
I'm not sure. As cygprof_entry/exit can be called for inlined functions, the filter could not identify which one is normal or inlined. That would break the assumption of stack base offset IMO. |
Hmm.. I need to check how gdb handles the arguments of inline functions when the binary is compiled with |
Pushed review/dwarf-argspec-v3. Changelog:
Example:
|
I've tested it using custom built cpython as follows:
The cpython is compiled with
|
Here is the steps to reproduce.
|
Thanks for testing, there were some bugs handling unnamed enums. I've updated the v3 branch with the fix. |
Thanks a lot for the fix. It works great!
By the way, do you want to use |
I have one more idea to ask you. There are so many address values in the argument display, but it'd be better to have its struct or pointer type name to give better idea to users. For example, instead of the below output,
It could be more informative with type information as follows:
Or, it could also show the variable name as well.
I'm just telling you the basic idea, so please let me know any kind of your thought about it. |
I think it's possible to get type info of library functions (if it's #included in the header file). But I'd like to leave it as a next step. What do you mean by "assertion like dump"? |
I'm okay with it.
I don't remember exactly but if |
It already checks NULL - all failure cases I saw had invalid addresses, thanks. |
I see. Thanks for the explanation. |
It seems that dwarf info is not made for functions that are marked as small Here is the symbol field for
But I don't find any info in |
You can test it with the below example: #include <iostream>
#include <algorithm>
bool cmp_less(int a, int b)
{
return a < b;
}
int main()
{
int x[5] = { 1, 3, 5, 7, 9 };
std::sort(x, x + 5, cmp_less);
std::sort(x, x + 5, [](int a, int b) { return a < b; });
}
|
It seems DWARF doesn't have linkage name for some entries and it makes fail to match. |
Pushed review/dwarf-argspec-v17 Changelog:
|
Thanks a lot. It looks good but I have two more comments.
|
And could you please check the test in #79?
|
It seems lambda function is passed as an empty struct, so it got ignored. I'll add a check. |
Right. lambda function is not an empty struct only when it captures some variables. It's usually an empty struct that has only |
There can be one more example, please test it with the below example. #include <iostream>
#include <algorithm>
bool cmp_less(int a, int b)
{
return a < b;
}
int main()
{
int x[5] = { 1, 3, 5, 7, 9 };
std::sort(x, x + 5, cmp_less);
std::sort(x, x + 5, [](int a, int b) { return a < b; });
std::sort(x, x + 5, std::less<int>());
}
|
FYI, /// One of the @link comparison_functors comparison functors@endlink.
template<typename _Tp>
struct less : public binary_function<_Tp, _Tp, bool>
{
_GLIBCXX14_CONSTEXPR
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x < __y; }
};
/**
* This is one of the @link functors functor base classes@endlink.
*/
template<typename _Arg1, typename _Arg2, typename _Result>
struct binary_function
{
/// @c first_argument_type is the type of the first argument
typedef _Arg1 first_argument_type;
/// @c second_argument_type is the type of the second argument
typedef _Arg2 second_argument_type;
/// @c result_type is the return type
typedef _Result result_type;
}; |
It seems clang puts invalid DWARF info for the function.. sigh.. |
Pushed review/dwarf-argspec-v18 Changelog:
|
Thanks a lot for the update! It works fine with I have one more thing to discuss. We use |
One more issue is that old uftrace cannot read uftrace data that is recorded by this dwarf supported version. It currently shows error messages as follows:
Would it be possible to show better error message? I think we better suggest to use higher version of uftrace. |
I have one more question. Is it possible to get dwarf info for
|
Thinking again, it'd be better not to cover |
Right, I'd like to leave it for now, it can be added later.. Regarding to the old versions, it's hard since we cannot change released version. One thing I can think of is adding a new feature bit so that users can notice there's an unsupported feature. |
Right. I understand that. I just hoped as general users' point of view. |
Pushed review/dwarf-argspec-v19 Changelog:
|
Thanks for the update. I have only trivial comments for v19.
t203_dwarf3: diff result of -pg -Os
--- expect 2018-07-05 22:30:15.704487042 +0900
+++ result 2018-07-05 22:30:15.704487042 +0900
@@ -2,6 +2,6 @@
C::C(0xADDR, 1, "debug info") {
- C::construct(0xADDR, 1, "debug info");
+ C::copy(0xADDR, 1, "debug info");
} /* C::C */
C::C(0xADDR, 2, "<0xADDR>") {
- C::construct(0xADDR, 2, "<0xADDR>");
+ C::copy(0xADDR, 2, "<0xADDR>");
} /* C::C */
@@ -10,7 +10,7 @@
} /* C::C */
- foo(0xADDR, 0xADDR, 0xADDR, 0.001000) {
+ foo(0xADDR, 1, 0.000000, 2) {
C::C(0xADDR, 3, "passed by value") {
- C::construct(0xADDR, 3, "passed by value");
+ C::copy(0xADDR, 3, "passed by value");
} /* C::C */
- } = 0xADDR; /* foo */
+ } /* foo */
} = 0; /* main */
203 dwarf3 : OK OK NG NG NG |
Pushed review/dwarf-argspec-v20. The dwarf3 test still fails ... Changelog:
|
In addition to auto-args (#173), it could look at the DWARF and identify information regarding argument and return value. The usage is same as auto-args using
-A
or-R
option with no explicit argspec. An explicit argspec suppresses DWARF (and auto-args) argspec. It seems DWARF only creates debug info for user-defined functions, so library calls still needs the auto-args facility.Let's look at the following example:
With DWARF support, it should work like below:
The text was updated successfully, but these errors were encountered: