GDB (xrefs)
Loading...
Searching...
No Matches
ada-imported.c
Go to the documentation of this file.
1/* Ada Pragma Import support.
2
3 Copyright (C) 2023 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>. */
19
20#include "defs.h"
21#include "symtab.h"
22#include "value.h"
23#include "dwarf2/loc.h"
24
25/* Helper to get the imported symbol's real name. */
26static const char *
27get_imported_name (const struct symbol *sym)
28{
29 return (const char *) SYMBOL_LOCATION_BATON (sym);
30}
31
32/* Implement the read_variable method from symbol_computed_ops. */
33
34static struct value *
36{
37 const char *name = get_imported_name (symbol);
39 if (minsym.minsym == nullptr)
40 error (_("could not find imported name %s"), name);
41 return value_at (symbol->type (), minsym.value_address ());
42}
43
44/* Implement the read_variable method from symbol_computed_ops. */
45
46static enum symbol_needs_kind
51
52/* Implement the describe_location method from
53 symbol_computed_ops. */
54
55static void
57 struct ui_file *stream)
58{
59 gdb_printf (stream, "an imported name for '%s'",
61}
62
63/* Implement the tracepoint_var_ref method from
64 symbol_computed_ops. */
65
66static void
68 struct axs_value *value)
69{
70 /* Probably could be done, but not needed right now. */
71 error (_("not implemented: trace of imported Ada symbol"));
72}
73
74/* Implement the generate_c_location method from
75 symbol_computed_ops. */
76
77static void
79 struct gdbarch *gdbarch,
80 std::vector<bool> &registers_used,
81 CORE_ADDR pc, const char *result_name)
82{
83 /* Probably could be done, but not needed right now, and perhaps not
84 ever. */
85 error (_("not implemented: compile translation of imported Ada symbol"));
86}
87
98
99/* Implement the get_block_value method from symbol_block_ops. */
100
101static const block *
103{
104 const char *name = get_imported_name (sym);
105 block_symbol real_symbol = lookup_global_symbol (name, nullptr,
106 VAR_DOMAIN);
107 if (real_symbol.symbol == nullptr)
108 error (_("could not find alias '%s' for function '%s'"),
109 name, sym->print_name ());
110 if (real_symbol.symbol->aclass () != LOC_BLOCK)
111 error (_("alias '%s' for function '%s' is not a function"),
112 name, sym->print_name ());
113
114 return real_symbol.symbol->value_block ();
115}
116
118{
119 nullptr,
120 nullptr,
122};
const char *const name
static void ada_imported_describe_location(struct symbol *symbol, CORE_ADDR addr, struct ui_file *stream)
static const block * ada_alias_get_block_value(const struct symbol *sym)
static enum symbol_needs_kind ada_imported_get_symbol_read_needs(struct symbol *symbol)
const struct symbol_block_ops ada_function_alias_funcs
static void ada_imported_generate_c_location(struct symbol *symbol, string_file *stream, struct gdbarch *gdbarch, std::vector< bool > &registers_used, CORE_ADDR pc, const char *result_name)
static void ada_imported_tracepoint_var_ref(struct symbol *symbol, struct agent_expr *ax, struct axs_value *value)
static const char * get_imported_name(const struct symbol *sym)
static struct value * ada_imported_read_variable(struct symbol *symbol, frame_info_ptr frame)
const struct symbol_computed_ops ada_imported_funcs
symbol_needs_kind
Definition defs.h:448
@ SYMBOL_NEEDS_NONE
Definition defs.h:450
bound_minimal_symbol lookup_minimal_symbol_linkage(const char *name, struct objfile *objf)
Definition minsyms.c:573
struct symbol * symbol
Definition symtab.h:1533
Definition block.h:109
CORE_ADDR value_address() const
Definition minsyms.h:41
struct minimal_symbol * minsym
Definition minsyms.h:49
const char * print_name() const
Definition symtab.h:475
const block * value_block() const
Definition symtab.h:1549
address_class aclass() const
Definition symtab.h:1274
struct type * type() const
Definition symtab.h:1331
Definition value.h:130
struct block_symbol lookup_global_symbol(const char *name, const struct block *block, const domain_enum domain)
Definition symtab.c:2613
@ LOC_BLOCK
Definition symtab.h:1028
@ VAR_DOMAIN
Definition symtab.h:910
#define SYMBOL_LOCATION_BATON(symbol)
Definition symtab.h:1546
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition utils.c:1886
struct value * value_at(struct type *type, CORE_ADDR addr)
Definition valops.c:1015