~ubuntu-branches/ubuntu/utopic/libunwind/utopic-proposed

« back to all changes in this revision

Viewing changes to src/longjmp.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Delahaye
  • Date: 2005-04-22 11:12:14 UTC
  • mto: (4.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20050422111214-0m74olipxly1ra8a
Tags: upstream-0.98.5
ImportĀ upstreamĀ versionĀ 0.98.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* libunwind - a platform-independent unwind library
2
 
   Copyright (C) 2003 Hewlett-Packard Co
 
2
   Copyright (C) 2003-2004 Hewlett-Packard Co
3
3
        Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
4
4
 
5
5
This file is part of libunwind.
31
31
#include <signal.h>
32
32
#include <stdlib.h>
33
33
 
 
34
#include "jmpbuf.h"
 
35
 
34
36
#if UNW_TARGET_IA64
35
37
# include "ia64/rse.h"
36
38
#endif
38
40
void
39
41
_longjmp (jmp_buf env, int val)
40
42
{
41
 
  extern int _UI_siglongjmp_cont;
42
 
  sigset_t current_mask;
 
43
  extern int _UI_longjmp_cont;
43
44
  unw_context_t uc;
44
45
  unw_cursor_t c;
45
46
  unw_word_t sp;
52
53
    {
53
54
      if (unw_get_reg (&c, UNW_REG_SP, &sp) < 0)
54
55
        abort ();
55
 
      if (sp != wp[0])
 
56
      if (sp != wp[JB_SP])
56
57
        continue;
57
58
 
58
59
#if UNW_TARGET_IA64
67
68
        sol = (pfs >> 7) & 0x7f;
68
69
        bsp = ia64_rse_skip_regs (bsp, sol);
69
70
 
70
 
        if (bsp != wp[2])
 
71
        if (bsp != wp[JB_BSP])
71
72
          continue;
 
73
 
 
74
        if (unlikely (sol == 0))
 
75
          {
 
76
            unw_word_t prev_sp;
 
77
            unw_cursor_t tmp = c;
 
78
 
 
79
            /* The caller of {sig,}setjmp() cannot have a NULL-frame.
 
80
               If we see a NULL-frame, we haven't reached the right
 
81
               target yet.  To have a NULL-frame, the number of locals
 
82
               must be zero and the stack-frame must also be
 
83
               empty.  */
 
84
 
 
85
            if (unw_step (&tmp) < 0)
 
86
              abort ();
 
87
 
 
88
            if (unw_get_reg (&tmp, UNW_REG_SP, &prev_sp) < 0)
 
89
              abort ();
 
90
 
 
91
            if (sp == prev_sp)
 
92
              /* got a NULL-frame; keep looking... */
 
93
              continue;
 
94
          }
72
95
      }
73
96
#endif
74
97
 
75
98
      /* found the right frame: */
76
99
 
77
 
      if (sigprocmask (SIG_BLOCK, NULL, &current_mask) < 0)
78
 
        abort ();
79
 
 
80
100
      if (UNW_NUM_EH_REGS >= 4)
81
101
        {
82
 
          if (unw_set_reg (&c, UNW_REG_EH + 0, wp[1]) < 0
 
102
          if (unw_set_reg (&c, UNW_REG_EH + 0, wp[JB_RP]) < 0
83
103
              || unw_set_reg (&c, UNW_REG_EH + 1, val) < 0
84
 
              || unw_set_reg (&c, UNW_REG_EH + 2,
85
 
                              ((unw_word_t *) &current_mask)[0]) < 0
86
104
              || unw_set_reg (&c, UNW_REG_IP,
87
 
                              (unw_word_t) &_UI_siglongjmp_cont))
 
105
                              (unw_word_t) &_UI_longjmp_cont))
88
106
            abort ();
89
 
 
90
 
          if (_NSIG > 8 * sizeof (unw_word_t))
91
 
            {
92
 
              if (_NSIG > 16 * sizeof (unw_word_t))
93
 
                abort ();
94
 
              if (unw_set_reg (&c, UNW_REG_EH + 3,
95
 
                               ((unw_word_t *) &current_mask)[1]) < 0)
96
 
                abort ();
97
 
            }
98
107
        }
99
108
      else
100
109
        abort ();