Skip to content

Instantly share code, notes, and snippets.

@benesch
Last active October 18, 2020 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benesch/2b2b4ffb76019d7a2cda6c6002bb2aa0 to your computer and use it in GitHub Desktop.
Save benesch/2b2b4ffb76019d7a2cda6c6002bb2aa0 to your computer and use it in GitHub Desktop.
#include <signal.h>
#include <execinfo.h>
#include <stdio.h>
#include <stddef.h>
static void
handler(int s)
{
printf("x %d\n", s);
void *array[10];
size_t size = backtrace (array, 10);
printf ("Backtrace %zd stack frames.\n", size);
backtrace_symbols_fd (array, size, 2);
}
__attribute__ ((noinline))
int
run(void) {
for (;;)
continue;
}
int
main(int argc, char **argv)
{
signal(SIGINT, handler);
run();
return 0;
}
===================================================================
RCS file: /cvsroot/src/lib/libc/arch/x86_64/sys/__sigtramp2.S,v
retrieving revision 1.8
diff -u -r1.8 __sigtramp2.S
--- arch/x86_64/sys/__sigtramp2.S 12 Oct 2020 17:55:54 -0000 1.8
+++ arch/x86_64/sys/__sigtramp2.S 18 Oct 2020 15:51:51 -0000
@@ -58,7 +58,7 @@
.cfi_offset rsi, UC_GREGS_RSI
.cfi_offset rdi, UC_GREGS_RDI
.cfi_offset rbp, UC_GREGS_RBP
- /* The unwinder will use the CFA to restore RSP. */
+ .cfi_offset rsp, UC_GREGS_RSP
.cfi_offset r8, UC_GREGS_R8
.cfi_offset r9, UC_GREGS_R9
.cfi_offset r10, UC_GREGS_R10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment