~kdsch/uc

bc97631806f28b059fe34f7aa8676f9a955225ab — Karl Schultheisz 2 years ago fde1775
tracer: call unw_strerror correctly

libunwind confusingly returns the _negative_ of the error codes
it defines, presumably on the assumption that a nonnegative error
code implies success. But the unw_strerror function expects the
inverted values, so the caller doesn't have to invert them.
1 files changed, 3 insertions(+), 3 deletions(-)

M tracer.c
M tracer.c => tracer.c +3 -3
@@ 118,7 118,7 @@ wait:
	int err = unw_init_remote(&t->cur, t->as, t->ctx);  // 2

	if (err < 0) {
		printf("DEBUG (%s:%d) unw_init_remote %s\n", __FILE__, __LINE__, unw_strerror(-err));
		printf("DEBUG (%s:%d) unw_init_remote %s\n", __FILE__, __LINE__, unw_strerror(err));
		return TRACER_ERR;
	}



@@ 132,7 132,7 @@ tracer_step(void *data, struct frame *f)
	int err = unw_get_reg(&t->cur, UNW_REG_IP, &f->ip); // 3

	if (err < 0) {
		printf("DEBUG (%s:%d) unw_get_reg %s\n", __FILE__, __LINE__, unw_strerror(-err));
		printf("DEBUG (%s:%d) unw_get_reg %s\n", __FILE__, __LINE__, unw_strerror(err));
		return TRACE_ERR;
	}



@@ 145,7 145,7 @@ tracer_step(void *data, struct frame *f)
		return TRACE_DONE;
	}

	printf("DEBUG (%s:%d) unw_step %s\n", __FILE__, __LINE__, unw_strerror(-err));
	printf("DEBUG (%s:%d) unw_step %s\n", __FILE__, __LINE__, unw_strerror(err));
	return TRACE_ERR;
}