2005-07-12 21:06:54 +08:00
|
|
|
/* DWARF 2 location expression support for GDB.
|
|
|
|
|
2011-01-01 23:34:07 +08:00
|
|
|
Copyright (C) 2003, 2005, 2007, 2008, 2009, 2010, 2011
|
2010-01-01 15:32:07 +08:00
|
|
|
Free Software Foundation, Inc.
|
Based on a patch from Daniel Berlin (dberlin@dberlin.org).
* symtab.h: Add opaque declarations of struct axs_value and
struct agent_expr.
(enum address_class): Add LOC_COMPUTED and LOC_COMPUTED_ARG.
(struct location_funcs): New type.
(struct symbol): Add "loc" to aux_value.
(SYMBOL_LOCATION_BATON, SYMBOL_LOCATION_FUNCS): New macros.
* dwarf2read.c: Include "dwarf2expr.h".
(dwarf2_symbol_mark_computed): New function.
(read_func_scope): Use it.
(var_decode_location): New function.
(new_symbol): Use it.
* dwarf2expr.c, dwarf2expr.h, dwarf2loc.c, dwarf2loc.h: New files.
* Makefile.in (SFILES): Add dwarf2loc.c and dwarf2expr.c.
(dwarf2expr_h, dwarf2loc_h): New variables.
(COMMON_OBS): Add dwarf2expr.o and dwarf2loc.o.
(dwarf2expr.o, dwarf2loc.o): New rules.
(dwarf2read.o): Add $(dwarf2expr_h) and $(dwarf2loc_h).
* buildsym.c (finish_block): Handle LOC_COMPUTED and
LOC_COMPUTED_ARG.
* findvar.c (symbol_read_needs_frame, read_var_value): Likewise.
* m2-exp.y (yylex): Likewise.
* printcmd.c (address_info, print_frame_args): Likewise.
* stack.c (print_block_frame_locals, print_frame_arg_vars): Likewise.
* symmisc.c (print_symbol, print_partial_symbols): Likewise.
* ada-lang.c (ada_resolve_subexp, symtab_for_sym)
(ada_add_block_symbols, fill_in_ada_prototype): Likewise.
* symtab.c (lookup_block_symbol): Likewise.
2003-02-21 23:24:18 +08:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-24 02:08:50 +08:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
Based on a patch from Daniel Berlin (dberlin@dberlin.org).
* symtab.h: Add opaque declarations of struct axs_value and
struct agent_expr.
(enum address_class): Add LOC_COMPUTED and LOC_COMPUTED_ARG.
(struct location_funcs): New type.
(struct symbol): Add "loc" to aux_value.
(SYMBOL_LOCATION_BATON, SYMBOL_LOCATION_FUNCS): New macros.
* dwarf2read.c: Include "dwarf2expr.h".
(dwarf2_symbol_mark_computed): New function.
(read_func_scope): Use it.
(var_decode_location): New function.
(new_symbol): Use it.
* dwarf2expr.c, dwarf2expr.h, dwarf2loc.c, dwarf2loc.h: New files.
* Makefile.in (SFILES): Add dwarf2loc.c and dwarf2expr.c.
(dwarf2expr_h, dwarf2loc_h): New variables.
(COMMON_OBS): Add dwarf2expr.o and dwarf2loc.o.
(dwarf2expr.o, dwarf2loc.o): New rules.
(dwarf2read.o): Add $(dwarf2expr_h) and $(dwarf2loc_h).
* buildsym.c (finish_block): Handle LOC_COMPUTED and
LOC_COMPUTED_ARG.
* findvar.c (symbol_read_needs_frame, read_var_value): Likewise.
* m2-exp.y (yylex): Likewise.
* printcmd.c (address_info, print_frame_args): Likewise.
* stack.c (print_block_frame_locals, print_frame_arg_vars): Likewise.
* symmisc.c (print_symbol, print_partial_symbols): Likewise.
* ada-lang.c (ada_resolve_subexp, symtab_for_sym)
(ada_add_block_symbols, fill_in_ada_prototype): Likewise.
* symtab.c (lookup_block_symbol): Likewise.
2003-02-21 23:24:18 +08:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-24 02:08:50 +08:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
Based on a patch from Daniel Berlin (dberlin@dberlin.org).
* symtab.h: Add opaque declarations of struct axs_value and
struct agent_expr.
(enum address_class): Add LOC_COMPUTED and LOC_COMPUTED_ARG.
(struct location_funcs): New type.
(struct symbol): Add "loc" to aux_value.
(SYMBOL_LOCATION_BATON, SYMBOL_LOCATION_FUNCS): New macros.
* dwarf2read.c: Include "dwarf2expr.h".
(dwarf2_symbol_mark_computed): New function.
(read_func_scope): Use it.
(var_decode_location): New function.
(new_symbol): Use it.
* dwarf2expr.c, dwarf2expr.h, dwarf2loc.c, dwarf2loc.h: New files.
* Makefile.in (SFILES): Add dwarf2loc.c and dwarf2expr.c.
(dwarf2expr_h, dwarf2loc_h): New variables.
(COMMON_OBS): Add dwarf2expr.o and dwarf2loc.o.
(dwarf2expr.o, dwarf2loc.o): New rules.
(dwarf2read.o): Add $(dwarf2expr_h) and $(dwarf2loc_h).
* buildsym.c (finish_block): Handle LOC_COMPUTED and
LOC_COMPUTED_ARG.
* findvar.c (symbol_read_needs_frame, read_var_value): Likewise.
* m2-exp.y (yylex): Likewise.
* printcmd.c (address_info, print_frame_args): Likewise.
* stack.c (print_block_frame_locals, print_frame_arg_vars): Likewise.
* symmisc.c (print_symbol, print_partial_symbols): Likewise.
* ada-lang.c (ada_resolve_subexp, symtab_for_sym)
(ada_add_block_symbols, fill_in_ada_prototype): Likewise.
* symtab.c (lookup_block_symbol): Likewise.
2003-02-21 23:24:18 +08:00
|
|
|
|
|
|
|
#if !defined (DWARF2LOC_H)
|
|
|
|
#define DWARF2LOC_H
|
|
|
|
|
2009-06-04 20:28:39 +08:00
|
|
|
struct symbol_computed_ops;
|
2008-03-19 03:40:47 +08:00
|
|
|
struct objfile;
|
|
|
|
struct dwarf2_per_cu_data;
|
2010-11-30 05:18:16 +08:00
|
|
|
struct dwarf2_loclist_baton;
|
2011-02-18 00:20:44 +08:00
|
|
|
struct agent_expr;
|
|
|
|
struct axs_value;
|
2004-01-27 04:36:32 +08:00
|
|
|
|
Based on a patch from Daniel Berlin (dberlin@dberlin.org).
* symtab.h: Add opaque declarations of struct axs_value and
struct agent_expr.
(enum address_class): Add LOC_COMPUTED and LOC_COMPUTED_ARG.
(struct location_funcs): New type.
(struct symbol): Add "loc" to aux_value.
(SYMBOL_LOCATION_BATON, SYMBOL_LOCATION_FUNCS): New macros.
* dwarf2read.c: Include "dwarf2expr.h".
(dwarf2_symbol_mark_computed): New function.
(read_func_scope): Use it.
(var_decode_location): New function.
(new_symbol): Use it.
* dwarf2expr.c, dwarf2expr.h, dwarf2loc.c, dwarf2loc.h: New files.
* Makefile.in (SFILES): Add dwarf2loc.c and dwarf2expr.c.
(dwarf2expr_h, dwarf2loc_h): New variables.
(COMMON_OBS): Add dwarf2expr.o and dwarf2loc.o.
(dwarf2expr.o, dwarf2loc.o): New rules.
(dwarf2read.o): Add $(dwarf2expr_h) and $(dwarf2loc_h).
* buildsym.c (finish_block): Handle LOC_COMPUTED and
LOC_COMPUTED_ARG.
* findvar.c (symbol_read_needs_frame, read_var_value): Likewise.
* m2-exp.y (yylex): Likewise.
* printcmd.c (address_info, print_frame_args): Likewise.
* stack.c (print_block_frame_locals, print_frame_arg_vars): Likewise.
* symmisc.c (print_symbol, print_partial_symbols): Likewise.
* ada-lang.c (ada_resolve_subexp, symtab_for_sym)
(ada_add_block_symbols, fill_in_ada_prototype): Likewise.
* symtab.c (lookup_block_symbol): Likewise.
2003-02-21 23:24:18 +08:00
|
|
|
/* This header is private to the DWARF-2 reader. It is shared between
|
|
|
|
dwarf2read.c and dwarf2loc.c. */
|
|
|
|
|
2010-07-13 23:09:03 +08:00
|
|
|
/* Return the OBJFILE associated with the compilation unit CU. If CU
|
|
|
|
came from a separate debuginfo file, then the master objfile is
|
|
|
|
returned. */
|
2008-03-19 03:40:47 +08:00
|
|
|
struct objfile *dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *cu);
|
|
|
|
|
|
|
|
/* Return the address size given in the compilation unit header for CU. */
|
|
|
|
CORE_ADDR dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *cu);
|
|
|
|
|
2010-06-03 03:37:56 +08:00
|
|
|
/* Return the offset size given in the compilation unit header for CU. */
|
|
|
|
int dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *cu);
|
|
|
|
|
2010-07-13 23:09:03 +08:00
|
|
|
/* Return the text offset of the CU. The returned offset comes from
|
|
|
|
this CU's objfile. If this objfile came from a separate debuginfo
|
|
|
|
file, then the offset may be different from the corresponding
|
|
|
|
offset in the parent objfile. */
|
|
|
|
CORE_ADDR dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *cu);
|
|
|
|
|
2010-11-30 05:18:16 +08:00
|
|
|
/* Find a particular location expression from a location list. */
|
|
|
|
const gdb_byte *dwarf2_find_location_expression
|
|
|
|
(struct dwarf2_loclist_baton *baton,
|
|
|
|
size_t *locexpr_length,
|
|
|
|
CORE_ADDR pc);
|
|
|
|
|
2010-06-08 03:55:33 +08:00
|
|
|
struct dwarf2_locexpr_baton dwarf2_fetch_die_location_block
|
2010-11-30 05:18:16 +08:00
|
|
|
(unsigned int offset, struct dwarf2_per_cu_data *per_cu,
|
|
|
|
CORE_ADDR (*get_frame_pc) (void *baton),
|
|
|
|
void *baton);
|
2010-06-08 03:55:33 +08:00
|
|
|
|
2010-08-13 03:55:38 +08:00
|
|
|
/* Evaluate a location description, starting at DATA and with length
|
|
|
|
SIZE, to find the current location of variable of TYPE in the context
|
|
|
|
of FRAME. */
|
|
|
|
|
|
|
|
struct value *dwarf2_evaluate_loc_desc (struct type *type,
|
|
|
|
struct frame_info *frame,
|
|
|
|
const gdb_byte *data,
|
|
|
|
unsigned short size,
|
|
|
|
struct dwarf2_per_cu_data *per_cu);
|
|
|
|
|
2003-04-13 23:43:35 +08:00
|
|
|
/* The symbol location baton types used by the DWARF-2 reader (i.e.
|
|
|
|
SYMBOL_LOCATION_BATON for a LOC_COMPUTED symbol). "struct
|
|
|
|
dwarf2_locexpr_baton" is for a symbol with a single location
|
|
|
|
expression; "struct dwarf2_loclist_baton" is for a symbol with a
|
|
|
|
location list. */
|
Based on a patch from Daniel Berlin (dberlin@dberlin.org).
* symtab.h: Add opaque declarations of struct axs_value and
struct agent_expr.
(enum address_class): Add LOC_COMPUTED and LOC_COMPUTED_ARG.
(struct location_funcs): New type.
(struct symbol): Add "loc" to aux_value.
(SYMBOL_LOCATION_BATON, SYMBOL_LOCATION_FUNCS): New macros.
* dwarf2read.c: Include "dwarf2expr.h".
(dwarf2_symbol_mark_computed): New function.
(read_func_scope): Use it.
(var_decode_location): New function.
(new_symbol): Use it.
* dwarf2expr.c, dwarf2expr.h, dwarf2loc.c, dwarf2loc.h: New files.
* Makefile.in (SFILES): Add dwarf2loc.c and dwarf2expr.c.
(dwarf2expr_h, dwarf2loc_h): New variables.
(COMMON_OBS): Add dwarf2expr.o and dwarf2loc.o.
(dwarf2expr.o, dwarf2loc.o): New rules.
(dwarf2read.o): Add $(dwarf2expr_h) and $(dwarf2loc_h).
* buildsym.c (finish_block): Handle LOC_COMPUTED and
LOC_COMPUTED_ARG.
* findvar.c (symbol_read_needs_frame, read_var_value): Likewise.
* m2-exp.y (yylex): Likewise.
* printcmd.c (address_info, print_frame_args): Likewise.
* stack.c (print_block_frame_locals, print_frame_arg_vars): Likewise.
* symmisc.c (print_symbol, print_partial_symbols): Likewise.
* ada-lang.c (ada_resolve_subexp, symtab_for_sym)
(ada_add_block_symbols, fill_in_ada_prototype): Likewise.
* symtab.c (lookup_block_symbol): Likewise.
2003-02-21 23:24:18 +08:00
|
|
|
|
|
|
|
struct dwarf2_locexpr_baton
|
|
|
|
{
|
2003-04-13 23:43:35 +08:00
|
|
|
/* Pointer to the start of the location expression. */
|
2010-05-26 23:21:13 +08:00
|
|
|
const gdb_byte *data;
|
2003-04-13 23:43:35 +08:00
|
|
|
|
|
|
|
/* Length of the location expression. */
|
2007-01-28 09:38:40 +08:00
|
|
|
unsigned long size;
|
2003-04-13 23:43:35 +08:00
|
|
|
|
2008-03-19 03:40:47 +08:00
|
|
|
/* The compilation unit containing the symbol whose location
|
|
|
|
we're computing. */
|
|
|
|
struct dwarf2_per_cu_data *per_cu;
|
2003-04-13 23:43:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dwarf2_loclist_baton
|
|
|
|
{
|
|
|
|
/* The initial base address for the location list, based on the compilation
|
|
|
|
unit. */
|
|
|
|
CORE_ADDR base_address;
|
|
|
|
|
|
|
|
/* Pointer to the start of the location list. */
|
2010-05-26 23:21:13 +08:00
|
|
|
const gdb_byte *data;
|
2003-04-13 23:43:35 +08:00
|
|
|
|
|
|
|
/* Length of the location list. */
|
2007-01-28 09:38:40 +08:00
|
|
|
unsigned long size;
|
2003-04-13 23:43:35 +08:00
|
|
|
|
2008-03-19 03:40:47 +08:00
|
|
|
/* The compilation unit containing the symbol whose location
|
|
|
|
we're computing. */
|
|
|
|
struct dwarf2_per_cu_data *per_cu;
|
Based on a patch from Daniel Berlin (dberlin@dberlin.org).
* symtab.h: Add opaque declarations of struct axs_value and
struct agent_expr.
(enum address_class): Add LOC_COMPUTED and LOC_COMPUTED_ARG.
(struct location_funcs): New type.
(struct symbol): Add "loc" to aux_value.
(SYMBOL_LOCATION_BATON, SYMBOL_LOCATION_FUNCS): New macros.
* dwarf2read.c: Include "dwarf2expr.h".
(dwarf2_symbol_mark_computed): New function.
(read_func_scope): Use it.
(var_decode_location): New function.
(new_symbol): Use it.
* dwarf2expr.c, dwarf2expr.h, dwarf2loc.c, dwarf2loc.h: New files.
* Makefile.in (SFILES): Add dwarf2loc.c and dwarf2expr.c.
(dwarf2expr_h, dwarf2loc_h): New variables.
(COMMON_OBS): Add dwarf2expr.o and dwarf2loc.o.
(dwarf2expr.o, dwarf2loc.o): New rules.
(dwarf2read.o): Add $(dwarf2expr_h) and $(dwarf2loc_h).
* buildsym.c (finish_block): Handle LOC_COMPUTED and
LOC_COMPUTED_ARG.
* findvar.c (symbol_read_needs_frame, read_var_value): Likewise.
* m2-exp.y (yylex): Likewise.
* printcmd.c (address_info, print_frame_args): Likewise.
* stack.c (print_block_frame_locals, print_frame_arg_vars): Likewise.
* symmisc.c (print_symbol, print_partial_symbols): Likewise.
* ada-lang.c (ada_resolve_subexp, symtab_for_sym)
(ada_add_block_symbols, fill_in_ada_prototype): Likewise.
* symtab.c (lookup_block_symbol): Likewise.
2003-02-21 23:24:18 +08:00
|
|
|
};
|
|
|
|
|
2009-06-04 20:28:39 +08:00
|
|
|
extern const struct symbol_computed_ops dwarf2_locexpr_funcs;
|
|
|
|
extern const struct symbol_computed_ops dwarf2_loclist_funcs;
|
Based on a patch from Daniel Berlin (dberlin@dberlin.org).
* symtab.h: Add opaque declarations of struct axs_value and
struct agent_expr.
(enum address_class): Add LOC_COMPUTED and LOC_COMPUTED_ARG.
(struct location_funcs): New type.
(struct symbol): Add "loc" to aux_value.
(SYMBOL_LOCATION_BATON, SYMBOL_LOCATION_FUNCS): New macros.
* dwarf2read.c: Include "dwarf2expr.h".
(dwarf2_symbol_mark_computed): New function.
(read_func_scope): Use it.
(var_decode_location): New function.
(new_symbol): Use it.
* dwarf2expr.c, dwarf2expr.h, dwarf2loc.c, dwarf2loc.h: New files.
* Makefile.in (SFILES): Add dwarf2loc.c and dwarf2expr.c.
(dwarf2expr_h, dwarf2loc_h): New variables.
(COMMON_OBS): Add dwarf2expr.o and dwarf2loc.o.
(dwarf2expr.o, dwarf2loc.o): New rules.
(dwarf2read.o): Add $(dwarf2expr_h) and $(dwarf2loc_h).
* buildsym.c (finish_block): Handle LOC_COMPUTED and
LOC_COMPUTED_ARG.
* findvar.c (symbol_read_needs_frame, read_var_value): Likewise.
* m2-exp.y (yylex): Likewise.
* printcmd.c (address_info, print_frame_args): Likewise.
* stack.c (print_block_frame_locals, print_frame_arg_vars): Likewise.
* symmisc.c (print_symbol, print_partial_symbols): Likewise.
* ada-lang.c (ada_resolve_subexp, symtab_for_sym)
(ada_add_block_symbols, fill_in_ada_prototype): Likewise.
* symtab.c (lookup_block_symbol): Likewise.
2003-02-21 23:24:18 +08:00
|
|
|
|
2011-02-18 00:20:44 +08:00
|
|
|
/* Compile a DWARF location expression to an agent expression.
|
|
|
|
|
|
|
|
EXPR is the agent expression we are building.
|
|
|
|
LOC is the agent value we modify.
|
|
|
|
ARCH is the architecture.
|
|
|
|
ADDR_SIZE is the size of addresses, in bytes.
|
|
|
|
OP_PTR is the start of the location expression.
|
|
|
|
OP_END is one past the last byte of the location expression.
|
|
|
|
|
|
|
|
This will throw an exception for various kinds of errors -- for
|
|
|
|
example, if the expression cannot be compiled, or if the expression
|
|
|
|
is invalid. */
|
|
|
|
|
|
|
|
extern void dwarf2_compile_expr_to_ax (struct agent_expr *expr,
|
|
|
|
struct axs_value *loc,
|
|
|
|
struct gdbarch *arch,
|
|
|
|
unsigned int addr_size,
|
|
|
|
const gdb_byte *op_ptr,
|
|
|
|
const gdb_byte *op_end,
|
|
|
|
struct dwarf2_per_cu_data *per_cu);
|
|
|
|
|
2005-07-12 21:06:54 +08:00
|
|
|
#endif /* dwarf2loc.h */
|