Skip to content

Commit

Permalink
fix(austinp): fix sample output
Browse files Browse the repository at this point in the history
  • Loading branch information
P403n1x87 committed Sep 9, 2021
1 parent 93c6d38 commit 86e12ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/py_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,7 @@ py_proc__sample(py_proc_t * self) {

#ifdef NATIVE
_py_proc__interrupt_threads(self, &raddr);
time_delta = gettime() - self->timestamp;
#endif

if (fail(py_thread__fill_from_raddr(&py_thread, &raddr, self))) {
Expand All @@ -1184,9 +1185,6 @@ py_proc__sample(py_proc_t * self) {
current_thread = _py_proc__get_current_thread_state_raddr(self);
}

#ifdef NATIVE
time_delta = gettime() - self->timestamp;
#endif
do {
if (pargs.memory) {
mem_delta = 0;
Expand Down
15 changes: 7 additions & 8 deletions src/py_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ py_thread__save_kernel_stack(py_thread_t * self) {
FAIL;
}

log_d("kstacks: %p", _kstacks);
sfree(_kstacks[self->tid]);

sprintf(stack_path, "/proc/%d/task/%ld/stack", self->proc->pid, self->tid);
Expand Down Expand Up @@ -461,7 +460,8 @@ _py_thread__unwind_native_frame_stack(py_thread_t * self) {
void *context = _tids[self->tid];
unw_cursor_t cursor;

while (unw_init_remote(&cursor, self->proc->unwind.as, context));
if (unw_init_remote(&cursor, self->proc->unwind.as, context))
FAIL;

do {
unw_word_t offset, pc;
Expand Down Expand Up @@ -643,10 +643,6 @@ py_thread__print_collapsed_stack(py_thread_t * self, ctime_t time_delta, ssize_t
}
}

// Group entries by thread.
fprintf(pargs.output_file, SAMPLE_HEAD, self->proc->pid, self->tid);


#ifdef NATIVE
_stackp = 0;

Expand All @@ -655,17 +651,20 @@ py_thread__print_collapsed_stack(py_thread_t * self, ctime_t time_delta, ssize_t
// The downside is that the kernel stack might not be in sync with the other
// ones.
if (pargs.kernel) {
log_t("unwinding kernel stack");
_py_thread__unwind_kernel_frame_stack(self);
}
_py_thread__unwind_native_frame_stack(self);
if (fail(_py_thread__unwind_native_frame_stack(self)))
return;

size_t basep = _stackp;
// Update the thread state to improve guarantees that it will be in sync with
// the native stack just collected
py_thread__fill_from_raddr(self, &self->raddr, self->proc);
#endif

// Group entries by thread.
fprintf(pargs.output_file, SAMPLE_HEAD, self->proc->pid, self->tid);

if (self->stack_height) {
_py_thread__unwind_frame_stack(self);

Expand Down

0 comments on commit 86e12ee

Please sign in to comment.