This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[commit] Fix PPC OF bugs
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sun, 22 Jun 2003 09:05:46 -0400
- Subject: [commit] Fix PPC OF bugs
Hello,
This fixes two OF problems: nextprop never handled/returned the first
property. the math to decide of a htab was too big was wrong.
Found by Joshua LeVasseur.
Andrew
2003-06-22 Andrew Cagney <cagney@redhat.com>
Problems reported by Joshua LeVasseur.
* emul_chirp.c: Update copyright.
(chirp_emul_nextprop): Return the first property.
* hw_htab.c: Update copyright.
(htab_decode_hash_table): Fix check for htab size.
Index: emul_chirp.c
===================================================================
RCS file: /cvs/src/src/sim/ppc/emul_chirp.c,v
retrieving revision 1.2
diff -u -r1.2 emul_chirp.c
--- emul_chirp.c 26 Oct 2001 04:37:54 -0000 1.2
+++ emul_chirp.c 22 Jun 2003 13:01:51 -0000
@@ -1,6 +1,6 @@
/* This file is part of the program psim.
- Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
+ Copyright 1994, 1995, 1996, 1997, 2003 Andrew Cagney
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -584,10 +584,15 @@
if (chirp_read_t2h_args(&args, sizeof(args), 3, 1, data, processor, cia))
return -1;
phandle = external_to_device(data->root, args.phandle);
- emul_read_string(previous,
- args.previous,
- sizeof(previous),
- processor, cia);
+ if (args.previous != 0)
+ emul_read_string(previous,
+ args.previous,
+ sizeof(previous),
+ processor, cia);
+ else
+ /* If previous is NULL, make it look like the empty string. The
+ next property after the empty string is the first property. */
+ strcpy (previous, "");
TRACE(trace_os_emul, ("nextprop - in - phandle=0x%lx(0x%lx`%s') previous=`%s' buf=0x%lx\n",
(unsigned long)args.phandle,
(unsigned long)phandle,
@@ -602,11 +607,19 @@
else {
const device_property *prev_prop = device_find_property(phandle, previous);
if (prev_prop == NULL) {
- args.flag = -1; /* name invalid */
+ if (strcmp (previous, "") == 0)
+ args.flag = 0; /* No properties */
+ else
+ args.flag = -1; /* name invalid */
}
else {
const device_property *next_prop;
- next_prop = device_next_property(prev_prop);
+ if (strcmp (previous, "") == 0) {
+ next_prop = prev_prop; /* The first property. */
+ }
+ else {
+ next_prop = device_next_property(prev_prop);
+ }
if (next_prop == NULL) {
args.flag = 0; /* last property */
}
Index: hw_htab.c
===================================================================
RCS file: /cvs/src/src/sim/ppc/hw_htab.c,v
retrieving revision 1.2
diff -u -r1.2 hw_htab.c
--- hw_htab.c 26 Oct 2001 04:37:54 -0000 1.2
+++ hw_htab.c 22 Jun 2003 13:01:51 -0000
@@ -1,6 +1,6 @@
/* This file is part of the program psim.
- Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
+ Copyright 1994, 1995, 1996, 2003 Andrew Cagney
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -217,14 +217,21 @@
device_error(parent, "must be a htab device");
htab_ra = device_find_integer_property(parent, "real-address");
htab_nr_bytes = device_find_integer_property(parent, "nr-bytes");
+ if (htab_nr_bytes < 0x10000) {
+ device_error(parent, "htab size 0x%x less than 0x1000",
+ htab_nr_bytes);
+ }
for (n = htab_nr_bytes; n > 1; n = n / 2) {
if (n % 2 != 0)
device_error(parent, "htab size 0x%x not a power of two",
htab_nr_bytes);
}
*htaborg = htab_ra;
+ /* Position the HTABMASK ready for use against a hashed address and
+ not ready for insertion into SDR1.HTABMASK. */
*htabmask = MASKED32(htab_nr_bytes - 1, 7, 31-6);
- if ((htab_ra & INSERTED32(*htabmask, 7, 15)) != 0) {
+ /* Check that the MASK and ADDRESS do not overlap. */
+ if ((htab_ra & (*htabmask)) != 0) {
device_error(parent, "htaborg 0x%lx not aligned to htabmask 0x%lx",
(unsigned long)*htaborg, (unsigned long)*htabmask);
}