This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA]: patch clean up immediate_quit...
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: [RFA]: patch clean up immediate_quit...
- From: jtc at redback dot com (J.T. Conklin)
- Date: 23 Aug 2000 16:21:23 -0700
- Reply-To: jtc at redback dot com
Enclosed is a patch that fixes some dcache problems (mainly cache
corruptions caused by target write errors), and changes the places
where immediate_quit is set or reset to increment and decrement its
value so that such calls are nested. I'm not entirely sure that it
is necessary, now that immediate_quit is not set by the dcache code,
but it does make things more robust going forward.
As the dcache maintainer, I already approve of my dcache changes.
It's changes to immediate_quit that I'm looking for approval.
--jtc
2000-08-23 J.T. Conklin <jtc@redback.com>
* dcache.c (dcache_read_line): New function.
(dcache_peek_byte): Use it.
(dcache_alloc): Return NULL if write of reclaimed cache line fails.
(dcache_peek_byte, dcache_poke_byte): Return failure if
dcache_alloc() returns a NULL data block pointer.
(dcache_xfer_memory): Don't force writeback unless we were writing.
* monitor.c (monitor_expect): Change places where immediate_quit
is set to 1 or 0 to increments and decrements respectively. This
allows such changes to nest properly.
* ocd.c (ocd_start_remote): Likewise.
* remote-adapt.c (expect): Likewise.
* remote-array.c (expect): Likewise.
* remote-eb.c (expect): Likewise.
* remote-e7000.c (e7000_start_remote): Likewise.
* remote-mips.c (mips_expect_timeout, mips_getstring): Likewise.
* remote-nrom.c (expect): Likewise.
* remote-os9k.c (expect): Likewise.
* remote-sds.c (sds_start_remote): Likewise.
* remote-st.c (expect): Likewise.
* remote-utils.c (sr_expect): Likewise.
* remote.c (remote_start_remote): Likewise.
* tracepoint.c (read_actions): Likewise.
* remote-mips.c (mips_getstring): Balance changes to immediate_quit.
Index: dcache.c
===================================================================
RCS file: /cvs/src/src/gdb/dcache.c,v
retrieving revision 1.8
diff -c -r1.8 dcache.c
*** dcache.c 2000/08/18 22:52:22 1.8
--- dcache.c 2000/08/23 22:41:10
***************
*** 149,166 ****
int cache_has_stuff;
};
! static int dcache_poke_byte (DCACHE * dcache, CORE_ADDR addr, char *ptr);
! static int dcache_peek_byte (DCACHE * dcache, CORE_ADDR addr, char *ptr);
! static struct dcache_block *dcache_hit (DCACHE * dcache, CORE_ADDR addr);
! static int dcache_write_line (DCACHE * dcache, struct dcache_block *db);
! static struct dcache_block *dcache_alloc (DCACHE * dcache, CORE_ADDR addr);
! static int dcache_writeback (DCACHE * dcache);
static void dcache_info (char *exp, int tty);
void _initialize_dcache (void);
--- 149,168 ----
int cache_has_stuff;
};
! static int dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr);
! static int dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr);
! static struct dcache_block *dcache_hit (DCACHE *dcache, CORE_ADDR addr);
! static int dcache_write_line (DCACHE *dcache, struct dcache_block *db);
! static int dcache_read_line (DCACHE *dcache, struct dcache_block *db);
! static struct dcache_block *dcache_alloc (DCACHE *dcache, CORE_ADDR addr);
+ static int dcache_writeback (DCACHE *dcache);
+
static void dcache_info (char *exp, int tty);
void _initialize_dcache (void);
***************
*** 231,237 ****
{
int s;
int e;
! s = 0;
if (db->anydirty)
{
for (s = 0; s < LINE_SIZE; s++)
--- 233,239 ----
{
int s;
int e;
!
if (db->anydirty)
{
for (s = 0; s < LINE_SIZE; s++)
***************
*** 266,271 ****
--- 268,311 ----
}
+ /* Read cache line */
+ static int
+ dcache_read_line (DCACHE *dcache, struct dcache_block *db)
+ {
+ CORE_ADDR memaddr;
+ char *myaddr;
+ int len;
+ int res;
+
+ /* If there are any dirty bytes in the line, it must be written
+ before a new line can be read */
+ if (db->anydirty)
+ {
+ if (!dcache_write_line (dcache, db))
+ return 0;
+ }
+
+ len = LINE_SIZE;
+ memaddr = db->addr;
+ myaddr = db->data;
+
+ while (len > 0)
+ {
+ res = (*dcache->read_memory) (memaddr, myaddr, len);
+ if (res == 0)
+ return 0;
+
+ memaddr += res;
+ myaddr += res;
+ len -= res;
+ }
+
+ memset (db->state, ENTRY_OK, sizeof (db->data));
+ db->anydirty = 0;
+
+ return 1;
+ }
+
/* Get a free cache block, put or keep it on the valid list,
and return its address. */
***************
*** 287,295 ****
{
/* Nothing left on free list, so grab one from the valid list */
db = dcache->valid_head;
- dcache->valid_head = db->p;
! dcache_write_line (dcache, db);
}
db->addr = MASK(addr);
--- 327,337 ----
{
/* Nothing left on free list, so grab one from the valid list */
db = dcache->valid_head;
! if (!dcache_write_line (dcache, db))
! return NULL;
!
! dcache->valid_head = db->p;
}
db->addr = MASK(addr);
***************
*** 308,355 ****
return db;
}
- /* Using the data cache DCACHE return the contents of the byte at
- address ADDR in the remote machine.
-
- Returns 0 on error. */
-
- static int
- dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
- {
- register struct dcache_block *db = dcache_hit (dcache, addr);
- int ok = 1;
- int done = 0;
- if (db == 0
- || db->state[XFORM (addr)] == ENTRY_BAD)
- {
- if (db)
- {
- dcache_write_line (dcache, db);
- }
- else
- db = dcache_alloc (dcache, addr);
-
- immediate_quit++;
- while (done < LINE_SIZE)
- {
- int try =
- (*dcache->read_memory)
- (db->addr + done,
- db->data + done,
- LINE_SIZE - done);
- if (try == 0)
- return 0;
- done += try;
- }
- immediate_quit--;
-
- memset (db->state, ENTRY_OK, sizeof (db->data));
- db->anydirty = 0;
- }
- *ptr = db->data[XFORM (addr)];
- return ok;
- }
-
/* Writeback any dirty lines to the remote. */
static int
dcache_writeback (DCACHE *dcache)
--- 350,355 ----
***************
*** 368,373 ****
--- 368,401 ----
}
+ /* Using the data cache DCACHE return the contents of the byte at
+ address ADDR in the remote machine.
+
+ Returns 0 on error. */
+
+ static int
+ dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
+ {
+ register struct dcache_block *db = dcache_hit (dcache, addr);
+
+ if (!db)
+ {
+ db = dcache_alloc (dcache, addr);
+ if (!db)
+ return 0;
+ }
+
+ if (db->state[XFORM (addr)] == ENTRY_BAD)
+ {
+ if (!dcache_read_line(dcache, db))
+ return 0;
+ }
+
+ *ptr = db->data[XFORM (addr)];
+ return 1;
+ }
+
+
/* Write the byte at PTR into ADDR in the data cache.
Return zero on write error.
*/
***************
*** 380,385 ****
--- 408,415 ----
if (!db)
{
db = dcache_alloc (dcache, addr);
+ if (!db)
+ return 0;
}
db->data[XFORM (addr)] = *ptr;
***************
*** 435,441 ****
if (dcache_enabled_p)
{
! int (*xfunc) (DCACHE * dcache, CORE_ADDR addr, char *ptr);
xfunc = should_write ? dcache_poke_byte : dcache_peek_byte;
for (i = 0; i < len; i++)
--- 465,471 ----
if (dcache_enabled_p)
{
! int (*xfunc) (DCACHE *dcache, CORE_ADDR addr, char *ptr);
xfunc = should_write ? dcache_poke_byte : dcache_peek_byte;
for (i = 0; i < len; i++)
***************
*** 443,450 ****
if (!xfunc (dcache, memaddr + i, myaddr + i))
return 0;
}
dcache->cache_has_stuff = 1;
- dcache_writeback (dcache);
}
else
{
--- 473,483 ----
if (!xfunc (dcache, memaddr + i, myaddr + i))
return 0;
}
+
+ if (should_write)
+ dcache_writeback (dcache);
+
dcache->cache_has_stuff = 1;
}
else
{
Index: monitor.c
===================================================================
RCS file: /cvs/src/src/gdb/monitor.c,v
retrieving revision 1.10
diff -c -r1.10 monitor.c
*** monitor.c 2000/08/18 22:52:22 1.10
--- monitor.c 2000/08/23 22:41:11
***************
*** 521,527 ****
fprintf_unfiltered (gdb_stdlog, "MON Expecting '%s'\n", safe_string);
}
! immediate_quit = 1;
while (1)
{
if (buf)
--- 521,527 ----
fprintf_unfiltered (gdb_stdlog, "MON Expecting '%s'\n", safe_string);
}
! immediate_quit++;
while (1)
{
if (buf)
***************
*** 529,535 ****
if (buflen < 2)
{
*buf = '\000';
! immediate_quit = 0;
return -1;
}
--- 529,535 ----
if (buflen < 2)
{
*buf = '\000';
! immediate_quit--;
return -1;
}
***************
*** 549,555 ****
p++;
if (*p == '\0')
{
! immediate_quit = 0;
if (buf)
{
--- 549,555 ----
p++;
if (*p == '\0')
{
! immediate_quit--;
if (buf)
{
Index: ocd.c
===================================================================
RCS file: /cvs/src/src/gdb/ocd.c,v
retrieving revision 1.7
diff -c -r1.7 ocd.c
*** ocd.c 2000/08/18 22:52:22 1.7
--- ocd.c 2000/08/23 22:41:12
***************
*** 181,187 ****
target_type = *(enum ocd_target_type *) dummy;
! immediate_quit = 1; /* Allow user to interrupt it */
SERIAL_SEND_BREAK (ocd_desc); /* Wake up the wiggler */
--- 181,187 ----
target_type = *(enum ocd_target_type *) dummy;
! immediate_quit++; /* Allow user to interrupt it */
SERIAL_SEND_BREAK (ocd_desc); /* Wake up the wiggler */
***************
*** 243,249 ****
ocd_error ("OCD_SET_CTL_FLAGS:", error_code);
#endif
! immediate_quit = 0;
/* This is really the job of start_remote however, that makes an assumption
that the target is about to print out a status message of some sort. That
--- 243,249 ----
ocd_error ("OCD_SET_CTL_FLAGS:", error_code);
#endif
! immediate_quit--;
/* This is really the job of start_remote however, that makes an assumption
that the target is about to print out a status message of some sort. That
Index: remote-adapt.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-adapt.c,v
retrieving revision 1.3
diff -c -r1.3 remote-adapt.c
*** remote-adapt.c 2000/07/30 01:48:26 1.3
--- remote-adapt.c 2000/08/23 22:41:13
***************
*** 201,207 ****
char *p = string;
fflush (adapt_stream);
! immediate_quit = 1;
while (1)
{
if (readchar () == *p)
--- 201,207 ----
char *p = string;
fflush (adapt_stream);
! immediate_quit++;
while (1)
{
if (readchar () == *p)
***************
*** 209,215 ****
p++;
if (*p == '\0')
{
! immediate_quit = 0;
return;
}
}
--- 209,215 ----
p++;
if (*p == '\0')
{
! immediate_quit--;
return;
}
}
Index: remote-array.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-array.c,v
retrieving revision 1.5
diff -c -r1.5 remote-array.c
*** remote-array.c 2000/08/18 22:02:43 1.5
--- remote-array.c 2000/08/23 22:41:15
***************
*** 363,369 ****
debuglogs (1, "Expecting \"%s\".", string);
! immediate_quit = 1;
while (1)
{
c = readchar (timeout);
--- 363,369 ----
debuglogs (1, "Expecting \"%s\".", string);
! immediate_quit++;
while (1)
{
c = readchar (timeout);
***************
*** 373,379 ****
{
if (*p == '\0')
{
! immediate_quit = 0;
debuglogs (4, "Matched");
return;
}
--- 373,379 ----
{
if (*p == '\0')
{
! immediate_quit--;
debuglogs (4, "Matched");
return;
}
Index: remote-e7000.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-e7000.c,v
retrieving revision 1.7
diff -c -r1.7 remote-e7000.c
*** remote-e7000.c 2000/07/31 16:25:36 1.7
--- remote-e7000.c 2000/08/23 22:41:16
***************
*** 569,575 ****
int try;
int quit_trying;
! immediate_quit = 1; /* Allow user to interrupt it */
/* Hello? Are you there? */
sync = 0;
--- 569,575 ----
int try;
int quit_trying;
! immediate_quit++; /* Allow user to interrupt it */
/* Hello? Are you there? */
sync = 0;
***************
*** 635,641 ****
puts_e7000debug ("b -\r"); /* Clear breakpoints */
expect_prompt ();
! immediate_quit = 0;
/* This is really the job of start_remote however, that makes an assumption
that the target is about to print out a status message of some sort. That
--- 635,641 ----
puts_e7000debug ("b -\r"); /* Clear breakpoints */
expect_prompt ();
! immediate_quit--;
/* This is really the job of start_remote however, that makes an assumption
that the target is about to print out a status message of some sort. That
Index: remote-eb.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-eb.c,v
retrieving revision 1.3
diff -c -r1.3 remote-eb.c
*** remote-eb.c 2000/07/30 01:48:26 1.3
--- remote-eb.c 2000/08/23 22:41:17
***************
*** 100,106 ****
{
char *p = string;
! immediate_quit = 1;
while (1)
{
if (readchar () == *p)
--- 100,106 ----
{
char *p = string;
! immediate_quit++;
while (1)
{
if (readchar () == *p)
***************
*** 108,114 ****
p++;
if (*p == '\0')
{
! immediate_quit = 0;
return;
}
}
--- 108,114 ----
p++;
if (*p == '\0')
{
! immediate_quit--;
return;
}
}
Index: remote-mips.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-mips.c,v
retrieving revision 1.8
diff -c -r1.8 remote-mips.c
*** remote-mips.c 2000/08/03 08:41:23 1.8
--- remote-mips.c 2000/08/23 22:41:19
***************
*** 551,557 ****
fprintf_unfiltered (gdb_stdlog, "\", got \"");
}
! immediate_quit = 1;
while (1)
{
int c;
--- 551,557 ----
fprintf_unfiltered (gdb_stdlog, "\", got \"");
}
! immediate_quit++;
while (1)
{
int c;
***************
*** 575,581 ****
{
if (*p == '\0')
{
! immediate_quit = 0;
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "\": OK\n");
return 1;
--- 575,581 ----
{
if (*p == '\0')
{
! immediate_quit--;
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "\": OK\n");
return 1;
***************
*** 609,615 ****
char *p = string;
int c;
! immediate_quit = 1;
while (n > 0)
{
c = SERIAL_READCHAR (mips_desc, 2);
--- 609,615 ----
char *p = string;
int c;
! immediate_quit++;
while (n > 0)
{
c = SERIAL_READCHAR (mips_desc, 2);
***************
*** 618,623 ****
--- 618,624 ----
{
fprintf_unfiltered (gdb_stderr,
"Failed to read %d characters from target (TIMEOUT)\n", n);
+ immediate_quit--;
return 0;
}
***************
*** 625,630 ****
--- 626,632 ----
n--;
}
+ immediate_quit--;
return 1;
}
Index: remote-nrom.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-nrom.c,v
retrieving revision 1.3
diff -c -r1.3 remote-nrom.c
*** remote-nrom.c 2000/07/30 01:48:26 1.3
--- remote-nrom.c 2000/08/23 22:41:20
***************
*** 66,72 ****
char *p = string;
int c;
! immediate_quit = 1;
while (1)
{
--- 66,72 ----
char *p = string;
int c;
! immediate_quit++;
while (1)
{
***************
*** 76,83 ****
{
if (*p == '\0')
{
! immediate_quit = 0;
!
return 0;
}
}
--- 76,82 ----
{
if (*p == '\0')
{
! immediate_quit--;
return 0;
}
}
Index: remote-os9k.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-os9k.c,v
retrieving revision 1.4
diff -c -r1.4 remote-os9k.c
*** remote-os9k.c 2000/07/30 01:48:26 1.4
--- remote-os9k.c 2000/08/23 22:41:20
***************
*** 143,149 ****
if (sr_get_debug ())
printf ("Expecting \"%s\"\n", string);
! immediate_quit = 1;
while (1)
{
c = readchar (timeout);
--- 143,149 ----
if (sr_get_debug ())
printf ("Expecting \"%s\"\n", string);
! immediate_quit++;
while (1)
{
c = readchar (timeout);
***************
*** 153,159 ****
{
if (*p == '\0')
{
! immediate_quit = 0;
if (sr_get_debug ())
printf ("\nMatched\n");
return;
--- 153,159 ----
{
if (*p == '\0')
{
! immediate_quit--;
if (sr_get_debug ())
printf ("\nMatched\n");
return;
Index: remote-sds.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sds.c,v
retrieving revision 1.6
diff -c -r1.6 remote-sds.c
*** remote-sds.c 2000/08/18 22:52:23 1.6
--- remote-sds.c 2000/08/23 22:41:21
***************
*** 163,169 ****
char c;
unsigned char buf[200];
! immediate_quit = 1; /* Allow user to interrupt it */
/* Ack any packet which the remote side has already sent. */
SERIAL_WRITE (sds_desc, "{#*\r\n", 5);
--- 163,169 ----
char c;
unsigned char buf[200];
! immediate_quit++; /* Allow user to interrupt it */
/* Ack any packet which the remote side has already sent. */
SERIAL_WRITE (sds_desc, "{#*\r\n", 5);
***************
*** 181,187 ****
buf[0] = 0;
sds_send (buf, 1);
! immediate_quit = 0;
start_remote (); /* Initialize gdb process mechanisms */
return 1;
--- 181,187 ----
buf[0] = 0;
sds_send (buf, 1);
! immediate_quit--;
start_remote (); /* Initialize gdb process mechanisms */
return 1;
Index: remote-st.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-st.c,v
retrieving revision 1.3
diff -c -r1.3 remote-st.c
*** remote-st.c 2000/07/30 01:48:27 1.3
--- remote-st.c 2000/08/23 22:41:22
***************
*** 117,123 ****
char *p = string;
int c;
! immediate_quit = 1;
while (1)
{
c = readchar (timeout);
--- 117,123 ----
char *p = string;
int c;
! immediate_quit++;
while (1)
{
c = readchar (timeout);
***************
*** 125,131 ****
{
if (*p == '\0')
{
! immediate_quit = 0;
return;
}
}
--- 125,131 ----
{
if (*p == '\0')
{
! immediate_quit--;
return;
}
}
Index: remote-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-utils.c,v
retrieving revision 1.6
diff -c -r1.6 remote-utils.c
*** remote-utils.c 2000/08/18 22:52:23 1.6
--- remote-utils.c 2000/08/23 22:41:22
***************
*** 264,270 ****
{
char *p = string;
! immediate_quit = 1;
while (1)
{
if (sr_readchar () == *p)
--- 264,270 ----
{
char *p = string;
! immediate_quit++;
while (1)
{
if (sr_readchar () == *p)
***************
*** 272,278 ****
p++;
if (*p == '\0')
{
! immediate_quit = 0;
return;
}
}
--- 272,278 ----
p++;
if (*p == '\0')
{
! immediate_quit--;
return;
}
}
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.21
diff -c -r1.21 remote.c
*** remote.c 2000/08/18 22:52:23 1.21
--- remote.c 2000/08/23 22:41:26
***************
*** 1975,1981 ****
static int
remote_start_remote (PTR dummy)
{
! immediate_quit = 1; /* Allow user to interrupt it */
/* Ack any packet which the remote side has already sent. */
SERIAL_WRITE (remote_desc, "+", 1);
--- 1975,1981 ----
static int
remote_start_remote (PTR dummy)
{
! immediate_quit++; /* Allow user to interrupt it */
/* Ack any packet which the remote side has already sent. */
SERIAL_WRITE (remote_desc, "+", 1);
***************
*** 1988,1994 ****
get_offsets (); /* Get text, data & bss offsets */
putpkt ("?"); /* initiate a query from remote machine */
! immediate_quit = 0;
return remote_start_remote_dummy (dummy);
}
--- 1988,1994 ----
get_offsets (); /* Get text, data & bss offsets */
putpkt ("?"); /* initiate a query from remote machine */
! immediate_quit--;
return remote_start_remote_dummy (dummy);
}
Index: tracepoint.c
===================================================================
RCS file: /cvs/src/src/gdb/tracepoint.c,v
retrieving revision 1.9
diff -c -r1.9 tracepoint.c
*** tracepoint.c 2000/08/01 05:06:03 1.9
--- tracepoint.c 2000/08/23 22:41:29
***************
*** 889,895 ****
if (job_control)
signal (STOP_SIGNAL, SIG_DFL);
#endif
! immediate_quit = 0;
discard_cleanups (old_chain);
}
--- 889,895 ----
if (job_control)
signal (STOP_SIGNAL, SIG_DFL);
#endif
! immediate_quit--;
discard_cleanups (old_chain);
}
--
J.T. Conklin
RedBack Networks