Article View: gnu.gdb.bug
Article #648remote.c fixes & hp9k320 support
From: Glenn Engel
Date: Sat, 31 Dec 1988 18:30
Date: Sat, 31 Dec 1988 18:30
405 lines
10023 bytes
10023 bytes
The following patches support remote process debugging on hp-ux (hp9k320).
These patches only support the form of attach where a device file is specified
for remote communication.
These patches are for gdb3.0 :
1) hp9k320-dep.c Addition of attach and detach routines.
2) m-hp9k320.h defined ATTACH_DETACH
3) remote.c Numerous generic bug fixes applicable to all machines.
Thanks for including these in the next release,
--
| Glenn R. Engel
| Hewlett-Packard
| (206) 335-2066
| glenne%hplsla@hplabs.hp.com
*** ../dist-gdb/hp9k320-dep.c Tue Nov 15 07:30:28 1988
--- hp9k320-dep.c Sat Dec 31 09:50:57 1988
***************
*** 40,45
#include <sys/stat.h>
extern int errno;
/* This function simply calls ptrace with the given arguments.
It exists so that all calls to ptrace are isolated in this
--- 39,45 -----
#include <sys/stat.h>
extern int errno;
+ extern int attach_flag;
/* This function simply calls ptrace with the given arguments.
It exists so that all calls to ptrace are isolated in this
***************
*** 93,98
perror_with_name ("ptrace");
}
}
#define INFERIOR_AR0(u) \
((ptrace \
--- 94,130 -----
perror_with_name ("ptrace");
}
}
+
+ #ifdef ATTACH_DETACH
+
+ /* Start debugging the process whose number is PID. */
+
+ attach (pid)
+ int pid;
+ {
+ errno = 0;
+ /* ptrace (PTRACE_ATTACH, pid, 0, 0); */ /* how do we do this ? */
+ if (errno)
+ perror_with_name ("ptrace");
+ attach_flag = 1;
+ return pid;
+ }
+
+ /* Stop debugging the process whose number is PID
+ and continue it with signal number SIGNAL.
+ SIGNAL = 0 means just continue it. */
+
+ void
+ detach (signal)
+ int signal;
+ {
+ errno = 0;
+ /* ptrace (PTRACE_DETACH, inferior_pid, 1, signal); */ /* how do we do this ? */
+ if (errno)
+ perror_with_name ("ptrace");
+ attach_flag = 0;
+ }
+ #endif /* ATTACH_DETACH */
#define INFERIOR_AR0(u) \
((ptrace \
***************
*** 190,201
struct user u;
register int regno;
register unsigned int ar0_offset;
!
! ar0_offset = (INFERIOR_AR0 (u));
! for (regno = 0; (regno < FP0_REGNUM); regno++)
! fetch_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
! for (; (regno < NUM_REGS); regno++)
! fetch_inferior_register (regno, (FP_REGISTER_ADDR (u, regno)));
}
/* Store our register values back into the inferior.
--- 222,238 -----
struct user u;
register int regno;
register unsigned int ar0_offset;
! extern char registers[];
! if (remote_debugging)
! remote_fetch_registers (registers);
! else
! {
! ar0_offset = (INFERIOR_AR0 (u));
! for (regno = 0; (regno < FP0_REGNUM); regno++)
! fetch_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
! for (; (regno < NUM_REGS); regno++)
! fetch_inferior_register (regno, (FP_REGISTER_ADDR (u, regno)));
! }
}
/* Store our register values back into the inferior.
***************
*** 207,214
{
struct user u;
register unsigned int ar0_offset;
!
! if (regno >= FP0_REGNUM)
{
store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno)));
return;
--- 244,253 -----
{
struct user u;
register unsigned int ar0_offset;
! extern char registers[];
! if (remote_debugging)
! remote_store_registers (registers);
! else
{
if (regno >= FP0_REGNUM)
{
***************
*** 210,218
if (regno >= FP0_REGNUM)
{
! store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno)));
! return;
! }
ar0_offset = (INFERIOR_AR0 (u));
if (regno >= 0)
--- 249,259 -----
remote_store_registers (registers);
else
{
! if (regno >= FP0_REGNUM)
! {
! store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno)));
! return;
! }
ar0_offset = (INFERIOR_AR0 (u));
if (regno >= 0)
***************
*** 214,224
return;
}
! ar0_offset = (INFERIOR_AR0 (u));
! if (regno >= 0)
! {
! store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
! return;
}
for (regno = 0; (regno < FP0_REGNUM); regno++)
--- 255,271 -----
return;
}
! ar0_offset = (INFERIOR_AR0 (u));
! if (regno >= 0)
! {
! store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
! return;
! }
!
! for (regno = 0; (regno < FP0_REGNUM); regno++)
! store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
! for (; (regno < NUM_REGS); regno++)
! store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno)));
}
return;
}
***************
*** 220,230
store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
return;
}
-
- for (regno = 0; (regno < FP0_REGNUM); regno++)
- store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
- for (; (regno < NUM_REGS); regno++)
- store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno)));
return;
}
--- 267,272 -----
for (; (regno < NUM_REGS); regno++)
store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno)));
}
return;
}
*** ../dist-gdb/remote.c Wed Nov 23 13:39:54 1988
--- remote.c Fri Dec 30 11:26:58 1988
***************
*** 101,107
/* Descriptor for I/O to remote machine. */
int remote_desc;
! #define PBUFSIZ 300
static void remote_send ();
static void putpkt ();
--- 101,108 -----
/* Descriptor for I/O to remote machine. */
int remote_desc;
! /* need at least 360 bytes for hex form of 680x0/6888x registers */
! #define PBUFSIZ 400
static void remote_send ();
static void putpkt ();
***************
*** 128,134
ioctl (remote_desc, TIOCGETP, &sg);
#ifdef HAVE_TERMIO
! sg.c_lflag &= ~ICANON;
#else
sg.sg_flags = RAW;
#endif
--- 129,137 -----
ioctl (remote_desc, TIOCGETP, &sg);
#ifdef HAVE_TERMIO
! sg.c_cc[VMIN] = 1; /* read at least 1 char */
! sg.c_cc[VTIME] = 0;
! sg.c_lflag &= ~(ICANON | ECHO);
#else
sg.sg_flags = RAW;
#endif
***************
*** 187,193
remote_wait (status)
WAITTYPE *status;
{
! char buf[PBUFSIZ];
WSETEXIT ((*status), 0);
getpkt (buf);
--- 190,196 -----
remote_wait (status)
WAITTYPE *status;
{
! unsigned char buf[PBUFSIZ];
WSETEXIT ((*status), 0);
getpkt (buf);
***************
*** 245,250
*p++ = tohex ((regs[i] >> 4) & 0xf);
*p++ = tohex (regs[i] & 0xf);
}
remote_send (buf);
}
--- 248,254 -----
*p++ = tohex ((regs[i] >> 4) & 0xf);
*p++ = tohex (regs[i] & 0xf);
}
+ *p = '\0';
remote_send (buf);
}
***************
*** 311,316
*p++ = tohex ((myaddr[i] >> 4) & 0xf);
*p++ = tohex (myaddr[i] & 0xf);
}
remote_send (buf);
}
--- 315,321 -----
*p++ = tohex ((myaddr[i] >> 4) & 0xf);
*p++ = tohex (myaddr[i] & 0xf);
}
+ *p = '\0';
remote_send (buf);
}
***************
*** 395,401
char *buf;
{
int i;
! char csum = 0;
char buf2[500];
char buf3[1];
int cnt = strlen (buf);
--- 400,406 -----
char *buf;
{
int i;
! unsigned char csum = 0;
char buf2[500];
char buf3[1];
int cnt = strlen (buf);
***************
*** 443,449
char *buf;
{
char *bp;
! char csum = 0;
int c, c1, c2;
extern kiodebug;
--- 448,454 -----
char *buf;
{
char *bp;
! unsigned char csum;
int c, c1, c2;
extern kiodebug;
***************
*** 449,454
while (1)
{
while ((c = readchar()) != '$');
bp = buf;
--- 454,460 -----
while (1)
{
+ csum = 0;
while ((c = readchar()) != '$');
bp = buf;
*** ../dist-gdb/m-hp9k320.h Fri Dec 9 12:44:34 1988
--- m-hp9k320.h Fri Dec 30 11:12:04 1988
***************
*** 22,27
#define HP9K320
#endif
/* Set flag to indicate whether HP's assembler is in use. */
#ifdef __GNU__
#ifdef __HPUX_ASM__
--- 22,31 -----
#define HP9K320
#endif
+ /* parameter to lseek - set pointer to value, increment pointer */
+ #define L_SET 0
+ #define L_INCR 1
+
/* Set flag to indicate whether HP's assembler is in use. */
#ifdef __GNU__
#ifdef __HPUX_ASM__
***************
*** 245,250
? (&u.u_pcb.pcb_mc68881[FMC68881_R0 + (((regno) - FP0_REGNUM) * 3)]) \
: (&u.u_pcb.pcb_mc68881[FMC68881_C + ((regno) - FPC_REGNUM)]))) \
- ((char *) (& u)))
/* It is safe to look for symsegs on a Sun, because Sun's ld
does not screw up with random garbage at end of file. */
--- 249,258 -----
? (&u.u_pcb.pcb_mc68881[FMC68881_R0 + (((regno) - FP0_REGNUM) * 3)]) \
: (&u.u_pcb.pcb_mc68881[FMC68881_C + ((regno) - FPC_REGNUM)]))) \
- ((char *) (& u)))
+
+ /* Do implement the attach and detach commands. */
+
+ #define ATTACH_DETACH
/* It is safe to look for symsegs on a Sun, because Sun's ld
does not screw up with random garbage at end of file. */
Technical Details
Message-ID:
<8812311830.AA05148@labgre.HP.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!HPLABS.HP.COM!glenne%hplslaShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!HPLABS.HP.COM!glenne%hplsla From: glenne%hplsla@HPLABS.HP.COM (Glenn Engel) Newsgroups: gnu.gdb.bug Subject: remote.c fixes & hp9k320 support Message-ID: <8812311830.AA05148@labgre.HP.COM> Date: 31 Dec 88 18:30:47 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 405