mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-11-25 16:47:38 +01:00
Include <libunwind-ia64.h> instead of <libunwind.h> (this program is slightly
ia64-specific). (sighandler): Rename rp to ip. (doit): Declare argument as volatile pointer. (Logical change 1.18)
This commit is contained in:
parent
934d3b52b0
commit
e324c4c115
1 changed files with 13 additions and 11 deletions
24
tests/sig.c
24
tests/sig.c
|
@ -20,7 +20,7 @@ GNU General Public License for more details. */
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <unwind.h>
|
#include <libunwind-ia64.h>
|
||||||
|
|
||||||
#define panic(args...) \
|
#define panic(args...) \
|
||||||
{ fprintf (stderr, args); exit (-1); }
|
{ fprintf (stderr, args); exit (-1); }
|
||||||
|
@ -29,14 +29,13 @@ static void
|
||||||
sighandler (int signal)
|
sighandler (int signal)
|
||||||
{
|
{
|
||||||
unw_cursor_t cursor, cursor2;
|
unw_cursor_t cursor, cursor2;
|
||||||
unw_word_t rp;
|
unw_word_t ip;
|
||||||
unw_context_t uc;
|
unw_context_t uc;
|
||||||
|
|
||||||
printf ("caught signal %d\n", signal);
|
printf ("caught signal %d\n", signal);
|
||||||
|
|
||||||
unw_getcontext(&uc);
|
unw_getcontext (&uc);
|
||||||
|
if (unw_init_local (&cursor, &uc) < 0)
|
||||||
if (unw_init (&cursor, &uc) < 0)
|
|
||||||
panic ("unw_init() failed!\n");
|
panic ("unw_init() failed!\n");
|
||||||
|
|
||||||
/* get cursor for caller of sighandler: */
|
/* get cursor for caller of sighandler: */
|
||||||
|
@ -48,15 +47,18 @@ sighandler (int signal)
|
||||||
if (unw_step (&cursor2) < 0)
|
if (unw_step (&cursor2) < 0)
|
||||||
panic ("failed to find signal frame!\n");
|
panic ("failed to find signal frame!\n");
|
||||||
|
|
||||||
if (unw_get_reg (&cursor2, UNW_REG_RP, &rp) < 0)
|
if (unw_step (&cursor2) < 0)
|
||||||
|
panic ("unw_step() failed!\n");
|
||||||
|
|
||||||
|
if (unw_get_reg (&cursor2, UNW_REG_IP, &ip) < 0)
|
||||||
panic ("failed to get IP!\n");
|
panic ("failed to get IP!\n");
|
||||||
|
|
||||||
/* skip faulting instruction (doesn't handle MLX template) */
|
/* skip faulting instruction (doesn't handle MLX template) */
|
||||||
++rp;
|
++ip;
|
||||||
if (rp & 0x3 == 0x3)
|
if (ip & 0x3 == 0x3)
|
||||||
rp += 13;
|
ip += 13;
|
||||||
|
|
||||||
if (unw_set_reg (&cursor2, UNW_REG_RP, rp) < 0)
|
if (unw_set_reg (&cursor2, UNW_REG_IP, ip) < 0)
|
||||||
panic ("failed to set IP!\n");
|
panic ("failed to set IP!\n");
|
||||||
|
|
||||||
unw_resume (&cursor); /* update context & return to caller of sighandler() */
|
unw_resume (&cursor); /* update context & return to caller of sighandler() */
|
||||||
|
@ -65,7 +67,7 @@ sighandler (int signal)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
doit (char *p)
|
doit (volatile char *p)
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue