From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30141 invoked by alias); 28 Feb 2003 19:50:40 -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 30116 invoked from network); 28 Feb 2003 19:50:37 -0000 Received: from unknown (HELO zenia.red-bean.com) (66.244.67.22) by 172.16.49.205 with SMTP; 28 Feb 2003 19:50:37 -0000 Received: from zenia.red-bean.com (localhost.localdomain [127.0.0.1]) by zenia.red-bean.com (8.12.5/8.12.5) with ESMTP id h1SJjW8A001954; Fri, 28 Feb 2003 14:45:33 -0500 Received: (from jimb@localhost) by zenia.red-bean.com (8.12.5/8.12.5/Submit) id h1SJjUgR001950; Fri, 28 Feb 2003 14:45:30 -0500 To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com Subject: Re: RFA: Fix tracepoints for LOC_COMPUTED - sort of References: <20030223183002.GA13814@nevyn.them.org> <20030226213128.GA17660@nevyn.them.org> From: Jim Blandy Date: Fri, 28 Feb 2003 19:50:00 -0000 In-Reply-To: <20030226213128.GA17660@nevyn.them.org> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.92 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-02/txt/msg00824.txt.bz2 Looks good to me! Daniel Jacobowitz writes: > On Mon, Feb 24, 2003 at 04:50:27PM -0500, Jim Blandy wrote: > > > > Daniel Jacobowitz writes: > > > 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? > > > > Well, the problem is likely to sit around indefinitely: > > 1) I don't think anyone's using tracepoints at the moment. > > 2) Compiling Dwarf 2 bytecodes into ax bytecodes is, in general, not > > a simple thing at all. > > > > So its importance and difficulty both work against it. Would a > > comment be better in this sort of situation? I don't know. > > I went for a comment, because I'm a comment sort of person. > > > You know, dwarf2read.c's read_{un,}signed_leb128 don't actually need > > their BFD argument for anything. The call to bfd_get_8 ignores it; > > it's just a char fetch anyway. In the future, I wonder if we could > > just use those everywhere. > > Probably. There's a set in dwarf2cfi.c too; it would be nice to cut > them down. > > > Gotta have a better error message, dude. It only takes a few > > seconsd. Think of the poor user. > > > You should check that that's actually the end of the expression, too. > > OK, even I am kind of ashamed of the error messages in the last > version... thanks for keeping me honest. How's this? > > -- > Daniel Jacobowitz > MontaVista Software Debian GNU/Linux Developer > > 2003-02-26 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 26 Feb 2003 21:30:44 -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.20 > diff -u -p -r1.20 ax-gdb.c > --- ax-gdb.c 25 Feb 2003 21:36:16 -0000 1.20 > +++ ax-gdb.c 26 Feb 2003 21:30:44 -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 26 Feb 2003 21:30:44 -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 26 Feb 2003 21:30:44 -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 26 Feb 2003 21:30:44 -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,73 @@ locexpr_describe_location (struct symbol > return 1; > } > > + > +/* Describe the location of SYMBOL as an agent value in VALUE, generating > + any necessary bytecode in AX. > + > + NOTE drow/2003-02-26: This function is extremely minimal, because > + doing it correctly is extremely complicated and there is no > + publicly available stub with tracepoint support for me to test > + against. When there is one this function should be revisited. */ > + > +void > +locexpr_tracepoint_var_ref (struct symbol * symbol, struct agent_expr * ax, > + struct axs_value * value) > +{ > + struct dwarf2_locexpr_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol); > + > + if (dlbaton->size == 0) > + error ("Symbol \"%s\" has been optimized out.", > + SYMBOL_PRINT_NAME (symbol)); > + > + 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; > + char *buf_end; > + > + buf_end = read_sleb128 (dlbaton->data + 1, dlbaton->data + dlbaton->size, > + &frame_offset); > + if (buf_end != dlbaton->data + dlbaton->size) > + error ("Unexpected opcode after DW_OP_fbreg for symbol \"%s\".", > + SYMBOL_PRINT_NAME (symbol)); > + > + 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); > + > + ax_const_l (ax, frame_offset); > + ax_simple (ax, aop_add); > + value->kind = axs_lvalue_memory; > + } > + else > + error ("Unsupported DWARF opcode in the location of \"%s\".", > + SYMBOL_PRINT_NAME (symbol)); > +} > + > /* 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 > };