* Re: [commited] small changes to fix hpux-cc compile
@ 2004-05-16 15:55 Michael Elizabeth Chastain
2004-05-16 17:21 ` Randolph Chung
0 siblings, 1 reply; 7+ messages in thread
From: Michael Elizabeth Chastain @ 2004-05-16 15:55 UTC (permalink / raw)
To: randolph; +Cc: gdb-patches
> Yes, this was indeed my thinking and why i hardcoded it.
So what happens if your hardcoded auto array of size 4 ever overflows?
We get a nasty bit of stack corruption. I hate seeing code like this
creep into gdb. It works until something else changes and then it
quietly crashes or prints random bad results.
The reason this code stopped compiling is that TARGET_INT_BIT became
more dynamic; it changed from a manifest constant to a function call.
char dld_flags_buffer[4];
...
status = target_read_memory (addr, dld_flags_buffer, TARGET_INT_BIT / TARGET_CHAR_BIT);
That's just wrong!
Michael C
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [commited] small changes to fix hpux-cc compile
2004-05-16 15:55 [commited] small changes to fix hpux-cc compile Michael Elizabeth Chastain
@ 2004-05-16 17:21 ` Randolph Chung
0 siblings, 0 replies; 7+ messages in thread
From: Randolph Chung @ 2004-05-16 17:21 UTC (permalink / raw)
To: Michael Elizabeth Chastain; +Cc: gdb-patches
> So what happens if your hardcoded auto array of size 4 ever overflows?
> We get a nasty bit of stack corruption. I hate seeing code like this
> creep into gdb. It works until something else changes and then it
> quietly crashes or prints random bad results.
ok, how about like this then? this is consistent with how __dld_flags
isused in other parts of somsolib.c
2004-05-16 Randolph Chung <tausq@debian.org>
* somsolib.c (som_solib_remove_inferior_hook): Make all the size
references to dld_flags_buffer consistent.
Index: somsolib.c
===================================================================
RCS file: /cvs/src/src/gdb/somsolib.c,v
retrieving revision 1.33
diff -u -p -r1.33 somsolib.c
--- somsolib.c 16 May 2004 04:33:41 -0000 1.33
+++ somsolib.c 16 May 2004 17:19:04 -0000
@@ -1081,16 +1081,13 @@ som_solib_remove_inferior_hook (int pid)
msymbol = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
addr = SYMBOL_VALUE_ADDRESS (msymbol);
- status = target_read_memory (addr, dld_flags_buffer, TARGET_INT_BIT / TARGET_CHAR_BIT);
+ status = target_read_memory (addr, dld_flags_buffer, 4);
- dld_flags_value = extract_unsigned_integer (dld_flags_buffer,
- sizeof (dld_flags_value));
+ dld_flags_value = extract_unsigned_integer (dld_flags_buffer, 4);
dld_flags_value &= ~DLD_FLAGS_HOOKVALID;
- store_unsigned_integer (dld_flags_buffer,
- sizeof (dld_flags_value),
- dld_flags_value);
- status = target_write_memory (addr, dld_flags_buffer, TARGET_INT_BIT / TARGET_CHAR_BIT);
+ store_unsigned_integer (dld_flags_buffer, 4, dld_flags_value);
+ status = target_write_memory (addr, dld_flags_buffer, 4);
do_cleanups (old_cleanups);
}
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [commited] small changes to fix hpux-cc compile
@ 2004-05-16 18:46 Michael Elizabeth Chastain
0 siblings, 0 replies; 7+ messages in thread
From: Michael Elizabeth Chastain @ 2004-05-16 18:46 UTC (permalink / raw)
To: randolph; +Cc: gdb-patches
Yes, this would make me happy, because it's consistent and there's
no chance of memory corruption. Thank you for this.
Michael C
===
2004-05-16 Randolph Chung <tausq@debian.org>
* somsolib.c (som_solib_remove_inferior_hook): Make all the size
references to dld_flags_buffer consistent.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [commited] small changes to fix hpux-cc compile
@ 2004-05-16 10:12 Michael Elizabeth Chastain
2004-05-16 10:33 ` Mark Kettenis
0 siblings, 1 reply; 7+ messages in thread
From: Michael Elizabeth Chastain @ 2004-05-16 10:12 UTC (permalink / raw)
To: gdb-patches, randolph
Hi Randolph,
In this change:
- char dld_flags_buffer[TARGET_INT_BIT / TARGET_CHAR_BIT];
+ char dld_flags_buffer[4];
I just ran into the same problem with TARGET_INT_BIT so I understand
why this needs to change. But why 4? What if the target configuration
has 64-bit ints?
How about this instead:
char * dld_flags_buffer = alloca(TARGET_INT_BIT/TARGET_CHAR_BIT);
Michael C
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [commited] small changes to fix hpux-cc compile
2004-05-16 10:12 Michael Elizabeth Chastain
@ 2004-05-16 10:33 ` Mark Kettenis
2004-05-16 15:32 ` Randolph Chung
0 siblings, 1 reply; 7+ messages in thread
From: Mark Kettenis @ 2004-05-16 10:33 UTC (permalink / raw)
To: mec.gnu; +Cc: gdb-patches, randolph
Date: Sun, 16 May 2004 06:12:23 -0400 (EDT)
From: mec.gnu@mindspring.com (Michael Elizabeth Chastain)
Hi Randolph,
In this change:
- char dld_flags_buffer[TARGET_INT_BIT / TARGET_CHAR_BIT];
+ char dld_flags_buffer[4];
I just ran into the same problem with TARGET_INT_BIT so I understand
why this needs to change. But why 4? What if the target configuration
has 64-bit ints?
The question should be: will there ever be a target that uses SOM that
doesn't use 32-bit ints? I think we can be fairly certain that there
won't be such target in the future. HP already has abandoned SOM in
favour of ELF of 64-bit HP-UX, and even that still has 32-bit ints.
As a matter of fact, I'm not aware of any ABI that has 64-bit ints.
But in general:
How about this instead:
char * dld_flags_buffer = alloca(TARGET_INT_BIT/TARGET_CHAR_BIT);
This is indeed the right approach.
Mark
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [commited] small changes to fix hpux-cc compile
2004-05-16 10:33 ` Mark Kettenis
@ 2004-05-16 15:32 ` Randolph Chung
0 siblings, 0 replies; 7+ messages in thread
From: Randolph Chung @ 2004-05-16 15:32 UTC (permalink / raw)
To: Mark Kettenis; +Cc: mec.gnu, gdb-patches
> The question should be: will there ever be a target that uses SOM that
> doesn't use 32-bit ints? I think we can be fairly certain that there
> won't be such target in the future. HP already has abandoned SOM in
> favour of ELF of 64-bit HP-UX, and even that still has 32-bit ints.
> As a matter of fact, I'm not aware of any ABI that has 64-bit ints.
Yes, this was indeed my thinking and why i hardcoded it.
> But in general:
>
> How about this instead:
>
> char * dld_flags_buffer = alloca(TARGET_INT_BIT/TARGET_CHAR_BIT);
>
> This is indeed the right approach.
actually in the code:
unsigned int dld_flags_value;
[...]
dld_flags_value = extract_unsigned_integer (dld_flags_buffer,
sizeof (dld_flags_value));
so the code does not anyway allow dld_flags_value to be 64-bit. (i don't
think anyone ever does 64-bit int's, right?)
randolph
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [commited] small changes to fix hpux-cc compile
@ 2004-05-16 4:35 Randolph Chung
0 siblings, 0 replies; 7+ messages in thread
From: Randolph Chung @ 2004-05-16 4:35 UTC (permalink / raw)
To: gdb-patches
Some small changes were needed to get gdb to compile with the HPUX ANSI
C compiler.
Committed as obvious.
thanks,
randolph
2004-05-15 Randolph Chung <tausq@debian.org>
* hppa-tdep.h (hppa_frame_prev_register_helper): Pass save_regs
as pointer instead of array reference since HPUX compiler does
not accept unsized array arguments.
* somsolib.c (dld_flags_buffer): Use constant array size.
Index: hppa-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.h,v
retrieving revision 1.8
diff -u -p -r1.8 hppa-tdep.h
--- hppa-tdep.h 9 May 2004 20:56:41 -0000 1.8
+++ hppa-tdep.h 16 May 2004 04:26:38 -0000
@@ -194,7 +194,7 @@ int hppa_sign_extend (unsigned int, unsi
void
hppa_frame_prev_register_helper (struct frame_info *next_frame,
- struct trad_frame_saved_reg saved_regs[],
+ struct trad_frame_saved_reg *saved_regs,
int regnum, int *optimizedp,
enum lval_type *lvalp, CORE_ADDR *addrp,
int *realnump, void *valuep);
Index: somsolib.c
===================================================================
RCS file: /cvs/src/src/gdb/somsolib.c,v
retrieving revision 1.32
diff -u -p -r1.32 somsolib.c
--- somsolib.c 7 May 2004 05:48:49 -0000 1.32
+++ somsolib.c 16 May 2004 04:26:38 -0000
@@ -1064,7 +1064,7 @@ som_solib_remove_inferior_hook (int pid)
CORE_ADDR addr;
struct minimal_symbol *msymbol;
int status;
- char dld_flags_buffer[TARGET_INT_BIT / TARGET_CHAR_BIT];
+ char dld_flags_buffer[4];
unsigned int dld_flags_value;
struct cleanup *old_cleanups = save_inferior_ptid ();
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-05-16 18:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-16 15:55 [commited] small changes to fix hpux-cc compile Michael Elizabeth Chastain
2004-05-16 17:21 ` Randolph Chung
-- strict thread matches above, loose matches on Subject: below --
2004-05-16 18:46 Michael Elizabeth Chastain
2004-05-16 10:12 Michael Elizabeth Chastain
2004-05-16 10:33 ` Mark Kettenis
2004-05-16 15:32 ` Randolph Chung
2004-05-16 4:35 Randolph Chung
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox