-
Notifications
You must be signed in to change notification settings - Fork 13
[crashtracking] Little improvements to the FFI api #842
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
[crashtracking] Little improvements to the FFI api #842
Conversation
95c725e
to
a21b4c8
Compare
BenchmarksComparisonBenchmark execution time: 2025-02-06 08:53:32 Comparing candidate commit 1987c10 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 52 metrics, 2 unstable metrics. CandidateCandidate benchmark detailsGroup 1
Group 2
Group 3
Group 4
Group 5
Group 6
Group 7
Group 8
Group 9
Group 10
Group 11
Group 12
Group 13
BaselineOmitted due to size. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #842 +/- ##
==========================================
- Coverage 71.48% 71.45% -0.03%
==========================================
Files 320 319 -1
Lines 47115 47124 +9
==========================================
- Hits 33680 33674 -6
- Misses 13435 13450 +15
|
a21b4c8
to
6d17ec9
Compare
8e1814b
to
202ffdc
Compare
06e271c
to
92216f0
Compare
) -> VoidResult { | ||
wrap_with_void_ffi_result!({ | ||
if thread.crashed { | ||
let stack = (thread.stack.to_inner_mut())?.clone(); | ||
builder.to_inner_mut()?.with_stack(stack)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if ddog_crasht_CrashInfoBuilder_with_stack
shouldn't be removed ? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is only one executing thread, does it make sense to have it twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you're the main user of this API, so do what makes sense to you!
) -> VoidResult { | ||
wrap_with_void_ffi_result!({ | ||
if thread.crashed { | ||
let stack = (thread.stack.to_inner_mut())?.clone(); | ||
builder.to_inner_mut()?.with_stack(stack)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is only one executing thread, does it make sense to have it twice?
) -> VoidResult { | ||
wrap_with_void_ffi_result!({ | ||
if thread.crashed { | ||
let stack = (thread.stack.to_inner_mut())?.clone(); | ||
builder.to_inner_mut()?.with_stack(stack)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you're the main user of this API, so do what makes sense to you!
e604600
to
82cd9e1
Compare
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// FFI API // | ||
//////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
||
#[allow(dead_code)] | ||
#[repr(C)] | ||
pub enum StackTraceNewResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use ddcommon_ffi::Result
e.g. ddcommon_ffi::Result<Handle<StackTrace>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I use ddcommon_ffi::Result<Handle<StackFrame>>
instead of StackFrameNewResult
The enum item name is
DDOG_CRASHT_STACK_FRAME_NEW_RESULT_OK_HANDLE_STACK_FRAME
(with renaming)
or
DDOG_CRASHT_RESULT_HANDLE_FRAME_OK_HANDLE_STACK_FRAME
If I use the new enum StackFrameNewResult
, I got this
DDOG_CRASHT_STACK_FRAME_NEW_RESULT_OK
which is shorter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you know a way to prevent a new enum to have shorter name, I'll be happy :)
82cd9e1
to
5d0dbee
Compare
a2a6b6f
to
e14a873
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a few more minor comments
ddcommon-ffi/src/string.rs
Outdated
|
||
impl ToHexStr for usize { | ||
fn to_hex_str(&self) -> String { | ||
format!("0x{:X}", self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want this to be fixed length? i.e. should 2
be 0x2
or 0x0000000000000002
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷
the specification says that it's a hexadecimal string prefixed with 0x
but nothing about the length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that either is standards compliant. Its just aesthetically, which do we prefer?
6678fa3
to
cbbb00a
Compare
cbbb00a
to
1987c10
Compare
What does this PR do?
This PR tries to improve a bit the crashtracker ffi APIs.
Motivation
The goal is to simplify the crashtracker ffi API and adding code in the
crashinfo.cpp
example.Implementation
usize
(expecting it to be 64bit on x86_64, and 32bit on x86 architecture) and build a0x
-prefixed string from it.ddog_crasht_CrashInfoBuilder_with_stack
adds the callstack of the crashing threads but only the callstack.If we want to add the crashing thread (
ThreadData
), we have to duplicate the callstack and make one calls toddog_crasht_CrashInfoBuilder_with_stack
andddog_crasht_CrashInfoBuilder_with_thread
.Instead, we check the
crashed
field, and call intowith_stack
to add a duplicate of the callstack thread (if it's true) and call intowith_thread
with the thread dataMaybe we could remove the
ddog_crasht_CrashInfoBuilder_with_stack
?XXXNewResult
types to have shorter symbols for the generated code.Additional Notes
Anything else we should know when reviewing?
How to test the change?
Describe here in detail how the change can be validated.