From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jim Blandy To: Nick Duffek Cc: ezannoni@cygnus.com, gdb-patches@sources.redhat.com Subject: Re: [RFA] findvar.c: support LOC_BASEREG[_ARG] on Harvard archs Date: Mon, 16 Jul 2001 11:29:00 -0000 Message-id: References: <200107161713.f6GHDNC08483@rtl.cygnus.com> X-SW-Source: 2001-07/msg00382.html Nick Duffek writes: > At the moment, GDB doesn't apply the necessary POINTER_TO_ADDRESS > translation to the base register value used for finding LOC_BASEREG and > LOC_BASEREG_ARG variables. > > This patch applies that translation. Okay to apply? (I think David Taylor is the maintainer for findvar.c.) The idea seems fine. The alternative would be to have that code call value_from_register and then value_as_pointer, as is done for LOC_REGPARM_ADDR, rather than banging the bits yourself with get_saved_register and extract_address. But if you are going to bang the bits yourself, you do need to call POINTER_TO_ADDRESS. I think it would be a little cleaner to use `lookup_pointer_type (type)' instead of builtin_type_void_data_ptr; that gives more information to the target's POINTER_TO_ADDRESS function. ANSI C says void * can be used as a generic type for all data pointers, but GDB is supposed to support other languages, too. You should do similar things for LOC_INDIRECT, LOC_REF_ARG, LOC_THREAD_LOCAL_STATIC. I think it's not needed for LOC_REGPARM_ADDR; value_as_pointer should do the work. > > ChangeLog: > > * findvar.c (read_var_value): Filter LOC_BASEREG and > LOC_BASEREG_ARG register values through POINTER_TO_ADDRESS. > > Nick Duffek > > > [patch follows] > > Index: gdb/findvar.c > =================================================================== > diff -up gdb/findvar.c gdb/findvar.c > --- gdb/findvar.c Mon Jul 16 12:41:21 2001 > +++ gdb/findvar.c Mon Jul 16 12:39:40 2001 > @@ -612,9 +612,10 @@ addresses have not been bound by the dyn > case LOC_BASEREG_ARG: > { > char *buf = (char*) alloca (MAX_REGISTER_RAW_SIZE); > + memset (buf, 0, MAX_REGISTER_RAW_SIZE); > get_saved_register (buf, NULL, NULL, frame, SYMBOL_BASEREG (var), > NULL); > - addr = extract_address (buf, REGISTER_RAW_SIZE (SYMBOL_BASEREG (var))); > + addr = POINTER_TO_ADDRESS (builtin_type_void_data_ptr, buf); > addr += SYMBOL_VALUE (var); > break; > } >