2004-03-15 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / frame-unwind.c
CommitLineData
494cca16
AC
1/* Definitions for frame unwinder, for GDB, the GNU debugger.
2
41fe5eb3 3 Copyright 2003, 2004 Free Software Foundation, Inc.
494cca16
AC
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22#include "defs.h"
23#include "frame.h"
24#include "frame-unwind.h"
25#include "gdb_assert.h"
26#include "dummy-frame.h"
41fe5eb3 27#include "gdb_obstack.h"
494cca16
AC
28
29static struct gdbarch_data *frame_unwind_data;
30
41fe5eb3 31struct frame_unwind_table_entry
494cca16 32{
41fe5eb3
AC
33 frame_unwind_sniffer_ftype *sniffer;
34 struct frame_unwind_table_entry *next;
494cca16
AC
35};
36
41fe5eb3 37struct frame_unwind_table
494cca16 38{
41fe5eb3
AC
39 struct frame_unwind_table_entry *head;
40 struct frame_unwind_table_entry **tail;
41};
494cca16
AC
42
43static void *
41fe5eb3 44frame_unwind_init (struct obstack *obstack)
494cca16 45{
41fe5eb3
AC
46 struct frame_unwind_table *table
47 = OBSTACK_ZALLOC (obstack, struct frame_unwind_table);
48 table->head = OBSTACK_ZALLOC (obstack, struct frame_unwind_table_entry);
49 table->head->sniffer = dummy_frame_sniffer;
50 table->tail = &table->head->next;
494cca16
AC
51 return table;
52}
53
e8a89fe2
AC
54void
55frame_unwind_append_sniffer (struct gdbarch *gdbarch,
56 frame_unwind_sniffer_ftype *sniffer)
494cca16 57{
41fe5eb3
AC
58 struct frame_unwind_table *table = gdbarch_data (gdbarch, frame_unwind_data);
59 (*table->tail) = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_unwind_table_entry);
60 (*table->tail)->sniffer = sniffer;
61 table->tail = &((*table->tail)->next);
e8a89fe2
AC
62}
63
64const struct frame_unwind *
65frame_unwind_find_by_frame (struct frame_info *next_frame)
66{
67 int i;
68 struct gdbarch *gdbarch = get_frame_arch (next_frame);
69 struct frame_unwind_table *table = gdbarch_data (gdbarch, frame_unwind_data);
41fe5eb3 70 struct frame_unwind_table_entry *entry;
e7d7bd65 71 if (!DEPRECATED_USE_GENERIC_DUMMY_FRAMES && legacy_frame_p (gdbarch))
6dc42492
AC
72 /* Seriously old code. Don't even try to use this new mechanism.
73 (Note: The variable USE_GENERIC_DUMMY_FRAMES is deprecated, not
74 the dummy frame mechanism. All architectures should be using
75 generic dummy frames). */
76 return legacy_saved_regs_unwind;
41fe5eb3 77 for (entry = table->head; entry != NULL; entry = entry->next)
494cca16 78 {
e8a89fe2 79 const struct frame_unwind *desc;
41fe5eb3 80 desc = entry->sniffer (next_frame);
494cca16
AC
81 if (desc != NULL)
82 return desc;
83 }
6dc42492 84 return legacy_saved_regs_unwind;
494cca16
AC
85}
86
b9362cc7
AC
87extern initialize_file_ftype _initialize_frame_unwind; /* -Wmissing-prototypes */
88
494cca16
AC
89void
90_initialize_frame_unwind (void)
91{
41fe5eb3 92 frame_unwind_data = gdbarch_data_register_pre_init (frame_unwind_init);
494cca16 93}
This page took 0.133632 seconds and 4 git commands to generate.