From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5515 invoked by alias); 23 Feb 2003 18:30:07 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 5506 invoked from network); 23 Feb 2003 18:30:06 -0000 Received: from unknown (HELO crack.them.org) (65.125.64.184) by 172.16.49.205 with SMTP; 23 Feb 2003 18:30:06 -0000 Received: from nevyn.them.org ([66.93.61.169] ident=mail) by crack.them.org with asmtp (Exim 3.12 #1 (Debian)) id 18n2mG-0003Xz-00; Sun, 23 Feb 2003 14:31:13 -0600 Received: from drow by nevyn.them.org with local (Exim 3.36 #1 (Debian)) id 18n0t0-0003bI-00; Sun, 23 Feb 2003 13:30:02 -0500 Date: Sun, 23 Feb 2003 18:30:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sources.redhat.com Cc: jimb@redhat.com Subject: RFA: Fix tracepoints for LOC_COMPUTED - sort of Message-ID: <20030223183002.GA13814@nevyn.them.org> Mail-Followup-To: gdb-patches@sources.redhat.com, jimb@redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.1i X-SW-Source: 2003-02/txt/msg00552.txt.bz2 Like the description function, this is pretty minimal; I don't have time to write a full evaluator right now, and I don't have access to a tracepoint stub, so I suggest someone who does implement this properly. For now, though, this handles the most likely types: DW_OP_reg and DW_OP_fbreg. It's enough to fix the test failures; it's correct as far as it goes; and it properly raises an error if it gets confused. Is this OK? Should I file a PR about the need for a proper evaluator? -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer 2003-02-23 Daniel Jacobowitz * Makefile.in (dwarf2loc.o): Update dependencies. * ax-gdb.c (gen_var_ref): Handle LOC_COMPUTED and LOC_COMPUTED_ARG. * dwarf2expr.c (read_uleb128, read_sleb128): Make non-static. * dwarf2expr.h (read_uleb128, read_sleb128): Add prototypes. * dwarf2loc.c: Include "ax.h" and "ax-gdb.h". (locexpr_tracepoint_var_ref): New function. (dwarf2_locexpr_funcs): Add locexpr_tracepoint_var_ref. Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.335 diff -u -p -r1.335 Makefile.in --- Makefile.in 21 Feb 2003 15:24:17 -0000 1.335 +++ Makefile.in 23 Feb 2003 18:24:14 -0000 @@ -1639,7 +1639,7 @@ dwarf2expr.o: dwarf2expr.c $(defs_h) $(s $(gdbcore_h) $(dwarf2expr_h) dwarf2loc.o: dwarf2loc.c $(defs_h) $(ui_out_h) $(value_h) $(frame_h) \ $(gdbcore_h) $(target_h) $(inferior_h) $(dwarf2expr_h) \ - $(dwarf2loc_h) $(gdb_string_h) + $(dwarf2loc_h) $(ax_h) $(ax_gdb_h) $(gdb_string_h) dwarf2read.o: dwarf2read.c $(defs_h) $(bfd_h) $(symtab_h) $(gdbtypes_h) \ $(symfile_h) $(objfiles_h) $(elf_dwarf2_h) $(buildsym_h) \ $(demangle_h) $(expression_h) $(filenames_h) $(macrotab_h) \ Index: ax-gdb.c =================================================================== RCS file: /cvs/src/src/gdb/ax-gdb.c,v retrieving revision 1.19 diff -u -p -r1.19 ax-gdb.c --- ax-gdb.c 20 Feb 2003 17:17:23 -0000 1.19 +++ ax-gdb.c 23 Feb 2003 18:24:14 -0000 @@ -618,6 +618,11 @@ gen_var_ref (struct agent_expr *ax, stru } break; + case LOC_COMPUTED: + case LOC_COMPUTED_ARG: + (*SYMBOL_LOCATION_FUNCS (var)->tracepoint_var_ref) (var, ax, value); + break; + case LOC_OPTIMIZED_OUT: error ("The variable `%s' has been optimized out.", SYMBOL_PRINT_NAME (var)); Index: dwarf2expr.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2expr.c,v retrieving revision 1.1 diff -u -p -r1.1 dwarf2expr.c --- dwarf2expr.c 21 Feb 2003 15:24:17 -0000 1.1 +++ dwarf2expr.c 23 Feb 2003 18:24:14 -0000 @@ -115,7 +115,7 @@ dwarf_expr_eval (struct dwarf_expr_conte by R, and return the new value of BUF. Verify that it doesn't extend past BUF_END. */ -static unsigned char * +unsigned char * read_uleb128 (unsigned char *buf, unsigned char *buf_end, ULONGEST * r) { unsigned shift = 0; @@ -141,7 +141,7 @@ read_uleb128 (unsigned char *buf, unsign by R, and return the new value of BUF. Verify that it doesn't extend past BUF_END. */ -static unsigned char * +unsigned char * read_sleb128 (unsigned char *buf, unsigned char *buf_end, LONGEST * r) { unsigned shift = 0; Index: dwarf2expr.h =================================================================== RCS file: /cvs/src/src/gdb/dwarf2expr.h,v retrieving revision 1.1 diff -u -p -r1.1 dwarf2expr.h --- dwarf2expr.h 21 Feb 2003 15:24:17 -0000 1.1 +++ dwarf2expr.h 23 Feb 2003 18:24:14 -0000 @@ -94,4 +94,10 @@ void dwarf_expr_eval (struct dwarf_expr_ size_t len); CORE_ADDR dwarf_expr_fetch (struct dwarf_expr_context *ctx, int n); + +unsigned char *read_uleb128 (unsigned char *buf, unsigned char *buf_end, + ULONGEST * r); +unsigned char *read_sleb128 (unsigned char *buf, unsigned char *buf_end, + LONGEST * r); + #endif Index: dwarf2loc.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2loc.c,v retrieving revision 1.1 diff -u -p -r1.1 dwarf2loc.c --- dwarf2loc.c 21 Feb 2003 15:24:17 -0000 1.1 +++ dwarf2loc.c 23 Feb 2003 18:24:14 -0000 @@ -26,6 +26,8 @@ #include "gdbcore.h" #include "target.h" #include "inferior.h" +#include "ax.h" +#include "ax-gdb.h" #include "elf/dwarf2.h" #include "dwarf2expr.h" @@ -277,11 +279,58 @@ locexpr_describe_location (struct symbol return 1; } +void +locexpr_tracepoint_var_ref (struct symbol * symbol, struct agent_expr * ax, + struct axs_value * value) +{ + /* FIXME: This one is also a bit minimal. */ + struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol); + + if (dlbaton->size == 0) + error ("Optimized out."); + + if (dlbaton->size == 1 + && dlbaton->data[0] >= DW_OP_reg0 + && dlbaton->data[0] <= DW_OP_reg31) + { + value->kind = axs_lvalue_register; + value->u.reg = dlbaton->data[0] - DW_OP_reg0; + } + else if (dlbaton->data[0] == DW_OP_regx) + { + ULONGEST reg; + read_uleb128 (dlbaton->data + 1, dlbaton->data + dlbaton->size, + ®); + value->kind = axs_lvalue_register; + value->u.reg = reg; + } + else if (dlbaton->data[0] == DW_OP_fbreg) + { + /* And this is worse than just minimal; we should honor the frame base + as above. */ + int frame_reg; + LONGEST frame_offset; + + TARGET_VIRTUAL_FRAME_POINTER (ax->scope, &frame_reg, &frame_offset); + ax_reg (ax, frame_reg); + ax_const_l (ax, frame_offset); + ax_simple (ax, aop_add); + + read_sleb128 (dlbaton->data + 1, dlbaton->data + dlbaton->size, + &frame_offset); + ax_const_l (ax, frame_offset); + ax_simple (ax, aop_add); + value->kind = axs_lvalue_memory; + } + else + error ("Can't do it."); +} + /* The set of location functions used with the DWARF-2 expression evaluator. */ struct location_funcs dwarf2_locexpr_funcs = { locexpr_read_variable, locexpr_read_needs_frame, locexpr_describe_location, - NULL + locexpr_tracepoint_var_ref };