Correct unwinding stop condition

On successful completion, `unw_step()` returns a positive value
  if the updated cursor refers to a valid stack frame,
  or `0` if the previous stack frame was the last frame in the
  chain. On error, the negative value of one of the error-codes
  below is returned.

PiperOrigin-RevId: 491588164
Change-Id: Ie361023ef69eed6c895856832a8208f2791f644d
This commit is contained in:
Wiktor Garbacz 2022-11-29 03:23:59 -08:00 committed by Copybara-Service
parent 92a8247777
commit 755f29b35e

View File

@ -86,12 +86,7 @@ absl::StatusOr<std::vector<uintptr_t>> RunLibUnwind(pid_t pid, int max_frames) {
break; break;
} }
ips.push_back(ip); ips.push_back(ip);
rc = unw_step(&cursor); if (unw_step(&cursor) <= 0) {
// Non-error condition: UNW_ESUCCESS (0).
if (rc < 0) {
// If anything but UNW_ESTOPUNWIND (-5), there has been an error.
// However since we can't do anything about it and it appears that
// this happens every time we don't log this.
break; break;
} }
} }