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

« back to all changes in this revision

Viewing changes to src/ia64/Gparser-ia64.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
 
/* libunwind - a platform-independent unwind library
2
 
   Copyright (C) 2001-2004 Hewlett-Packard Co
3
 
        Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
4
 
 
5
 
This file is part of libunwind.
6
 
 
7
 
Permission is hereby granted, free of charge, to any person obtaining
8
 
a copy of this software and associated documentation files (the
9
 
"Software"), to deal in the Software without restriction, including
10
 
without limitation the rights to use, copy, modify, merge, publish,
11
 
distribute, sublicense, and/or sell copies of the Software, and to
12
 
permit persons to whom the Software is furnished to do so, subject to
13
 
the following conditions:
14
 
 
15
 
The above copyright notice and this permission notice shall be
16
 
included in all copies or substantial portions of the Software.
17
 
 
18
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
 
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
 
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
 
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
 
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
 
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
 
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
25
 
 
26
 
#include <assert.h>
27
 
#include <stdio.h>
28
 
#include <stdlib.h>
29
 
#include <string.h>
30
 
 
31
 
#include "unwind_i.h"
32
 
 
33
 
/* forward declaration: */
34
 
static int create_state_record_for (struct cursor *c,
35
 
                                    struct ia64_state_record *sr,
36
 
                                    unw_word_t ip);
37
 
 
38
 
typedef unsigned long unw_word;
39
 
 
40
 
#define alloc_reg_state()       (mempool_alloc (&unw.reg_state_pool))
41
 
#define free_reg_state(rs)      (mempool_free (&unw.reg_state_pool, rs))
42
 
#define alloc_labeled_state()   (mempool_alloc (&unw.labeled_state_pool))
43
 
#define free_labeled_state(s)   (mempool_free (&unw.labeled_state_pool, s))
44
 
 
45
 
/* Routines to manipulate the state stack.  */
46
 
 
47
 
static inline void
48
 
push (struct ia64_state_record *sr)
49
 
{
50
 
  struct ia64_reg_state *rs;
51
 
 
52
 
  rs = alloc_reg_state ();
53
 
  if (!rs)
54
 
    {
55
 
      print_error ("libunwind: cannot stack reg state!\n");
56
 
      return;
57
 
    }
58
 
  memcpy (rs, &sr->curr, sizeof (*rs));
59
 
  sr->curr.next = rs;
60
 
}
61
 
 
62
 
static void
63
 
pop (struct ia64_state_record *sr)
64
 
{
65
 
  struct ia64_reg_state *rs = sr->curr.next;
66
 
 
67
 
  if (!rs)
68
 
    {
69
 
      print_error ("libunwind: stack underflow!\n");
70
 
      return;
71
 
    }
72
 
  memcpy (&sr->curr, rs, sizeof (*rs));
73
 
  free_reg_state (rs);
74
 
}
75
 
 
76
 
/* Make a copy of the state stack.  Non-recursive to avoid stack overflows.  */
77
 
static struct ia64_reg_state *
78
 
dup_state_stack (struct ia64_reg_state *rs)
79
 
{
80
 
  struct ia64_reg_state *copy, *prev = NULL, *first = NULL;
81
 
 
82
 
  while (rs)
83
 
    {
84
 
      copy = alloc_reg_state ();
85
 
      if (!copy)
86
 
        {
87
 
          print_error ("unwind.dup_state_stack: out of memory\n");
88
 
          return NULL;
89
 
        }
90
 
      memcpy (copy, rs, sizeof (*copy));
91
 
      if (first)
92
 
        prev->next = copy;
93
 
      else
94
 
        first = copy;
95
 
      rs = rs->next;
96
 
      prev = copy;
97
 
    }
98
 
  return first;
99
 
}
100
 
 
101
 
/* Free all stacked register states (but not RS itself).  */
102
 
static void
103
 
free_state_stack (struct ia64_reg_state *rs)
104
 
{
105
 
  struct ia64_reg_state *p, *next;
106
 
 
107
 
  for (p = rs->next; p != NULL; p = next)
108
 
    {
109
 
      next = p->next;
110
 
      free_reg_state (p);
111
 
    }
112
 
  rs->next = NULL;
113
 
}
114
 
 
115
 
/* Unwind decoder routines */
116
 
 
117
 
static enum ia64_pregnum __attribute__ ((const))
118
 
decode_abreg (unsigned char abreg, int memory)
119
 
{
120
 
  switch (abreg)
121
 
    {
122
 
    case 0x04 ... 0x07:
123
 
      return IA64_REG_R4 + (abreg - 0x04);
124
 
    case 0x22 ... 0x25:
125
 
      return IA64_REG_F2 + (abreg - 0x22);
126
 
    case 0x30 ... 0x3f:
127
 
      return IA64_REG_F16 + (abreg - 0x30);
128
 
    case 0x41 ... 0x45:
129
 
      return IA64_REG_B1 + (abreg - 0x41);
130
 
    case 0x60:
131
 
      return IA64_REG_PR;
132
 
    case 0x61:
133
 
      return IA64_REG_PSP;
134
 
    case 0x62:
135
 
      return memory ? IA64_REG_PRI_UNAT_MEM : IA64_REG_PRI_UNAT_GR;
136
 
    case 0x63:
137
 
      return IA64_REG_IP;
138
 
    case 0x64:
139
 
      return IA64_REG_BSP;
140
 
    case 0x65:
141
 
      return IA64_REG_BSPSTORE;
142
 
    case 0x66:
143
 
      return IA64_REG_RNAT;
144
 
    case 0x67:
145
 
      return IA64_REG_UNAT;
146
 
    case 0x68:
147
 
      return IA64_REG_FPSR;
148
 
    case 0x69:
149
 
      return IA64_REG_PFS;
150
 
    case 0x6a:
151
 
      return IA64_REG_LC;
152
 
    default:
153
 
      break;
154
 
    }
155
 
  dprintf ("libunwind: bad abreg=0x%x\n", abreg);
156
 
  return IA64_REG_LC;
157
 
}
158
 
 
159
 
static void
160
 
set_reg (struct ia64_reg_info *reg, enum ia64_where where, int when,
161
 
         unsigned long val)
162
 
{
163
 
  reg->val = val;
164
 
  reg->where = where;
165
 
  if (reg->when == IA64_WHEN_NEVER)
166
 
    reg->when = when;
167
 
}
168
 
 
169
 
static void
170
 
alloc_spill_area (unsigned long *offp, unsigned long regsize,
171
 
                  struct ia64_reg_info *lo, struct ia64_reg_info *hi)
172
 
{
173
 
  struct ia64_reg_info *reg;
174
 
 
175
 
  for (reg = hi; reg >= lo; --reg)
176
 
    {
177
 
      if (reg->where == IA64_WHERE_SPILL_HOME)
178
 
        {
179
 
          reg->where = IA64_WHERE_PSPREL;
180
 
          *offp -= regsize;
181
 
          reg->val = *offp;
182
 
        }
183
 
    }
184
 
}
185
 
 
186
 
static inline void
187
 
spill_next_when (struct ia64_reg_info **regp, struct ia64_reg_info *lim,
188
 
                 unw_word t)
189
 
{
190
 
  struct ia64_reg_info *reg;
191
 
 
192
 
  for (reg = *regp; reg <= lim; ++reg)
193
 
    {
194
 
      if (reg->where == IA64_WHERE_SPILL_HOME)
195
 
        {
196
 
          reg->when = t;
197
 
          *regp = reg + 1;
198
 
          return;
199
 
        }
200
 
    }
201
 
  dprintf ("libunwind: excess spill!\n");
202
 
}
203
 
 
204
 
static inline void
205
 
finish_prologue (struct ia64_state_record *sr)
206
 
{
207
 
  struct ia64_reg_info *reg;
208
 
  unsigned long off;
209
 
  int i;
210
 
 
211
 
  /* First, resolve implicit register save locations (see Section
212
 
     "11.4.2.3 Rules for Using Unwind Descriptors", rule 3). */
213
 
  for (i = 0; i < (int) NELEMS (unw.save_order); ++i)
214
 
    {
215
 
      reg = sr->curr.reg + unw.save_order[i];
216
 
      if (reg->where == IA64_WHERE_GR_SAVE)
217
 
        {
218
 
          reg->where = IA64_WHERE_GR;
219
 
          reg->val = sr->gr_save_loc++;
220
 
        }
221
 
    }
222
 
 
223
 
  /* Next, compute when the fp, general, and branch registers get
224
 
     saved.  This must come before alloc_spill_area() because we need
225
 
     to know which registers are spilled to their home locations.  */
226
 
 
227
 
  if (sr->imask)
228
 
    {
229
 
      unsigned char kind, mask = 0, *cp = sr->imask;
230
 
      unsigned long t;
231
 
      static const unsigned char limit[3] =
232
 
        {
233
 
          IA64_REG_F31, IA64_REG_R7, IA64_REG_B5
234
 
        };
235
 
      struct ia64_reg_info *(regs[3]);
236
 
 
237
 
      regs[0] = sr->curr.reg + IA64_REG_F2;
238
 
      regs[1] = sr->curr.reg + IA64_REG_R4;
239
 
      regs[2] = sr->curr.reg + IA64_REG_B1;
240
 
 
241
 
      for (t = 0; (int) t < sr->region_len; ++t)
242
 
        {
243
 
          if ((t & 3) == 0)
244
 
            mask = *cp++;
245
 
          kind = (mask >> 2 * (3 - (t & 3))) & 3;
246
 
          if (kind > 0)
247
 
            spill_next_when (&regs[kind - 1], sr->curr.reg + limit[kind - 1],
248
 
                             sr->region_start + t);
249
 
        }
250
 
    }
251
 
 
252
 
  /* Next, lay out the memory stack spill area.  */
253
 
 
254
 
  if (sr->any_spills)
255
 
    {
256
 
      off = sr->spill_offset;
257
 
      alloc_spill_area (&off, 16, sr->curr.reg + IA64_REG_F2,
258
 
                        sr->curr.reg + IA64_REG_F31);
259
 
      alloc_spill_area (&off, 8, sr->curr.reg + IA64_REG_B1,
260
 
                        sr->curr.reg + IA64_REG_B5);
261
 
      alloc_spill_area (&off, 8, sr->curr.reg + IA64_REG_R4,
262
 
                        sr->curr.reg + IA64_REG_R7);
263
 
    }
264
 
}
265
 
 
266
 
/* Region header descriptors.  */
267
 
 
268
 
static void
269
 
desc_prologue (int body, unw_word rlen, unsigned char mask,
270
 
               unsigned char grsave, struct ia64_state_record *sr)
271
 
{
272
 
  int i, region_start;
273
 
 
274
 
  if (!(sr->in_body || sr->first_region))
275
 
    finish_prologue (sr);
276
 
  sr->first_region = 0;
277
 
 
278
 
  /* check if we're done: */
279
 
  if (sr->when_target < sr->region_start + sr->region_len)
280
 
    {
281
 
      sr->done = 1;
282
 
      return;
283
 
    }
284
 
 
285
 
  region_start = sr->region_start + sr->region_len;
286
 
 
287
 
  for (i = 0; i < sr->epilogue_count; ++i)
288
 
    pop (sr);
289
 
  sr->epilogue_count = 0;
290
 
  sr->when_sp_restored = IA64_WHEN_NEVER;
291
 
 
292
 
  sr->region_start = region_start;
293
 
  sr->region_len = rlen;
294
 
  sr->in_body = body;
295
 
 
296
 
  if (!body)
297
 
    {
298
 
      push (sr);
299
 
 
300
 
      if (mask)
301
 
        for (i = 0; i < 4; ++i)
302
 
          {
303
 
            if (mask & 0x8)
304
 
              set_reg (sr->curr.reg + unw.save_order[i], IA64_WHERE_GR,
305
 
                       sr->region_start + sr->region_len - 1, grsave++);
306
 
            mask <<= 1;
307
 
          }
308
 
      sr->gr_save_loc = grsave;
309
 
      sr->any_spills = 0;
310
 
      sr->imask = 0;
311
 
      sr->spill_offset = 0x10;  /* default to psp+16 */
312
 
    }
313
 
}
314
 
 
315
 
/* Prologue descriptors.  */
316
 
 
317
 
static inline void
318
 
desc_abi (unsigned char abi, unsigned char context,
319
 
          struct ia64_state_record *sr)
320
 
{
321
 
  sr->abi_marker = (abi << 8) | context;
322
 
}
323
 
 
324
 
static inline void
325
 
desc_br_gr (unsigned char brmask, unsigned char gr,
326
 
            struct ia64_state_record *sr)
327
 
{
328
 
  int i;
329
 
 
330
 
  for (i = 0; i < 5; ++i)
331
 
    {
332
 
      if (brmask & 1)
333
 
        set_reg (sr->curr.reg + IA64_REG_B1 + i, IA64_WHERE_GR,
334
 
                 sr->region_start + sr->region_len - 1, gr++);
335
 
      brmask >>= 1;
336
 
    }
337
 
}
338
 
 
339
 
static inline void
340
 
desc_br_mem (unsigned char brmask, struct ia64_state_record *sr)
341
 
{
342
 
  int i;
343
 
 
344
 
  for (i = 0; i < 5; ++i)
345
 
    {
346
 
      if (brmask & 1)
347
 
        {
348
 
          set_reg (sr->curr.reg + IA64_REG_B1 + i, IA64_WHERE_SPILL_HOME,
349
 
                   sr->region_start + sr->region_len - 1, 0);
350
 
          sr->any_spills = 1;
351
 
        }
352
 
      brmask >>= 1;
353
 
    }
354
 
}
355
 
 
356
 
static inline void
357
 
desc_frgr_mem (unsigned char grmask, unw_word frmask,
358
 
               struct ia64_state_record *sr)
359
 
{
360
 
  int i;
361
 
 
362
 
  for (i = 0; i < 4; ++i)
363
 
    {
364
 
      if ((grmask & 1) != 0)
365
 
        {
366
 
          set_reg (sr->curr.reg + IA64_REG_R4 + i, IA64_WHERE_SPILL_HOME,
367
 
                   sr->region_start + sr->region_len - 1, 0);
368
 
          sr->any_spills = 1;
369
 
        }
370
 
      grmask >>= 1;
371
 
    }
372
 
  for (i = 0; i < 20; ++i)
373
 
    {
374
 
      if ((frmask & 1) != 0)
375
 
        {
376
 
          int base = (i < 4) ? IA64_REG_F2 : IA64_REG_F16 - 4;
377
 
          set_reg (sr->curr.reg + base + i, IA64_WHERE_SPILL_HOME,
378
 
                   sr->region_start + sr->region_len - 1, 0);
379
 
          sr->any_spills = 1;
380
 
        }
381
 
      frmask >>= 1;
382
 
    }
383
 
}
384
 
 
385
 
static inline void
386
 
desc_fr_mem (unsigned char frmask, struct ia64_state_record *sr)
387
 
{
388
 
  int i;
389
 
 
390
 
  for (i = 0; i < 4; ++i)
391
 
    {
392
 
      if ((frmask & 1) != 0)
393
 
        {
394
 
          set_reg (sr->curr.reg + IA64_REG_F2 + i, IA64_WHERE_SPILL_HOME,
395
 
                   sr->region_start + sr->region_len - 1, 0);
396
 
          sr->any_spills = 1;
397
 
        }
398
 
      frmask >>= 1;
399
 
    }
400
 
}
401
 
 
402
 
static inline void
403
 
desc_gr_gr (unsigned char grmask, unsigned char gr,
404
 
            struct ia64_state_record *sr)
405
 
{
406
 
  int i;
407
 
 
408
 
  for (i = 0; i < 4; ++i)
409
 
    {
410
 
      if ((grmask & 1) != 0)
411
 
        set_reg (sr->curr.reg + IA64_REG_R4 + i, IA64_WHERE_GR,
412
 
                 sr->region_start + sr->region_len - 1, gr++);
413
 
      grmask >>= 1;
414
 
    }
415
 
}
416
 
 
417
 
static inline void
418
 
desc_gr_mem (unsigned char grmask, struct ia64_state_record *sr)
419
 
{
420
 
  int i;
421
 
 
422
 
  for (i = 0; i < 4; ++i)
423
 
    {
424
 
      if ((grmask & 1) != 0)
425
 
        {
426
 
          set_reg (sr->curr.reg + IA64_REG_R4 + i, IA64_WHERE_SPILL_HOME,
427
 
                   sr->region_start + sr->region_len - 1, 0);
428
 
          sr->any_spills = 1;
429
 
        }
430
 
      grmask >>= 1;
431
 
    }
432
 
}
433
 
 
434
 
static inline void
435
 
desc_mem_stack_f (unw_word t, unw_word size, struct ia64_state_record *sr)
436
 
{
437
 
  set_reg (sr->curr.reg + IA64_REG_PSP, IA64_WHERE_NONE,
438
 
           sr->region_start + MIN ((int) t, sr->region_len - 1), 16 * size);
439
 
}
440
 
 
441
 
static inline void
442
 
desc_mem_stack_v (unw_word t, struct ia64_state_record *sr)
443
 
{
444
 
  sr->curr.reg[IA64_REG_PSP].when =
445
 
    sr->region_start + MIN ((int) t, sr->region_len - 1);
446
 
}
447
 
 
448
 
static inline void
449
 
desc_reg_gr (unsigned char reg, unsigned char dst,
450
 
             struct ia64_state_record *sr)
451
 
{
452
 
  set_reg (sr->curr.reg + reg, IA64_WHERE_GR,
453
 
           sr->region_start + sr->region_len - 1, dst);
454
 
}
455
 
 
456
 
static inline void
457
 
desc_reg_psprel (unsigned char reg, unw_word pspoff,
458
 
                 struct ia64_state_record *sr)
459
 
{
460
 
  set_reg (sr->curr.reg + reg, IA64_WHERE_PSPREL,
461
 
           sr->region_start + sr->region_len - 1, 0x10 - 4 * pspoff);
462
 
}
463
 
 
464
 
static inline void
465
 
desc_reg_sprel (unsigned char reg, unw_word spoff,
466
 
                struct ia64_state_record *sr)
467
 
{
468
 
  set_reg (sr->curr.reg + reg, IA64_WHERE_SPREL,
469
 
           sr->region_start + sr->region_len - 1, 4 * spoff);
470
 
}
471
 
 
472
 
static inline void
473
 
desc_rp_br (unsigned char dst, struct ia64_state_record *sr)
474
 
{
475
 
  sr->return_link_reg = dst;
476
 
}
477
 
 
478
 
static inline void
479
 
desc_reg_when (unsigned char regnum, unw_word t, struct ia64_state_record *sr)
480
 
{
481
 
  struct ia64_reg_info *reg = sr->curr.reg + regnum;
482
 
 
483
 
  if (reg->where == IA64_WHERE_NONE)
484
 
    reg->where = IA64_WHERE_GR_SAVE;
485
 
  reg->when = sr->region_start + MIN ((int) t, sr->region_len - 1);
486
 
}
487
 
 
488
 
static inline void
489
 
desc_spill_base (unw_word pspoff, struct ia64_state_record *sr)
490
 
{
491
 
  sr->spill_offset = 0x10 - 4 * pspoff;
492
 
}
493
 
 
494
 
static inline unsigned char *
495
 
desc_spill_mask (unsigned char *imaskp, struct ia64_state_record *sr)
496
 
{
497
 
  sr->imask = imaskp;
498
 
  return imaskp + (2 * sr->region_len + 7) / 8;
499
 
}
500
 
 
501
 
/* Body descriptors.  */
502
 
 
503
 
static inline void
504
 
desc_epilogue (unw_word t, unw_word ecount, struct ia64_state_record *sr)
505
 
{
506
 
  sr->when_sp_restored = sr->region_start + sr->region_len - 1 - t;
507
 
  sr->epilogue_count = ecount + 1;
508
 
}
509
 
 
510
 
static inline void
511
 
desc_copy_state (unw_word label, struct ia64_state_record *sr)
512
 
{
513
 
  struct ia64_labeled_state *ls;
514
 
 
515
 
  for (ls = sr->labeled_states; ls; ls = ls->next)
516
 
    {
517
 
      if (ls->label == label)
518
 
        {
519
 
          free_state_stack (&sr->curr);
520
 
          memcpy (&sr->curr, &ls->saved_state, sizeof (sr->curr));
521
 
          sr->curr.next = dup_state_stack (ls->saved_state.next);
522
 
          return;
523
 
        }
524
 
    }
525
 
  print_error ("libunwind: failed to find labeled state\n");
526
 
}
527
 
 
528
 
static inline void
529
 
desc_label_state (unw_word label, struct ia64_state_record *sr)
530
 
{
531
 
  struct ia64_labeled_state *ls;
532
 
 
533
 
  ls = alloc_labeled_state ();
534
 
  if (!ls)
535
 
    {
536
 
      print_error ("unwind.desc_label_state(): out of memory\n");
537
 
      return;
538
 
    }
539
 
  ls->label = label;
540
 
  memcpy (&ls->saved_state, &sr->curr, sizeof (ls->saved_state));
541
 
  ls->saved_state.next = dup_state_stack (sr->curr.next);
542
 
 
543
 
  /* insert into list of labeled states: */
544
 
  ls->next = sr->labeled_states;
545
 
  sr->labeled_states = ls;
546
 
}
547
 
 
548
 
/* General descriptors.  */
549
 
 
550
 
static inline int
551
 
desc_is_active (unsigned char qp, unw_word t, struct ia64_state_record *sr)
552
 
{
553
 
  if (sr->when_target <= sr->region_start + MIN ((int) t, sr->region_len - 1))
554
 
    return 0;
555
 
  if (qp > 0)
556
 
    {
557
 
      if ((sr->pr_val & ((unw_word_t) 1 << qp)) == 0)
558
 
        return 0;
559
 
      sr->pr_mask |= ((unw_word_t) 1 << qp);
560
 
    }
561
 
  return 1;
562
 
}
563
 
 
564
 
static inline void
565
 
desc_restore_p (unsigned char qp, unw_word t, unsigned char abreg,
566
 
                struct ia64_state_record *sr)
567
 
{
568
 
  struct ia64_reg_info *r;
569
 
 
570
 
  if (!desc_is_active (qp, t, sr))
571
 
    return;
572
 
 
573
 
  r = sr->curr.reg + decode_abreg (abreg, 0);
574
 
  r->where = IA64_WHERE_NONE;
575
 
  r->when = IA64_WHEN_NEVER;
576
 
  r->val = 0;
577
 
}
578
 
 
579
 
static inline void
580
 
desc_spill_reg_p (unsigned char qp, unw_word t, unsigned char abreg,
581
 
                  unsigned char x, unsigned char ytreg,
582
 
                  struct ia64_state_record *sr)
583
 
{
584
 
  enum ia64_where where = IA64_WHERE_GR;
585
 
  struct ia64_reg_info *r;
586
 
 
587
 
  if (!desc_is_active (qp, t, sr))
588
 
    return;
589
 
 
590
 
  if (x)
591
 
    where = IA64_WHERE_BR;
592
 
  else if (ytreg & 0x80)
593
 
    where = IA64_WHERE_FR;
594
 
 
595
 
  r = sr->curr.reg + decode_abreg (abreg, 0);
596
 
  r->where = where;
597
 
  r->when = sr->region_start + MIN ((int) t, sr->region_len - 1);
598
 
  r->val = (ytreg & 0x7f);
599
 
}
600
 
 
601
 
static inline void
602
 
desc_spill_psprel_p (unsigned char qp, unw_word t, unsigned char abreg,
603
 
                     unw_word pspoff, struct ia64_state_record *sr)
604
 
{
605
 
  struct ia64_reg_info *r;
606
 
 
607
 
  if (!desc_is_active (qp, t, sr))
608
 
    return;
609
 
 
610
 
  r = sr->curr.reg + decode_abreg (abreg, 1);
611
 
  r->where = IA64_WHERE_PSPREL;
612
 
  r->when = sr->region_start + MIN ((int) t, sr->region_len - 1);
613
 
  r->val = 0x10 - 4 * pspoff;
614
 
}
615
 
 
616
 
static inline void
617
 
desc_spill_sprel_p (unsigned char qp, unw_word t, unsigned char abreg,
618
 
                    unw_word spoff, struct ia64_state_record *sr)
619
 
{
620
 
  struct ia64_reg_info *r;
621
 
 
622
 
  if (!desc_is_active (qp, t, sr))
623
 
    return;
624
 
 
625
 
  r = sr->curr.reg + decode_abreg (abreg, 1);
626
 
  r->where = IA64_WHERE_SPREL;
627
 
  r->when = sr->region_start + MIN ((int) t, sr->region_len - 1);
628
 
  r->val = 4 * spoff;
629
 
}
630
 
 
631
 
#define UNW_DEC_BAD_CODE(code)                                          \
632
 
        print_error ("libunwind: unknown code encountered\n")
633
 
 
634
 
/* Register names.  */
635
 
#define UNW_REG_BSP             IA64_REG_BSP
636
 
#define UNW_REG_BSPSTORE        IA64_REG_BSPSTORE
637
 
#define UNW_REG_FPSR            IA64_REG_FPSR
638
 
#define UNW_REG_LC              IA64_REG_LC
639
 
#define UNW_REG_PFS             IA64_REG_PFS
640
 
#define UNW_REG_PR              IA64_REG_PR
641
 
#define UNW_REG_RNAT            IA64_REG_RNAT
642
 
#define UNW_REG_PSP             IA64_REG_PSP
643
 
#define UNW_REG_RP              IA64_REG_IP
644
 
#define UNW_REG_UNAT            IA64_REG_UNAT
645
 
 
646
 
/* Region headers.  */
647
 
#define UNW_DEC_PROLOGUE_GR(fmt,r,m,gr,arg)     desc_prologue(0,r,m,gr,arg)
648
 
#define UNW_DEC_PROLOGUE(fmt,b,r,arg)           desc_prologue(b,r,0,32,arg)
649
 
 
650
 
/* Prologue descriptors.  */
651
 
#define UNW_DEC_ABI(fmt,a,c,arg)                desc_abi(a,c,arg)
652
 
#define UNW_DEC_BR_GR(fmt,b,g,arg)              desc_br_gr(b,g,arg)
653
 
#define UNW_DEC_BR_MEM(fmt,b,arg)               desc_br_mem(b,arg)
654
 
#define UNW_DEC_FRGR_MEM(fmt,g,f,arg)           desc_frgr_mem(g,f,arg)
655
 
#define UNW_DEC_FR_MEM(fmt,f,arg)               desc_fr_mem(f,arg)
656
 
#define UNW_DEC_GR_GR(fmt,m,g,arg)              desc_gr_gr(m,g,arg)
657
 
#define UNW_DEC_GR_MEM(fmt,m,arg)               desc_gr_mem(m,arg)
658
 
#define UNW_DEC_MEM_STACK_F(fmt,t,s,arg)        desc_mem_stack_f(t,s,arg)
659
 
#define UNW_DEC_MEM_STACK_V(fmt,t,arg)          desc_mem_stack_v(t,arg)
660
 
#define UNW_DEC_REG_GR(fmt,r,d,arg)             desc_reg_gr(r,d,arg)
661
 
#define UNW_DEC_REG_PSPREL(fmt,r,o,arg)         desc_reg_psprel(r,o,arg)
662
 
#define UNW_DEC_REG_SPREL(fmt,r,o,arg)          desc_reg_sprel(r,o,arg)
663
 
#define UNW_DEC_REG_WHEN(fmt,r,t,arg)           desc_reg_when(r,t,arg)
664
 
#define UNW_DEC_PRIUNAT_WHEN_GR(fmt,t,arg) \
665
 
        desc_reg_when(IA64_REG_PRI_UNAT_GR,t,arg)
666
 
#define UNW_DEC_PRIUNAT_WHEN_MEM(fmt,t,arg) \
667
 
        desc_reg_when(IA64_REG_PRI_UNAT_MEM,t,arg)
668
 
#define UNW_DEC_PRIUNAT_GR(fmt,r,arg) \
669
 
        desc_reg_gr(IA64_REG_PRI_UNAT_GR,r,arg)
670
 
#define UNW_DEC_PRIUNAT_PSPREL(fmt,o,arg) \
671
 
        desc_reg_psprel(IA64_REG_PRI_UNAT_MEM,o,arg)
672
 
#define UNW_DEC_PRIUNAT_SPREL(fmt,o,arg) \
673
 
        desc_reg_sprel(IA64_REG_PRI_UNAT_MEM,o,arg)
674
 
#define UNW_DEC_RP_BR(fmt,d,arg)                desc_rp_br(d,arg)
675
 
#define UNW_DEC_SPILL_BASE(fmt,o,arg)           desc_spill_base(o,arg)
676
 
#define UNW_DEC_SPILL_MASK(fmt,m,arg)           (m = desc_spill_mask(m,arg))
677
 
 
678
 
/* Body descriptors.  */
679
 
#define UNW_DEC_EPILOGUE(fmt,t,c,arg)           desc_epilogue(t,c,arg)
680
 
#define UNW_DEC_COPY_STATE(fmt,l,arg)           desc_copy_state(l,arg)
681
 
#define UNW_DEC_LABEL_STATE(fmt,l,arg)          desc_label_state(l,arg)
682
 
 
683
 
/* General unwind descriptors.  */
684
 
#define UNW_DEC_SPILL_REG_P(f,p,t,a,x,y,arg)    desc_spill_reg_p(p,t,a,x,y,arg)
685
 
#define UNW_DEC_SPILL_REG(f,t,a,x,y,arg)        desc_spill_reg_p(0,t,a,x,y,arg)
686
 
#define UNW_DEC_SPILL_PSPREL_P(f,p,t,a,o,arg) \
687
 
        desc_spill_psprel_p(p,t,a,o,arg)
688
 
#define UNW_DEC_SPILL_PSPREL(f,t,a,o,arg) \
689
 
        desc_spill_psprel_p(0,t,a,o,arg)
690
 
#define UNW_DEC_SPILL_SPREL_P(f,p,t,a,o,arg)    desc_spill_sprel_p(p,t,a,o,arg)
691
 
#define UNW_DEC_SPILL_SPREL(f,t,a,o,arg)        desc_spill_sprel_p(0,t,a,o,arg)
692
 
#define UNW_DEC_RESTORE_P(f,p,t,a,arg)          desc_restore_p(p,t,a,arg)
693
 
#define UNW_DEC_RESTORE(f,t,a,arg)              desc_restore_p(0,t,a,arg)
694
 
 
695
 
#include "unwind_decoder.h"
696
 
 
697
 
/* parse dynamic unwind info */
698
 
 
699
 
static struct ia64_reg_info *
700
 
lookup_preg (int regnum, int memory, struct ia64_state_record *sr)
701
 
{
702
 
  int preg;
703
 
 
704
 
  switch (regnum)
705
 
    {
706
 
    case UNW_IA64_AR_BSP:               preg = IA64_REG_BSP; break;
707
 
    case UNW_IA64_AR_BSPSTORE:          preg = IA64_REG_BSPSTORE; break;
708
 
    case UNW_IA64_AR_FPSR:              preg = IA64_REG_FPSR; break;
709
 
    case UNW_IA64_AR_LC:                preg = IA64_REG_LC; break;
710
 
    case UNW_IA64_AR_PFS:               preg = IA64_REG_PFS; break;
711
 
    case UNW_IA64_AR_RNAT:              preg = IA64_REG_RNAT; break;
712
 
    case UNW_IA64_AR_UNAT:              preg = IA64_REG_UNAT; break;
713
 
    case UNW_IA64_BR + 0:               preg = IA64_REG_IP; break;
714
 
    case UNW_IA64_PR:                   preg = IA64_REG_PR; break;
715
 
    case UNW_IA64_SP:                   preg = IA64_REG_PSP; break;
716
 
 
717
 
    case UNW_IA64_NAT:
718
 
      if (memory)
719
 
        preg = IA64_REG_PRI_UNAT_MEM;
720
 
      else
721
 
        preg = IA64_REG_PRI_UNAT_GR;
722
 
      break;
723
 
 
724
 
    case UNW_IA64_GR + 4 ... UNW_IA64_GR + 7:
725
 
      preg = IA64_REG_R4 + (regnum - (UNW_IA64_GR + 4));
726
 
      break;
727
 
 
728
 
    case UNW_IA64_BR + 1 ... UNW_IA64_BR + 5:
729
 
      preg = IA64_REG_B1 + (regnum - UNW_IA64_BR);
730
 
      break;
731
 
 
732
 
    case UNW_IA64_FR + 2 ... UNW_IA64_FR + 5:
733
 
      preg = IA64_REG_F2 + (regnum - (UNW_IA64_FR + 2));
734
 
      break;
735
 
 
736
 
    case UNW_IA64_FR + 16 ... UNW_IA64_FR + 31:
737
 
      preg = IA64_REG_F16 + (regnum - (UNW_IA64_FR + 16));
738
 
      break;
739
 
 
740
 
    default:
741
 
      dprintf ("%s: invalid register number %d\n", __FUNCTION__, regnum);
742
 
      return NULL;
743
 
    }
744
 
  return sr->curr.reg + preg;
745
 
}
746
 
 
747
 
/* An alias directive inside a region of length RLEN is interpreted to
748
 
   mean that the region behaves exactly like the first RLEN
749
 
   instructions at the aliased IP.  RLEN=0 implies that the current
750
 
   state matches exactly that of the aliased IP.  */
751
 
 
752
 
static int
753
 
desc_alias (unw_dyn_op_t *op, struct cursor *c, struct ia64_state_record *sr)
754
 
{
755
 
  struct ia64_state_record orig_sr = *sr;
756
 
  int i, ret, when, rlen = sr->region_len;
757
 
  unw_word_t new_ip;
758
 
 
759
 
  when = MIN(sr->when_target, rlen - 1);
760
 
  new_ip = op->val + ((when / 3) * 16 + (when % 3));
761
 
 
762
 
  if ((ret = ia64_fetch_proc_info (c, new_ip, 1)) < 0)
763
 
    return ret;
764
 
 
765
 
  if ((ret = create_state_record_for (c, sr, new_ip)) < 0)
766
 
    return ret;
767
 
 
768
 
  sr->first_region = orig_sr.first_region;
769
 
  sr->done = 0;
770
 
  sr->any_spills |= orig_sr.any_spills;
771
 
  sr->in_body = orig_sr.in_body;
772
 
  sr->region_start = orig_sr.region_start;
773
 
  sr->region_len = orig_sr.region_len;
774
 
  if (sr->when_sp_restored != IA64_WHEN_NEVER)
775
 
    sr->when_sp_restored = op->when + MIN (orig_sr.when_sp_restored, rlen - 1);
776
 
  sr->epilogue_count = orig_sr.epilogue_count;
777
 
  sr->when_target = orig_sr.when_target;
778
 
 
779
 
  for (i = 0; i < IA64_NUM_PREGS; ++i)
780
 
    if (sr->curr.reg[i].when != IA64_WHEN_NEVER)
781
 
      sr->curr.reg[i].when = op->when + MIN (sr->curr.reg[i].when, rlen - 1);
782
 
 
783
 
  ia64_free_state_record (sr);
784
 
  sr->labeled_states = orig_sr.labeled_states;
785
 
  sr->curr.next = orig_sr.curr.next;
786
 
  return 0;
787
 
}
788
 
 
789
 
static inline int
790
 
parse_dynamic (struct cursor *c, struct ia64_state_record *sr)
791
 
{
792
 
  unw_dyn_info_t *di = c->pi.unwind_info;
793
 
  unw_dyn_proc_info_t *proc = &di->u.pi;
794
 
  unw_dyn_region_info_t *r;
795
 
  struct ia64_reg_info *ri;
796
 
  enum ia64_where where;
797
 
  int32_t when, len;
798
 
  unw_dyn_op_t *op;
799
 
  unw_word_t val;
800
 
  int memory, ret;
801
 
  int8_t qp;
802
 
 
803
 
  for (r = proc->regions; r; r = r->next)
804
 
    {
805
 
      len = r->insn_count;
806
 
      if (len < 0)
807
 
        {
808
 
          if (r->next)
809
 
            {
810
 
              Debug (1, "negative region length allowed in last region only!");
811
 
              return -UNW_EINVAL;
812
 
            }
813
 
          len = -len;
814
 
          /* hack old region info to set the start where we need it: */
815
 
          sr->region_start = (di->end_ip - di->start_ip) / 0x10 * 3 - len;
816
 
          sr->region_len = 0;
817
 
        }
818
 
      /* all regions are treated as prologue regions: */
819
 
      desc_prologue (0, len, 0, 0, sr);
820
 
 
821
 
      if (sr->done)
822
 
        return 0;
823
 
 
824
 
      for (op = r->op; op < r->op + r->op_count; ++op)
825
 
        {
826
 
          when = op->when;
827
 
          val = op->val;
828
 
          qp = op->qp;
829
 
 
830
 
          if (!desc_is_active (qp, when, sr))
831
 
            continue;
832
 
 
833
 
          when = sr->region_start + MIN ((int) when, sr->region_len - 1);
834
 
 
835
 
          switch (op->tag)
836
 
            {
837
 
            case UNW_DYN_SAVE_REG:
838
 
              memory = 0;
839
 
              if ((unsigned) (val - UNW_IA64_GR) < 128)
840
 
                where = IA64_WHERE_GR;
841
 
              else if ((unsigned) (val - UNW_IA64_FR) < 128)
842
 
                where = IA64_WHERE_FR;
843
 
              else if ((unsigned) (val - UNW_IA64_BR) < 8)
844
 
                where = IA64_WHERE_BR;
845
 
              else
846
 
                {
847
 
                  dprintf ("%s: can't save to register number %d\n",
848
 
                           __FUNCTION__, (int) op->reg);
849
 
                  return -UNW_EBADREG;
850
 
                }
851
 
              /* fall through */
852
 
            update_reg_info:
853
 
              ri = lookup_preg (op->reg, memory, sr);
854
 
              if (!ri)
855
 
                return -UNW_EBADREG;
856
 
              ri->where = where;
857
 
              ri->when = when;
858
 
              ri->val = val;
859
 
              break;
860
 
 
861
 
            case UNW_DYN_SPILL_FP_REL:
862
 
              memory = 1;
863
 
              where = IA64_WHERE_PSPREL;
864
 
              val = 0x10 - val;
865
 
              goto update_reg_info;
866
 
 
867
 
            case UNW_DYN_SPILL_SP_REL:
868
 
              memory = 1;
869
 
              where = IA64_WHERE_SPREL;
870
 
              goto update_reg_info;
871
 
 
872
 
            case UNW_DYN_ADD:
873
 
              if (op->reg == UNW_IA64_SP)
874
 
                {
875
 
                  if (val & 0xf)
876
 
                    {
877
 
                      dprintf ("%s: frame-size %ld not an integer "
878
 
                               "multiple of 16\n",
879
 
                               __FUNCTION__, (long) op->val);
880
 
                      return -UNW_EINVAL;
881
 
                    }
882
 
                  desc_mem_stack_f (when, -((int64_t) val / 16), sr);
883
 
                }
884
 
              else
885
 
                {
886
 
                  dprintf ("%s: can only ADD to stack-pointer\n",
887
 
                           __FUNCTION__);
888
 
                  return -UNW_EBADREG;
889
 
                }
890
 
              break;
891
 
 
892
 
            case UNW_DYN_POP_FRAMES:
893
 
              sr->when_sp_restored = when;
894
 
              sr->epilogue_count = op->val;
895
 
              break;
896
 
 
897
 
            case UNW_DYN_LABEL_STATE:
898
 
              desc_label_state (op->val, sr);
899
 
              break;
900
 
 
901
 
            case UNW_DYN_COPY_STATE:
902
 
              desc_copy_state (op->val, sr);
903
 
              break;
904
 
 
905
 
            case UNW_DYN_ALIAS:
906
 
              if ((ret = desc_alias (op, c, sr)) < 0)
907
 
                return ret;
908
 
 
909
 
            case UNW_DYN_STOP:
910
 
              goto end_of_ops;
911
 
            }
912
 
        }
913
 
    end_of_ops:
914
 
      ;
915
 
    }
916
 
  return 0;
917
 
}
918
 
 
919
 
 
920
 
HIDDEN int
921
 
ia64_fetch_proc_info (struct cursor *c, unw_word_t ip, int need_unwind_info)
922
 
{
923
 
  int ret, dynamic = 1;
924
 
 
925
 
  if (c->pi_valid && !need_unwind_info)
926
 
    return 0;
927
 
 
928
 
  /* check dynamic info first --- it overrides everything else */
929
 
  ret = unwi_find_dynamic_proc_info (c->as, ip, &c->pi, need_unwind_info,
930
 
                                     c->as_arg);
931
 
  if (ret == -UNW_ENOINFO)
932
 
    {
933
 
      dynamic = 0;
934
 
      ret = ia64_find_proc_info (c, ip, need_unwind_info);
935
 
    }
936
 
 
937
 
  c->pi_valid = 1;
938
 
  c->pi_is_dynamic = dynamic;
939
 
  return ret;
940
 
}
941
 
 
942
 
static inline void
943
 
put_unwind_info (struct cursor *c, unw_proc_info_t *pi)
944
 
{
945
 
  if (!c->pi_valid)
946
 
    return;
947
 
 
948
 
  if (c->pi_is_dynamic)
949
 
    unwi_put_dynamic_unwind_info (c->as, pi, c->as_arg);
950
 
  else
951
 
    ia64_put_unwind_info (c, pi);
952
 
}
953
 
 
954
 
static int
955
 
create_state_record_for (struct cursor *c, struct ia64_state_record *sr,
956
 
                         unw_word_t ip)
957
 
{
958
 
  unw_word_t predicates = c->pr;
959
 
  struct ia64_reg_info *r;
960
 
  uint8_t *dp, *desc_end;
961
 
  int ret;
962
 
 
963
 
  assert (c->pi_valid);
964
 
 
965
 
  /* build state record */
966
 
  memset (sr, 0, sizeof (*sr));
967
 
  for (r = sr->curr.reg; r < sr->curr.reg + IA64_NUM_PREGS; ++r)
968
 
    r->when = IA64_WHEN_NEVER;
969
 
  sr->pr_val = predicates;
970
 
  sr->first_region = 1;
971
 
 
972
 
  if (!c->pi.unwind_info)
973
 
    {
974
 
      /* No info, return default unwinder (leaf proc, no mem stack, no
975
 
         saved regs), rp in b0, pfs in ar.pfs.  */
976
 
      Debug (1, "no unwind info for ip=0x%lx (gp=%lx)\n",
977
 
             (long) ip, (long) c->pi.gp);
978
 
      sr->curr.reg[IA64_REG_IP].where = IA64_WHERE_BR;
979
 
      sr->curr.reg[IA64_REG_IP].when = -1;
980
 
      sr->curr.reg[IA64_REG_IP].val = 0;
981
 
      goto out;
982
 
    }
983
 
 
984
 
  sr->when_target = (3 * ((ip & ~(unw_word_t) 0xf) - c->pi.start_ip) / 16
985
 
                     + (ip & 0xf));
986
 
 
987
 
  switch (c->pi.format)
988
 
    {
989
 
    case UNW_INFO_FORMAT_TABLE:
990
 
    case UNW_INFO_FORMAT_REMOTE_TABLE:
991
 
      dp = c->pi.unwind_info;
992
 
      desc_end = dp + c->pi.unwind_info_size;
993
 
      while (!sr->done && dp < desc_end)
994
 
        dp = unw_decode (dp, sr->in_body, sr);
995
 
      ret = 0;
996
 
      break;
997
 
 
998
 
    case UNW_INFO_FORMAT_DYNAMIC:
999
 
      ret = parse_dynamic (c, sr);
1000
 
      break;
1001
 
 
1002
 
    default:
1003
 
      ret = -UNW_EINVAL;
1004
 
    }
1005
 
 
1006
 
  put_unwind_info (c, &c->pi);
1007
 
 
1008
 
  if (ret < 0)
1009
 
    return ret;
1010
 
 
1011
 
  if (sr->when_target > sr->when_sp_restored)
1012
 
    {
1013
 
      /* sp has been restored and all values on the memory stack below
1014
 
         psp also have been restored.  */
1015
 
      sr->curr.reg[IA64_REG_PSP].val = 0;
1016
 
      sr->curr.reg[IA64_REG_PSP].where = IA64_WHERE_NONE;
1017
 
      sr->curr.reg[IA64_REG_PSP].when = IA64_WHEN_NEVER;
1018
 
      for (r = sr->curr.reg; r < sr->curr.reg + IA64_NUM_PREGS; ++r)
1019
 
        if ((r->where == IA64_WHERE_PSPREL && r->val <= 0x10)
1020
 
            || r->where == IA64_WHERE_SPREL)
1021
 
          {
1022
 
            r->val = 0;
1023
 
            r->where = IA64_WHERE_NONE;
1024
 
            r->when = IA64_WHEN_NEVER;
1025
 
          }
1026
 
    }
1027
 
 
1028
 
  /* If RP did't get saved, generate entry for the return link
1029
 
     register.  */
1030
 
  if (sr->curr.reg[IA64_REG_IP].when >= sr->when_target)
1031
 
    {
1032
 
      sr->curr.reg[IA64_REG_IP].where = IA64_WHERE_BR;
1033
 
      sr->curr.reg[IA64_REG_IP].when = -1;
1034
 
      sr->curr.reg[IA64_REG_IP].val = sr->return_link_reg;
1035
 
    }
1036
 
 
1037
 
  if (sr->when_target > sr->curr.reg[IA64_REG_BSP].when
1038
 
      && sr->when_target > sr->curr.reg[IA64_REG_BSPSTORE].when
1039
 
      && sr->when_target > sr->curr.reg[IA64_REG_RNAT].when)
1040
 
    {
1041
 
      Debug (8, "func 0x%lx may switch the register-backing-store\n",
1042
 
             c->pi.start_ip);
1043
 
      c->pi.flags |= UNW_PI_FLAG_IA64_RBS_SWITCH;
1044
 
    }
1045
 
 out:
1046
 
#if UNW_DEBUG
1047
 
  if (unwi_debug_level > 0)
1048
 
    {
1049
 
      dprintf ("libunwind: state record for func 0x%lx, t=%u (flags=0x%lx):\n",
1050
 
               (long) c->pi.start_ip, sr->when_target, (long) c->pi.flags);
1051
 
      for (r = sr->curr.reg; r < sr->curr.reg + IA64_NUM_PREGS; ++r)
1052
 
        {
1053
 
          if (r->where != IA64_WHERE_NONE || r->when != IA64_WHEN_NEVER)
1054
 
            {
1055
 
              dprintf ("  %s <- ", unw.preg_name[r - sr->curr.reg]);
1056
 
              switch (r->where)
1057
 
                {
1058
 
                case IA64_WHERE_GR:
1059
 
                  dprintf ("r%lu", (long) r->val);
1060
 
                  break;
1061
 
                case IA64_WHERE_FR:
1062
 
                  dprintf ("f%lu", (long) r->val);
1063
 
                  break;
1064
 
                case IA64_WHERE_BR:
1065
 
                  dprintf ("b%lu", (long) r->val);
1066
 
                  break;
1067
 
                case IA64_WHERE_SPREL:
1068
 
                  dprintf ("[sp+0x%lx]", (long) r->val);
1069
 
                  break;
1070
 
                case IA64_WHERE_PSPREL:
1071
 
                  dprintf ("[psp+0x%lx]", (long) r->val);
1072
 
                  break;
1073
 
                case IA64_WHERE_NONE:
1074
 
                  dprintf ("%s+0x%lx",
1075
 
                           unw.preg_name[r - sr->curr.reg], (long) r->val);
1076
 
                  break;
1077
 
                default:
1078
 
                  dprintf ("BADWHERE(%d)", r->where);
1079
 
                  break;
1080
 
                }
1081
 
              dprintf ("\t\t%d\n", r->when);
1082
 
            }
1083
 
        }
1084
 
    }
1085
 
#endif
1086
 
  return 0;
1087
 
}
1088
 
 
1089
 
/* The proc-info must be valid for IP before this routine can be
1090
 
   called.  */
1091
 
HIDDEN int
1092
 
ia64_create_state_record (struct cursor *c, struct ia64_state_record *sr)
1093
 
{
1094
 
  return create_state_record_for (c, sr, c->ip);
1095
 
}
1096
 
 
1097
 
HIDDEN int
1098
 
ia64_free_state_record (struct ia64_state_record *sr)
1099
 
{
1100
 
  struct ia64_labeled_state *ls, *next;
1101
 
 
1102
 
  /* free labeled register states & stack: */
1103
 
 
1104
 
  for (ls = sr->labeled_states; ls; ls = next)
1105
 
    {
1106
 
      next = ls->next;
1107
 
      free_state_stack (&ls->saved_state);
1108
 
      free_labeled_state (ls);
1109
 
    }
1110
 
  free_state_stack (&sr->curr);
1111
 
 
1112
 
  return 0;
1113
 
}
1114
 
 
1115
 
HIDDEN int
1116
 
ia64_make_proc_info (struct cursor *c)
1117
 
{
1118
 
  if (c->as->caching_policy == UNW_CACHE_NONE
1119
 
      || ia64_get_cached_proc_info (c) < 0)
1120
 
    /* Lookup it up the slow way... */
1121
 
    return ia64_fetch_proc_info (c, c->ip, 0);
1122
 
  return 0;
1123
 
}