Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem committed Apr 19, 2021
1 parent 51b8fed commit c857782
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
22 changes: 11 additions & 11 deletions include/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ SENTRY_EXPERIMENTAL_API sentry_value_t sentry_value_new_thread(
* The returned object needs to be attached to either an exception
* event, or a thread object.
*
* If `ips` is NULL the current stacktrace is captured, otherwise `len`
* stacktrace instruction pointers are attached to the event.
* If `ips` is NULL the current stack trace is captured, otherwise `len`
* stack trace instruction pointers are attached to the event.
*/
SENTRY_EXPERIMENTAL_API sentry_value_t sentry_value_new_stacktrace(
void **ips, size_t len);
Expand All @@ -407,15 +407,15 @@ SENTRY_EXPERIMENTAL_API sentry_value_t sentry_value_new_stacktrace(
*
* This takes ownership of the `exception`.
*/
SENTRY_EXPERIMENTAL_API void sentry_event_value_add_exception(
SENTRY_EXPERIMENTAL_API void sentry_event_add_exception(
sentry_value_t event, sentry_value_t exception);

/**
* Adds a Thread to an Event value.
*
* This takes ownership of the `thread`.
*/
SENTRY_EXPERIMENTAL_API void sentry_event_value_add_thread(
SENTRY_EXPERIMENTAL_API void sentry_event_add_thread(
sentry_value_t event, sentry_value_t thread);

/* -- Experimental APIs -- */
Expand All @@ -431,15 +431,15 @@ SENTRY_EXPERIMENTAL_API char *sentry_value_to_msgpack(
sentry_value_t value, size_t *size_out);

/**
* Adds a stacktrace to an event.
* Adds a stack trace to an event.
*
* The stacktrace is added as part of a new thread object.
* The stack trace is added as part of a new thread object.
* This function is **deprecated** in favor of using
* `sentry_value_new_stacktrace` in combination with `sentry_value_new_thread`
* and `sentry_event_value_add_thread`.
* and `sentry_event_add_thread`.
*
* If `ips` is NULL the current stacktrace is captured, otherwise `len`
* stacktrace instruction pointers are attached to the event.
* If `ips` is NULL the current stack trace is captured, otherwise `len`
* stack trace instruction pointers are attached to the event.
*/
SENTRY_EXPERIMENTAL_API void sentry_event_value_add_stacktrace(
sentry_value_t event, void **ips, size_t len);
Expand All @@ -463,7 +463,7 @@ typedef struct sentry_ucontext_s {
*
* If the address is given in `addr` the stack is unwound form there.
* Otherwise (NULL is passed) the current instruction pointer is used as
* start address. The stacktrace is written to `stacktrace_out` with up to
* start address. The stack trace is written to `stacktrace_out` with up to
* `max_len` frames being written. The actual number of unwound stackframes
* is returned.
*/
Expand All @@ -473,7 +473,7 @@ SENTRY_EXPERIMENTAL_API size_t sentry_unwind_stack(
/**
* Unwinds the stack from the given context.
*
* The stacktrace is written to `stacktrace_out` with up to `max_len` frames
* The stack trace is written to `stacktrace_out` with up to `max_len` frames
* being written. The actual number of unwound stackframes is returned.
*/
SENTRY_EXPERIMENTAL_API size_t sentry_unwind_stack_from_ucontext(
Expand Down
16 changes: 9 additions & 7 deletions src/sentry_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -1052,8 +1052,8 @@ sentry_value_new_thread(uint64_t id, const char *name)
{
sentry_value_t thread = sentry_value_new_object();

// TODO: would be nice to be able to actually use a `u64` as value.
char buf[100];
// NOTE: values end up as JSON, which has no support for `u64`.
char buf[20 + 1];
size_t written
= (size_t)snprintf(buf, sizeof(buf), "%llu", (unsigned long long)id);
if (written < sizeof(buf)) {
Expand Down Expand Up @@ -1094,7 +1094,7 @@ sentry_value_new_stacktrace(void **ips, size_t len)
}

static sentry_value_t
sentry__get_values_list(sentry_value_t parent, const char *key)
sentry__get_or_insert_values_list(sentry_value_t parent, const char *key)
{
sentry_value_t obj = sentry_value_get_by_key(parent, key);
if (sentry_value_is_null(obj)) {
Expand All @@ -1118,16 +1118,18 @@ sentry__get_values_list(sentry_value_t parent, const char *key)
}

void
sentry_event_value_add_exception(sentry_value_t event, sentry_value_t exception)
sentry_event_add_exception(sentry_value_t event, sentry_value_t exception)
{
sentry_value_t exceptions = sentry__get_values_list(event, "exception");
sentry_value_t exceptions
= sentry__get_or_insert_values_list(event, "exception");
sentry_value_append(exceptions, exception);
}

void
sentry_event_value_add_thread(sentry_value_t event, sentry_value_t thread)
sentry_event_add_thread(sentry_value_t event, sentry_value_t thread)
{
sentry_value_t threads = sentry__get_values_list(event, "threads");
sentry_value_t threads
= sentry__get_or_insert_values_list(event, "threads");
sentry_value_append(threads, thread);
}

Expand Down

0 comments on commit c857782

Please sign in to comment.