* Re: [PATCH]: multi-arch fix for monitor.c [not found] ` <3907743C.BDD@cygnus.com> @ 2001-09-05 0:14 ` Frank Ch. Eigler [not found] ` <39077739.62400899@cygnus.com> 1 sibling, 0 replies; 3+ messages in thread From: Frank Ch. Eigler @ 2001-09-05 0:14 UTC (permalink / raw) To: gdb-patches; +Cc: msnyder msnyder wrote: > ! static char *zerobuf; > + if (zerobuf == NULL) > + zerobuf = malloc (MAX_REGISTER_RAW_SIZE); Something is still a little suspicious. If the gdbarch were to change during run time, there is no way to reallocate space to match the new MAX_REGISTER_RAW_SIZE. That value is treated a de facto constant. Is allocating a new zerobuf too at every call too much work? - FChE ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <39077739.62400899@cygnus.com>]
[parent not found: <39077B95.D8EA5F06@cygnus.com>]
[parent not found: <39077F1C.4D2E@cygnus.com>]
* Re: [PATCH]: multi-arch fix for monitor.c [not found] ` <39077F1C.4D2E@cygnus.com> @ 2001-09-05 0:16 ` Michael Snyder 2001-09-05 0:15 ` Michael Snyder 0 siblings, 1 reply; 3+ messages in thread From: Michael Snyder @ 2001-09-05 0:16 UTC (permalink / raw) To: gdb-patches Michael Snyder wrote in message <39077F1C.4D2E@cygnus.com>... >Andrew Cagney wrote: >> >> Andrew Cagney wrote: >> > >> > Michael Snyder wrote: >> > > >> > > OK, try #2: >> > > >> > > 2000-04-26 Michael Snyder <msnyder@seadog.cygnus.com> >> > > >> > > * monitor.c (monitor_fetch_register): MAX_REGISTER_RAW_SIZE >> > > is not static in the MULTI_ARCH world, so don't use it in a >> > > static array declaration. >> > >> > I'm not so sure :-( MAX_REGISTER_RAW_SIZE can change and hence the >> > allocated size of zerobuf could need to change. >> > >> > What about chaning its only use to write_register (..., 0)? >> >> Sorry, ignore this suggestion. write_register is for high-level >> accesses to GDB. As Frank suggested, it would be safer to just create >> the buffer when it is needed. > >That's why I keep you guys around. ;-) >Here is the new patch. And then I see that I failed to include it. Ok, HERE is the new patch: 2000-04-26 Michael Snyder <msnyder@seadog.cygnus.com> * monitor.c (monitor_fetch_register): MAX_REGISTER_RAW_SIZE is not static in the MULTI_ARCH world, so don't use it in a static array declaration. Index: monitor.c =================================================================== RCS file: /cvs/src/src/gdb/monitor.c,v retrieving revision 1.4 diff -c -r1.4 monitor.c *** monitor.c 2000/04/04 02:08:52 1.4 --- monitor.c 2000/04/27 15:22:37 *************** *** 1206,1215 **** int regno; { char *name; ! static char zerobuf[MAX_REGISTER_RAW_SIZE] = ! {0}; ! char regbuf[MAX_REGISTER_RAW_SIZE * 2 + 1]; int i; name = current_monitor->regnames[regno]; monitor_debug ("MON fetchreg %d '%s'\n", regno, name ? name : "(null name)") ; --- 1206,1218 ---- int regno; { char *name; ! char *zerobuf; ! char *regbuf; int i; + + regbuf = alloca (MAX_REGISTER_RAW_SIZE * 2 + 1); + zerobuf = alloca (MAX_REGISTER_RAW_SIZE); + memset (zerobuf, 0, MAX_REGISTER_RAW_SIZE); name = current_monitor->regnames[regno]; monitor_debug ("MON fetchreg %d '%s'\n", regno, name ? name : "(null name)") ; ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH]: multi-arch fix for monitor.c 2001-09-05 0:16 ` Michael Snyder @ 2001-09-05 0:15 ` Michael Snyder 0 siblings, 0 replies; 3+ messages in thread From: Michael Snyder @ 2001-09-05 0:15 UTC (permalink / raw) To: gdb-patches FYI, I've committed the final form of this patch. Michael Snyder wrote: > > Michael Snyder wrote in message <39077F1C.4D2E@cygnus.com>... > >Andrew Cagney wrote: > >> > >> Andrew Cagney wrote: > >> > > >> > Michael Snyder wrote: > >> > > > >> > > OK, try #2: > >> > > > >> > > 2000-04-26 Michael Snyder <msnyder@seadog.cygnus.com> > >> > > > >> > > * monitor.c (monitor_fetch_register): MAX_REGISTER_RAW_SIZE > >> > > is not static in the MULTI_ARCH world, so don't use it in a > >> > > static array declaration. > >> > > >> > I'm not so sure :-( MAX_REGISTER_RAW_SIZE can change and hence the > >> > allocated size of zerobuf could need to change. > >> > > >> > What about chaning its only use to write_register (..., 0)? > >> > >> Sorry, ignore this suggestion. write_register is for high-level > >> accesses to GDB. As Frank suggested, it would be safer to just create > >> the buffer when it is needed. > > > >That's why I keep you guys around. ;-) > >Here is the new patch. > > And then I see that I failed to include it. Ok, HERE is the new patch: > > 2000-04-26 Michael Snyder <msnyder@seadog.cygnus.com> > > * monitor.c (monitor_fetch_register): MAX_REGISTER_RAW_SIZE > is not static in the MULTI_ARCH world, so don't use it in a > static array declaration. > > Index: monitor.c > =================================================================== > RCS file: /cvs/src/src/gdb/monitor.c,v > retrieving revision 1.4 > diff -c -r1.4 monitor.c > *** monitor.c 2000/04/04 02:08:52 1.4 > --- monitor.c 2000/04/27 15:22:37 > *************** > *** 1206,1215 **** > int regno; > { > char *name; > ! static char zerobuf[MAX_REGISTER_RAW_SIZE] = > ! {0}; > ! char regbuf[MAX_REGISTER_RAW_SIZE * 2 + 1]; > int i; > > name = current_monitor->regnames[regno]; > monitor_debug ("MON fetchreg %d '%s'\n", regno, name ? name : "(null > name)") > ; > --- 1206,1218 ---- > int regno; > { > char *name; > ! char *zerobuf; > ! char *regbuf; > int i; > + > + regbuf = alloca (MAX_REGISTER_RAW_SIZE * 2 + 1); > + zerobuf = alloca (MAX_REGISTER_RAW_SIZE); > + memset (zerobuf, 0, MAX_REGISTER_RAW_SIZE); > > name = current_monitor->regnames[regno]; > monitor_debug ("MON fetchreg %d '%s'\n", regno, name ? name : "(null > name)") > ; ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-09-05 0:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <200004262144.OAA05362@seadog.cygnus.com>
[not found] ` <3907743C.BDD@cygnus.com>
2001-09-05 0:14 ` [PATCH]: multi-arch fix for monitor.c Frank Ch. Eigler
[not found] ` <39077739.62400899@cygnus.com>
[not found] ` <39077B95.D8EA5F06@cygnus.com>
[not found] ` <39077F1C.4D2E@cygnus.com>
2001-09-05 0:16 ` Michael Snyder
2001-09-05 0:15 ` Michael Snyder
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox