mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-11-25 05:00:01 +00:00
Changes to support GDB running on DOS using GO32 and H8 support
* defs.h: if xm.h doesn't define FOPEN_RB, include "fopen-same.h", allowing hosts with different text and binary file formats to work. * coffread.c (read_coff_symtab): changed calling convention and operation - now it opens its own file with FOPEN_RB rather than duping and fdopening the provided handle. * dbxread.c, cplus-dem.c: #include mangling. * exec.c: If O_BINARY isn't defined, set it to 0, call openp for binary files oring in the right bit. * utils.c, terminal.h, inflow.c: hackery because dos doesn't have terminals. * remote-hms.c: cleanup to use the new remote serial stuff * serial.h, ser-termios.c, ser-go32.c: newfiles to provide host independent remote terminal I/O. * remote.c: if DONT_USE_REMOTE is defined, then don't use it. * source.c (openp): fix off by one problem removing / - can now open a source file in the root directory with DOS. * values.c (value_as_pointer): remove bogus address bits from long. (unpack_long): unpack into unsigned long/short if pointer.
This commit is contained in:
parent
bbbd93b8e9
commit
ae0ea72ee2
@ -90,6 +90,7 @@ gdbcmd.h
|
||||
gdbcore.h
|
||||
gdbtypes.c
|
||||
gdbtypes.h
|
||||
go32-xdep.c
|
||||
gould-pinsn.c
|
||||
gould-xdep.c
|
||||
h8300-tdep.c
|
||||
@ -171,6 +172,9 @@ sparc-xdep.c
|
||||
stack.c
|
||||
standalone.c
|
||||
stuff.c
|
||||
serial.h
|
||||
ser-termios.c
|
||||
ser-go32.c
|
||||
sun3-xdep.c
|
||||
sun386-xdep.c
|
||||
symfile.c
|
||||
@ -246,7 +250,6 @@ xcoffread.c
|
||||
xcoffsolib.c
|
||||
xcoffsolib.h
|
||||
xm-3b1.h
|
||||
xm-m88k.h
|
||||
xm-altos.h
|
||||
xm-amix.h
|
||||
xm-apollo68v.h
|
||||
@ -254,6 +257,7 @@ xm-arm.h
|
||||
xm-bigmips.h
|
||||
xm-convex.h
|
||||
xm-delta88.h
|
||||
xm-go32.h
|
||||
xm-hp300bsd.h
|
||||
xm-hp300hpux.h
|
||||
xm-i386mach.h
|
||||
@ -265,6 +269,7 @@ xm-irix3.h
|
||||
xm-irix4.h
|
||||
xm-isi.h
|
||||
xm-m68k.h
|
||||
xm-m88k.h
|
||||
xm-merlin.h
|
||||
xm-mips.h
|
||||
xm-news.h
|
||||
|
@ -1,3 +1,26 @@
|
||||
Tue May 12 17:44:39 1992 Steve Chamberlain (sac@thepub.cygnus.com)
|
||||
Changes to support GDB running on DOS using GO32 and H8 support
|
||||
|
||||
* defs.h: if xm.h doesn't define FOPEN_RB, include "fopen-same.h",
|
||||
allowing hosts with different text and binary file formats to
|
||||
work.
|
||||
* coffread.c (read_coff_symtab): changed calling convention and
|
||||
operation - now it opens its own file with FOPEN_RB rather than
|
||||
duping and fdopening the provided handle.
|
||||
* dbxread.c, cplus-dem.c: #include mangling.
|
||||
* exec.c: If O_BINARY isn't defined, set it to 0, call openp for
|
||||
binary files oring in the right bit.
|
||||
* utils.c, terminal.h, inflow.c: hackery because dos doesn't have terminals.
|
||||
* remote-hms.c: cleanup to use the new remote serial stuff
|
||||
* serial.h, ser-termios.c, ser-go32.c: newfiles to provide host
|
||||
independent remote terminal I/O.
|
||||
* remote.c: if DONT_USE_REMOTE not defined, then don't use it.
|
||||
* source.c (openp): fix off by one problem removing / - can now
|
||||
open a source file in the root directory with DOS.
|
||||
* values.c (value_as_pointer): remove bogus address bits from
|
||||
long. (unpack_long): unpack into unsigned long/short if pointer.
|
||||
|
||||
|
||||
Tue May 12 14:15:48 1992 Stu Grossman (grossman at cygnus.com)
|
||||
|
||||
* infrun.c (child_attach): Don't allow gdb to attach to itself.
|
||||
|
@ -102,6 +102,7 @@ i386)
|
||||
ncr) gdb_host=ncr3000 ;;
|
||||
*)
|
||||
case "${host_os}" in
|
||||
go32) gdb_host=go32 ;;
|
||||
sysv32) gdb_host=i386v32 ;;
|
||||
sysv4*) gdb_host=i386v4 ;;
|
||||
sysv*) gdb_host=i386v ;;
|
||||
|
@ -30,13 +30,7 @@
|
||||
#include "demangle.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef USG
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#if !defined (GNU_DEMANGLING) && !defined (ARM_DEMANGLING)
|
||||
# define GNU_DEMANGLING 1
|
||||
|
43
gdb/go32-xdep.c
Normal file
43
gdb/go32-xdep.c
Normal file
@ -0,0 +1,43 @@
|
||||
/* Host-dependent code for dos running GO32 for GDB, the GNU debugger.
|
||||
Copyright 1992
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GDB.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static void uerror(char *s)
|
||||
{
|
||||
fprintf(stderr, "Fatal: %s!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fork(){uerror("attempt to call fork()");}
|
||||
vfork(){uerror("attempt to call vfork()");}
|
||||
wait(){uerror("attempt to call wait()");}
|
||||
execlp(){uerror("attempt to call execlp()");}
|
||||
kill_inferior_fast(){uerror("attempt to call kill_inferior_fast()");}
|
||||
kill_inferior(){uerror("attempt to call kill_inferior()");}
|
||||
re_comp(){uerror("attempt to call re_comp()");}
|
||||
re_exec(){uerror("attempt to call re_exec()");}
|
||||
call_ptrace(){uerror("attempt to call call_ptrace()");}
|
||||
child_resume(){uerror("attempt to call child_resume()");}
|
||||
fetch_inferior_registers(){uerror("attempt to call fetch_inferior_registers()");}
|
||||
store_inferior_registers(){uerror("attempt to call store_inferior_registers()");}
|
||||
child_xfer_memory(){uerror("attempt to call child_xfer_memory()");}
|
||||
fetch_core_registers(){uerror("attempt to call fetch_core_registers()");}
|
||||
|
499
gdb/remote-hms.c
499
gdb/remote-hms.c
@ -234,75 +234,37 @@ dcache_init ()
|
||||
***********************************************************************/
|
||||
|
||||
static int timeout = 2;
|
||||
static char *dev_name = "/dev/ttya";
|
||||
|
||||
|
||||
static CONST char *dev_name;
|
||||
|
||||
|
||||
/* Descriptor for I/O to remote machine. Initialize it to -1 so that
|
||||
hms_open knows that we don't have a file open when the program
|
||||
starts. */
|
||||
int hms_desc = -1;
|
||||
#define OPEN(x) ((x) >= 0)
|
||||
|
||||
|
||||
void hms_open();
|
||||
int is_open = 0;
|
||||
int check_open()
|
||||
{
|
||||
if (!is_open)
|
||||
{
|
||||
error("remote device not open");
|
||||
}
|
||||
}
|
||||
|
||||
#define ON 1
|
||||
#define OFF 0
|
||||
static void
|
||||
rawmode(desc, turnon)
|
||||
int desc;
|
||||
int turnon;
|
||||
{
|
||||
TERMINAL sg;
|
||||
|
||||
if (desc < 0)
|
||||
return;
|
||||
|
||||
ioctl (desc, TIOCGETP, &sg);
|
||||
|
||||
if (turnon) {
|
||||
#ifdef HAVE_TERMIO
|
||||
sg.c_lflag &= ~(ICANON);
|
||||
#else
|
||||
sg.sg_flags |= RAW;
|
||||
#endif
|
||||
} else {
|
||||
#ifdef HAVE_TERMIO
|
||||
sg.c_lflag |= ICANON;
|
||||
#else
|
||||
sg.sg_flags &= ~(RAW);
|
||||
#endif
|
||||
}
|
||||
ioctl (desc, TIOCSETP, &sg);
|
||||
}
|
||||
|
||||
|
||||
/* Read a character from the remote system, doing all the fancy
|
||||
timeout stuff. */
|
||||
static int
|
||||
readchar ()
|
||||
{
|
||||
char buf;
|
||||
int ok;
|
||||
int buf;
|
||||
buf = serial_timedreadchar(timeout, &ok);
|
||||
|
||||
buf = '\0';
|
||||
#ifdef HAVE_TERMIO
|
||||
/* termio does the timeout for us. */
|
||||
read (hms_desc, &buf, 1);
|
||||
#else
|
||||
alarm (timeout);
|
||||
if (read (hms_desc, &buf, 1) < 0)
|
||||
{
|
||||
if (errno == EINTR)
|
||||
error ("Timeout reading from remote system.");
|
||||
else
|
||||
perror_with_name ("remote");
|
||||
}
|
||||
alarm (0);
|
||||
#endif
|
||||
|
||||
if (buf == '\0')
|
||||
if (!ok)
|
||||
error ("Timeout reading from remote system.");
|
||||
|
||||
if (!quiet)
|
||||
@ -314,26 +276,15 @@ readchar ()
|
||||
static int
|
||||
readchar_nofail ()
|
||||
{
|
||||
char buf;
|
||||
int ok;
|
||||
int buf;
|
||||
buf = serial_timedreadchar(timeout, &ok);
|
||||
if (!ok) buf = 0;
|
||||
if (!quiet)
|
||||
printf("%c",buf);
|
||||
|
||||
buf = '\0';
|
||||
#ifdef HAVE_TERMIO
|
||||
/* termio does the timeout for us. */
|
||||
read (hms_desc, &buf, 1);
|
||||
#else
|
||||
alarm (timeout);
|
||||
if (read (hms_desc, &buf, 1) < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
alarm (0);
|
||||
#endif
|
||||
|
||||
if (buf == '\0')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return buf & 0x7f;
|
||||
|
||||
}
|
||||
|
||||
/* Keep discarding input from the remote system, until STRING is found.
|
||||
@ -379,7 +330,6 @@ expect (string)
|
||||
static void
|
||||
expect_prompt ()
|
||||
{
|
||||
|
||||
expect ("HMS>");
|
||||
}
|
||||
|
||||
@ -435,21 +385,7 @@ get_hex_word()
|
||||
return val;
|
||||
}
|
||||
/* Called when SIGALRM signal sent due to alarm() timeout. */
|
||||
#ifndef HAVE_TERMIO
|
||||
|
||||
#ifndef __STDC__
|
||||
# ifndef volatile
|
||||
# define volatile /**/
|
||||
# endif
|
||||
#endif
|
||||
volatile int n_alarms;
|
||||
|
||||
void
|
||||
hms_timer ()
|
||||
{
|
||||
n_alarms++;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Number of SIGTRAPs we need to simulate. That is, the next
|
||||
@ -466,12 +402,7 @@ int from_tty;
|
||||
|
||||
}
|
||||
|
||||
static check_open()
|
||||
{
|
||||
if (!OPEN(hms_desc)) {
|
||||
hms_open("",0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Download a file specified in 'args', to the hms.
|
||||
@ -486,6 +417,7 @@ int fromtty;
|
||||
int n;
|
||||
char buffer[1024];
|
||||
|
||||
|
||||
DENTER("hms_load()");
|
||||
check_open();
|
||||
|
||||
@ -512,9 +444,9 @@ int fromtty;
|
||||
int i;
|
||||
|
||||
|
||||
#define DELTA 2048
|
||||
#define DELTA 1024
|
||||
char *buffer = xmalloc(DELTA);
|
||||
printf_filtered("%s: %4x .. %4x ",s->name, s->vma, s->vma + s->_raw_size);
|
||||
printf_filtered("%s\t: 0x%4x .. 0x%4x ",s->name, s->vma, s->vma + s->_raw_size);
|
||||
for (i = 0; i < s->_raw_size; i+= DELTA)
|
||||
{
|
||||
int delta = DELTA;
|
||||
@ -531,7 +463,9 @@ int fromtty;
|
||||
}
|
||||
s = s->next;
|
||||
}
|
||||
|
||||
sprintf(buffer, "r PC=%x", abfd->start_address);
|
||||
hms_write_cr(buffer);
|
||||
expect_prompt();
|
||||
|
||||
DEXIT("hms_load()");
|
||||
}
|
||||
@ -545,7 +479,7 @@ hms_create_inferior (execfile, args, env)
|
||||
char **env;
|
||||
{
|
||||
int entry_pt;
|
||||
|
||||
char buffer[100];
|
||||
DENTER("hms_create_inferior()");
|
||||
|
||||
if (args && *args)
|
||||
@ -557,62 +491,20 @@ hms_create_inferior (execfile, args, env)
|
||||
entry_pt = (int) bfd_get_start_address (exec_bfd);
|
||||
check_open();
|
||||
|
||||
if (OPEN(hms_desc))
|
||||
{
|
||||
char buffer[100];
|
||||
|
||||
hms_kill(NULL,NULL);
|
||||
hms_clear_breakpoints();
|
||||
init_wait_for_inferior ();
|
||||
/* Clear the input because what the hms sends back is different
|
||||
* depending on whether it was running or not.
|
||||
*/
|
||||
/*sprintf(buffer,"g %x", entry_pt);
|
||||
|
||||
hms_write_cr(buffer);
|
||||
*/
|
||||
hms_write_cr("");
|
||||
|
||||
hms_write_cr("");
|
||||
expect_prompt();
|
||||
|
||||
|
||||
insert_breakpoints (); /* Needed to get correct instruction in cache */
|
||||
proceed(entry_pt, -1, 0);
|
||||
|
||||
|
||||
}
|
||||
DEXIT("hms_create_inferior()");
|
||||
}
|
||||
|
||||
/* Translate baud rates from integers to damn B_codes. Unix should
|
||||
have outgrown this crap years ago, but even POSIX wouldn't buck it. */
|
||||
|
||||
#ifndef B19200
|
||||
#define B19200 EXTA
|
||||
#endif
|
||||
#ifndef B38400
|
||||
#define B38400 EXTB
|
||||
#endif
|
||||
|
||||
static struct {int rate, damn_b;} baudtab[] = {
|
||||
{9600, B9600},
|
||||
{19200, B19200},
|
||||
{300, B300},
|
||||
{1200, B1200},
|
||||
{2400, B2400},
|
||||
{4800, B4800},
|
||||
{-1, -1},
|
||||
};
|
||||
|
||||
static int damn_b (rate)
|
||||
int rate;
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; baudtab[i].rate != -1; i++)
|
||||
if (rate == baudtab[i].rate) return baudtab[i].damn_b;
|
||||
return B19200;
|
||||
}
|
||||
|
||||
|
||||
/* Open a connection to a remote debugger.
|
||||
NAME is the filename used for communication, then a space,
|
||||
@ -661,65 +553,46 @@ static int baudrate = 9600;
|
||||
static int
|
||||
is_baudrate_right()
|
||||
{
|
||||
|
||||
|
||||
int ok;
|
||||
/* Put this port into NORMAL mode, send the 'normal' character */
|
||||
|
||||
hms_write("\001", 1); /* Control A */
|
||||
hms_write("\r", 1); /* Cr */
|
||||
|
||||
while ( readchar_nofail()) /* Skip noise we put there */
|
||||
;
|
||||
while (1)
|
||||
{
|
||||
serial_timedreadchar(timeout, &ok);
|
||||
if (!ok) break;
|
||||
}
|
||||
|
||||
hms_write("r",1);
|
||||
|
||||
hms_write("r");
|
||||
if (readchar_nofail() == 'r')
|
||||
return 1;
|
||||
|
||||
/* Not the right baudrate, or the board's not on */
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
static void
|
||||
set_rate()
|
||||
{
|
||||
TERMINAL sg;
|
||||
ioctl (hms_desc, TIOCGETP, &sg);
|
||||
#ifdef HAVE_TERMIO
|
||||
sg.c_cc[VMIN] = 0; /* read with timeout. */
|
||||
sg.c_cc[VTIME] = timeout * 10;
|
||||
sg.c_lflag &= ~(ICANON | ECHO);
|
||||
sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate);
|
||||
#else
|
||||
sg.sg_ispeed = damn_b (baudrate);
|
||||
sg.sg_ospeed = damn_b (baudrate);
|
||||
sg.sg_flags |= RAW | ANYP;
|
||||
sg.sg_flags &= ~ECHO;
|
||||
#endif
|
||||
|
||||
ioctl (hms_desc, TIOCSETP, &sg);
|
||||
|
||||
if (!serial_setbaudrate(baudrate))
|
||||
error("Can't set baudrate");
|
||||
}
|
||||
|
||||
static void
|
||||
get_baudrate_right()
|
||||
{
|
||||
|
||||
int which_rate = 0;
|
||||
|
||||
while (!is_baudrate_right())
|
||||
{
|
||||
which_rate++;
|
||||
|
||||
if (baudtab[which_rate].rate == -1)
|
||||
{
|
||||
which_rate = 0;
|
||||
baudrate = serial_nextbaudrate(baudrate);
|
||||
if (baudrate == 0) {
|
||||
printf_filtered("Board not yet in sync\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
baudrate = baudtab[which_rate].rate;
|
||||
printf_filtered("Board not responding, trying %d baud\n",baudrate);
|
||||
QUIT;
|
||||
set_rate();
|
||||
serial_setbaudrate(baudrate);
|
||||
}
|
||||
}
|
||||
|
||||
@ -738,46 +611,32 @@ hms_open (name, from_tty)
|
||||
name = "";
|
||||
|
||||
}
|
||||
|
||||
if (is_open)
|
||||
hms_close (0);
|
||||
if (name && strlen(name))
|
||||
dev_name = strdup(name);
|
||||
if (!serial_open(dev_name))
|
||||
perror_with_name ((char *)dev_name);
|
||||
serial_raw();
|
||||
is_open = 1;
|
||||
|
||||
hms_desc = open (dev_name, O_RDWR);
|
||||
if (hms_desc < 0)
|
||||
perror_with_name (dev_name);
|
||||
|
||||
set_rate();
|
||||
|
||||
dcache_init();
|
||||
|
||||
|
||||
/* start_remote (); /* Initialize gdb process mechanisms */
|
||||
|
||||
|
||||
#ifndef HAVE_TERMIO
|
||||
#ifndef NO_SIGINTERRUPT
|
||||
/* Cause SIGALRM's to make reads fail with EINTR instead of resuming
|
||||
the read. */
|
||||
if (siginterrupt (SIGALRM, 1) != 0)
|
||||
perror ("hms_open: error in siginterrupt");
|
||||
#endif
|
||||
|
||||
/* Set up read timeout timer. */
|
||||
if ((void (*)) signal (SIGALRM, hms_timer) == (void (*)) -1)
|
||||
perror ("hms_open: error in signal");
|
||||
#endif
|
||||
|
||||
get_baudrate_right();
|
||||
|
||||
/* Hello? Are you there? */
|
||||
write (hms_desc, "\r", 1);
|
||||
|
||||
serial_write("\r",1);
|
||||
expect_prompt ();
|
||||
|
||||
/* Clear any break points */
|
||||
hms_clear_breakpoints();
|
||||
|
||||
|
||||
printf_filtered("Remote debugging on an H8/300 HMS via %s.\n",dev_name);
|
||||
printf_filtered("Connected to remote H8/300 HMS system.\n");
|
||||
|
||||
DEXIT("hms_open()");
|
||||
}
|
||||
@ -795,21 +654,10 @@ hms_close (quitting)
|
||||
hms_clear_breakpoints();
|
||||
|
||||
/* Put this port back into REMOTE mode */
|
||||
if (OPEN(hms_desc)) {
|
||||
|
||||
sleep(1); /* Let any output make it all the way back */
|
||||
write(hms_desc, "R\r", 2);
|
||||
}
|
||||
|
||||
/* Due to a bug in Unix, fclose closes not only the stdio stream,
|
||||
but also the file descriptor. So we don't actually close
|
||||
hms_desc. */
|
||||
if (OPEN(hms_desc))
|
||||
close (hms_desc);
|
||||
|
||||
/* Do not try to close hms_desc again, later in the program. */
|
||||
|
||||
hms_desc = -1;
|
||||
serial_write("R\r", 2);
|
||||
serial_close();
|
||||
is_open = 0;
|
||||
|
||||
DEXIT("hms_close()");
|
||||
}
|
||||
@ -852,11 +700,9 @@ hms_detach (args,from_tty)
|
||||
int from_tty;
|
||||
{
|
||||
DENTER("hms_detach()");
|
||||
if (OPEN(hms_desc)) { /* Send it on its way (tell it to continue) */
|
||||
if (is_open)
|
||||
{
|
||||
hms_clear_breakpoints();
|
||||
#if 0
|
||||
fprintf(hms_stream,"G\r");
|
||||
#endif
|
||||
}
|
||||
|
||||
pop_target(); /* calls hms_close to do the real work */
|
||||
@ -934,7 +780,7 @@ hms_wait (status)
|
||||
return 0;
|
||||
}
|
||||
|
||||
timeout = 0; /* Don't time out -- user program is running. */
|
||||
timeout = 99999; /* Don't time out -- user program is running. */
|
||||
immediate_quit = 1; /* Helps ability to QUIT */
|
||||
while (1)
|
||||
{
|
||||
@ -1010,11 +856,8 @@ static char *
|
||||
get_reg_name (regno)
|
||||
int regno;
|
||||
{
|
||||
static char *rn[NUM_REGS]= REGISTER_NAMES;
|
||||
|
||||
|
||||
static char *rn[NUM_REGS]= REGISTER_NAMES;
|
||||
return rn[regno];
|
||||
|
||||
}
|
||||
|
||||
/* Read the remote registers. */
|
||||
@ -1069,7 +912,8 @@ hms_write(a,l)
|
||||
char *a;
|
||||
{
|
||||
int i;
|
||||
write(hms_desc,a,l);
|
||||
serial_write(a, l);
|
||||
|
||||
if (!quiet)
|
||||
for (i = 0; i < l ; i++)
|
||||
{
|
||||
@ -1080,12 +924,13 @@ char *a;
|
||||
hms_write_cr(s)
|
||||
char *s;
|
||||
{
|
||||
hms_write( s, strlen(s));
|
||||
hms_write("\r",1);
|
||||
hms_write( s, strlen(s));
|
||||
hms_write("\r",1);
|
||||
}
|
||||
|
||||
static void
|
||||
hms_fetch_registers ()
|
||||
hms_fetch_register (dummy)
|
||||
int dummy;
|
||||
{
|
||||
#define REGREPLY_SIZE 79
|
||||
char linebuf[REGREPLY_SIZE+1];
|
||||
@ -1132,43 +977,30 @@ hms_fetch_registers ()
|
||||
while (!gottok);
|
||||
for (i = 0; i < NUM_REGS; i++)
|
||||
{
|
||||
supply_register (i, reg+i);
|
||||
char swapped[2];
|
||||
swapped[1] = reg[i];
|
||||
swapped[0] = (reg[i])>> 8;
|
||||
|
||||
supply_register (i, swapped);
|
||||
}
|
||||
}
|
||||
|
||||
/* Fetch register REGNO, or all registers if REGNO is -1.
|
||||
*/
|
||||
static void
|
||||
hms_fetch_register (regno)
|
||||
int regno;
|
||||
{
|
||||
|
||||
hms_fetch_registers ();
|
||||
|
||||
}
|
||||
|
||||
/* Store the remote registers from the contents of the block REGS. */
|
||||
|
||||
static int
|
||||
hms_store_registers ()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < NUM_REGS; i++)
|
||||
hms_store_register(i);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/* Store register REGNO, or all if REGNO == -1.
|
||||
Return errno value. */
|
||||
int
|
||||
static void
|
||||
hms_store_register (regno)
|
||||
int regno;
|
||||
{
|
||||
|
||||
/* printf("hms_store_register() called.\n"); fflush(stdout); /* */
|
||||
if (regno == -1)
|
||||
hms_store_registers ();
|
||||
{
|
||||
for (regno = 0; regno < NUM_REGS; regno ++)
|
||||
{
|
||||
hms_store_register(regno);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char *name = get_reg_name (regno);
|
||||
@ -1179,9 +1011,11 @@ hms_store_register (regno)
|
||||
}
|
||||
|
||||
DEXIT("hms_store_registers()");
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Get ready to modify the registers array. On machines which store
|
||||
individual registers, this doesn't need to do anything. On machines
|
||||
which store all the registers in one fell swoop, this makes sure
|
||||
@ -1301,50 +1135,53 @@ hms_xfer_inferior_memory(memaddr, myaddr, len, write, target)
|
||||
return len;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int
|
||||
hms_xfer_inferior_memory (memaddr, myaddr, len, write)
|
||||
CORE_ADDR memaddr;
|
||||
char *myaddr;
|
||||
int len;
|
||||
int write;
|
||||
{
|
||||
memaddr &= 0xffff;
|
||||
if (write)
|
||||
return hms_write_inferior_memory (memaddr, myaddr, len);
|
||||
else
|
||||
return hms_read_inferior_memory (memaddr, myaddr, len);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
hms_write_inferior_memory (memaddr, myaddr, len)
|
||||
CORE_ADDR memaddr;
|
||||
char *myaddr;
|
||||
unsigned char *myaddr;
|
||||
int len;
|
||||
{
|
||||
bfd_vma addr;
|
||||
int done;
|
||||
int todo ;
|
||||
done = 0;
|
||||
while(done < len)
|
||||
{
|
||||
char buffer[20];
|
||||
int thisgo;
|
||||
int idx;
|
||||
thisgo = len - done;
|
||||
if (thisgo > 20) thisgo = 20;
|
||||
|
||||
bfd *abfd = bfd_openw(dev_name, "srec");
|
||||
asection *a;
|
||||
|
||||
bfd_set_format(abfd, bfd_object);
|
||||
a = bfd_make_section(abfd, ".text");
|
||||
a->vma = memaddr;
|
||||
a->_raw_size = len;
|
||||
a->flags = SEC_LOAD | SEC_HAS_CONTENTS;
|
||||
hms_write_cr("tl"); /* tell hms here comes the recs */
|
||||
bfd_set_section_contents(abfd, a, myaddr, 0, len);
|
||||
bfd_close(abfd);
|
||||
|
||||
sprintf(buffer,"M.B %4x =", memaddr+done);
|
||||
hms_write(buffer,10);
|
||||
for (idx = 0; idx < thisgo; idx++)
|
||||
{
|
||||
char buf[20];
|
||||
sprintf(buf, "%2x ", myaddr[idx+done]);
|
||||
hms_write(buf, 3);
|
||||
}
|
||||
hms_write_cr("");
|
||||
expect_prompt();
|
||||
done += thisgo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
hms_files_info ()
|
||||
{
|
||||
printf_filtered("\tAttached to %s at %d baud and running program %s\n",
|
||||
dev_name, baudrate, bfd_get_filename(exec_bfd));
|
||||
char *file = "nothing";
|
||||
if (exec_bfd)
|
||||
file = bfd_get_filename(exec_bfd);
|
||||
|
||||
if (exec_bfd)
|
||||
#ifdef __GO32__
|
||||
printf_filtered("\tAttached to DOS asynctsr and running program %s\n",file);
|
||||
#else
|
||||
printf_filtered("\tAttached to %s at %d baud and running program %s\n",file);
|
||||
#endif
|
||||
printf_filtered("\ton an H8/300 processor.\n");
|
||||
}
|
||||
|
||||
@ -1431,17 +1268,9 @@ hms_read_inferior_memory(memaddr, myaddr, len)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
hms_write_cr(" ");
|
||||
expect_prompt();
|
||||
|
||||
|
||||
|
||||
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
/* This routine is run as a hook, just before the main command loop is
|
||||
@ -1457,29 +1286,6 @@ hms_before_main_loop ()
|
||||
extern jmp_buf to_top_level;
|
||||
|
||||
push_target (&hms_ops);
|
||||
#if 0
|
||||
|
||||
while (current_target != &hms_ops) {
|
||||
/* remote tty not specified yet */
|
||||
if ( instream == stdin ){
|
||||
printf("\nEnter device and filename, or \"quit\" to quit: ");
|
||||
fflush( stdout );
|
||||
}
|
||||
fgets( ttyname, sizeof(ttyname)-1, stdin );
|
||||
|
||||
if ( !strcmp("quit", ttyname) ){
|
||||
exit(1);
|
||||
}
|
||||
|
||||
hms_open( ttyname, 1 );
|
||||
|
||||
/* Now that we have a tty open for talking to the remote machine,
|
||||
download the executable file if one was specified. */
|
||||
if ( !setjmp(to_top_level) && exec_bfd ) {
|
||||
target_load (bfd_get_filename (exec_bfd), 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1490,23 +1296,25 @@ hms_insert_breakpoint(addr, save)
|
||||
CORE_ADDR addr;
|
||||
char *save; /* Throw away, let hms save instructions */
|
||||
{
|
||||
|
||||
DENTER("hms_insert_breakpoint()");
|
||||
check_open();
|
||||
|
||||
if (num_brkpts < MAX_BREAKS) {
|
||||
if (num_brkpts < MAX_BREAKS)
|
||||
{
|
||||
char buffer[100];
|
||||
num_brkpts++;
|
||||
sprintf(buffer,"b %x", addr & 0xffff);
|
||||
hms_write_cr(buffer);
|
||||
expect_prompt ();
|
||||
DEXIT("hms_insert_breakpoint() success");
|
||||
return(0); /* Success */
|
||||
} else {
|
||||
return(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf_filtered(stderr,
|
||||
"Too many break points, break point not installed\n");
|
||||
DEXIT("hms_insert_breakpoint() failure");
|
||||
return(1); /* Failure */
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
@ -1517,7 +1325,8 @@ CORE_ADDR addr;
|
||||
char *save; /* Throw away, let hms save instructions */
|
||||
{
|
||||
DENTER("hms_remove_breakpoint()");
|
||||
if (num_brkpts > 0) {
|
||||
if (num_brkpts > 0)
|
||||
{
|
||||
char buffer[100];
|
||||
|
||||
num_brkpts--;
|
||||
@ -1536,12 +1345,11 @@ hms_clear_breakpoints()
|
||||
{
|
||||
|
||||
DENTER("hms_clear_breakpoint()");
|
||||
if (OPEN(hms_desc)) {
|
||||
if (is_open) {
|
||||
hms_write_cr("b -");
|
||||
expect_prompt ();
|
||||
}
|
||||
num_brkpts = 0;
|
||||
|
||||
DEXIT("hms_clear_breakpoint()");
|
||||
}
|
||||
static void
|
||||
@ -1549,39 +1357,14 @@ hms_mourn()
|
||||
{
|
||||
DENTER("hms_mourn()");
|
||||
hms_clear_breakpoints();
|
||||
/* pop_target (); /* Pop back to no-child state */
|
||||
generic_mourn_inferior ();
|
||||
DEXIT("hms_mourn()");
|
||||
}
|
||||
|
||||
/* Display everthing we read in from the hms until we match/see the
|
||||
* specified string
|
||||
*/
|
||||
static int
|
||||
display_until(str)
|
||||
char *str;
|
||||
{
|
||||
int i=0,j,c;
|
||||
|
||||
while (c=readchar()) {
|
||||
if (c==str[i]) {
|
||||
i++;
|
||||
if (i == strlen(str)) return;
|
||||
} else {
|
||||
if (i) {
|
||||
for (j=0 ; j<i ; j++) /* Put everthing we matched */
|
||||
putchar(str[j]);
|
||||
i=0;
|
||||
}
|
||||
putchar(c);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Put a command string, in args, out to the hms. The hms is assumed to
|
||||
be in raw mode, all writing/reading done through hms_desc.
|
||||
be in raw mode, all writing/reading done through desc.
|
||||
Ouput from the hms is placed on the users terminal until the
|
||||
prompt from the hms is seen.
|
||||
FIXME: Can't handle commands that take input. */
|
||||
@ -1597,11 +1380,9 @@ hms_com (args, fromtty)
|
||||
|
||||
/* Clear all input so only command relative output is displayed */
|
||||
|
||||
|
||||
hms_write_cr(args);
|
||||
hms_write("\030",1);
|
||||
expect_prompt();
|
||||
|
||||
}
|
||||
|
||||
/* Define the target subroutine names */
|
||||
@ -1634,36 +1415,36 @@ by a serial line.",
|
||||
hms_quiet()
|
||||
{
|
||||
quiet = ! quiet;
|
||||
if (quiet)
|
||||
printf_filtered("Snoop disabled\n");
|
||||
else
|
||||
printf_filtered("Snoop enabled\n");
|
||||
|
||||
}
|
||||
|
||||
hms_device(s)
|
||||
char *s;
|
||||
{
|
||||
if (s) {
|
||||
if (s)
|
||||
{
|
||||
dev_name = get_word(&s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
hms_speed(s)
|
||||
char *s;
|
||||
{
|
||||
check_open();
|
||||
|
||||
check_open();
|
||||
|
||||
if (s)
|
||||
{
|
||||
char buffer[100];
|
||||
int newrate = atoi(s);
|
||||
int which = 0;
|
||||
while (baudtab[which].rate != newrate)
|
||||
{
|
||||
if (baudtab[which].rate == -1)
|
||||
{
|
||||
if (!serial_setbaudrate(newrate))
|
||||
error("Can't use %d baud\n", newrate);
|
||||
}
|
||||
which++;
|
||||
}
|
||||
|
||||
printf_filtered("Checking target is in sync\n");
|
||||
|
||||
@ -1687,12 +1468,14 @@ _initialize_remote_hms ()
|
||||
"Send a command to the HMS monitor.");
|
||||
add_com ("snoop", class_obscure, hms_quiet,
|
||||
"Show what commands are going to the monitor");
|
||||
|
||||
add_com ("device", class_obscure, hms_device,
|
||||
"Set the terminal line for HMS communications");
|
||||
|
||||
add_com ("speed", class_obscure, hms_speed,
|
||||
"Set the terminal line speed for HMS communications");
|
||||
|
||||
dev_name = serial_default_name();
|
||||
}
|
||||
|
||||
|
||||
|
330
gdb/ser-go32.c
Normal file
330
gdb/ser-go32.c
Normal file
@ -0,0 +1,330 @@
|
||||
/* Remote serial interface for GO32
|
||||
|
||||
Copyright 1992
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GDB.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/dos.h>
|
||||
|
||||
#include "defs.h"
|
||||
#include "serial.h"
|
||||
|
||||
|
||||
#define SIGNATURE 0x4154
|
||||
#define VERSION 1
|
||||
#define OFFSET 0x104
|
||||
|
||||
/*#define MONO 1*/
|
||||
|
||||
#define dprintf if(0)printf
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define far
|
||||
#define peek(a,b) (*(unsigned short *)(0xe0000000 + (a)*16 + (b)))
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
short jmp_op;
|
||||
short signature;
|
||||
short version;
|
||||
short buffer_start;
|
||||
short buffer_end;
|
||||
short getp;
|
||||
short putp;
|
||||
short iov;
|
||||
} ASYNC_STRUCT;
|
||||
|
||||
static ASYNC_STRUCT far *async;
|
||||
static int iov;
|
||||
#define com_rb iov
|
||||
#define com_tb iov
|
||||
#define com_ier iov+1
|
||||
#define com_ifr iov+2
|
||||
#define com_bfr iov+3
|
||||
#define com_mcr iov+4
|
||||
#define com_lsr iov+5
|
||||
#define com_msr iov+6
|
||||
|
||||
#if MONO
|
||||
#include <sys/pc.h>
|
||||
static int mono_pos=0;
|
||||
#define mono_rx 0x07
|
||||
#define mono_tx 0x70
|
||||
|
||||
void mono_put(char byte, char attr)
|
||||
{
|
||||
ScreenSecondary[320+mono_pos+80] = 0x0720;
|
||||
ScreenSecondary[320+mono_pos] = (attr<<8) | (byte&0xff);
|
||||
mono_pos = (mono_pos+1) % 1200;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static char far *aptr(short p)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
return (char *)((unsigned)async - OFFSET + p);
|
||||
#else
|
||||
return (char far *)MK_FP(FP_SEG(async), p);
|
||||
#endif
|
||||
}
|
||||
|
||||
static ASYNC_STRUCT far *getivec(int which)
|
||||
{
|
||||
ASYNC_STRUCT far *a;
|
||||
|
||||
if (peek(0, which*4) != OFFSET)
|
||||
return 0;
|
||||
#ifdef __GNUC__
|
||||
a = (ASYNC_STRUCT *)(0xe0000000 + peek(0, which*4+2)*16 + peek(0, which*4));
|
||||
|
||||
#else
|
||||
a = (ASYNC_STRUCT far *)MK_FP(peek(0,which*4+2),peek(0,which*4));
|
||||
#endif
|
||||
if (a->signature != SIGNATURE)
|
||||
return 0;
|
||||
if (a->version != VERSION)
|
||||
return 0;
|
||||
return a;
|
||||
}
|
||||
|
||||
int dos_async_init()
|
||||
{
|
||||
int i;
|
||||
ASYNC_STRUCT far *a1;
|
||||
ASYNC_STRUCT far *a2;
|
||||
a1 = getivec(12);
|
||||
a2 = getivec(11);
|
||||
async = 0;
|
||||
if (a1)
|
||||
async = a1;
|
||||
if (a2)
|
||||
async = a2;
|
||||
if (a1 && a2)
|
||||
{
|
||||
if (a1 < a2)
|
||||
async = a1;
|
||||
else
|
||||
async = a2;
|
||||
}
|
||||
if (async == 0)
|
||||
{
|
||||
error("GDB can not connect to asynctsr program, check that it is installed\n\
|
||||
and that serial I/O is not being redirected (perhaps by NFS)\n\n\
|
||||
example configuration:\n\
|
||||
C> mode com2:9600,n,8,1,p\n\
|
||||
C> asynctsr 2\n\
|
||||
C> gdb \n");
|
||||
|
||||
}
|
||||
iov = async->iov;
|
||||
outportb(com_ier, 0x0f);
|
||||
outportb(com_bfr, 0x03);
|
||||
outportb(com_mcr, 0x0b);
|
||||
async->getp = async->putp = async->buffer_start;
|
||||
|
||||
#if MONO
|
||||
for (i=0; i<1200; i++)
|
||||
ScreenSecondary[320+i] = 0x0720;
|
||||
#endif
|
||||
if (iov > 0x300)
|
||||
return 1;
|
||||
else
|
||||
return 2;
|
||||
}
|
||||
|
||||
dos_async_tx(char c)
|
||||
{
|
||||
dprintf("dos_async_tx: enter %x - with IOV %x", c, com_lsr);
|
||||
fflush(stdout);
|
||||
while (~inportb(com_lsr) & 0x20);
|
||||
outportb(com_tb, c);
|
||||
#if MONO
|
||||
mono_put(c, mono_tx);
|
||||
#endif
|
||||
dprintf("exit\n");
|
||||
}
|
||||
|
||||
int dos_async_ready()
|
||||
{
|
||||
return (async->getp != async->putp);
|
||||
}
|
||||
|
||||
int dos_async_rx()
|
||||
{
|
||||
char rv;
|
||||
dprintf("dos_async_rx: enter - ");
|
||||
fflush(stdout);
|
||||
while (!dos_async_ready())
|
||||
if (kbhit())
|
||||
{
|
||||
printf("abort!\n");
|
||||
return 0;
|
||||
}
|
||||
dprintf("async=%x getp=%x\n", async, async->getp);
|
||||
fflush(stdout);
|
||||
rv = *aptr(async->getp++);
|
||||
#if MONO
|
||||
mono_put(rv, mono_rx);
|
||||
#endif
|
||||
if (async->getp >= async->buffer_end)
|
||||
async->getp = async->buffer_start;
|
||||
dprintf("exit %x\n", rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int dos_kb_ready()
|
||||
{
|
||||
return (peek(0x40,0x1a) != peek(0x40,0x1c));
|
||||
}
|
||||
|
||||
int dos_kb_rx()
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
return getkey();
|
||||
#else
|
||||
return getch();
|
||||
#endif
|
||||
}
|
||||
|
||||
int dosasync_read(int fd, char *buffer, int length, int timeout)
|
||||
{
|
||||
long now, then;
|
||||
int l = length;
|
||||
time (&now);
|
||||
then = now+timeout;
|
||||
dprintf("dosasync_read: enter(%d,%d)\n", length, timeout);
|
||||
while (l--)
|
||||
{
|
||||
if (timeout)
|
||||
{
|
||||
while (!dos_async_ready())
|
||||
{
|
||||
time (&now);
|
||||
if (now == then)
|
||||
{
|
||||
dprintf("dosasync_read: timeout(%d)\n", length-l-1);
|
||||
return length-l-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
*buffer++ = dos_async_rx();
|
||||
}
|
||||
dprintf("dosasync_read: exit %d\n", length);
|
||||
return length;
|
||||
}
|
||||
|
||||
int dosasync_write(int fd, CONST char *buffer, int length)
|
||||
{
|
||||
int l = length;
|
||||
while (l--)
|
||||
dos_async_tx(*buffer++);
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *strlwr(char *s)
|
||||
{
|
||||
char *p = s;
|
||||
while (*s)
|
||||
{
|
||||
if ((*s >= 'A') && (*s <= 'Z'))
|
||||
*s += 'a'-'A';
|
||||
s++;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
sigsetmask() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int fd;
|
||||
|
||||
CONST char *
|
||||
DEFUN_VOID(serial_default_name)
|
||||
{
|
||||
return "com1";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DEFUN_VOID(serial_raw)
|
||||
{
|
||||
/* Always in raw mode */
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DEFUN(serial_open,(name),
|
||||
CONST char *name)
|
||||
{
|
||||
fd = dos_async_init();
|
||||
if (fd) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
DEFUN(serial_timedreadchar,(to, ok),
|
||||
int to AND
|
||||
int *ok)
|
||||
{
|
||||
char buf;
|
||||
if ( dosasync_read(fd, &buf, 1, to))
|
||||
{
|
||||
*ok = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ok = 0;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
int
|
||||
DEFUN(serial_setbaudrate,(rate),
|
||||
int rate)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
DEFUN(serial_nextbaudrate,(rate),
|
||||
int rate)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
DEFUN(serial_write,(str, len),
|
||||
CONST char *str AND
|
||||
int len)
|
||||
{
|
||||
dosasync_write(fd, str, len);
|
||||
}
|
||||
|
||||
int
|
||||
DEFUN_VOID(serial_close)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
208
gdb/ser-termios.c
Normal file
208
gdb/ser-termios.c
Normal file
@ -0,0 +1,208 @@
|
||||
/* Remote serial interface for OS's with termios
|
||||
|
||||
Copyright 1992
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GDB.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include "defs.h"
|
||||
#include "serial.h"
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
static int desc;
|
||||
|
||||
|
||||
CONST char *
|
||||
DEFUN_VOID(serial_default_name)
|
||||
{
|
||||
return "/dev/ttya";
|
||||
}
|
||||
|
||||
void
|
||||
DEFUN_VOID(serial_raw)
|
||||
{
|
||||
/* Now happens inside of serial_open */
|
||||
}
|
||||
|
||||
static struct termios otermios;
|
||||
static int oflags;
|
||||
|
||||
void
|
||||
DEFUN_VOID(serial_normal)
|
||||
{
|
||||
fcntl(desc, oflags, 0);
|
||||
|
||||
if (tcsetattr(desc, TCSANOW, &otermios))
|
||||
{
|
||||
printf("tcgetattr failed: errno=%d\n", errno);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
DEFUN(serial_open,(name),
|
||||
CONST char *name)
|
||||
{
|
||||
struct termios termios;
|
||||
|
||||
desc = open (name, O_RDWR);
|
||||
if (desc < 0)
|
||||
perror("Open failed: ");
|
||||
|
||||
oflags = fcntl(desc, F_GETFL, 0);
|
||||
|
||||
fcntl(desc, F_SETFL, oflags|FNDELAY);
|
||||
|
||||
if (tcgetattr(desc, &termios)) {
|
||||
printf("tcgetattr failed: errno=%d\n", errno);
|
||||
}
|
||||
|
||||
otermios = termios;
|
||||
|
||||
termios.c_iflag = 0;
|
||||
termios.c_oflag = 0;
|
||||
termios.c_lflag = 0;
|
||||
termios.c_cc[VMIN] = 0;
|
||||
termios.c_cc[VTIME] = 0;
|
||||
|
||||
if (tcsetattr(desc, TCSANOW, &termios)) {
|
||||
printf("tcgetattr failed: errno=%d\n", errno);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
DEFUN(serial_timedreadchar,(timeout, ok),
|
||||
int timeout AND
|
||||
int *ok)
|
||||
{
|
||||
unsigned char buf;
|
||||
fd_set readfds;
|
||||
int val;
|
||||
struct timeval tv;
|
||||
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(desc, &readfds);
|
||||
|
||||
tv.tv_sec = timeout;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
val = select(desc+1, &readfds, 0, 0, &tv);
|
||||
|
||||
if (val > 0 && FD_ISSET(desc, &readfds))
|
||||
{
|
||||
val = read (desc, &buf, 1);
|
||||
|
||||
if (val == 1)
|
||||
{
|
||||
*ok = 1;
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
*ok = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Translate baud rates from integers to damn B_codes. Unix should
|
||||
have outgrown this crap years ago, but even POSIX wouldn't buck it. */
|
||||
|
||||
#ifndef B19200
|
||||
#define B19200 EXTA
|
||||
#endif
|
||||
#ifndef B38400
|
||||
#define B38400 EXTB
|
||||
#endif
|
||||
|
||||
static struct {int rate, damn_b;} baudtab[] = {
|
||||
{9600, B9600},
|
||||
|
||||
{19200, B19200},
|
||||
#if 0
|
||||
{300, B300},
|
||||
{1200, B1200},
|
||||
{2400, B2400},
|
||||
{4800, B4800},
|
||||
#endif
|
||||
{-1, -1},
|
||||
};
|
||||
|
||||
static int
|
||||
DEFUN(damn_b,(rate),
|
||||
int rate)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; baudtab[i].rate != -1; i++)
|
||||
{
|
||||
if (rate == baudtab[i].rate)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
DEFUN(serial_setbaudrate,(rate),int rate)
|
||||
{
|
||||
struct termios termios;
|
||||
|
||||
if (tcgetattr(desc, &termios)) {
|
||||
printf("tcgetattr failed: errno=%d\n", errno);
|
||||
}
|
||||
|
||||
cfsetospeed(&termios, baudtab[damn_b(rate)].damn_b);
|
||||
cfsetispeed(&termios, baudtab[damn_b(rate)].damn_b);
|
||||
|
||||
if (tcsetattr(desc, TCSANOW, &termios)) {
|
||||
printf("tcgetattr failed: errno=%d\n", errno);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
DEFUN(serial_nextbaudrate,(rate),
|
||||
int rate)
|
||||
{
|
||||
int lookup;
|
||||
lookup = damn_b(rate);
|
||||
if (lookup == -1)
|
||||
return baudtab[0].rate;
|
||||
lookup++;
|
||||
if (baudtab[lookup].rate == -1)
|
||||
return baudtab[0].rate;
|
||||
return baudtab[lookup].rate;
|
||||
}
|
||||
|
||||
int
|
||||
DEFUN(serial_write,(str, len),
|
||||
CONST char *str AND
|
||||
int len)
|
||||
{
|
||||
write (desc, str, len);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DEFUN_VOID(serial_close)
|
||||
{
|
||||
close(desc);
|
||||
}
|
62
gdb/serial.h
Normal file
62
gdb/serial.h
Normal file
@ -0,0 +1,62 @@
|
||||
/* Remote Serial support interface definitions for GDB, the GNU Debugger.
|
||||
Copyright 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GDB.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* Return a sensible default name for a serial device, something which
|
||||
can be used as an argument to serial_open */
|
||||
|
||||
CONST char *EXFUN(serial_default_name,(void));
|
||||
|
||||
/* Try to open the serial device "name", return 1 if ok, 0 if not. */
|
||||
|
||||
int EXFUN(serial_open,(CONST char *name));
|
||||
|
||||
/* Turn the port into raw mode */
|
||||
|
||||
void EXFUN(serial_raw,(void));
|
||||
|
||||
|
||||
/* Turn the port into normal mode */
|
||||
|
||||
void EXFUN(serial_normal,(void));
|
||||
|
||||
|
||||
/* Read one char from the serial device with timeout, return char, and
|
||||
set ok if ok */
|
||||
|
||||
int EXFUN(serial_timedreadchar,(int to , int *ok));
|
||||
|
||||
|
||||
/* Set the baudrate to the value supplied, and return 1, or fail and
|
||||
return 0 */
|
||||
|
||||
int EXFUN(serial_setbaudrate,(int to));
|
||||
|
||||
/* Return the next rate in the sequence, or return 0 for a fail*/
|
||||
|
||||
int EXFUN(serial_nextbaudrate,(int rate));
|
||||
|
||||
|
||||
/* Write some chars to the device, return 1 if ok, 0 if not */
|
||||
|
||||
int EXFUN(serial_write,( CONST char *str , int len));
|
||||
|
||||
|
||||
/* Close the serial port */
|
||||
|
||||
int EXFUN(serial_close,(void));
|
@ -287,9 +287,9 @@ UNSIGNED_SHORT(read_memory_integer (read_register (SP_REGNUM), 2))
|
||||
|
||||
|
||||
#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
|
||||
{ bcopy ((FROM), (TO), 2); }
|
||||
{ memcpy((TO), (FROM), 2); }
|
||||
#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
|
||||
{ bcopy ((FROM), (TO), 4); }
|
||||
{ memcpy((TO), (FROM), 2); }
|
||||
|
||||
#define BEFORE_MAIN_LOOP_HOOK \
|
||||
hms_before_main_loop();
|
||||
@ -303,3 +303,5 @@ typedef unsigned short INSN_WORD;
|
||||
#define ADDR_BITS_SET(addr) (((addr)))
|
||||
|
||||
#define read_memory_short(x) (read_memory_integer(x,2) & 0xffff)
|
||||
#define DONT_USE_REMOTE
|
||||
|
||||
|
@ -551,7 +551,7 @@ value_as_pointer (val)
|
||||
{
|
||||
/* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure
|
||||
whether we want this to be true eventually. */
|
||||
return value_as_long (val);
|
||||
return ADDR_BITS_REMOVE(value_as_long (val));
|
||||
}
|
||||
|
||||
/* Unpack raw data (copied from debugee, target byte order) at VALADDR
|
||||
@ -705,14 +705,14 @@ unpack_long (type, valaddr)
|
||||
{
|
||||
if (len == sizeof(long))
|
||||
{
|
||||
long retval;
|
||||
unsigned long retval;
|
||||
bcopy (valaddr, &retval, sizeof(retval));
|
||||
SWAP_TARGET_AND_HOST (&retval, sizeof(retval));
|
||||
return retval;
|
||||
}
|
||||
else if (len == sizeof(short))
|
||||
{
|
||||
short retval;
|
||||
unsigned short retval;
|
||||
bcopy (valaddr, &retval, len);
|
||||
SWAP_TARGET_AND_HOST (&retval, len);
|
||||
return retval;
|
||||
|
5
gdb/xm-go32.h
Normal file
5
gdb/xm-go32.h
Normal file
@ -0,0 +1,5 @@
|
||||
#undef EIO
|
||||
#define EIO 0
|
||||
#define SYS_SIGLIST_MISSING 1
|
||||
#define HOST_BYTE_ORDER LITTLE_ENDIAN
|
||||
#include "fopen-bin.h"
|
Loading…
Reference in New Issue
Block a user