* RFC: Variables in blocks of registers @ 2003-02-01 14:48 Mark Kettenis 2003-02-01 15:48 ` Andrew Cagney 0 siblings, 1 reply; 11+ messages in thread From: Mark Kettenis @ 2003-02-01 14:48 UTC (permalink / raw) To: gdb On my i386-unknown-freebsd4.7 system, various tests in gdb.base/store.exp fail. The reason is related to the problem described in tdep/214; register variables that don't fit in a single variable. GDB assumes that such variables are stored in consecutive registers (according to its own register numbering scheme), which defenitely isn't what GCC uses on the i386. I'm looking into the suggestion Daniel made in tdep/214; teaching GDB about the order in which GCC allocates registers. There are several caveats though: * While GCC allocates its registers in a particular order right now, and always allocates blocks of consecutive registers, there is no guarantee that it will continue to do so. * I have no idea what other compilers do. If GDB's register numbering was chosen to match for example the System V compiler, teaching GDB GCC's register ordering will cause regressions on system that use it. We might play tricks with gcc_compiled of course. Since AFAIK GDB's internal register ordering is still not decoupled from the remote interface, I propose to add a new multi-arch function "next_regnum" which returns the next register to look in based on the register number passed to it as an argument. Comments? Mark ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: Variables in blocks of registers 2003-02-01 14:48 RFC: Variables in blocks of registers Mark Kettenis @ 2003-02-01 15:48 ` Andrew Cagney 2003-02-01 17:09 ` Daniel Jacobowitz 0 siblings, 1 reply; 11+ messages in thread From: Andrew Cagney @ 2003-02-01 15:48 UTC (permalink / raw) To: Mark Kettenis; +Cc: gdb > On my i386-unknown-freebsd4.7 system, various tests in > gdb.base/store.exp fail. The reason is related to the problem > described in tdep/214; register variables that don't fit in a single > variable. GDB assumes that such variables are stored in consecutive > registers (according to its own register numbering scheme), which > defenitely isn't what GCC uses on the i386. > > I'm looking into the suggestion Daniel made in tdep/214; teaching GDB > about the order in which GCC allocates registers. There are several > caveats though: > > * While GCC allocates its registers in a particular order right now, > and always allocates blocks of consecutive registers, there is no > guarantee that it will continue to do so. > > * I have no idea what other compilers do. If GDB's register numbering > was chosen to match for example the System V compiler, teaching GDB > GCC's register ordering will cause regressions on system that use > it. We might play tricks with gcc_compiled of course. > > Since AFAIK GDB's internal register ordering is still not decoupled > from the remote interface, I propose to add a new multi-arch function > "next_regnum" which returns the next register to look in based on the > register number passed to it as an argument. > > Comments? dwarf2 makes it possible to scatter a value across both memory and registers. It's been proposed that the `struct value' be augmented with something like `struct location' that knows how to find any sub component of a value. Andrew ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: Variables in blocks of registers 2003-02-01 15:48 ` Andrew Cagney @ 2003-02-01 17:09 ` Daniel Jacobowitz 2003-02-01 20:45 ` Andrew Cagney 2003-02-02 15:33 ` Daniel Berlin 0 siblings, 2 replies; 11+ messages in thread From: Daniel Jacobowitz @ 2003-02-01 17:09 UTC (permalink / raw) To: Andrew Cagney; +Cc: Mark Kettenis, gdb On Sat, Feb 01, 2003 at 10:48:32AM -0500, Andrew Cagney wrote: > >On my i386-unknown-freebsd4.7 system, various tests in > >gdb.base/store.exp fail. The reason is related to the problem > >described in tdep/214; register variables that don't fit in a single > >variable. GDB assumes that such variables are stored in consecutive > >registers (according to its own register numbering scheme), which > >defenitely isn't what GCC uses on the i386. > > > >I'm looking into the suggestion Daniel made in tdep/214; teaching GDB > >about the order in which GCC allocates registers. There are several > >caveats though: > > > >* While GCC allocates its registers in a particular order right now, > > and always allocates blocks of consecutive registers, there is no > > guarantee that it will continue to do so. > > > >* I have no idea what other compilers do. If GDB's register numbering > > was chosen to match for example the System V compiler, teaching GDB > > GCC's register ordering will cause regressions on system that use > > it. We might play tricks with gcc_compiled of course. > > > >Since AFAIK GDB's internal register ordering is still not decoupled > >from the remote interface, I propose to add a new multi-arch function > >"next_regnum" which returns the next register to look in based on the > >register number passed to it as an argument. > > > >Comments? > > dwarf2 makes it possible to scatter a value across both memory and > registers. It's been proposed that the `struct value' be augmented with > something like `struct location' that knows how to find any sub > component of a value. However, right now GCC doesn't generate this. Probably because it would kill us. If I have any mental energy left after location lists, I may implement support for DW_OP_piece. Michael, I think the new multi-arch function is a good idea as long as it is a fallback from explicit debug info support, when we have such. I also think it needs a better name; but I'm not quite sure what. Hmm, that could be mitigated by adequate commenting. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: Variables in blocks of registers 2003-02-01 17:09 ` Daniel Jacobowitz @ 2003-02-01 20:45 ` Andrew Cagney 2003-02-02 16:13 ` Mark Kettenis 2003-02-04 2:31 ` Jim Blandy 2003-02-02 15:33 ` Daniel Berlin 1 sibling, 2 replies; 11+ messages in thread From: Andrew Cagney @ 2003-02-01 20:45 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Mark Kettenis, gdb >> dwarf2 makes it possible to scatter a value across both memory and >> registers. It's been proposed that the `struct value' be augmented with >> something like `struct location' that knows how to find any sub >> component of a value. > > > However, right now GCC doesn't generate this. Probably because it > would kill us. I'm not so sure. In the past, GCC hasn't waited for GDB so I don't think that would be the reason now. > If I have any mental energy left after location lists, > I may implement support for DW_OP_piece. Perhaphs leave that one for someone else? > Michael, I think the new multi-arch function is a good idea as long as > it is a fallback from explicit debug info support, when we have such. > I also think it needs a better name; but I'm not quite sure what. Hmm, > that could be mitigated by adequate commenting. I think it is very dangerous. It's assuming a specific algorithm in the compiler. That locks both GDB and GCC into something of a death spiral. I think its far better to try and get a proper location mechanism working. Andrew ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: Variables in blocks of registers 2003-02-01 20:45 ` Andrew Cagney @ 2003-02-02 16:13 ` Mark Kettenis 2003-02-02 5:21 ` Daniel Jacobowitz 2003-02-02 16:52 ` Andrew Cagney 2003-02-04 2:31 ` Jim Blandy 1 sibling, 2 replies; 11+ messages in thread From: Mark Kettenis @ 2003-02-02 16:13 UTC (permalink / raw) To: ac131313; +Cc: drow, gdb Date: Sat, 01 Feb 2003 15:45:52 -0500 From: Andrew Cagney <ac131313@redhat.com> > Michael, I think the new multi-arch function is a good idea as long as > it is a fallback from explicit debug info support, when we have such. > I also think it needs a better name; but I'm not quite sure what. Hmm, > that could be mitigated by adequate commenting. I suppose Daniel meant me, Mark, here ;-). I think it is very dangerous. It's assuming a specific algorithm in the compiler. That locks both GDB and GCC into something of a death spiral. I think its far better to try and get a proper location mechanism working. Hmm, I agree that it is better to get a proper location mechanism working. However, I don't think we have any hope at getting such a mechanism working with stabs. And I don't agree that it is very dangerous to assume the specific algorithm that GCC has been using for several years. Besides GDB already uses a specific algorithm since it assumes that registers have been allocated by the compiler in the order that is dictated by GDB's register cache. That algorithm is known to be wrong for the majority of GDB's users, makes GDB print bugus values and can lead to segfaults in the inferior when setting variables. Why not replace this algorithm with something better? The changes that are necessary aren't very invasive (see the end of this message for the changes to findvar.c and valops.c). Daniel, do you think next_allocated_regnum is a better name? Mark Index: findvar.c =================================================================== RCS file: /cvs/src/src/gdb/findvar.c,v retrieving revision 1.44 diff -u -p -r1.44 findvar.c --- findvar.c 14 Jan 2003 00:49:03 -0000 1.44 +++ findvar.c 1 Feb 2003 22:29:45 -0000 @@ -753,17 +753,18 @@ value_from_register (struct type *type, for (local_regnum = regnum; value_bytes_copied < len; (value_bytes_copied += REGISTER_RAW_SIZE (local_regnum), - ++local_regnum)) + local_regnum = gdbarch_next_allocated_regnum (current_gdbarch, + local_regnum))) { + if (local_regnum == -1) + return NULL; /* Register unknown. */ + get_saved_register (value_bytes + value_bytes_copied, - &optim, - &addr, - frame, - local_regnum, + &optim, &addr, frame, local_regnum, &lval); Index: valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.89 diff -u -p -r1.89 valops.c --- valops.c 30 Jan 2003 16:44:20 -0000 1.89 +++ valops.c 1 Feb 2003 22:29:47 -0000 @@ -704,13 +704,17 @@ value_assign (struct value *toval, struc /* Copy it out. */ for (regno = reg_offset, amount_copied = 0; amount_copied < amount_to_copy; - amount_copied += REGISTER_RAW_SIZE (regno), regno++) + (amount_copied += REGISTER_RAW_SIZE (regno), + regno = gdbarch_next_allocated_regnum (current_gdbarch, regno))) { enum lval_type lval; CORE_ADDR addr; int optim; int realnum; - + + if (regno == -1) + error ("Location of variable is unknown."); + /* Just find out where to put it. */ frame_register (frame, regno, &optim, &lval, &addr, &realnum, NULL); ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: Variables in blocks of registers 2003-02-02 16:13 ` Mark Kettenis @ 2003-02-02 5:21 ` Daniel Jacobowitz 2003-02-02 16:52 ` Andrew Cagney 1 sibling, 0 replies; 11+ messages in thread From: Daniel Jacobowitz @ 2003-02-02 5:21 UTC (permalink / raw) To: Mark Kettenis; +Cc: ac131313, gdb On Sat, Feb 01, 2003 at 11:35:03PM +0100, Mark Kettenis wrote: > Date: Sat, 01 Feb 2003 15:45:52 -0500 > From: Andrew Cagney <ac131313@redhat.com> > > > Michael, I think the new multi-arch function is a good idea as long as > > it is a fallback from explicit debug info support, when we have such. > > I also think it needs a better name; but I'm not quite sure what. Hmm, > > that could be mitigated by adequate commenting. > > I suppose Daniel meant me, Mark, here ;-). Ack ack! I'm sorry, Mark. > I think it is very dangerous. It's assuming a specific algorithm > in the compiler. That locks both GDB and GCC into something of a > death spiral. I think its far better to try and get a proper > location mechanism working. > > Hmm, I agree that it is better to get a proper location mechanism > working. However, I don't think we have any hope at getting such a > mechanism working with stabs. And I don't agree that it is very > dangerous to assume the specific algorithm that GCC has been using for > several years. Besides GDB already uses a specific algorithm since it > assumes that registers have been allocated by the compiler in the > order that is dictated by GDB's register cache. That algorithm is > known to be wrong for the majority of GDB's users, makes GDB print > bugus values and can lead to segfaults in the inferior when setting > variables. Why not replace this algorithm with something better? The > changes that are necessary aren't very invasive (see the end of this > message for the changes to findvar.c and valops.c). > > Daniel, do you think next_allocated_regnum is a better name? Hmm, yes, I like that better. We'll need to hook in a better mechanism when we have DW_OP_piece support, but it doesn't need to be designed now. The basic idea of your patch below looks good to me. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: Variables in blocks of registers 2003-02-02 16:13 ` Mark Kettenis 2003-02-02 5:21 ` Daniel Jacobowitz @ 2003-02-02 16:52 ` Andrew Cagney 2003-02-02 16:27 ` Daniel Jacobowitz 1 sibling, 1 reply; 11+ messages in thread From: Andrew Cagney @ 2003-02-02 16:52 UTC (permalink / raw) To: Mark Kettenis; +Cc: drow, gdb If only it were that easy. The dwarf2 reader, for instance, also contains the assumption that registers are allocated sequentially. Is the proposal to modify such readers so that they check against this next_allocated_regnum algorithm? Andrew > Index: findvar.c > =================================================================== > RCS file: /cvs/src/src/gdb/findvar.c,v > retrieving revision 1.44 > diff -u -p -r1.44 findvar.c > --- findvar.c 14 Jan 2003 00:49:03 -0000 1.44 > +++ findvar.c 1 Feb 2003 22:29:45 -0000 > @@ -753,17 +753,18 @@ value_from_register (struct type *type, > for (local_regnum = regnum; > value_bytes_copied < len; > (value_bytes_copied += REGISTER_RAW_SIZE (local_regnum), > - ++local_regnum)) > + local_regnum = gdbarch_next_allocated_regnum (current_gdbarch, > + local_regnum))) > { > + if (local_regnum == -1) > + return NULL; /* Register unknown. */ > + > get_saved_register (value_bytes + value_bytes_copied, > - &optim, > - &addr, > - frame, > - local_regnum, > + &optim, &addr, frame, local_regnum, > &lval); > > Index: valops.c > =================================================================== > RCS file: /cvs/src/src/gdb/valops.c,v > retrieving revision 1.89 > diff -u -p -r1.89 valops.c > --- valops.c 30 Jan 2003 16:44:20 -0000 1.89 > +++ valops.c 1 Feb 2003 22:29:47 -0000 > @@ -704,13 +704,17 @@ value_assign (struct value *toval, struc > /* Copy it out. */ > for (regno = reg_offset, amount_copied = 0; > amount_copied < amount_to_copy; > - amount_copied += REGISTER_RAW_SIZE (regno), regno++) > + (amount_copied += REGISTER_RAW_SIZE (regno), > + regno = gdbarch_next_allocated_regnum (current_gdbarch, regno))) > { > enum lval_type lval; > CORE_ADDR addr; > int optim; > int realnum; > - > + > + if (regno == -1) > + error ("Location of variable is unknown."); > + > /* Just find out where to put it. */ > frame_register (frame, regno, &optim, &lval, &addr, &realnum, > NULL); > > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: Variables in blocks of registers 2003-02-02 16:52 ` Andrew Cagney @ 2003-02-02 16:27 ` Daniel Jacobowitz 0 siblings, 0 replies; 11+ messages in thread From: Daniel Jacobowitz @ 2003-02-02 16:27 UTC (permalink / raw) To: Andrew Cagney; +Cc: Mark Kettenis, gdb On Sun, Feb 02, 2003 at 11:14:29AM -0500, Andrew Cagney wrote: > If only it were that easy. The dwarf2 reader, for instance, also > contains the assumption that registers are allocated sequentially. > > Is the proposal to modify such readers so that they check against this > next_allocated_regnum algorithm? Where? I can't find this; it doesn't even acknowledge multi-register values. -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: Variables in blocks of registers 2003-02-01 20:45 ` Andrew Cagney 2003-02-02 16:13 ` Mark Kettenis @ 2003-02-04 2:31 ` Jim Blandy 2003-02-04 4:07 ` Daniel Berlin 1 sibling, 1 reply; 11+ messages in thread From: Jim Blandy @ 2003-02-04 2:31 UTC (permalink / raw) To: Andrew Cagney; +Cc: Daniel Jacobowitz, Mark Kettenis, gdb Andrew Cagney <ac131313@redhat.com> writes: > >> dwarf2 makes it possible to scatter a value across both memory and > >> registers. It's been proposed that the `struct value' be augmented > >> with something like `struct location' that knows how to find any > >> sub component of a value. > > However, right now GCC doesn't generate this. Probably because it > > would kill us. > > I'm not so sure. In the past, GCC hasn't waited for GDB so I don't > think that would be the reason now. I thought it had. A lot of the C++ stuff, for example; DW_AT_MIPS_linkage_name; etc. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: Variables in blocks of registers 2003-02-04 2:31 ` Jim Blandy @ 2003-02-04 4:07 ` Daniel Berlin 0 siblings, 0 replies; 11+ messages in thread From: Daniel Berlin @ 2003-02-04 4:07 UTC (permalink / raw) To: Jim Blandy; +Cc: Andrew Cagney, Daniel Jacobowitz, Mark Kettenis, gdb On Mon, 3 Feb 2003, Jim Blandy wrote: > > Andrew Cagney <ac131313@redhat.com> writes: > > >> dwarf2 makes it possible to scatter a value across both memory and > > >> registers. It's been proposed that the `struct value' be augmented > > >> with something like `struct location' that knows how to find any > > >> sub component of a value. > > > However, right now GCC doesn't generate this. Probably because it > > > would kill us. > > > > I'm not so sure. In the past, GCC hasn't waited for GDB so I don't > > think that would be the reason now. > > I thought it had. A lot of the C++ stuff, for example; > DW_AT_MIPS_linkage_name; etc. > Yup. GCC has and does wait for GDB quite a bit, contrary to Andrew's assertion. There have been times when people get frustrated enough to give up waiting, it depends on the feature and the person who implemented it. Generally, I wait indefinitely to commit, and complain a lot. Others stew quietly, but give up waiting for GDB, and just commit it without waiting for gdb to catch up. If you'd rather me just do that, so you can consistently say that gcc doesn't wait for gdb, i'll happily do so. Just give me the word, and i'll go remove DW_AT_mips_linkage_name, for instance. It'll save a *large* amount of space in the C++ object files and binaries. There's other pieces of code already committed that are waiting for gdb too, a quick scan found this #if 0'd block in dwarf2out.c: #if 0 /* Disable this optimization for now; GDB wants to see two line notes at the beginning of a function so it can find the end of the prologue. */ /* Don't emit anything for redundant notes. Just updating the address doesn't accomplish anything, because we already assume that anything after the last address is this line. */ if (line_info->dw_line_num == current_line && line_info->dw_file_num == current_file) continue; #endif ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: Variables in blocks of registers 2003-02-01 17:09 ` Daniel Jacobowitz 2003-02-01 20:45 ` Andrew Cagney @ 2003-02-02 15:33 ` Daniel Berlin 1 sibling, 0 replies; 11+ messages in thread From: Daniel Berlin @ 2003-02-02 15:33 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Andrew Cagney, Mark Kettenis, gdb > > However, right now GCC doesn't generate this. Probably because it > would kill us. If I have any mental energy left after location lists, > I may implement support for DW_OP_piece. Err, the location list patch does. Even without it, you can get them in one specific case (If you have CONCAT's in RTL). So GCC *does* generate it, right now. CONCATS only pop up when we are using complex numbers, as far as a quick grep of the gcc code shows. --Dan ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2003-02-04 4:07 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-02-01 14:48 RFC: Variables in blocks of registers Mark Kettenis 2003-02-01 15:48 ` Andrew Cagney 2003-02-01 17:09 ` Daniel Jacobowitz 2003-02-01 20:45 ` Andrew Cagney 2003-02-02 16:13 ` Mark Kettenis 2003-02-02 5:21 ` Daniel Jacobowitz 2003-02-02 16:52 ` Andrew Cagney 2003-02-02 16:27 ` Daniel Jacobowitz 2003-02-04 2:31 ` Jim Blandy 2003-02-04 4:07 ` Daniel Berlin 2003-02-02 15:33 ` Daniel Berlin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox