* symfile.{c,h} (generic_load): New function.

remote{,-nindy,-eb,-mips}.c: Use it.
This commit is contained in:
Jim Kingdon 1993-06-08 19:48:15 +00:00
parent 3b4cc5ecfb
commit 6b27ebe851
5 changed files with 68 additions and 150 deletions

View File

@ -1,3 +1,8 @@
Tue Jun 8 11:08:29 1993 Jim Kingdon (kingdon@cygnus.com)
* symfile.{c,h} (generic_load): New function.
remote{,-nindy,-eb,-mips}.c: Use it.
Mon Jun 7 20:07:30 1993 Stu Grossman (grossman@cygnus.com)
* Makefile.in (depend): More sed gubbish to deal with

View File

@ -31,6 +31,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "a29k/tm-a29k.h"
#include "inferior.h"
#include "symfile.h"
#include "wait.h"
#include "value.h"
#include <ctype.h>
@ -984,7 +985,7 @@ executable as it exists on the remote computer. For example,\n\
0, 0, /* Breakpoints */
0, 0, 0, 0, 0, /* Terminal handling */
eb_kill,
0, /* load */
generic_load, /* load */
0, /* lookup_symbol */
eb_create_inferior,
eb_mourn_inferior,

View File

@ -21,6 +21,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
#include "inferior.h"
#include "symfile.h"
#include "bfd.h"
#include "wait.h"
#include "gdbcmd.h"
@ -1232,74 +1233,6 @@ mips_kill ()
#endif
}
/* Load an executable onto the board. */
static void
mips_load (args, from_tty)
char *args;
int from_tty;
{
bfd *abfd;
asection *s;
int err;
CORE_ADDR text;
abfd = bfd_openr (args, 0);
if (abfd == (bfd *) NULL)
error ("Unable to open file %s", args);
if (bfd_check_format (abfd, bfd_object) == 0)
error ("%s: Not an object file", args);
text = UINT_MAX;
for (s = abfd->sections; s != (asection *) NULL; s = s->next)
{
if ((s->flags & SEC_LOAD) != 0)
{
bfd_size_type size;
size = bfd_get_section_size_before_reloc (s);
if (size > 0)
{
char *buffer;
struct cleanup *old_chain;
bfd_vma vma;
buffer = xmalloc (size);
old_chain = make_cleanup (free, buffer);
vma = bfd_get_section_vma (abfd, s);
printf_filtered ("Loading section %s, size 0x%x vma 0x%x\n",
bfd_get_section_name (abfd, s), size, vma);
bfd_get_section_contents (abfd, s, buffer, 0, size);
mips_xfer_memory (vma, buffer, size, 1, &mips_ops);
do_cleanups (old_chain);
if ((bfd_get_section_flags (abfd, s) & SEC_CODE) != 0
&& vma < text)
text = vma;
}
}
}
mips_request ('R', (unsigned int) mips_map_regno (PC_REGNUM),
(unsigned int) abfd->start_address,
&err);
if (err)
error ("Can't write PC register: %s", safe_strerror (errno));
bfd_close (abfd);
/* FIXME: Should we call symbol_file_add here? The local variable
text exists just for this call. Making the call seems to confuse
gdb if more than one file is loaded in. Perhaps passing MAINLINE
as 1 would fix this, but it's not clear that that is correct
either since it is possible to load several files onto the board.
symbol_file_add (args, from_tty, text, 0, 0, 0); */
}
/* Start running on the target board. */
static void
@ -1361,7 +1294,7 @@ Specify the serial device it is connected to (e.g., /dev/ttya).", /* to_doc */
NULL, /* to_terminal_ours */
NULL, /* to_terminal_info */
mips_kill, /* to_kill */
mips_load, /* to_load */
generic_load, /* to_load */
NULL, /* to_lookup_symbol */
mips_create_inferior, /* to_create_inferior */
mips_mourn_inferior, /* to_mourn_inferior */

View File

@ -102,6 +102,7 @@ NINDY ROM monitor at the other end of the line.
#include "frame.h"
#include "inferior.h"
#include "symfile.h"
#include "target.h"
#include "gdbcore.h"
#include "command.h"
@ -271,57 +272,8 @@ nindy_files_info ()
nindy_initial_brk? " with initial break": "");
}
/******************************************************************************
* remote_load:
* Download an object file to the remote system by invoking the "comm960"
* utility. We look for "comm960" in $G960BIN, $G960BASE/bin, and
* DEFAULT_BASE/bin/HOST/bin where
* DEFAULT_BASE is defined in env.h, and
* HOST must be defined on the compiler invocation line.
******************************************************************************/
static void
nindy_load( filename, from_tty )
char *filename;
int from_tty;
{
asection *s;
/* Can't do unix style forking on a VMS system, so we'll use bfd to do
all the work for us
*/
bfd *file = bfd_openr(filename,0);
if (!file)
{
perror_with_name(filename);
return;
}
if (!bfd_check_format(file, bfd_object))
{
error("can't prove it's an object file\n");
return;
}
for ( s = file->sections; s; s=s->next)
{
if (s->flags & SEC_LOAD)
{
char *buffer = xmalloc(s->_raw_size);
bfd_get_section_contents(file, s, buffer, 0, s->_raw_size);
printf("Loading section %s, size %x vma %x\n",
s->name,
s->_raw_size,
s->vma);
ninMemPut(s->vma, buffer, s->_raw_size);
free(buffer);
}
}
bfd_close(file);
}
/* Return the number of characters in the buffer before the first DLE character.
*/
/* Return the number of characters in the buffer before
the first DLE character. */
static
int
@ -955,7 +907,7 @@ specified when you started GDB.",
0, 0, /* insert_breakpoint, remove_breakpoint, */
0, 0, 0, 0, 0, /* Terminal crud */
nindy_kill,
nindy_load,
generic_load,
0, /* lookup_symbol */
nindy_create_inferior,
nindy_mourn_inferior,

View File

@ -76,6 +76,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <fcntl.h>
#include "frame.h"
#include "inferior.h"
#include "symfile.h"
#include "target.h"
#include "wait.h"
#include "terminal.h"
@ -363,7 +364,7 @@ remote_interrupt_twice (signo)
signal (signo, ofunc);
target_terminal_ours ();
if (query ("Interrupted while waiting for the inferior.\n\
if (query ("Interrupted while waiting for the program.\n\
Give up (and stop debugging it)? "))
{
target_mourn_inferior ();
@ -739,25 +740,41 @@ putpkt (buf)
/* Send it over and over until we get a positive ack. */
do {
if (kiodebug)
{
*p = '\0';
printf ("Sending packet: %s...", buf2); fflush(stdout);
}
SERIAL_WRITE (remote_desc, buf2, p - buf2);
while (1)
{
if (kiodebug)
{
*p = '\0';
printf ("Sending packet: %s...", buf2); fflush(stdout);
}
if (SERIAL_WRITE (remote_desc, buf2, p - buf2))
perror_with_name ("putpkt: write failed");
/* read until either a timeout occurs (-2) or '+' is read */
do {
ch = readchar ();
if (kiodebug) {
if (ch == '+')
printf("Ack\n");
else
printf ("%02X%c ", ch&0xFF, ch);
}
} while ((ch != '+') && (ch != SERIAL_TIMEOUT));
} while (ch != '+');
/* read until either a timeout occurs (-2) or '+' is read */
while (1)
{
ch = readchar ();
switch (ch)
{
case '+':
if (kiodebug)
printf("Ack\n");
return;
case SERIAL_TIMEOUT:
break; /* Retransmit buffer */
case SERIAL_ERROR:
perror_with_name ("putpkt: couldn't read ACK");
case SERIAL_EOF:
error ("putpkt: EOF while trying to read ACK");
default:
if (kiodebug)
printf ("%02X %c ", ch&0xFF, ch);
continue;
}
break; /* Here to retransmit */
}
}
}
/* Read a packet from the remote machine, with error checking,
@ -782,14 +799,24 @@ getpkt (buf, forever)
/* This can loop forever if the remote side sends us characters
continuously, but if it pauses, we'll get a zero from readchar
because of timeout. Then we'll count that as a retry. */
while (c != '$')
if ((c = readchar()) == SERIAL_TIMEOUT)
if (!forever)
{
if (++retries >= MAX_RETRIES)
if (kiodebug) puts_filtered ("Timed out.\n");
goto out;
}
c = readchar();
if (c > 0 && c != '$')
continue;
if (c == SERIAL_TIMEOUT)
{
if (forever)
continue;
if (++retries >= MAX_RETRIES)
if (kiodebug) puts_filtered ("Timed out.\n");
goto out;
}
if (c == SERIAL_EOF)
error ("Remote connection closed");
if (c == SERIAL_ERROR)
perror_with_name ("Remote communication error");
/* Force csum to be zero here because of possible error retry. */
csum = 0;
@ -1050,7 +1077,7 @@ Specify the serial device it is connected to (e.g. /dev/ttya).", /* to_doc */
NULL, /* to_terminal_ours */
NULL, /* to_terminal_info */
remote_kill, /* to_kill */
NULL, /* to_load */
generic_load, /* to_load */
NULL, /* to_lookup_symbol */
NULL, /* to_create_inferior */
remote_mourn, /* to_mourn_inferior */