From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15543 invoked by alias); 17 Feb 2003 20:56:30 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 15536 invoked from network); 17 Feb 2003 20:56:29 -0000 Received: from unknown (HELO hub.ott.qnx.com) (209.226.137.76) by 172.16.49.205 with SMTP; 17 Feb 2003 20:56:29 -0000 Received: from smtp.ott.qnx.com (smtp.ott.qnx.com [10.0.2.158]) by hub.ott.qnx.com (8.9.3/8.9.3) with ESMTP id PAA14503 for ; Mon, 17 Feb 2003 15:45:00 -0500 Received: from catdog ([10.4.2.2]) by smtp.ott.qnx.com (8.8.8/8.6.12) with SMTP id PAA26825 for ; Mon, 17 Feb 2003 15:56:28 -0500 Message-ID: <067a01c2d6c7$092d87d0$0202040a@catdog> From: "Kris Warkentin" To: Subject: [Patch] QNX i386 native support take 2 Date: Mon, 17 Feb 2003 20:56:00 -0000 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0677_01C2D69D.20409C70" X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-SW-Source: 2003-02/txt/msg00359.txt.bz2 This is a multi-part message in MIME format. ------=_NextPart_000_0677_01C2D69D.20409C70 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-length: 1995 Here is take 2 of the patch. I decided not to make remote support configurable. It's a lot of work for the inclusion of one object and it's really just not done. If someone REALLY doesn't want remote support in a native configuration, they can just comment out remote-nto.c (as I have for this submission). cheers, Kris Top Level ChangeLog entry: 2003-03-02 Kris Warkentin kewarken@qnx.com * config.sub: Add nto i386 and multi-arch support * configure.in: add i[3456]86-*-nto* * configure: regenerate bfd/ChangeLog entry: 2003-03-02 Kris Warkentin kewarken@qnx.com * elf.c: Add qnx corefile support gdb/ChangeLog entry: 2003-03-02 Kris Warkentin kewarken@qnx.com * config/i386/i386nto.mt: New file * config/i386/nm-nto.h: New file - need to move it's define to configure or run time. * config/i386/nto.mh: New file * config/i386/tm-i386nto.h: New file - only solib stuff. * config/djgpp/fnchange.lst: add tm-i386nto.h * config/tm-qnxnto.h: New file - some signal stuff. * configure.host: add gdb_host=nto. * configure.tgt: add gdb_target=i386nto and gdb osabi GDB_OSABI_QNXNTO. * defs.h: add GDB_OSABI_QNXNTO. * nto-procfs.c: New file - native Neutrino procfs support. * nto-share/debug.h: New file - debug interface to our kernel. * nto-share/dsmsgs.h: New file - definitions for our remote protocol. * i386-nto-tdep.c: New file - i386 target specific functionality. * nto-tdep.c: New file - architecture independent functionality. * nto-tdep.h: New file - exports for nto-tdep.c * osabi.c: add "QNX Neutrino" to gdb_osabi_name array readline/ChangeLog entry: 2003-03-02 Kris Warkentin kewarken@qnx.com * Makefile.in: Check HAVE_WCWIDTH variable for conditionally compiling support/wcwidth.c * shlib/Makefile.in: Likewise * aclocal.m4: If we don't have wcwidth, define HAVE_WCWIDTH=no for Makefile generation ------=_NextPart_000_0677_01C2D69D.20409C70 Content-Type: application/octet-stream; name="qnxnto.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="qnxnto.diff" Content-length: 125971 diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/bfd/elf.c src.new/bfd/elf.c=0A= *** src.orig/bfd/elf.c Fri Feb 14 13:38:21 2003=0A= --- src.new/bfd/elf.c Fri Feb 14 12:55:54 2003=0A= *************** static bfd_boolean elfcore_grok_netbsd_p=0A= *** 97,102 ****=0A= --- 97,108 ----=0A= PARAMS ((bfd *, Elf_Internal_Note *));=0A= static bfd_boolean elfcore_grok_netbsd_note=0A= PARAMS ((bfd *, Elf_Internal_Note *));=0A= + static bfd_boolean elfcore_grok_nto_gregs=0A= + PARAMS ((bfd *, Elf_Internal_Note *, pid_t));=0A= + static bfd_boolean elfcore_grok_nto_status=0A= + PARAMS ((bfd *, Elf_Internal_Note *, pid_t *));=0A= + static bfd_boolean elfcore_grok_nto_note=0A= + PARAMS ((bfd *, Elf_Internal_Note *));=0A= =20=20=0A= /* Swap version information in and out. The version information is=0A= currently size independent. If that ever changes, this code will=0A= *************** elfcore_read_notes (abfd, offset, size)=0A= *** 7200,7205 ****=0A= --- 7206,7216 ----=0A= if (! elfcore_grok_netbsd_note (abfd, &in))=0A= goto error;=0A= }=0A= + else if (strncmp (in.namedata, "QNX", 3) =3D=3D 0)=0A= + {=0A= + if (! elfcore_grok_nto_note (abfd, &in))=0A= + goto error;=0A= + }=0A= else=0A= {=0A= if (! elfcore_grok_note (abfd, &in))=0A= *************** _bfd_elf_section_offset (abfd, info, sec=0A= *** 7402,7404 ****=0A= --- 7413,7516 ----=0A= return offset;=0A= }=0A= }=0A= +=20=0A= + static bfd_boolean=0A= + elfcore_grok_nto_status(abfd, note, tid)=0A= + bfd *abfd;=0A= + Elf_Internal_Note *note;=0A= + pid_t *tid;=0A= + {=0A= + void *ddata =3D note->descdata;=0A= + char buf[100];=0A= + char *name;=0A= + asection *sect;=0A= +=20=0A= + /* nto_procfs_status 'pid' field is at offset 0 */=0A= + elf_tdata (abfd)->core_pid =3D bfd_get_32( abfd, (bfd_byte *)ddata);=0A= +=20=0A= + /* nto_procfs_status 'tid' field is at offset 4 */=0A= + elf_tdata (abfd)->core_lwpid =3D bfd_get_32( abfd, (bfd_byte *)ddata + = 4);=0A= +=20=0A= + /* nto_procfs_status 'what' field is at offset 14 */=0A= + elf_tdata (abfd)->core_signal =3D bfd_get_16( abfd, (bfd_byte *)ddata += 14);=0A= +=20=0A= + /* pass tid back */=0A= + *tid =3D elf_tdata (abfd)->core_lwpid;=0A= +=20=0A= + /* Make a ".qnx_core_status/%d" section. */=0A= + sprintf (buf, ".qnx_core_status/%d", *tid);=0A= +=20=0A= + name =3D bfd_alloc (abfd, (bfd_size_type) strlen (buf) + 1);=0A= + if (name =3D=3D NULL)=0A= + return FALSE;=0A= + strcpy (name, buf);=0A= +=20=0A= + sect =3D bfd_make_section (abfd, name);=0A= + if (sect =3D=3D NULL)=0A= + return FALSE;=0A= +=20=0A= + sect->_raw_size =3D note->descsz;=0A= + sect->filepos =3D note->descpos;=0A= +=20=0A= + sect->flags =3D SEC_HAS_CONTENTS;=0A= + sect->alignment_power =3D 2;=0A= +=20=0A= + return (elfcore_maybe_make_sect (abfd, ".qnx_core_status", sect));=0A= + }=0A= +=20=0A= +=20=0A= + static bfd_boolean=0A= + elfcore_grok_nto_gregs(abfd, note, tid)=0A= + bfd *abfd;=0A= + Elf_Internal_Note *note;=0A= + pid_t tid;=0A= + {=0A= + char buf[100];=0A= + char *name;=0A= + asection *sect;=0A= +=20=0A= + /* Make a ".reg/%d" section. */=0A= + sprintf (buf, ".reg/%d", tid);=0A= +=20=0A= + name =3D bfd_alloc (abfd, (bfd_size_type) strlen (buf) + 1);=0A= + if (name =3D=3D NULL)=0A= + return FALSE;=0A= + strcpy (name, buf);=0A= +=20=0A= + sect =3D bfd_make_section (abfd, name);=0A= + if (sect =3D=3D NULL)=0A= + return FALSE;=0A= +=20=0A= + sect->_raw_size =3D note->descsz;=0A= + sect->filepos =3D note->descpos;=0A= +=20=0A= + sect->flags =3D SEC_HAS_CONTENTS;=0A= + sect->alignment_power =3D 2;=0A= +=20=0A= + return elfcore_maybe_make_sect (abfd, ".reg", sect);=0A= + }=0A= +=20=0A= + static bfd_boolean=0A= + elfcore_grok_nto_note (abfd, note)=0A= + bfd *abfd;=0A= + Elf_Internal_Note *note;=0A= + {=0A= + /* Every GREG section has a STATUS section before it. Store the=0A= + * tid from the previous call to pass down to the next gregs=20=0A= + * function. */=0A= + static pid_t tid =3D 1;=0A= + switch (note->type)=0A= + {=0A= + default:=0A= + return TRUE;=0A= + case 7: /* QNT_CORE_INFO */=0A= + return elfcore_make_note_pseudosection (abfd, ".qnx_core_info", note);= =0A= + case 8: /* QNT_CORE_STATUS */=0A= + return elfcore_grok_nto_status (abfd, note, &tid);=0A= + case 9: /* QNT_CORE_GREG */=0A= + return elfcore_grok_nto_gregs (abfd, note, tid);=0A= + case 10: /* QNT_CORE_FPREG */=0A= + return elfcore_grok_prfpreg (abfd, note);=0A= + }=0A= + /* NOTREACHED */=0A= + }=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/config.sub src.new/config.sub=0A= *** src.orig/config.sub Wed Jan 8 17:09:30 2003=0A= --- src.new/config.sub Fri Feb 14 16:07:18 2003=0A= *************** case $basic_machine in=0A= *** 727,732 ****=0A= --- 727,736 ----=0A= nsr-tandem)=0A= basic_machine=3Dnsr-tandem=0A= ;;=0A= + ntox86)=0A= + basic_machine=3Di386${os:--unknown}=0A= + os=3D-nto=0A= + ;;=0A= op50n-* | op60c-*)=0A= basic_machine=3Dhppa1.1-oki=0A= os=3D-proelf=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/configure.in src.new/configure.in=0A= *** src.orig/configure.in Fri Feb 14 13:38:30 2003=0A= --- src.new/configure.in Fri Feb 14 15:57:58 2003=0A= *************** case "${host}" in=0A= *** 1089,1094 ****=0A= --- 1089,1096 ----=0A= tentative_cc=3D"/usr/ccs/ATT/cc"=0A= host_makefile_frag=3D"config/mh-ncr3000"=0A= ;;=0A= + i[3456]86-*-nto*)=0A= + ;;=0A= i[[3456]]86-*-sco3.2v5*)=0A= ;;=0A= i[[3456]]86-*-sco*)=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/config/djgpp/fnchange.lst src.new/gdb/config/djgpp/fnchange.lst=0A= *** src.orig/gdb/config/djgpp/fnchange.lst Fri Feb 14 13:38:19 2003=0A= --- src.new/gdb/config/djgpp/fnchange.lst Fri Feb 14 16:04:58 2003=0A= ***************=0A= *** 90,95 ****=0A= --- 90,96 ----=0A= @V@/gdb/config/i386/nm-i386v4.h @V@/gdb/config/i386/nm-v4.h=0A= @V@/gdb/config/i386/nm-i386v42mp.h @V@/gdb/config/i386/nm-v42mp.h=0A= @V@/gdb/config/i386/tm-i386mk.h @V@/gdb/config/i386/tm-mk.h=0A= + @V@/gdb/config/i386/tm-i386nto.h @V@/gdb/config/i386/tm-nto.h=0A= @V@/gdb/config/i386/tm-i386sol2.h @V@/gdb/config/i386/tm-sol2.h=0A= @V@/gdb/config/i386/tm-i386v42mp.h @V@/gdb/config/i386/tm-v42mp.h=0A= @V@/gdb/config/i386/xm-i386mach.h @V@/gdb/config/i386/xm-mach.h=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/config/i386/i386nto.mt src.new/gdb/config/i386/i386nto.mt=0A= *** src.orig/gdb/config/i386/i386nto.mt Wed Dec 31 19:00:00 1969=0A= --- src.new/gdb/config/i386/i386nto.mt Fri Feb 14 16:02:03 2003=0A= ***************=0A= *** 0 ****=0A= --- 1,4 ----=0A= + # Target: Intel 386 running qnx6=0A= + TDEPFILES=3D i386-tdep.o i387-tdep.o corelow.o solib.o solib-svr4.o \=0A= + i386-nto-tdep.o nto-tdep.o # remote-nto.o=0A= + TM_FILE=3D tm-i386nto.h=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/config/i386/nm-nto.h src.new/gdb/config/i386/nm-nto.h=0A= *** src.orig/gdb/config/i386/nm-nto.h Wed Dec 31 19:00:00 1969=0A= --- src.new/gdb/config/i386/nm-nto.h Fri Feb 14 13:28:11 2003=0A= ***************=0A= *** 0 ****=0A= --- 1,6 ----=0A= + #ifndef _NM_NTO_H=0A= + #define _NM_NTO_H=0A= +=20=0A= + #define QNX_TARGET_CPUTYPE CPUTYPE_X86=0A= +=20=0A= + #endif /* _NM_NTO_H */=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/config/i386/nto.mh src.new/gdb/config/i386/nto.mh=0A= *** src.orig/gdb/config/i386/nto.mh Wed Dec 31 19:00:00 1969=0A= --- src.new/gdb/config/i386/nto.mh Thu Feb 13 13:18:02 2003=0A= ***************=0A= *** 0 ****=0A= --- 1,5 ----=0A= + # Host: Intel 386 running QNX=0A= +=20=0A= + NAT_FILE=3D nm-nto.h=0A= +=20=0A= + NATDEPFILES=3D nto-procfs.o=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/config/i386/tm-i386nto.h src.new/gdb/config/i386/tm-i386nto.h=0A= *** src.orig/gdb/config/i386/tm-i386nto.h Wed Dec 31 19:00:00 1969=0A= --- src.new/gdb/config/i386/tm-i386nto.h Mon Feb 17 15:21:22 2003=0A= ***************=0A= *** 0 ****=0A= --- 1,13 ----=0A= + #ifndef TM_I386NTO_H=0A= + #define TM_I386NTO_H 1=0A= +=20=0A= + /* Pick up most of what we need from the generic i386 target include file= . */=0A= + #include "i386/tm-i386.h"=0A= + #include "tm-qnxnto.h"=0A= +=20=0A= + /* Temporary until this is multi-arched */=0A= + #define HAVE_CONTINUABLE_WATCHPOINT 1=0A= +=20=0A= + #include "solib.h" /* shared lib support */=0A= +=20=0A= + #endif /* ifndef TM_I386NTO_H */=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/config/tm-qnxnto.h src.new/gdb/config/tm-qnxnto.h=0A= *** src.orig/gdb/config/tm-qnxnto.h Wed Dec 31 19:00:00 1969=0A= --- src.new/gdb/config/tm-qnxnto.h Fri Feb 14 13:28:11 2003=0A= ***************=0A= *** 0 ****=0A= --- 1,57 ----=0A= + /* Target machine sub-description for QNX Neutrino version 6.=0A= + This is included by other tm-*.h files to specify nto specific=0A= + stuff. Copyright 2002 Free Software Foundation, Inc.=0A= +=20=0A= + This file is part of GDB.=0A= +=20=0A= + This program is free software; you can redistribute it and/or modify= =0A= + it under the terms of the GNU General Public License as published by= =0A= + the Free Software Foundation; either version 2 of the License, or=0A= + (at your option) any later version.=0A= +=20=0A= + This program is distributed in the hope that it will be useful,=0A= + but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A= + GNU General Public License for more details.=0A= +=20=0A= + You should have received a copy of the GNU General Public License=0A= + along with this program; if not, write to the Free Software=0A= + Foundation, Inc., 59 Temple Place - Suite 330,=0A= + Boston, MA 02111-1307, USA. */=0A= +=20=0A= + #ifndef _TM_QNXNTO_H=0A= + #define _TM_QNXNTO_H=0A= +=20=0A= + #include "tm-sysv4.h"=0A= +=20=0A= + /* Setup the valid realtime signal range. */=0A= + #define REALTIME_LO 41=0A= + #define REALTIME_HI 56=0A= +=20=0A= + /* Set up the undefined useable signals. */=0A= + #define RAW_SIGNAL_LO 32=0A= + #define RAW_SIGNAL_HI (REALTIME_LO - 1)=0A= +=20=0A= + #define TARGET_SIGNAL_RAW_VALUES \=0A= + TARGET_SIGNAL_RAW0, \=0A= + TARGET_SIGNAL_RAW1, \=0A= + TARGET_SIGNAL_RAW2, \=0A= + TARGET_SIGNAL_RAW3, \=0A= + TARGET_SIGNAL_RAW4, \=0A= + TARGET_SIGNAL_RAW5, \=0A= + TARGET_SIGNAL_RAW6, \=0A= + TARGET_SIGNAL_RAW7, \=0A= + TARGET_SIGNAL_RAW8=0A= +=20=0A= + #define TARGET_SIGNAL_RAW_TABLE \=0A= + {"SIGNAL32", "Signal 32"}, \=0A= + {"SIGNAL33", "Signal 33"}, \=0A= + {"SIGNAL34", "Signal 34"}, \=0A= + {"SIGNAL35", "Signal 35"}, \=0A= + {"SIGNAL36", "Signal 36"}, \=0A= + {"SIGNAL37", "Signal 37"}, \=0A= + {"SIGNAL38", "Signal 38"}, \=0A= + {"SIGNAL39", "Signal 39"}, \=0A= + {"SIGNAL40", "Signal 40"}=0A= +=20=0A= + #endif /* _TM_QNXNTO_H */=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/configure.host src.new/gdb/configure.host=0A= *** src.orig/gdb/configure.host Fri Feb 14 13:38:15 2003=0A= --- src.new/gdb/configure.host Tue Feb 11 14:29:59 2003=0A= *************** i[3456]86-*-msdosdjgpp*) gdb_host=3Dgo32 ;=0A= *** 63,68 ****=0A= --- 63,69 ----=0A= i[3456]86-*-linux*) gdb_host=3Dlinux ;;=0A= i[3456]86-*-lynxos*) gdb_host=3Di386lynx ;;=0A= i[3456]86-*-gnu*) gdb_host=3Di386gnu ;;=0A= + i[3456]86-*-nto* | x86-*-nto*) gdb_host=3Dnto ;;=0A= i[3456]86-*-openbsd*) gdb_host=3Dobsd ;;=0A= i[3456]86-*-sco3.2v5*) gdb_host=3Di386sco5 ;;=0A= i[3456]86-*-sco3.2v4*) gdb_host=3Di386sco4 ;;=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/configure.tgt src.new/gdb/configure.tgt=0A= *** src.orig/gdb/configure.tgt Fri Feb 14 13:38:15 2003=0A= --- src.new/gdb/configure.tgt Tue Feb 11 16:53:32 2003=0A= *************** i[3456]86-*-netbsd*) gdb_target=3Dnbsd ;;=0A= *** 90,95 ****=0A= --- 90,96 ----=0A= i[3456]86-*-openbsd*) gdb_target=3Dobsd ;;=0A= i[3456]86-*-go32*) gdb_target=3Di386aout ;;=0A= i[3456]86-*-msdosdjgpp*) gdb_target=3Dgo32 ;;=0A= + i[3456]86-*-nto* | x86-*-nto*) gdb_target=3Di386nto;;=0A= i[3456]86-*-lynxos*) gdb_target=3Di386lynx ;;=0A= i[3456]86-*-solaris*) gdb_target=3Di386sol2 ;;=0A= i[3456]86-*-sco*) gdb_target=3Di386v ;;=0A= *************** esac=0A= *** 280,284 ****=0A= --- 281,286 ----=0A= case "${target}" in=0A= *-*-linux*) gdb_osabi=3DGDB_OSABI_LINUX ;;=0A= *-*-gnu*) gdb_osabi=3DGDB_OSABI_HURD ;;=0A= + *-*-nto*) gdb_osabi=3DGDB_OSABI_QNXNTO ;;=0A= *-*-solaris*) gdb_osabi=3DGDB_OSABI_SOLARIS ;;=0A= esac=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/defs.h src.new/gdb/defs.h=0A= *** src.orig/gdb/defs.h Fri Feb 14 13:38:15 2003=0A= --- src.new/gdb/defs.h Fri Feb 14 13:29:01 2003=0A= *************** enum gdb_osabi=0A= *** 1008,1013 ****=0A= --- 1008,1014 ----=0A= GDB_OSABI_ARM_EABI_V1,=0A= GDB_OSABI_ARM_EABI_V2,=0A= GDB_OSABI_ARM_APCS,=0A= + GDB_OSABI_QNXNTO,=0A= =20=20=0A= GDB_OSABI_INVALID /* keep this last */=0A= };=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/i386-nto-tdep.c src.new/gdb/i386-nto-tdep.c=0A= *** src.orig/gdb/i386-nto-tdep.c Wed Dec 31 19:00:00 1969=0A= --- src.new/gdb/i386-nto-tdep.c Mon Feb 17 15:25:27 2003=0A= ***************=0A= *** 0 ****=0A= --- 1,419 ----=0A= + #include "defs.h"=0A= + #include "gdb_string.h"=0A= + #include =0A= + #include "frame.h"=0A= + #include "inferior.h"=0A= + #include "bfd.h"=0A= + #include "symfile.h"=0A= + #include "target.h"=0A= + #include "gdb_wait.h"=0A= + #include "gdbcmd.h"=0A= + #include "objfiles.h"=0A= + #include "gdb-stabs.h"=0A= + #include "gdbthread.h"=0A= + #include "nto-share/dsmsgs.h"=0A= + #include "regcache.h"=0A= + #include "solib-svr4.h"=0A= + #include "dcache.h"=0A= + #include "i386-tdep.h"=0A= + #include "nto-tdep.h"=0A= + #include "osabi.h"=0A= +=20=0A= + #ifdef USG=0A= + #include =0A= + #endif=0A= +=20=0A= + #include =0A= + #include "serial.h"=0A= +=20=0A= + #include "nto-share/debug.h"=0A= +=20=0A= + /* Prototypes for i387_supply_fsave etc. */=0A= + #include "i387-tdep.h"=0A= +=20=0A= + #ifndef FPC_REGNUM=0A= + #define FPC_REGNUM (FP0_REGNUM + 8)=0A= + #endif=0A= +=20=0A= + #define NUM_GPREGS 13=0A= + static int gdb_to_nto[NUM_GPREGS] =3D=0A= + { 7, 6, 5, 4, 11, 2, 1, 0, 8, 10, 9, 12, -1 };=0A= +=20=0A= + #define GDB_TO_OS(x) ((x >=3D 0 && x < NUM_GPREGS) ? gdb_to_nto[x] : -1)= =0A= +=20=0A= + #ifndef X86_CPU_FXSR=0A= + #define X86_CPU_FXSR (1L << 12)=0A= + #endif=0A= +=20=0A= + extern struct dscpuinfo nto_cpuinfo;=0A= + extern int nto_cpuinfo_valid;=0A= + extern int nto_ostype, nto_cputype;=0A= + /*=0A= + Given a register return an id that represents the Neutrino regset it cam= e from=0A= + if reg =3D=3D -1 update all regsets=0A= + $MJC=0A= + */=0A= +=20=0A= + enum QNX_REGS=0A= + {=0A= + QNX_REGS_GP =3D 0,=0A= + QNX_REGS_FP =3D 1,=0A= + QNX_REGS_END =3D 2=0A= + };=0A= +=20=0A= + unsigned=0A= + nto_get_regset_id (int regno)=0A= + {=0A= + unsigned regset;=0A= + if (regno =3D=3D -1)=0A= + { /* return size so we can enumerate */=0A= + regset =3D 2;=0A= + }=0A= + else if (regno < FP0_REGNUM)=0A= + {=0A= + regset =3D 0;=0A= + }=0A= + else if (regno < FPC_REGNUM)=0A= + {=0A= + regset =3D 1;=0A= + }=0A= + else=0A= + {=0A= + regset =3D -1; /* error */=0A= + }=0A= + return regset;=0A= + }=0A= +=20=0A= + /* Tell GDB about the regset contained in the 'data' buffer */=0A= + static void=0A= + gp_regset_fetch (char *data)=0A= + {=0A= + unsigned first_regno;=0A= + for (first_regno =3D 0; first_regno < FP0_REGNUM; first_regno++)=0A= + {=0A= + int regno =3D GDB_TO_OS (first_regno);=0A= + int const minusone =3D -1;=0A= +=20=0A= + if (data =3D=3D NULL || regno =3D=3D -1)=0A= + {=0A= + supply_register (first_regno, (char *) &minusone);=0A= + }=0A= + else=0A= + {=0A= + supply_register (first_regno, &data[regno * 4]);=0A= + }=0A= + }=0A= + }=0A= +=20=0A= + /* get 8087 data */=0A= + static void=0A= + fp_regset_fetch (char *data)=0A= + {=0A= + if (nto_cpuinfo_valid && nto_cpuinfo.cpuflags | X86_CPU_FXSR)=0A= + i387_supply_fxsave (data);=0A= + else=0A= + i387_supply_fsave (data);=0A= + }=0A= +=20=0A= + void=0A= + nto_cpu_regset_fetch (int endian, int regset, void *data)=0A= + {=0A= + endian =3D endian; /* x86, don't care about endian */=0A= +=20=0A= + switch (regset)=0A= + {=0A= + case QNX_REGS_GP: /* QNX has different ordering of GP regs GDB */=0A= + gp_regset_fetch ((char *) data);=0A= + break;=0A= + case QNX_REGS_FP:=0A= + fp_regset_fetch ((char *) data);=0A= + break;=0A= + }=0A= + }=0A= +=20=0A= + /* get regset characteristics */=0A= + unsigned=0A= + nto_get_regset_area (unsigned regset, char *subcmd)=0A= + {=0A= + unsigned length =3D 0;=0A= + switch (regset)=0A= + {=0A= + case QNX_REGS_GP:=0A= + *subcmd =3D DSMSG_REG_GENERAL;=0A= + length =3D NUM_GPREGS * sizeof (unsigned);=0A= + break;=0A= + case QNX_REGS_FP:=0A= + *subcmd =3D DSMSG_REG_FLOAT;=0A= + /* FIXME: should we calculate based on fxsave/fsave? */=0A= + length =3D 512;=0A= + break;=0A= + default:=0A= + length =3D 0;=0A= + }=0A= + return length;=0A= + }=0A= +=20=0A= + /*-=0A= + Given the first and last register number, figure out the size/len=0A= + of the Neutrino register save area to ask for/tell about. Also set=0A= + the register set that's being dealt with in *subcmd. Watch out for=0A= + the range crossing a register set boundry.=0A= + */=0A= +=20=0A= + unsigned=0A= + nto_cpu_register_area (first_regno, last_regno, subcmd, off, len)=0A= + unsigned first_regno;=0A= + unsigned last_regno;=0A= + unsigned char *subcmd;=0A= + unsigned *off;=0A= + unsigned *len;=0A= + {=0A= + int regno =3D -1;=0A= +=20=0A= + if (first_regno < FP0_REGNUM)=0A= + {=0A= + if (last_regno >=3D FP0_REGNUM)=0A= + last_regno =3D FP0_REGNUM - 1;=0A= + *subcmd =3D DSMSG_REG_GENERAL;=0A= + regno =3D GDB_TO_OS (first_regno);=0A= + *off =3D regno * sizeof (unsigned);=0A= + if (regno =3D=3D -1)=0A= + *len =3D 0;=0A= + else=0A= + *len =3D (last_regno - first_regno + 1) * sizeof (unsigned);=0A= + }=0A= + else if (first_regno =3D=3D FP_REGNUM)=0A= + {=0A= + /* Frame Pointer Psuedo-register */=0A= + *off =3D SP_REGNUM * sizeof (unsigned);=0A= + *len =3D sizeof (unsigned);=0A= + return FP_REGNUM;=0A= + }=0A= + else if (first_regno >=3D FP0_REGNUM && first_regno < FPC_REGNUM)=0A= + {=0A= + unsigned off_adjust, regsize;=0A= +=20=0A= + if (nto_cpuinfo_valid && nto_cpuinfo.cpuflags | X86_CPU_FXSR)=0A= + {=0A= + off_adjust =3D 32;=0A= + regsize =3D 16;=0A= + }=0A= + else=0A= + {=0A= + off_adjust =3D 28;=0A= + regsize =3D 10;=0A= + }=0A= +=20=0A= + if (last_regno >=3D FPC_REGNUM)=0A= + last_regno =3D FPC_REGNUM - 1;=0A= + *subcmd =3D DSMSG_REG_FLOAT;=0A= + *off =3D (first_regno - FP0_REGNUM) * regsize + off_adjust;=0A= + *len =3D (last_regno - first_regno + 1) * 10;=0A= + /* Why 10? GDB only stores 10 bytes per FP register so if we're=0A= + * sending a register back to the target, we only want pdebug to wr= ite=0A= + * 10 bytes so as not to clobber the reserved 6 bytes in the fxsave= =0A= + * structure. The astute reader will note that this will fail if w= e=0A= + * try to send a range of fpregs rather than 1 at a time but, as fa= r=0A= + * as I know, there is no way to send more than one fpreg at a time= =0A= + * anyway. If this turns out to be wrong, we may need to put more = code=0A= + * in pdebug to deal with this - perhaps by masking off part of the= =0A= + * register when it writes it in.*/=0A= + }=0A= + else=0A= + {=0A= + *len =3D 0;=0A= + return last_regno;=0A= + }=0A= + return last_regno;=0A= + }=0A= +=20=0A= + /* Tell GDB about the registers contained in the 'data' buffer */=0A= +=20=0A= + void=0A= + nto_cpu_register_fetch (endian, first_regno, last_regno, data)=0A= + int endian;=0A= + unsigned first_regno;=0A= + unsigned last_regno;=0A= + void *data;=0A= + {=0A= + fprintf_unfiltered (gdb_stderr, "warning: nto_cpu_register_fetch called= \=0A= + in remote-nto-i386.c. This shouldn't happen\n");=0A= + /* If remote-nto-i386.c calls nto_supply_register in remote-nto.c,=0A= + * then remote-nto.c calls nto_cpu_register_fetch. Since this never=0A= + * happens, this function is left unimplemented. */=0A= + }=0A= +=20=0A= + /* Build the Neutrino register set info into the 'data' buffer */=0A= +=20=0A= + int=0A= + nto_cpu_register_store (endian, first_regno, last_regno, data)=0A= + int endian;=0A= + unsigned first_regno;=0A= + unsigned last_regno;=0A= + void *data;=0A= + {=0A= + /* Mostly (always?) you're only storing one at a time */=0A= + if (first_regno =3D=3D last_regno)=0A= + {=0A= + regcache_collect (first_regno, data);=0A= + return 1;=0A= + }=0A= + /* Floating point is the same for gdb and target */=0A= + if (first_regno >=3D FP0_REGNUM)=0A= + {=0A= + for (; first_regno <=3D last_regno; first_regno++)=0A= + {=0A= + regcache_collect (first_regno, data);=0A= + (char *) data +=3D REGISTER_RAW_SIZE (first_regno);=0A= + }=0A= + return 1;=0A= + }=0A= + /* GP registers are mapped differently for NTO than GDB */=0A= + for (; first_regno <=3D last_regno; first_regno++)=0A= + {=0A= + int regnum =3D GDB_TO_OS (first_regno);=0A= + if (regnum =3D=3D -1)=0A= + continue;=0A= + regcache_collect (first_regno,=0A= + (char *) data + sizeof (unsigned) * regnum);=0A= + }=0A= + return 1;=0A= + }=0A= +=20=0A= + /* nto_supply_* are used by nto_procfs.c and nto_core-regset.c */=0A= + void=0A= + nto_supply_gregset (gregsetp)=0A= + nto_gregset_t *gregsetp;=0A= + {=0A= + register int regi, i =3D 0;=0A= + register unsigned *regp =3D (unsigned *) gregsetp;=0A= +=20=0A= + for (regi =3D 0; regi < (NUM_REGS - FP0_REGNUM); regi++)=0A= + {=0A= + i =3D GDB_TO_OS (regi);=0A= + supply_register (regi, (char *) ®p[i]);=0A= + }=0A= + }=0A= +=20=0A= + void=0A= + nto_supply_fpregset (fpregsetp)=0A= + nto_fpregset_t *fpregsetp;=0A= + {=0A= + if (nto_cpuinfo_valid && nto_cpuinfo.cpuflags | X86_CPU_FXSR)=0A= + i387_supply_fxsave ((char *) fpregsetp);=0A= + else=0A= + i387_supply_fsave ((char *) fpregsetp);=0A= + }=0A= +=20=0A= + /* Fetch (and possibly build) an appropriate link_map_offsets=0A= + structure for native x86 targets using the struct offsets=0A= + defined in link.h (but without actual reference to that file).=0A= +=20=0A= + This makes it possible to access x86 shared libraries from a GDB=0A= + that was not built on an x86 host (for cross debugging). */=0A= +=20=0A= + static struct link_map_offsets *=0A= + i386_nto_svr4_fetch_link_map_offsets (void)=0A= + {=0A= + static struct link_map_offsets lmo;=0A= + static struct link_map_offsets *lmp =3D NULL;=0A= +=20=0A= + if (lmp =3D=3D NULL)=0A= + {=0A= + lmp =3D &lmo;=0A= +=20=0A= + lmo.r_debug_size =3D 8; /* The actual size is 20 bytes, but=0A= + this is all we need. */=0A= + lmo.r_map_offset =3D 4;=0A= + lmo.r_map_size =3D 4;=0A= +=20=0A= + lmo.link_map_size =3D 20; /* The actual size is 552 bytes, but=0A= + this is all we need. */=0A= + lmo.l_addr_offset =3D 0;=0A= + lmo.l_addr_size =3D 4;=0A= +=20=0A= + lmo.l_name_offset =3D 4;=0A= + lmo.l_name_size =3D 4;=0A= +=20=0A= + lmo.l_next_offset =3D 12;=0A= + lmo.l_next_size =3D 4;=0A= +=20=0A= + lmo.l_prev_offset =3D 16;=0A= + lmo.l_prev_size =3D 4;=0A= + }=0A= +=20=0A= + return lmp;=0A= + }=0A= +=20=0A= + struct link_map_offsets *=0A= + nto_fetch_link_map_offsets (void)=0A= + {=0A= + return i386_nto_svr4_fetch_link_map_offsets ();=0A= + }=0A= +=20=0A= + static int=0A= + i386_nto_pc_in_sigtramp (CORE_ADDR pc, char *name)=0A= + {=0A= + return name && strcmp ("__signalstub", name) =3D=3D 0;=0A= + }=0A= +=20=0A= + static CORE_ADDR=0A= + i386_nto_sigcontext_addr (struct frame_info *frame)=0A= + {=0A= + int sigcontext_offset =3D 136;=0A= +=20=0A= + if (get_next_frame (frame))=0A= + return get_frame_base (get_next_frame (frame)) + sigcontext_offset;= =0A= +=20=0A= + return read_register (SP_REGNUM) + sigcontext_offset;=0A= + }=0A= +=20=0A= + static void=0A= + i386_nto_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)=0A= + {=0A= + struct gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch);=0A= +=20=0A= + /* NTO uses ELF. */=0A= + i386_elf_init_abi (info, gdbarch);=0A= +=20=0A= + /* neutrino rewinds to look more normal */=0A= + set_gdbarch_decr_pc_after_break (gdbarch, 0);=0A= +=20=0A= + /* NTO has shared libraries. */=0A= + set_gdbarch_in_solib_call_trampoline (gdbarch, in_plt_section);=0A= + set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target= );=0A= +=20=0A= + set_gdbarch_pc_in_sigtramp (gdbarch, i386_nto_pc_in_sigtramp);=0A= + tdep->sigcontext_addr =3D i386_nto_sigcontext_addr;=0A= + tdep->sc_pc_offset =3D 56;=0A= + tdep->sc_sp_offset =3D 68;=0A= +=20=0A= + /* setjmp()'s return PC saved in EDX (5) */=0A= + tdep->jb_pc_offset =3D 5 * sizeof (int);=0A= +=20=0A= + set_solib_svr4_fetch_link_map_offsets (gdbarch,=0A= + i386_nto_svr4_fetch_link_map_offsets);=0A= +=20=0A= + /* Our loader handles solib relocations slightly differently than svr4 = */=0A= + current_target_so_ops->relocate_section_addresses =3D=0A= + nto_relocate_section_addresses;=0A= +=20=0A= + /* FIXME: Re-enable this and remove define from config/i386/tm-i386nto.= h=0A= + once it is multi-arched. */=0A= + #if 0=0A= + /* After a watchpoint trap, the PC points to the instruction after=0A= + the one that caused the trap. Therefore we don't need to step over it= .=0A= + But we do need to reset the status register to avoid another trap. */= =0A= + HAVE_CONTINUABLE_WATCHPOINT =3D 1;=0A= + #endif=0A= + }=0A= +=20=0A= + void=0A= + _initialize_i386_nto_tdep (void)=0A= + {=0A= + gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_QNXNTO,=0A= + i386_nto_init_abi);=0A= +=20=0A= + /* read our extra gdbinit file */=0A= + nto_source_extra_gdbinit (".ntox86-gdbinit");=0A= + }=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/nto-procfs.c src.new/gdb/nto-procfs.c=0A= *** src.orig/gdb/nto-procfs.c Wed Dec 31 19:00:00 1969=0A= --- src.new/gdb/nto-procfs.c Fri Feb 14 13:28:11 2003=0A= ***************=0A= *** 0 ****=0A= --- 1,1520 ----=0A= + /* Machine independent support for QNX Neutrino /proc (process file syste= m) for GDB.=0A= + Copyright 1991, 1992-99, 2000 Free Software Foundation, Inc.=0A= + Written by Colin Burgess at QNX Software Systems Limited.=20=20=0A= +=20=0A= + This file is part of GDB.=0A= +=20=0A= + This program is free software; you can redistribute it and/or modify=0A= + it under the terms of the GNU General Public License as published by=0A= + the Free Software Foundation; either version 2 of the License, or=0A= + (at your option) any later version.=0A= +=20=0A= + This program is distributed in the hope that it will be useful,=0A= + but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A= + GNU General Public License for more details.=0A= +=20=0A= + You should have received a copy of the GNU General Public License=0A= + along with this program; if not, write to the Free Software=0A= + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA= . */=0A= +=20=0A= + #include "defs.h"=0A= +=20=0A= + #include =0A= + #include =0A= + #include =0A= + #include =0A= + #include =0A= + #include =0A= + #include =0A= + #include =0A= + #include =0A= + #include =0A= + #include =0A= + #include =0A= + #include =0A= +=20=0A= + #include "defs.h"=0A= + #include "gdb_string.h"=0A= + #include "gdbcore.h"=0A= + #include "frame.h"=0A= + #include "inferior.h"=0A= + #include "bfd.h"=0A= + #include "symfile.h"=0A= + #include "target.h"=0A= + #include "gdb_wait.h"=0A= + #include "gdbcmd.h"=0A= + #include "objfiles.h"=0A= + #include "gdb-stabs.h"=0A= + #include "gdbthread.h"=0A= + #include "nto-share/dsmsgs.h"=0A= + #include "nto-tdep.h"=0A= + #include "dcache.h"=0A= + #include "gdb_stat.h"=0A= + #include "command.h"=0A= +=20=0A= + #define NULL_PID 0=0A= + #define _DEBUG_FLAG_TRACE (_DEBUG_FLAG_TRACE_EXEC|_DEBUG_FLAG_TRACE_RD|_D= EBUG_FLAG_TRACE_WR|_DEBUG_FLAG_TRACE_MODIFY)=0A= +=20=0A= + static struct target_ops procfs_ops;=0A= +=20=0A= + int ctl_fd;=0A= +=20=0A= + static void (*ofunc) ();=0A= +=20=0A= + static procfs_run run;=0A= +=20=0A= + static void procfs_open PARAMS ((char *, int));=0A= +=20=0A= + static int procfs_can_run PARAMS ((void));=0A= +=20=0A= + static ptid_t procfs_wait PARAMS ((ptid_t, struct target_waitstatus *));= =0A= +=20=0A= + static int procfs_xfer_memory=0A= + PARAMS ((CORE_ADDR, char *, int, int, struct mem_attrib * attrib,=0A= + struct target_ops *));=0A= +=20=0A= + static void procfs_fetch_registers PARAMS ((int));=0A= +=20=0A= + static void notice_signals (void);=0A= +=20=0A= + static void init_procfs_ops PARAMS ((void));=0A= +=20=0A= + static ptid_t do_attach PARAMS ((ptid_t ptid));=0A= +=20=0A= + static int procfs_can_use_hw_breakpoint PARAMS ((int, int, int));=0A= +=20=0A= + static int procfs_insert_hw_breakpoint PARAMS ((CORE_ADDR, char *));=0A= +=20=0A= + static int procfs_remove_hw_breakpoint PARAMS ((CORE_ADDR addr, char *));= =0A= +=20=0A= + static int procfs_insert_hw_watchpoint=0A= + PARAMS ((CORE_ADDR addr, int len, int type));=0A= +=20=0A= + static int procfs_remove_hw_watchpoint=0A= + PARAMS ((CORE_ADDR addr, int len, int type));=0A= +=20=0A= + static int procfs_stopped_by_watchpoint PARAMS ((void));=0A= +=20=0A= + /*=20=0A= + These two globals are only ever set in procfs_open(), but are=0A= + referenced elsewhere. 'nto_procfs_node' is a flag used to say=0A= + whether we are local, or we should get the current node descriptor=0A= + for the remote QNX node.=0A= + */=0A= + static char nto_procfs_path[PATH_MAX] =3D { "/proc" };=0A= + static unsigned nto_procfs_node =3D ND_LOCAL_NODE;=0A= +=20=0A= + /*=20=0A= + This is a simple wrapper for the netmgr_strtond() function. It is=0A= + only called from the QNX_NODE macro declared below. The reason for=0A= + the macro and function are because QNX node descriptors are transient,= =0A= + so we have to re-acquire them every time.=0A= + */=0A= + static unsigned=0A= + procfs_nto_node (unsigned node)=0A= + {=0A= + if (node =3D=3D -1)=0A= + {=0A= + error ("Lost the QNX node. Debug session probably over.");=0A= + /* NOTREACHED */=0A= + }=0A= + return (node);=0A= + }=0A= +=20=0A= + /*=20=0A= + This define returns the current QNX Node, or -1 on error. It calls th= e above=0A= + function which is a simple wrapper for the error() call.=0A= + */=0A= + #define QNX_NODE (ND_NODE_CMP(nto_procfs_node, ND_LOCAL_NODE) =3D=3D 0 ? = ND_LOCAL_NODE : \=0A= + procfs_nto_node(netmgr_strtond(nto_procfs_path, 0)))= =0A= +=20=0A= + /*=20=0A= + This is called when we call 'target procfs ' from the (gdb) promp= t.=0A= + For QNX6 (nto), the only valid arg will be a QNX node string,=20=0A= + eg: "/net/some_node". If arg is not a valid QNX node, we will=0A= + default to local.=20=0A= + */=0A= + static void=0A= + procfs_open (arg, from_tty)=0A= + char *arg;=0A= + int from_tty;=0A= + {=0A= + char *nodestr;=0A= + char *endstr;=0A= + char buffer[50];=0A= + int fd, total_size;=0A= + procfs_sysinfo *sysinfo;=0A= +=20=0A= + /* Set the default node used for spawning to this one,=0A= + and only override it if there is a valid arg. */=0A= +=20=0A= + nto_procfs_node =3D ND_LOCAL_NODE;=0A= + nodestr =3D arg ? strdup (arg) : arg;=0A= +=20=0A= + init_thread_list ();=0A= +=20=0A= + if (nodestr)=0A= + {=0A= + nto_procfs_node =3D netmgr_strtond (nodestr, &endstr);=0A= + if (nto_procfs_node =3D=3D -1)=0A= + {=0A= + if (errno =3D=3D ENOTSUP)=0A= + printf_filtered ("QNX Net Manager not found.\n");=0A= + printf_filtered ("Invalid QNX node %s: error %d (%s).\n", nodestr,=0A= + errno, strerror (errno));=0A= + xfree (nodestr);=0A= + nodestr =3D NULL;=0A= + nto_procfs_node =3D ND_LOCAL_NODE;=0A= + }=0A= + else if (*endstr)=0A= + {=0A= + if (*(endstr - 1) =3D=3D '/')=0A= + *(endstr - 1) =3D 0;=0A= + else=0A= + *endstr =3D 0;=0A= + }=0A= + }=0A= + sprintf (nto_procfs_path, "%s%s", nodestr ? nodestr : "", "/proc");=0A= + if (nodestr)=0A= + xfree (nodestr);=0A= +=20=0A= + fd =3D open (nto_procfs_path, O_RDONLY);=0A= + if (fd =3D=3D -1)=0A= + {=0A= + printf_filtered ("Error opening %s : %d (%s)\n", nto_procfs_path, e= rrno,=0A= + strerror (errno));=0A= + error ("Invalid procfs arg");=0A= + /* NOTREACHED */=0A= + }=0A= +=20=0A= + sysinfo =3D (void *) buffer;=0A= + if (devctl (fd, DCMD_PROC_SYSINFO, sysinfo, sizeof buffer, 0) !=3D EOK)= =0A= + {=0A= + printf_filtered ("Error getting size: %d (%s)\n", errno,=0A= + strerror (errno));=0A= + close (fd);=0A= + error ("Devctl failed.");=0A= + /* NOTREACHED */=0A= + }=0A= + else=0A= + {=0A= + total_size =3D sysinfo->total_size;=0A= + if (!(sysinfo =3D alloca (total_size)))=0A= + {=0A= + printf_filtered ("Memory error: %d (%s)\n", errno,=0A= + strerror (errno));=0A= + close (fd);=0A= + error ("alloca failed.");=0A= + /* NOTREACHED */=0A= + }=0A= + else=0A= + {=0A= + if (devctl (fd, DCMD_PROC_SYSINFO, sysinfo, total_size, 0) !=3D EOK)= =0A= + {=0A= + printf_filtered ("Error getting sysinfo: %d (%s)\n", errno,=0A= + strerror (errno));=0A= + close (fd);=0A= + error ("Devctl failed.");=0A= + /* NOTREACHED */=0A= + }=0A= + else=0A= + {=0A= + /* FIXME: do this dynamically to get rid of QNX_TARGET_CPUTYPE. */= =0A= + if (sysinfo->type !=3D QNX_TARGET_CPUTYPE)=0A= + {=0A= + close (fd);=0A= + error ("Invalid target CPU.");=0A= + /* NOTREACHED */=0A= + }=0A= + }=0A= + }=0A= + }=0A= + close (fd);=0A= + printf_filtered ("Debugging using %s\n", nto_procfs_path);=0A= +=20=0A= + }=0A= +=20=0A= + static void=0A= + procfs_set_thread (ptid)=0A= + ptid_t ptid;=0A= + {=0A= + pid_t tid;=0A= +=20=0A= + tid =3D ptid_get_tid (inferior_ptid);=0A= + devctl (ctl_fd, DCMD_PROC_CURTHREAD, &tid, sizeof (tid), 0);=0A= + }=0A= +=20=0A= + /* Return nonzero if the thread TH is still alive. */=0A= + static int=0A= + procfs_thread_alive (ptid_t ptid)=0A= + {=0A= + pid_t tid;=0A= +=20=0A= + tid =3D ptid_get_tid (ptid);=0A= + if (devctl (ctl_fd, DCMD_PROC_CURTHREAD, &tid, sizeof (tid), 0) =3D=3D = EOK)=0A= + return 1;=0A= + return 0;=0A= + }=0A= +=20=0A= +=20=0A= + void=0A= + procfs_find_new_threads (void)=0A= + {=0A= + procfs_status status;=0A= + pid_t pid;=0A= + ptid_t ptid;=0A= +=20=0A= + if (ctl_fd =3D=3D -1)=0A= + return;=0A= +=20=0A= + pid =3D ptid_get_pid (inferior_ptid);=0A= +=20=0A= + for (status.tid =3D 1;; ++status.tid)=0A= + {=0A= + if (devctl (ctl_fd, DCMD_PROC_TIDSTATUS, &status, sizeof (status), = 0) !=3D=0A= + EOK && status.tid !=3D 0)=0A= + {=0A= + break;=0A= + }=0A= + ptid =3D ptid_build (pid, 0, status.tid);=0A= + if (!in_thread_list (ptid))=0A= + add_thread (ptid);=0A= + }=0A= + return;=0A= + }=0A= +=20=0A= + void=0A= + procfs_pidlist (char *args, int from_tty)=0A= + {=0A= + static DIR *dp =3D NULL;=0A= + struct dirent *dirp =3D NULL;=0A= + int fd =3D -1;=0A= + char buf[512];=0A= + procfs_info *pidinfo =3D NULL;=0A= + procfs_debuginfo *info =3D NULL;=0A= + procfs_status *status =3D NULL;=0A= + pid_t num_threads =3D 0;=0A= + pid_t pid;=0A= + char name[512];=0A= +=20=0A= + dp =3D opendir (nto_procfs_path);=0A= + if (dp =3D=3D NULL)=0A= + {=0A= + printf ("failed to opendir \"%s\" - %d (%s)", nto_procfs_path, errn= o,=0A= + strerror (errno));=0A= + return;=0A= + }=0A= +=20=0A= + /* start scan at first pid */=0A= + rewinddir (dp);=0A= +=20=0A= + do=0A= + {=0A= + /* Get the right pid and procfs path for the pid */=0A= + do=0A= + {=0A= + if ((dirp =3D readdir (dp)) =3D=3D NULL)=0A= + {=0A= + closedir (dp);=0A= + return;=0A= + }=0A= + strcat (strcat=0A= + (strcat (strcpy (buf, nto_procfs_path), "/"), dirp->d_name),=0A= + "/as");=0A= + }=0A= + while ((pid =3D atoi (dirp->d_name)) =3D=3D 0);=0A= +=20=0A= + /* open the procfs path */=0A= + if ((fd =3D open (buf, O_RDONLY)) =3D=3D -1)=0A= + {=0A= + printf ("failed to open %s - %d (%s)\n", buf, errno,=0A= + strerror (errno));=0A= + closedir (dp);=0A= + return;=0A= + }=0A= +=20=0A= + pidinfo =3D (procfs_info *) buf;=0A= + if (devctl (fd, DCMD_PROC_INFO, pidinfo, sizeof (buf), 0) !=3D EOK)= =0A= + {=0A= + printf ("devctl DCMD_PROC_INFO failed - %d (%s)\n", errno,=0A= + strerror (errno));=0A= + break;=0A= + }=0A= + num_threads =3D pidinfo->num_threads;=0A= +=20=0A= + info =3D (procfs_debuginfo *) buf;=0A= + if (devctl (fd, DCMD_PROC_MAPDEBUG_BASE, info, sizeof (buf), 0) != =3D EOK)=0A= + strcpy (name, "unavailable");=0A= + else=0A= + strcpy (name, info->path);=0A= +=20=0A= + /* Collect state info on all the threads. */=0A= + status =3D (procfs_status *) buf;=0A= + for (status->tid =3D 1; status->tid <=3D num_threads; status->tid++= )=0A= + {=0A= + if (devctl (fd, DCMD_PROC_TIDSTATUS, status, sizeof (buf), 0) !=3D EOK= =0A= + && status->tid !=3D 0)=0A= + break;=0A= + if (status->tid !=3D 0)=0A= + printf_filtered ("%s - %d/%d\n", name, pid, status->tid);=0A= + }=0A= + close (fd);=0A= + }=0A= + while (dirp !=3D NULL);=0A= +=20=0A= + close (fd);=0A= + closedir (dp);=0A= + return;=0A= + }=0A= +=20=0A= +=20=0A= + void=0A= + procfs_meminfo (char *args, int from_tty)=0A= + {=0A= + procfs_mapinfo *mapinfos =3D NULL;=0A= + static int num_mapinfos =3D 0;=0A= + procfs_mapinfo *mapinfo_p, *mapinfo_p2;=0A= + int flags =3D ~0, err, num, i, j;=0A= +=20=0A= + struct=0A= + {=0A= + procfs_debuginfo info;=0A= + char buff[_POSIX_PATH_MAX];=0A= + } map;=0A= +=20=0A= + struct info=0A= + {=0A= + unsigned addr;=0A= + unsigned size;=0A= + unsigned flags;=0A= + unsigned debug_vaddr;=0A= + unsigned long long offset;=0A= + };=0A= +=20=0A= + struct printinfo=0A= + {=0A= + unsigned long long ino;=0A= + unsigned dev;=0A= + struct info text;=0A= + struct info data;=0A= + char name[256];=0A= + } printme;=0A= +=20=0A= +=20=0A= + /* Get the number of map entrys */=0A= + if ((err =3D devctl (ctl_fd, DCMD_PROC_MAPINFO, NULL, 0, &num)) !=3D EO= K)=0A= + {=0A= + printf ("failed devctl num mapinfos - %d (%s)\n", err, strerror (er= r));=0A= + return;=0A= + }=0A= +=20=0A= + mapinfos =3D xmalloc (num * sizeof (procfs_mapinfo));=0A= +=20=0A= + num_mapinfos =3D num;=0A= + mapinfo_p =3D mapinfos;=0A= +=20=0A= + /* fill the map entrys */=0A= + if ((err =3D=0A= + devctl (ctl_fd, DCMD_PROC_MAPINFO, mapinfo_p,=0A= + num * sizeof (procfs_mapinfo), &num)) !=3D EOK)=0A= + {=0A= + printf ("failed devctl mapinfos - %d (%s)\n", err, strerror (err));= =0A= + xfree (mapinfos);=0A= + return;=0A= + }=0A= +=20=0A= + num =3D min (num, num_mapinfos);=0A= +=20=0A= + /* Run through the list of mapinfo's, and store the data and text info= =0A= + so we can print it at the bottom of the loop. */=0A= + for (mapinfo_p =3D mapinfos, i =3D 0; i < num; i++, mapinfo_p++)=0A= + {=0A= + if (!(mapinfo_p->flags & flags))=0A= + mapinfo_p->ino =3D 0;=0A= +=20=0A= + if (mapinfo_p->ino =3D=3D 0) /* already visited */=0A= + continue;=0A= +=20=0A= + map.info.vaddr =3D mapinfo_p->vaddr;=0A= +=20=0A= + if ((err =3D=0A= + devctl (ctl_fd, DCMD_PROC_MAPDEBUG, &map, sizeof (map), 0)) !=3D EOK)= =0A= + continue;=0A= +=20=0A= + memset (&printme, 0, sizeof printme);=0A= + printme.dev =3D mapinfo_p->dev;=0A= + printme.ino =3D mapinfo_p->ino;=0A= + printme.text.addr =3D mapinfo_p->vaddr;=0A= + printme.text.size =3D mapinfo_p->size;=0A= + printme.text.flags =3D mapinfo_p->flags;=0A= + printme.text.offset =3D mapinfo_p->offset;=0A= + printme.text.debug_vaddr =3D map.info.vaddr;=0A= + strcpy (printme.name, map.info.path);=0A= +=20=0A= + /* check for matching data */=0A= + for (mapinfo_p2 =3D mapinfos, j =3D 0; j < num; j++, mapinfo_p2++)= =0A= + {=0A= + if (mapinfo_p2->vaddr !=3D mapinfo_p->vaddr &&=0A= + mapinfo_p2->ino =3D=3D mapinfo_p->ino=0A= + && mapinfo_p2->dev =3D=3D mapinfo_p->dev)=0A= + {=0A= + map.info.vaddr =3D mapinfo_p2->vaddr;=0A= + if ((err =3D=0A= + devctl (ctl_fd, DCMD_PROC_MAPDEBUG, &map, sizeof (map),=0A= + 0)) !=3D EOK)=0A= + continue;=0A= +=20=0A= + if (strcmp (map.info.path, printme.name))=0A= + {=0A= + continue;=0A= + }=0A= +=20=0A= + /*=0A= + * lower debug_vaddr is always text, if nessessary, swap=0A= + */=0A= + if ((int) map.info.vaddr < (int) printme.text.debug_vaddr)=0A= + {=0A= + memcpy (&(printme.data), &(printme.text),=0A= + sizeof (printme.data));=0A= + printme.text.addr =3D mapinfo_p2->vaddr;=0A= + printme.text.size =3D mapinfo_p2->size;=0A= + printme.text.flags =3D mapinfo_p2->flags;=0A= + printme.text.offset =3D mapinfo_p2->offset;=0A= + printme.text.debug_vaddr =3D map.info.vaddr;=0A= + }=0A= + else=0A= + {=0A= + printme.data.addr =3D mapinfo_p2->vaddr;=0A= + printme.data.size =3D mapinfo_p2->size;=0A= + printme.data.flags =3D mapinfo_p2->flags;=0A= + printme.data.offset =3D mapinfo_p2->offset;=0A= + printme.data.debug_vaddr =3D map.info.vaddr;=0A= + }=0A= + mapinfo_p2->ino =3D 0;=0A= + }=0A= + }=0A= + mapinfo_p->ino =3D 0;=0A= +=20=0A= + printf_filtered ("%s\n", printme.name);=0A= + printf_filtered ("\ttext=3D%08x bytes @ 0x%08x\n", printme.text.siz= e,=0A= + printme.text.addr);=0A= + printf_filtered ("\t\tflags=3D%08x\n", printme.text.flags);=0A= + printf_filtered ("\t\tdebug=3D%08x\n", printme.text.debug_vaddr);= =0A= + printf_filtered ("\t\toffset=3D%016llx\n", printme.text.offset);=0A= + if (printme.data.size)=0A= + {=0A= + printf_filtered ("\tdata=3D%08x bytes @ 0x%08x\n", printme.data.size,= =0A= + printme.data.addr);=0A= + printf_filtered ("\t\tflags=3D%08x\n", printme.data.flags);=0A= + printf_filtered ("\t\tdebug=3D%08x\n", printme.data.debug_vaddr);=0A= + printf_filtered ("\t\toffset=3D%016llx\n", printme.data.offset);=0A= + }=0A= + printf_filtered ("\tdev=3D0x%x\n", printme.dev);=0A= + printf_filtered ("\tino=3D0x%x\n", (unsigned int) printme.ino);=0A= + }=0A= + xfree (mapinfos);=0A= + return;=0A= + }=0A= +=20=0A= + /* Print status information about what we're accessing. */=0A= +=20=0A= + static void=0A= + procfs_files_info (ignore)=0A= + struct target_ops *ignore;=0A= + {=0A= + printf_unfiltered ("\tUsing the running image of %s %s via %s.\n",=0A= + attach_flag ? "attached" : "child",=0A= + target_pid_to_str (inferior_ptid), nto_procfs_path);=0A= + }=0A= +=20=0A= + /* Mark our target-struct as eligible for stray "run" and "attach" comman= ds. */=0A= + static int=0A= + procfs_can_run ()=0A= + {=0A= + return 1;=0A= + }=0A= +=20=0A= + /* Attach to process PID, then initialize for debugging it */=0A= + static void=0A= + procfs_attach (args, from_tty)=0A= + char *args;=0A= + int from_tty;=0A= + {=0A= + char *exec_file;=0A= + int pid;=0A= +=20=0A= + if (!args)=0A= + error_no_arg ("process-id to attach");=0A= +=20=0A= + pid =3D atoi (args);=0A= +=20=0A= + if (pid =3D=3D getpid ())=0A= + error ("Attaching GDB to itself is not a good idea...");=0A= +=20=0A= + if (from_tty)=0A= + {=0A= + exec_file =3D (char *) get_exec_file (0);=0A= +=20=0A= + if (exec_file)=0A= + printf_unfiltered ("Attaching to program `%s', %s\n", exec_file,=0A= + target_pid_to_str (pid_to_ptid (pid)));=0A= + else=0A= + printf_unfiltered ("Attaching to %s\n",=0A= + target_pid_to_str (pid_to_ptid (pid)));=0A= +=20=0A= + gdb_flush (gdb_stdout);=0A= + }=0A= + inferior_ptid =3D do_attach (pid_to_ptid (pid));=0A= + push_target (&procfs_ops);=0A= + }=0A= +=20=0A= + static ptid_t=0A= + do_attach (ptid_t ptid)=0A= + {=0A= + procfs_status status;=0A= + struct sigevent event;=0A= + char path[100];=0A= +=20=0A= + sprintf (path, "%s/%d/as", nto_procfs_path, PIDGET (ptid));=0A= + ctl_fd =3D open (path, O_RDWR);=0A= + if (ctl_fd =3D=3D -1)=0A= + {=0A= + error ("Couldn't open proc file %s, error %d (%s)", path, errno,=0A= + strerror (errno));=0A= + /* NOTREACHED */=0A= + }=0A= + if (devctl (ctl_fd, DCMD_PROC_STOP, &status, sizeof (status), 0) !=3D E= OK)=0A= + {=0A= + error ("Couldn't stop process");=0A= + /* NOTREACHED */=0A= + }=0A= +=20=0A= + /* Define a sigevent for process stopped notification. */=0A= + event.sigev_notify =3D SIGEV_SIGNAL_THREAD;=0A= + event.sigev_signo =3D SIGUSR1;=0A= + event.sigev_code =3D 0;=0A= + event.sigev_value.sival_ptr =3D NULL;=0A= + event.sigev_priority =3D -1;=0A= + devctl (ctl_fd, DCMD_PROC_EVENT, &event, sizeof (event), 0);=0A= +=20=0A= + if (devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0) =3D= =3D EOK)=0A= + {=0A= + if (status.flags & _DEBUG_FLAG_STOPPED)=0A= + {=0A= + SignalKill (QNX_NODE, PIDGET (ptid), 0, SIGCONT, 0, 0);=0A= + }=0A= + }=0A= + attach_flag =3D 1;=0A= + nto_init_solib_search_path ();=0A= + return ptid;=0A= + }=0A= +=20=0A= + /* Ask the user what to do when an interrupt is received. */=0A= +=20=0A= + static void=0A= + interrupt_query ()=0A= + {=0A= + target_terminal_ours ();=0A= +=20=0A= + if (query ("Interrupted while waiting for the program.\n\=0A= + Give up (and stop debugging it)? "))=0A= + {=0A= + target_mourn_inferior ();=0A= + throw_exception (RETURN_QUIT);=0A= + }=0A= +=20=0A= + target_terminal_inferior ();=0A= + }=0A= +=20=0A= + /* The user typed ^C twice. */=0A= + static void=0A= + nto_interrupt_twice (signo)=0A= + int signo;=0A= + {=0A= + signal (signo, ofunc);=0A= + interrupt_query ();=0A= + signal (signo, nto_interrupt_twice);=0A= + }=0A= +=20=0A= + static void=0A= + nto_interrupt (int signo)=0A= + {=0A= + /* If this doesn't work, try more severe steps. */=0A= + signal (signo, nto_interrupt_twice);=0A= +=20=0A= + target_stop ();=0A= + }=0A= +=20=0A= + static ptid_t=0A= + procfs_wait (ptid, ourstatus)=0A= + ptid_t ptid;=0A= + struct target_waitstatus *ourstatus;=0A= + {=0A= + sigset_t set;=0A= + siginfo_t info;=0A= + procfs_status status;=0A= + static int exit_signo =3D 0; /* used to track signals that cause termin= ation */=0A= +=20=0A= + ourstatus->kind =3D TARGET_WAITKIND_SPURIOUS;=0A= +=20=0A= + if (ptid_equal (inferior_ptid, null_ptid))=0A= + {=0A= + ourstatus->kind =3D TARGET_WAITKIND_STOPPED;=0A= + ourstatus->value.sig =3D TARGET_SIGNAL_0;=0A= + exit_signo =3D 0;=0A= + return null_ptid;=0A= + }=0A= +=20=0A= + sigemptyset (&set);=0A= + sigaddset (&set, SIGUSR1);=0A= +=20=0A= + devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0);=0A= + while (!(status.flags & _DEBUG_FLAG_ISTOP))=0A= + {=0A= + ofunc =3D (void (*)()) signal (SIGINT, nto_interrupt);=0A= + sigwaitinfo (&set, &info);=0A= + signal (SIGINT, ofunc);=0A= + devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0);=0A= + }=0A= +=20=0A= + if (status.flags & _DEBUG_FLAG_SSTEP)=0A= + {=0A= + ourstatus->kind =3D TARGET_WAITKIND_STOPPED;=0A= + ourstatus->value.sig =3D TARGET_SIGNAL_TRAP;=0A= + }=0A= + /* Was it a breakpoint? */=0A= + else if (status.flags & _DEBUG_FLAG_TRACE)=0A= + {=0A= + ourstatus->kind =3D TARGET_WAITKIND_STOPPED;=0A= + ourstatus->value.sig =3D TARGET_SIGNAL_TRAP;=0A= + }=0A= + else if (status.flags & _DEBUG_FLAG_ISTOP)=0A= + {=0A= + switch (status.why)=0A= + {=0A= + case _DEBUG_WHY_SIGNALLED:=0A= + ourstatus->kind =3D TARGET_WAITKIND_STOPPED;=0A= + ourstatus->value.sig =3D=0A= + target_signal_from_host (status.info.si_signo);=0A= + exit_signo =3D 0;=0A= + break;=0A= + case _DEBUG_WHY_FAULTED:=0A= + ourstatus->kind =3D TARGET_WAITKIND_STOPPED;=0A= + if (status.info.si_signo =3D=3D SIGTRAP)=0A= + {=0A= + ourstatus->value.sig =3D 0;=0A= + exit_signo =3D 0;=0A= + }=0A= + else=0A= + {=0A= + ourstatus->value.sig =3D=0A= + target_signal_from_host (status.info.si_signo);=0A= + exit_signo =3D ourstatus->value.sig;=0A= + }=0A= + break;=0A= +=20=0A= + case _DEBUG_WHY_TERMINATED:=0A= + {=0A= + int waitval =3D 0;=0A= +=20=0A= + waitpid (PIDGET (inferior_ptid), &waitval, WNOHANG);=0A= + if (exit_signo)=0A= + {=0A= + ourstatus->kind =3D TARGET_WAITKIND_SIGNALLED; /* abnormal death */=0A= + ourstatus->value.sig =3D exit_signo;=0A= + }=0A= + else=0A= + {=0A= + ourstatus->kind =3D TARGET_WAITKIND_EXITED; /* normal death */=0A= + ourstatus->value.integer =3D WEXITSTATUS (waitval);=0A= + }=0A= + exit_signo =3D 0;=0A= + break;=0A= + }=0A= +=20=0A= + case _DEBUG_WHY_REQUESTED:=0A= + /* we are assuming a requested stop is due to a SIGINT */=0A= + ourstatus->kind =3D TARGET_WAITKIND_STOPPED;=0A= + ourstatus->value.sig =3D TARGET_SIGNAL_INT;=0A= + exit_signo =3D 0;=0A= + break;=0A= + }=0A= + }=0A= +=20=0A= + return inferior_ptid;=0A= + }=0A= +=20=0A= + /*=0A= +=20=0A= + LOCAL FUNCTION=0A= +=20=0A= + procfs_fetch_registers -- fetch current registers from inferior=0A= +=20=0A= + SYNOPSIS=0A= +=20=0A= + void procfs_fetch_registers (int regno)=0A= +=20=0A= + DESCRIPTION=0A= +=20=0A= + Read the current values of the inferior's registers, both the=0A= + general register set and floating point registers (if supported)=0A= + and update gdb's idea of their current values.=0A= +=20=0A= + */=0A= +=20=0A= + static void=0A= + procfs_fetch_registers (regno)=0A= + int regno;=0A= + {=0A= + union=0A= + {=0A= + procfs_greg greg;=0A= + procfs_fpreg fpreg;=0A= + }=0A= + reg;=0A= + int regsize;=0A= +=20=0A= + procfs_set_thread (inferior_ptid);=0A= + if (devctl (ctl_fd, DCMD_PROC_GETGREG, ®, sizeof (reg), ®size) = =3D=3D EOK)=0A= + {=0A= + nto_supply_gregset (®.greg);=0A= + }=0A= + if (devctl (ctl_fd, DCMD_PROC_GETFPREG, ®, sizeof (reg), ®size) = =3D=3D=0A= + EOK)=0A= + {=0A= + nto_supply_fpregset (®.fpreg);=0A= + }=0A= + }=0A= +=20=0A= + /*=0A= +=20=0A= + LOCAL FUNCTION=0A= +=20=0A= + procfs_xfer_memory -- copy data to or from inferior memory space=0A= +=20=0A= + SYNOPSIS=0A= +=20=0A= + int procfs_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len,=0A= + int dowrite, struct target_ops target)=0A= +=20=0A= + DESCRIPTION=0A= +=20=0A= + Copy LEN bytes to/from inferior's memory starting at MEMADDR=0A= + from/to debugger memory starting at MYADDR. Copy from inferior=0A= + if DOWRITE is zero or to inferior if DOWRITE is nonzero.=0A= +=20=20=20=0A= + Returns the length copied, which is either the LEN argument or=0A= + zero. This xfer function does not do partial moves, since procfs_ops=0A= + doesn't allow memory operations to cross below us in the target stack=0A= + anyway.=0A= +=20=0A= + NOTES=0A= +=20=0A= + The /proc interface makes this an almost trivial task.=0A= + */=0A= +=20=0A= + static int=0A= + procfs_xfer_memory (memaddr, myaddr, len, dowrite, attrib, target)=0A= + CORE_ADDR memaddr;=0A= + char *myaddr;=0A= + int len;=0A= + int dowrite;=0A= + struct mem_attrib *attrib; /* ignored */=0A= + struct target_ops *target; /* ignored */=0A= + {=0A= + int nbytes =3D 0;=0A= +=20=0A= + if (lseek (ctl_fd, (off_t) memaddr, SEEK_SET) =3D=3D (off_t) memaddr)= =0A= + {=0A= + if (dowrite)=0A= + {=0A= + nbytes =3D write (ctl_fd, myaddr, len);=0A= + }=0A= + else=0A= + {=0A= + nbytes =3D read (ctl_fd, myaddr, len);=0A= + }=0A= + if (nbytes < 0)=0A= + {=0A= + nbytes =3D 0;=0A= + }=0A= + }=0A= + return (nbytes);=0A= + }=0A= +=20=0A= + /* Take a program previously attached to and detaches it.=0A= + The program resumes execution and will no longer stop=0A= + on signals, etc. We'd better not have left any breakpoints=0A= + in the program or it'll die when it hits one. For this=0A= + to work, it may be necessary for the process to have been=0A= + previously attached. It *might* work if the program was=0A= + started via the normal ptrace (PTRACE_TRACEME). */=0A= +=20=0A= + static void=0A= + procfs_detach (args, from_tty)=0A= + char *args;=0A= + int from_tty;=0A= + {=0A= + int siggnal =3D 0;=0A= +=20=0A= + if (from_tty)=0A= + {=0A= + char *exec_file =3D get_exec_file (0);=0A= + if (exec_file =3D=3D 0)=0A= + exec_file =3D "";=0A= + printf_unfiltered ("Detaching from program: %s %s\n",=0A= + exec_file, target_pid_to_str (inferior_ptid));=0A= + gdb_flush (gdb_stdout);=0A= + }=0A= + if (args)=0A= + siggnal =3D atoi (args);=0A= +=20=0A= + if (siggnal)=0A= + SignalKill (QNX_NODE, PIDGET (inferior_ptid), 0, siggnal, 0, 0);=0A= +=20=0A= + close (ctl_fd);=0A= + ctl_fd =3D -1;=0A= + init_thread_list ();=0A= + inferior_ptid =3D null_ptid;=0A= + attach_flag =3D 0;=0A= + unpush_target (&procfs_ops); /* Pop out of handling an inferior */=0A= + }=0A= +=20=0A= + static int=0A= + procfs_breakpoint (addr, type, size)=0A= + CORE_ADDR addr;=0A= + int type;=0A= + int size;=0A= + {=0A= + procfs_break brk;=0A= +=20=0A= + brk.type =3D type;=0A= + brk.addr =3D addr;=0A= + brk.size =3D size;=0A= + if ((errno =3D devctl (ctl_fd, DCMD_PROC_BREAK, &brk, sizeof (brk), 0))= !=3D=0A= + EOK)=0A= + {=0A= + return 1;=0A= + }=0A= + return 0;=0A= + }=0A= +=20=0A= + static int=0A= + procfs_insert_breakpoint (addr, contents_cache)=0A= + CORE_ADDR addr;=0A= + char *contents_cache;=0A= + {=0A= + return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC, 0);=0A= + }=0A= +=20=0A= + static int=0A= + procfs_remove_breakpoint (addr, contents_cache)=0A= + CORE_ADDR addr;=0A= + char *contents_cache;=0A= + {=0A= + return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC, -1);=0A= + }=0A= +=20=0A= + static int=0A= + procfs_insert_hw_breakpoint (addr, contents_cache)=0A= + CORE_ADDR addr;=0A= + char *contents_cache;=0A= + {=0A= + return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC | _DEBUG_BREAK_HW, 0)= ;=0A= + }=0A= +=20=0A= + static int=0A= + procfs_remove_hw_breakpoint (addr, contents_cache)=0A= + CORE_ADDR addr;=0A= + char *contents_cache;=0A= + {=0A= + return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC | _DEBUG_BREAK_HW, -1= );=0A= + }=0A= +=20=0A= + static void=0A= + procfs_resume (ptid_t ptid, int step, enum target_signal signo)=0A= + {=0A= + int signal_to_pass;=0A= + procfs_status status;=0A= +=20=0A= + if (ptid_equal (inferior_ptid, null_ptid))=0A= + return;=0A= +=20=0A= + procfs_set_thread (ptid_equal (ptid, minus_one_ptid) ? inferior_ptid := =0A= + ptid);=0A= +=20=0A= +=20=0A= + run.flags =3D _DEBUG_RUN_FAULT | _DEBUG_RUN_TRACE;=0A= + if (step)=0A= + run.flags |=3D _DEBUG_RUN_STEP;=0A= +=20=0A= + sigemptyset ((sigset_t *) & run.fault);=0A= + sigaddset ((sigset_t *) & run.fault, FLTBPT);=0A= + sigaddset ((sigset_t *) & run.fault, FLTTRACE);=0A= + sigaddset ((sigset_t *) & run.fault, FLTILL);=0A= + sigaddset ((sigset_t *) & run.fault, FLTPRIV);=0A= + sigaddset ((sigset_t *) & run.fault, FLTBOUNDS);=0A= + sigaddset ((sigset_t *) & run.fault, FLTIOVF);=0A= + sigaddset ((sigset_t *) & run.fault, FLTIZDIV);=0A= + sigaddset ((sigset_t *) & run.fault, FLTFPE);=0A= + /* Peter V will be changing this at some point... */=0A= + sigaddset ((sigset_t *) & run.fault, FLTPAGE);=0A= +=20=0A= + run.flags |=3D _DEBUG_RUN_ARM;=0A= +=20=0A= + sigemptyset (&run.trace);=0A= + notice_signals ();=0A= + signal_to_pass =3D target_signal_to_host (signo);=0A= +=20=0A= + if (signal_to_pass)=0A= + {=0A= + devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0);=0A= + signal_to_pass =3D target_signal_to_host (signo);=0A= + if (status.why & (_DEBUG_WHY_SIGNALLED | _DEBUG_WHY_FAULTED))=0A= + {=0A= + if (signal_to_pass !=3D status.info.si_signo)=0A= + {=0A= + SignalKill (QNX_NODE, PIDGET (inferior_ptid), 0, signal_to_pass,= =0A= + 0, 0);=0A= + run.flags |=3D _DEBUG_RUN_CLRFLT | _DEBUG_RUN_CLRSIG;=0A= + }=0A= + else=0A= + {=0A= + /* let it kill the program without telling us */=0A= + sigdelset (&run.trace, signal_to_pass);=0A= + }=0A= + }=0A= + }=0A= + else=0A= + {=0A= + run.flags |=3D _DEBUG_RUN_CLRSIG | _DEBUG_RUN_CLRFLT;=0A= + }=0A= + if ((errno =3D devctl (ctl_fd, DCMD_PROC_RUN, &run, sizeof (run), 0)) != =3D EOK)=0A= + {=0A= + perror ("run error!\n");=0A= + return;=0A= + }=0A= + }=0A= +=20=0A= + static void=0A= + procfs_mourn_inferior ()=0A= + {=0A= + if (!ptid_equal (inferior_ptid, null_ptid))=0A= + {=0A= + SignalKill (QNX_NODE, PIDGET (inferior_ptid), 0, SIGKILL, 0, 0);=0A= + close (ctl_fd);=0A= + }=0A= + inferior_ptid =3D null_ptid;=0A= + init_thread_list ();=0A= + unpush_target (&procfs_ops);=0A= + generic_mourn_inferior ();=0A= + attach_flag =3D 0;=0A= + }=0A= +=20=0A= + /* This function breaks up an argument string into an argument=0A= + * vector suitable for passing to execvp().=0A= + * E.g., on "run a b c d" this routine would get as input=0A= + * the string "a b c d", and as output it would fill in argv with=0A= + * the four arguments "a", "b", "c", "d". The only additional=0A= + * functionality is simple quoting. The gdb command:=0A= + * run a "b c d" f=0A= + * will fill in argv with the three args "a", "b c d", "e".=20=20=0A= + */=0A= + static void=0A= + breakup_args (scratch, argv)=0A= + char *scratch;=0A= + char **argv;=0A= + {=0A= + char *pp, *cp =3D scratch;=0A= + char quoting =3D 0;=0A= +=20=0A= + for (;;)=0A= + {=0A= +=20=0A= + /* Scan past leading separators */=0A= + quoting =3D 0;=0A= + while (*cp =3D=3D ' ' || *cp =3D=3D '\t' || *cp =3D=3D '\n')=0A= + {=0A= + cp++;=0A= + }=0A= +=20=0A= + /* Break if at end of string */=0A= + if (*cp =3D=3D '\0')=0A= + break;=0A= +=20=0A= + /* Take an arg */=0A= + if (*cp =3D=3D '"')=0A= + {=0A= + cp++;=0A= + quoting =3D strchr (cp, '"') ? 1 : 0;=0A= + }=0A= +=20=0A= + *argv++ =3D cp;=0A= +=20=0A= + /* Scan for next arg separator */=0A= + pp =3D cp;=0A= + if (quoting)=0A= + cp =3D strchr (pp, '"');=0A= + if ((cp =3D=3D NULL) || (!quoting))=0A= + cp =3D strchr (pp, ' ');=0A= + if (cp =3D=3D NULL)=0A= + cp =3D strchr (pp, '\t');=0A= + if (cp =3D=3D NULL)=0A= + cp =3D strchr (pp, '\n');=0A= +=20=0A= + /* No separators =3D> end of string =3D> break */=0A= + if (cp =3D=3D NULL)=0A= + {=0A= + pp =3D cp;=0A= + break;=0A= + }=0A= +=20=0A= + /* Replace the separator with a terminator */=0A= + *cp++ =3D '\0';=0A= + }=0A= +=20=0A= + /* execv requires a null-terminated arg vector */=0A= + *argv =3D NULL;=0A= +=20=0A= + }=0A= +=20=0A= + static void=0A= + procfs_create_inferior (exec_file, allargs, env)=0A= + char *exec_file;=0A= + char *allargs;=0A= + char **env;=0A= + {=0A= + struct inheritance inherit;=0A= + pid_t pid;=0A= + int flags, errn;=0A= + char **argv, *args;=0A= + char *in =3D "", *out =3D "", *err =3D "";=0A= + int fd, fds[3];=0A= + sigset_t set;=0A= +=20=0A= + argv =3D=0A= + (char **) xmalloc (((strlen (allargs) + 1) / (unsigned) 2 + 2) *=0A= + sizeof (*argv));=0A= + argv[0] =3D get_exec_file (1);=0A= + if (!argv[0])=0A= + {=0A= + if (exec_file)=0A= + argv[0] =3D exec_file;=0A= + else=0A= + return;=0A= + }=0A= +=20=0A= + args =3D strdup (allargs);=0A= + breakup_args (args, exec_file ? &argv[1] : &argv[0]);=0A= +=20=0A= + argv =3D nto_parse_redirection (argv, &in, &out, &err);=0A= +=20=0A= + fds[0] =3D STDIN_FILENO;=0A= + fds[1] =3D STDOUT_FILENO;=0A= + fds[2] =3D STDERR_FILENO;=0A= +=20=0A= + /* If the user specified I/O via gdb's --tty=3D arg, use it, but only= =0A= + if the i/o is not also being specified via redirection. */=0A= + if (inferior_io_terminal)=0A= + {=0A= + if (!in[0])=0A= + in =3D inferior_io_terminal;=0A= + if (!out[0])=0A= + out =3D inferior_io_terminal;=0A= + if (!err[0])=0A= + err =3D inferior_io_terminal;=0A= + }=0A= +=20=0A= + if (in[0])=0A= + {=0A= + if ((fd =3D open (in, O_RDONLY)) =3D=3D -1)=0A= + {=0A= + perror (in);=0A= + }=0A= + else=0A= + fds[0] =3D fd;=0A= + }=0A= + if (out[0])=0A= + {=0A= + if ((fd =3D open (out, O_WRONLY)) =3D=3D -1)=0A= + {=0A= + perror (out);=0A= + }=0A= + else=0A= + fds[1] =3D fd;=0A= + }=0A= + if (err[0])=0A= + {=0A= + if ((fd =3D open (err, O_WRONLY)) =3D=3D -1)=0A= + {=0A= + perror (err);=0A= + }=0A= + else=0A= + fds[2] =3D fd;=0A= + }=0A= +=20=0A= + /* Clear any pending SIGUSR1's but keep the behavior the same. */=0A= + signal (SIGUSR1, signal (SIGUSR1, SIG_IGN));=0A= +=20=0A= + sigemptyset (&set);=0A= + sigaddset (&set, SIGUSR1);=0A= + sigprocmask (SIG_UNBLOCK, &set, NULL);=0A= +=20=0A= + memset (&inherit, 0, sizeof (inherit));=0A= +=20=0A= + if (ND_NODE_CMP (nto_procfs_node, ND_LOCAL_NODE) !=3D 0)=0A= + {=0A= + inherit.nd =3D QNX_NODE;=0A= + inherit.flags |=3D SPAWN_SETND;=0A= + inherit.flags &=3D ~SPAWN_EXEC;=0A= + }=0A= + inherit.flags |=3D SPAWN_SETGROUP | SPAWN_HOLD;=0A= + inherit.pgroup =3D SPAWN_NEWPGROUP;=0A= + pid =3D=0A= + spawnp (argv[0], 3, fds, &inherit, argv,=0A= + ND_NODE_CMP (nto_procfs_node, ND_LOCAL_NODE) =3D=3D 0 ? env : 0);=0A= + xfree (args);=0A= +=20=0A= + sigprocmask (SIG_BLOCK, &set, NULL);=0A= +=20=0A= + if (pid =3D=3D -1)=0A= + error ("Error spawning %s: %d (%s)", argv[0], errno, strerror (errno)= );=0A= +=20=0A= + if (fds[0] !=3D STDIN_FILENO)=0A= + close (fds[0]);=0A= + if (fds[1] !=3D STDOUT_FILENO)=0A= + close (fds[1]);=0A= + if (fds[2] !=3D STDERR_FILENO)=0A= + close (fds[2]);=0A= +=20=0A= + inferior_ptid =3D do_attach (pid_to_ptid (pid));=0A= +=20=0A= + attach_flag =3D 0;=0A= + flags =3D _DEBUG_FLAG_KLC; /* Kill-on-Last-Close flag */=0A= + if ((errn =3D=0A= + devctl (ctl_fd, DCMD_PROC_SET_FLAG, &flags, sizeof (flags), 0)) != =3D EOK)=0A= + {=0A= + /* warning( "Failed to set Kill-on-Last-Close flag: errno =3D %d(%s= )\n", errn, strerror(errn) ); */=0A= + }=0A= + push_target (&procfs_ops);=0A= + target_terminal_init ();=0A= +=20=0A= + #ifdef SOLIB_CREATE_INFERIOR_HOOK=0A= + if (exec_bfd !=3D NULL=0A= + || (symfile_objfile !=3D NULL && symfile_objfile->obfd !=3D NULL))= =0A= + SOLIB_CREATE_INFERIOR_HOOK (pid);=0A= + #endif=0A= + }=0A= +=20=0A= + static void=0A= + procfs_stop ()=0A= + {=0A= + devctl (ctl_fd, DCMD_PROC_STOP, NULL, 0, 0);=0A= + }=0A= +=20=0A= + static void=0A= + procfs_kill_inferior ()=0A= + {=0A= + target_mourn_inferior ();=0A= + }=0A= +=20=0A= + /* Store register REGNO, or all registers if REGNO =3D=3D -1, from the co= ntents=0A= + of REGISTERS. */=0A= +=20=0A= + static void=0A= + procfs_prepare_to_store ()=0A= + {=0A= + }=0A= +=20=0A= + void=0A= + procfs_store_registers (regno)=0A= + int regno;=0A= + {=0A= + union=0A= + {=0A= + procfs_greg greg;=0A= + procfs_fpreg fpreg;=0A= + }=0A= + reg;=0A= + unsigned first;=0A= + unsigned last;=0A= + unsigned end;=0A= + unsigned off;=0A= + unsigned len;=0A= + unsigned char subcmd;=0A= + char *data;=0A= +=20=0A= + if (ptid_equal (inferior_ptid, null_ptid))=0A= + return;=0A= + procfs_set_thread (inferior_ptid);=0A= +=20=0A= + if (regno =3D=3D -1)=0A= + {=0A= + first =3D 0;=0A= + last =3D NUM_REGS - 1;=0A= + }=0A= + else=0A= + {=0A= + first =3D regno;=0A= + last =3D regno;=0A= + }=0A= + while (first <=3D last)=0A= + {=0A= + end =3D nto_cpu_register_area (first, last, &subcmd, &off, &len);= =0A= + switch (subcmd)=0A= + {=0A= + case DSMSG_REG_GENERAL:=0A= + if (devctl=0A= + (ctl_fd, DCMD_PROC_GETGREG, ®.greg, sizeof (reg.greg),=0A= + 0) !=3D EOK)=0A= + {=0A= + printf ("error fetching general registers\n");=0A= + break;=0A= + }=0A= + data =3D (char *) ®.greg + off;=0A= + if (nto_cpu_register_store (0, first, end, data))=0A= + {=0A= + devctl (ctl_fd, DCMD_PROC_SETGREG, ®.greg,=0A= + sizeof (reg.greg), 0);=0A= + }=0A= + break;=0A= + case DSMSG_REG_FLOAT:=0A= + if (devctl=0A= + (ctl_fd, DCMD_PROC_GETFPREG, ®.fpreg,=0A= + sizeof (reg.fpreg), 0) !=3D EOK)=0A= + {=0A= + /* Do not print a warning. Not all inferiors=20=0A= + have fpregs. */=0A= + break;=0A= + }=0A= + data =3D (char *) ®.fpreg + off;=0A= + if (nto_cpu_register_store (0, first, end, data))=0A= + {=0A= + devctl (ctl_fd, DCMD_PROC_SETFPREG, ®.fpreg,=0A= + sizeof (reg.fpreg), 0);=0A= + }=0A= + break;=0A= + case DSMSG_REG_SYSTEM:=0A= + break;=0A= + default:=0A= + break;=0A= + }=0A= + first =3D end + 1;=0A= + }=0A= + }=0A= +=20=0A= + static void=0A= + notice_signals (void)=0A= + {=0A= + int signo;=0A= +=20=0A= + for (signo =3D 1; signo < NSIG; signo++)=0A= + {=0A= + if (signal_stop_state (target_signal_from_host (signo)) =3D=3D 0 &&= =0A= + signal_print_state (target_signal_from_host (signo)) =3D=3D 0 &&=0A= + signal_pass_state (target_signal_from_host (signo)) =3D=3D 1)=0A= + {=0A= + sigdelset (&run.trace, signo);=0A= + }=0A= + else=0A= + {=0A= + sigaddset (&run.trace, signo);=0A= + }=0A= + }=0A= + }=0A= +=20=0A= + /*=0A= +=20=0A= + GLOBAL FUNCTION=0A= +=20=0A= + procfs_notice_signals=0A= +=20=0A= + SYNOPSIS=0A= +=20=0A= + static void procfs_notice_signals (int pid);=0A= +=20=0A= + DESCRIPTION=0A= +=20=0A= + When the user changes the state of gdb's signal handling via the=0A= + "handle" command, this function gets called to see if any change=0A= + in the /proc interface is required. It is also called internally=0A= + by other /proc interface functions to initialize the state of=0A= + the traced signal set.=0A= +=20=0A= + One thing it does is that signals for which the state is "nostop",=0A= + "noprint", and "pass", have their trace bits reset in the pr_trace=0A= + field, so that they are no longer traced. This allows them to be=0A= + delivered directly to the inferior without the debugger ever being=0A= + involved.=0A= + */=0A= +=20=0A= + static void=0A= + procfs_notice_signals (pid)=0A= + int pid;=0A= + {=0A= + sigemptyset (&run.trace);=0A= + notice_signals ();=0A= + }=0A= +=20=0A= + static struct tidinfo *=0A= + procfs_thread_info (pid_t pid, short tid)=0A= + {=0A= + /* NYI */=0A= + return NULL;=0A= + }=0A= +=20=0A= + char *=0A= + procfs_pid_to_str (ptid_t ptid)=0A= + {=0A= + static char buf[1024];=0A= + int pid, tid, n;=0A= + struct tidinfo *tip;=0A= +=20=0A= + pid =3D ptid_get_pid (ptid);=0A= + tid =3D ptid_get_tid (ptid);=0A= +=20=0A= + n =3D sprintf (buf, "process %d", pid);=0A= +=20=0A= + tip =3D procfs_thread_info (pid, tid);=0A= + if (tip !=3D NULL)=0A= + sprintf (&buf[n], " (state =3D 0x%02x)", tip->state);=0A= +=20=0A= + return buf;=0A= + }=0A= +=20=0A= + static void=0A= + init_procfs_ops ()=0A= + {=0A= + procfs_ops.to_shortname =3D "procfs";=0A= + procfs_ops.to_longname =3D "QNX Neutrino procfs child process";=0A= + procfs_ops.to_doc =3D=0A= + "QNX Neutrino procfs child process (started by the \"run\" command).\= n\=0A= + target procfs ";=0A= + procfs_ops.to_open =3D procfs_open;=0A= + procfs_ops.to_attach =3D procfs_attach;=0A= + procfs_ops.to_detach =3D procfs_detach;=0A= + procfs_ops.to_resume =3D procfs_resume;=0A= + procfs_ops.to_wait =3D procfs_wait;=0A= + procfs_ops.to_fetch_registers =3D procfs_fetch_registers;=0A= + procfs_ops.to_store_registers =3D procfs_store_registers;=0A= + procfs_ops.to_prepare_to_store =3D procfs_prepare_to_store;=0A= + procfs_ops.to_xfer_memory =3D procfs_xfer_memory;=0A= + procfs_ops.to_files_info =3D procfs_files_info;=0A= + procfs_ops.to_insert_breakpoint =3D procfs_insert_breakpoint;=0A= + procfs_ops.to_remove_breakpoint =3D procfs_remove_breakpoint;=0A= + procfs_ops.to_can_use_hw_breakpoint =3D procfs_can_use_hw_breakpoint;= =0A= + procfs_ops.to_insert_hw_breakpoint =3D procfs_insert_hw_breakpoint;=0A= + procfs_ops.to_remove_hw_breakpoint =3D procfs_remove_breakpoint;=0A= + procfs_ops.to_insert_watchpoint =3D procfs_insert_hw_watchpoint;=0A= + procfs_ops.to_remove_watchpoint =3D procfs_remove_hw_watchpoint;=0A= + procfs_ops.to_stopped_by_watchpoint =3D procfs_stopped_by_watchpoint;= =0A= + procfs_ops.to_terminal_init =3D terminal_init_inferior;=0A= + procfs_ops.to_terminal_inferior =3D terminal_inferior;=0A= + procfs_ops.to_terminal_ours_for_output =3D terminal_ours_for_output;=0A= + procfs_ops.to_terminal_ours =3D terminal_ours;=0A= + procfs_ops.to_terminal_info =3D child_terminal_info;=0A= + procfs_ops.to_kill =3D procfs_kill_inferior;=0A= + procfs_ops.to_create_inferior =3D procfs_create_inferior;=0A= + procfs_ops.to_mourn_inferior =3D procfs_mourn_inferior;=0A= + procfs_ops.to_can_run =3D procfs_can_run;=0A= + procfs_ops.to_notice_signals =3D procfs_notice_signals;=0A= + procfs_ops.to_thread_alive =3D procfs_thread_alive;=0A= + procfs_ops.to_find_new_threads =3D procfs_find_new_threads;=0A= + procfs_ops.to_pid_to_str =3D procfs_pid_to_str;=0A= + procfs_ops.to_stop =3D procfs_stop;=0A= + procfs_ops.to_stratum =3D process_stratum;=0A= + procfs_ops.to_has_all_memory =3D 1;=0A= + procfs_ops.to_has_memory =3D 1;=0A= + procfs_ops.to_has_stack =3D 1;=0A= + procfs_ops.to_has_registers =3D 1;=0A= + procfs_ops.to_has_execution =3D 1;=0A= + procfs_ops.to_magic =3D OPS_MAGIC;=0A= + }=0A= +=20=0A= + extern int nto_ostype;=0A= +=20=0A= + void=0A= + _initialize_procfs ()=0A= + {=0A= + sigset_t set;=0A= + extern struct dscpuinfo nto_cpuinfo;=0A= + extern int nto_cpuinfo_valid;=0A= +=20=0A= + init_procfs_ops ();=0A= + add_target (&procfs_ops);=0A= + nto_ostype =3D OSTYPE_NTO;=0A= +=20=0A= + /* We use SIGUSR1 to gain control after we block waiting for a process.= =0A= + We use sigwaitevent to wait. */=0A= + sigemptyset (&set);=0A= + sigaddset (&set, SIGUSR1);=0A= + sigprocmask (SIG_BLOCK, &set, NULL);=0A= +=20=0A= + /* Set up trace and fault sets, as gdb expects them. */=0A= + sigemptyset (&run.trace);=0A= + notice_signals ();=0A= +=20=0A= + /* Stuff some information */=0A= + nto_cpuinfo.cpuflags =3D SYSPAGE_ENTRY (cpuinfo)->flags;=0A= + nto_cpuinfo_valid =3D 1;=0A= +=20=0A= + add_info ("pidlist", procfs_pidlist, "pidlist");=0A= + add_info ("meminfo", procfs_meminfo, "memory information");=0A= + }=0A= +=20=0A= +=20=0A= + static int=0A= + procfs_hw_watchpoint (int addr, int len, int type)=0A= + {=0A= + procfs_break brk;=0A= + int err;=0A= +=20=0A= + switch (type)=0A= + {=0A= + case 1: /* Read */=0A= + brk.type =3D _DEBUG_BREAK_RD;=0A= + break;=0A= + case 2: /* Read/Write */=0A= + brk.type =3D _DEBUG_BREAK_RW;=0A= + break;=0A= + default: /* Modify */=0A= + /* brk.type =3D _DEBUG_BREAK_RWM; This should work, shouldn't it? I g= et EINVAL */=0A= + brk.type =3D _DEBUG_BREAK_RW;=0A= + }=0A= + brk.type |=3D _DEBUG_BREAK_HW; /* always ask for HW */=0A= + brk.addr =3D addr;=0A= + brk.size =3D len;=0A= +=20=0A= + if ((err =3D devctl (ctl_fd, DCMD_PROC_BREAK, &brk, sizeof (brk), 0)) != =3D EOK)=0A= + {=0A= + errno =3D err;=0A= + perror ("Failed to set hardware watchpoint");=0A= + return -1;=0A= + }=0A= + return 0;=0A= + }=0A= +=20=0A= + static int=0A= + procfs_can_use_hw_breakpoint (int type, int cnt, int othertype)=0A= + {=0A= + return 1;=0A= + }=0A= +=20=0A= + static int=0A= + procfs_remove_hw_watchpoint (CORE_ADDR addr, int len, int type)=0A= + {=0A= + return procfs_hw_watchpoint (addr, -1, type);=0A= + }=0A= +=20=0A= + static int=0A= + procfs_insert_hw_watchpoint (CORE_ADDR addr, int len, int type)=0A= + {=0A= + return procfs_hw_watchpoint (addr, len, type);=0A= + }=0A= +=20=0A= + static int=0A= + procfs_stopped_by_watchpoint (void)=0A= + {=0A= + return 0;=0A= + }=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/nto-share/debug.h src.new/gdb/nto-share/debug.h=0A= *** src.orig/gdb/nto-share/debug.h Wed Dec 31 19:00:00 1969=0A= --- src.new/gdb/nto-share/debug.h Fri Feb 14 13:28:11 2003=0A= ***************=0A= *** 0 ****=0A= --- 1,429 ----=0A= + #ifndef __DEBUG_H_INCLUDED=0A= + #define __DEBUG_H_INCLUDED=0A= +=20=0A= + #include =0A= + #include =0A= + #include =0A= +=20=0A= + #define QNX_NOTE_NAME "QNX"=0A= +=20=0A= + enum Elf_nto_note_types=0A= + {=0A= + QNT_NULL =3D 0,=0A= + QNT_DEBUG_FULLPATH,=0A= + QNT_DEBUG_RELOC,=0A= + QNT_STACK,=0A= + QNT_GENERATOR,=0A= + QNT_DEFAULT_LIB,=0A= + QNT_CORE_SYSINFO,=0A= + QNT_CORE_INFO,=0A= + QNT_CORE_STATUS,=0A= + QNT_CORE_GREG,=0A= + QNT_CORE_FPREG,=0A= + QNT_NUM=0A= + };=0A= +=20=0A= + typedef struct=0A= + {=0A= + long bits[2];=0A= + } nto_sigset_t;=0A= +=20=0A= + union nto_sigval=0A= + {=0A= + int sival_int;=0A= + void *sival_ptr;=0A= + };=0A= +=20=0A= + typedef struct nto_siginfo=0A= + {=0A= + int si_signo;=0A= + int si_code; /* if SI_NOINFO, only si_signo is valid */=0A= + void (*si_handler) ();=0A= + union=0A= + {=0A= + int _pad[6];=0A= + struct=0A= + {=0A= + pid_t _pid;=0A= + union=0A= + {=0A= + struct=0A= + {=0A= + union nto_sigval _value;=0A= + uid_t _uid;=0A= + } _kill; /* si_code <=3D 0 SI_FROMUSER */=0A= + struct=0A= + {=0A= + int _status; /* CLD_EXITED status, else signo */=0A= + clock_t _utime;=0A= + clock_t _stime;=0A= + } _chld; /* si_signo=3DSIGCHLD si_code=3DCLD_* */=0A= + } _pdata;=0A= + } _proc;=0A= + struct=0A= + {=0A= + int _fltno;=0A= + void *_addr;=0A= + void *_fltip;=0A= + } _fault; /* si_signo=3DSIGSEGV,ILL,FPE,TRAP,BUS */=0A= + } _data;=0A= + } nto_siginfo_t;=0A= +=20=0A= + typedef struct arm_cpu_registers=0A= + {=0A= + unsigned gpr[16];=0A= + unsigned spsr;=0A= + } ARM_CPU_REGISTERS;=0A= +=20=0A= + typedef struct arm_fpu_registers=0A= + {=0A= + /*=0A= + * There is no architecturally defined FPU=0A= + */=0A= + unsigned __dummy;=0A= + } ARM_FPU_REGISTERS;=0A= +=20=0A= + typedef struct arm_alt_registers=0A= + {=0A= + union=0A= + {=0A= + struct xscale_cp0=0A= + {=0A= + unsigned acc0_lo;=0A= + unsigned acc0_hi;=0A= + } xscale;=0A= + } un;=0A= + } ARM_ALT_REGISTERS;=0A= +=20=0A= + typedef union=0A= + {=0A= + unsigned long long u64;=0A= + double f;=0A= + } mipsfloat;=0A= +=20=0A= + typedef struct mips_cpu_registers=0A= + {=0A= + unsigned regs[74];=0A= + unsigned long long regs_alignment;=0A= + } MIPS_CPU_REGISTERS;=0A= +=20=0A= + typedef struct mips_fpu_registers=0A= + {=0A= + mipsfloat fpr[32];=0A= + unsigned fpcr31;=0A= + } MIPS_FPU_REGISTERS;=0A= +=20=0A= + typedef struct mips_alt_registers=0A= + {=0A= + union=0A= + {=0A= + struct mips_tx79=0A= + {=0A= + unsigned long long gpr_hi[32];=0A= + unsigned long long lo1;=0A= + unsigned long long hi1;=0A= + unsigned sa;=0A= + } tx79;=0A= + } un;=0A= + } MIPS_ALT_REGISTERS;=0A= +=20=0A= + #ifdef __BIGREGS__=0A= + typedef unsigned long long ppcint;=0A= + #else=0A= + typedef unsigned ppcint;=0A= + #endif=0A= +=20=0A= + typedef union=0A= + {=0A= + unsigned long long u64;=0A= + double f;=0A= + } ppcfloat;=0A= +=20=0A= + typedef union=0A= + {=0A= + unsigned long long u64[2];=0A= + unsigned u32[4];=0A= + unsigned char u8[16];=0A= + float f32[4];=0A= + } ppcvmx;=0A= +=20=0A= + typedef struct ppc_cpu_registers=0A= + {=0A= + ppcint gpr[32];=0A= + ppcint ctr;=0A= + ppcint lr;=0A= + ppcint msr;=0A= + ppcint iar;=0A= + unsigned cr;=0A= + unsigned xer;=0A= + unsigned ear; /* not present on all chips */=0A= + unsigned mq; /* only on the 601 */=0A= + unsigned vrsave; /* on Altivec CPU's, SPR256 */=0A= + } PPC_CPU_REGISTERS;=0A= +=20=0A= + typedef struct ppc_fpu_registers=0A= + {=0A= + ppcfloat fpr[32];=0A= + unsigned fpscr;=0A= + unsigned fpscr_val;=0A= + /* load/store of fpscr is done through fprs, the real value is in [32,6= 3] of a fpr.=0A= + fpscr is the address for lfd, stfd. fpscr_val is the real value of f= pscr */=0A= + } PPC_FPU_REGISTERS;=0A= +=20=0A= + typedef struct ppc_vmx_registers=0A= + {=0A= + ppcvmx vmxr[32];=0A= + ppcvmx vscr;=0A= + } PPC_VMX_REGISTERS;=0A= +=20=0A= + typedef struct ppc_alt_registers=0A= + {=0A= + PPC_VMX_REGISTERS vmx;=0A= + } PPC_ALT_REGISTERS;=0A= +=20=0A= + typedef unsigned shint;=0A= +=20=0A= + typedef unsigned shfloat;=0A= +=20=0A= + typedef struct sh_cpu_registers=0A= + {=0A= + shint gr[16];=0A= + shint sr;=0A= + shint pc;=0A= + /* shint dbr; */=0A= + shint gbr;=0A= + shint mach;=0A= + shint macl;=0A= + shint pr;=0A= + } SH_CPU_REGISTERS;=0A= +=20=0A= + typedef struct sh_fpu_registers=0A= + {=0A= + shfloat fpr_bank0[16];=0A= + shfloat fpr_bank1[16];=0A= + unsigned fpul;=0A= + unsigned fpscr;=0A= + } SH_FPU_REGISTERS;=0A= +=20=0A= + typedef struct sh_alt_registers=0A= + {=0A= + /*=0A= + * There are no architecturally defined alt regs=0A= + */=0A= + unsigned __dummy;=0A= + } SH_ALT_REGISTERS;=0A= +=20=0A= + typedef struct x86_cpu_registers=0A= + {=0A= + #ifdef __SEGMENTS__=0A= + unsigned gs, fs;=0A= + unsigned es, ds;=0A= + #endif=0A= + unsigned edi, esi, ebp, exx, ebx, edx, ecx, eax;=0A= + unsigned eip, cs, efl;=0A= + unsigned esp, ss;=0A= + } X86_CPU_REGISTERS;=0A= +=20=0A= + typedef struct fsave_area=0A= + {=0A= + unsigned fpu_control_word;=0A= + unsigned fpu_status_word;=0A= + unsigned fpu_tag_word;=0A= + unsigned fpu_ip;=0A= + unsigned fpu_cs;=0A= + unsigned fpu_op;=0A= + unsigned fpu_ds;=0A= + unsigned char st_regs[80]; /* each register is 10 bytes! */=0A= + } X86_FSAVE_REGISTERS;=0A= +=20=0A= + typedef struct fxsave_area=0A= + {=0A= + unsigned short fpu_control_word;=0A= + unsigned short fpu_status_word;=0A= + unsigned short fpu_tag_word;=0A= + unsigned short fpu_operand;=0A= + unsigned fpu_ip;=0A= + unsigned fpu_cs;=0A= + unsigned fpu_op;=0A= + unsigned fpu_ds;=0A= + unsigned mxcsr;=0A= + unsigned reserved;=0A= + unsigned char st_regs[128];=0A= + unsigned char xmm_regs[128];=0A= + unsigned char reserved2[224];=0A= + } X86_FXSAVE_REGISTERS;=0A= +=20=0A= + typedef union x86_fpu_registers=0A= + {=0A= + X86_FSAVE_REGISTERS fsave_area;=0A= + X86_FXSAVE_REGISTERS fxsave_area;=0A= + unsigned char data[512]; /* Needs to be this big for the emulator. */= =0A= + } X86_FPU_REGISTERS;=0A= +=20=0A= + #ifdef __QNX__=0A= + __BEGIN_DECLS=0A= + #include <_pack64.h>=0A= + #endif=0A= + #define _DEBUG_FLAG_STOPPED 0x00000001 /* Thread is not running */=0A= + #define DEBUG_FLAG_ISTOP 0x00000002 /* Stopped at point of interest */= =0A= + #define _DEBUG_FLAG_IPINVAL 0x00000010 /* IP is not valid */=0A= + #define _DEBUG_FLAG_ISSYS 0x00000020 /* System process */=0A= + #define _DEBUG_FLAG_SSTEP 0x00000040 /* Stopped because of single step = */=0A= + #define _DEBUG_FLAG_CURTID 0x00000080 /* Thread is current thread */=0A= + #define DEBUG_FLAG_TRACE_EXEC 0x00000100 /* Stopped because of breakpoin= t */=0A= + #define _DEBUG_FLAG_TRACE_RD 0x00000200 /* Stopped because of read acces= s */=0A= + #define _DEBUG_FLAG_TRACE_WR 0x00000400 /* Stopped because of write acce= ss */=0A= + #define _DEBUG_FLAG_TRACE_MODIFY 0x00000800 /* Stopped because of modifie= d memory */=0A= + #define _DEBUG_FLAG_RLC 0x00010000 /* Run-on-Last-Close flag is set */= =0A= + #define _DEBUG_FLAG_KLC 0x00020000 /* Kill-on-Last-Close flag is set *= /=0A= + #define _DEBUG_FLAG_FORK 0x00040000 /* Child inherits flags (Stop on fo= rk/spawn) */=0A= + #define _DEBUG_FLAG_MASK 0x000f0000 /* Flags that can be changed */=0A= + enum=0A= + {=0A= + _DEBUG_WHY_REQUESTED,=0A= + _DEBUG_WHY_SIGNALLED,=0A= + _DEBUG_WHY_FAULTED,=0A= + _DEBUG_WHY_JOBCONTROL,=0A= + _DEBUG_WHY_TERMINATED,=0A= + _DEBUG_WHY_CHILD,=0A= + _DEBUG_WHY_EXEC=0A= + };=0A= +=20=0A= + #define _DEBUG_RUN_CLRSIG 0x00000001 /* Clear pending signal */=0A= + #define _DEBUG_RUN_CLRFLT 0x00000002 /* Clear pending fault */=0A= + #define DEBUG_RUN_TRACE 0x00000004 /* Trace mask flags interesting sign= als */=0A= + #define DEBUG_RUN_HOLD 0x00000008 /* Hold mask flags interesting signa= ls */=0A= + #define DEBUG_RUN_FAULT 0x00000010 /* Fault mask flags interesting faul= ts */=0A= + #define _DEBUG_RUN_VADDR 0x00000020 /* Change ip before running */=0A= + #define _DEBUG_RUN_STEP 0x00000040 /* Single step only one thread */= =0A= + #define _DEBUG_RUN_STEP_ALL 0x00000080 /* Single step one thread, other= threads run */=0A= + #define _DEBUG_RUN_CURTID 0x00000100 /* Change current thread (target t= hread) */=0A= + #define DEBUG_RUN_ARM 0x00000200 /* Deliver event at point of interest= */=0A= +=20=0A= + typedef struct _debug_process_info=0A= + {=0A= + pid_t pid;=0A= + pid_t parent;=0A= + unsigned flags;=0A= + unsigned umask;=0A= + pid_t child;=0A= + pid_t sibling;=0A= + pid_t pgrp;=0A= + pid_t sid;=0A= + int base_address;=0A= + int initial_stack;=0A= + uid_t uid;=0A= + gid_t gid;=0A= + uid_t euid;=0A= + gid_t egid;=0A= + uid_t suid;=0A= + gid_t sgid;=0A= + nto_sigset_t sig_ignore;=0A= + nto_sigset_t sig_queue;=0A= + nto_sigset_t sig_pending;=0A= + unsigned num_chancons;=0A= + unsigned num_fdcons;=0A= + unsigned num_threads;=0A= + unsigned num_timers;=0A= + unsigned long long reserved[20];=0A= + } nto_procfs_info;=0A= +=20=0A= + typedef struct _debug_thread_info=0A= + {=0A= + pid_t pid;=0A= + unsigned tid;=0A= + unsigned flags;=0A= + unsigned short why;=0A= + unsigned short what;=0A= + int ip;=0A= + int sp;=0A= + int stkbase;=0A= + int tls;=0A= + unsigned stksize;=0A= + unsigned tid_flags;=0A= + unsigned char priority;=0A= + unsigned char real_priority;=0A= + unsigned char policy;=0A= + unsigned char state;=0A= + short syscall;=0A= + unsigned short last_cpu;=0A= + unsigned timeout;=0A= + int last_chid;=0A= + nto_sigset_t sig_blocked;=0A= + nto_sigset_t sig_pending;=0A= + nto_siginfo_t info;=0A= + unsigned reserved1;=0A= + union=0A= + {=0A= + struct=0A= + {=0A= + unsigned tid;=0A= + } join;=0A= + struct=0A= + {=0A= + int id;=0A= + int sync;=0A= + } sync;=0A= + struct=0A= + {=0A= + unsigned nid;=0A= + pid_t pid;=0A= + int coid;=0A= + int chid;=0A= + int scoid;=0A= + } connect;=0A= + struct=0A= + {=0A= + int chid;=0A= + } channel;=0A= + struct=0A= + {=0A= + pid_t pid;=0A= + int vaddr;=0A= + unsigned flags;=0A= + } waitpage;=0A= + struct=0A= + {=0A= + unsigned size;=0A= + } stack;=0A= + unsigned long long filler[4];=0A= + } blocked;=0A= + unsigned long long reserved2[8];=0A= + } nto_procfs_status;=0A= +=20=0A= + typedef union _debug_gregs=0A= + {=0A= + ARM_CPU_REGISTERS arm;=0A= + MIPS_CPU_REGISTERS mips;=0A= + PPC_CPU_REGISTERS ppc;=0A= + SH_CPU_REGISTERS sh;=0A= + X86_CPU_REGISTERS x86;=0A= + unsigned long long padding[1024];=0A= + } nto_gregset_t;=0A= +=20=0A= + typedef union _debug_fpregs=0A= + {=0A= + /* ARM_FPU_REGISTERS arm; */=0A= + MIPS_FPU_REGISTERS mips;=0A= + PPC_FPU_REGISTERS ppc;=0A= + SH_FPU_REGISTERS sh;=0A= + X86_FPU_REGISTERS x86;=0A= + unsigned long long padding[1024];=0A= + } nto_fpregset_t;=0A= +=20=0A= + typedef union _debug_altregs=0A= + {=0A= + ARM_ALT_REGISTERS arm;=0A= + MIPS_ALT_REGISTERS mips;=0A= + PPC_ALT_REGISTERS ppc;=0A= + /* SH_ALT_REGISTERS sh; */=0A= + /* X86_ALT_REGISTERS x86; */=0A= + unsigned long long padding[1024];=0A= + } debug_altreg_t;=0A= +=20=0A= + #ifdef __QNX__=0A= + #include <_packpop.h>=0A= +=20=0A= + __END_DECLS=0A= + #endif=0A= + #endif=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/nto-share/dsmsgs.h src.new/gdb/nto-share/dsmsgs.h=0A= *** src.orig/gdb/nto-share/dsmsgs.h Wed Dec 31 19:00:00 1969=0A= --- src.new/gdb/nto-share/dsmsgs.h Fri Feb 14 15:37:26 2003=0A= ***************=0A= *** 0 ****=0A= --- 1,714 ----=0A= + #ifndef __DSMSGS_H__=0A= + #define __DSMSGS_H__=0A= +=20=0A= + /* These are the protocol versioning numbers=0A= + Update them with changes that introduce potential=20=0A= + compatibility issues */=0A= + #define PDEBUG_PROTOVER_MAJOR 0x00000000=0A= + #define PDEBUG_PROTOVER_MINOR 0x00000003=0A= +=20=0A= + #include =0A= +=20=0A= + /* These are pdebug specific errors, sent sometimes with the errno after= =0A= + an action failed. Simply provides additional info on the reason for t= he=20=0A= + error. Sent in the DSrMsg_err_t.hdr.subcmd byte. */=0A= +=20=0A= + #define PDEBUG_ENOERR 0 /* No error */=0A= + #define PDEBUG_ENOPTY 1 /* No Pseudo Terminals found */=0A= + #define PDEBUG_ETHREAD 2 /* Thread Create error */=0A= + #define PDEBUG_ECONINV 3 /* Invalid Console number */=0A= + #define PDEBUG_ESPAWN 4 /* Spawn error */=0A= + #define PDEBUG_EPROCFS 5 /* NTO Proc File System error */=0A= + #define PDEBUG_EPROCSTOP 6 /* NTO Process Stop error */=0A= + #define PDEBUG_EQPSINFO 7 /* QNX4 PSINFO error */=0A= + #define PDEBUG_EQMEMMODEL 8 /* QNX4 - Flat Memory Model only supported */= =0A= + #define PDEBUG_EQPROXY 9 /* QNX4 Proxy error */=0A= + #define PDEBUG_EQDBG 10 /* QNX4 qnx_debug_* error */=0A= +=20=0A= + /* There is room for pdebugerrnos up to sizeof(unsigned char)=0A= +=20=0A= + We are moving away from the channel commands - only the RESET=0A= + and NAK are required. The DEBUG and TEXT channels are now part=0A= + of the DShdr and TShdr structs, 4th byte. GP June 1 1999.=0A= + They are still supported, but not required.=20=0A= +=20=0A= + A packet containg a single byte is a set channel command.=20=0A= + IE: 7e xx chksum 7e=20=0A= +=20=0A= + After a set channel all following packets are in the format=0A= + for the specified channel. Currently three channels are defined.=0A= + The raw channel has no structure. The other channels are all framed.= =0A= + The contents of each channel is defined by structures below.=20=0A= +=20=20=20=0A= + 0 - Reset channel. Used when either end starts.=0A= +=20=20=20=0A= + 1 - Debug channel with the structure which follows below.=0A= + Uses DS (Debug Services) prefix.=0A= +=20=20=20=0A= + 2 - Text channel with the structure which follows below.=0A= + Uses TS (Text Services) prefix.=0A= +=20=20=20=0A= + 0xff - Negative acknowledgment of a packet transmission. */=0A= +=20=0A= + #define SET_CHANNEL_RESET 0=0A= + #define SET_CHANNEL_DEBUG 1=0A= + #define SET_CHANNEL_TEXT 2=0A= + #define SET_CHANNEL_NAK 0xff=0A= +=20=0A= +=20=0A= + /* Debug channel Messages: DS - Debug services */=0A= +=20=0A= + /* Defines and structures for the debug channel. */=0A= +=20=0A= + #define DS_DATA_MAX_SIZE 1024=0A= + #define DS_DATA_RCV_SIZE(msg, total) ((total) - (sizeof(*(msg)) - DS_DATA= _MAX_SIZE))=0A= + #define DS_MSG_OKSTATUS_FLAG 0x20000000=0A= + #define DS_MSG_OKDATA_FLAG 0x40000000=0A= + #define DS_MSG_NO_RESPONSE 0x80000000=0A= +=20=0A= + #define QNXNTO_NSIG 57 /* from signals.h NSIG */=0A= +=20=0A= + /* Common message header. It must be 32 or 64 bit aligned.=0A= + The top bit of cmd is 1 for BIG endian data format. */=0A= + #define DSHDR_MSG_BIG_ENDIAN 0x80=0A= + struct DShdr=0A= + {=0A= + unsigned char cmd;=0A= + unsigned char subcmd;=0A= + unsigned char mid;=0A= + unsigned char channel;=0A= + };=0A= +=20=0A= + /* Command types */=0A= + enum=0A= + {=0A= + DStMsg_connect, /* 0 0x0 */=0A= + DStMsg_disconnect, /* 1 0x1 */=0A= + DStMsg_select, /* 2 0x2 */=0A= + DStMsg_mapinfo, /* 3 0x3 */=0A= + DStMsg_load, /* 4 0x4 */=0A= + DStMsg_attach, /* 5 0x5 */=0A= + DStMsg_detach, /* 6 0x6 */=0A= + DStMsg_kill, /* 7 0x7 */=0A= + DStMsg_stop, /* 8 0x8 */=0A= + DStMsg_memrd, /* 9 0x9 */=0A= + DStMsg_memwr, /* 10 0xA */=0A= + DStMsg_regrd, /* 11 0xB */=0A= + DStMsg_regwr, /* 12 0xC */=0A= + DStMsg_run, /* 13 0xD */=0A= + DStMsg_brk, /* 14 0xE */=0A= + DStMsg_fileopen, /* 15 0xF */=0A= + DStMsg_filerd, /* 16 0x10 */=0A= + DStMsg_filewr, /* 17 0x11 */=0A= + DStMsg_fileclose, /* 18 0x12 */=0A= + DStMsg_pidlist, /* 19 0x13 */=0A= + DStMsg_cwd, /* 20 0x14 */=0A= + DStMsg_env, /* 21 0x15 */=0A= + DStMsg_base_address, /* 22 0x16 */=0A= + DStMsg_protover, /* 23 0x17 */=0A= + DStMsg_handlesig, /* 24 0x18 */=0A= + DStMsg_cpuinfo, /* 25 0x19 */=0A= + /* Room for new codes here */=0A= + DSrMsg_err =3D 32, /* 32 0x20 */=0A= + DSrMsg_ok, /* 33 0x21 */=0A= + DSrMsg_okstatus, /* 34 0x22 */=0A= + DSrMsg_okdata, /* 35 0x23 */=0A= + /* Room for new codes here */=0A= + DShMsg_notify =3D 64 /* 64 0x40 */=0A= + };=0A= +=20=0A= +=20=0A= + /* Subcommand types */=0A= + enum=0A= + {=0A= + DSMSG_LOAD_DEBUG,=0A= + DSMSG_LOAD_RUN,=0A= + DSMSG_LOAD_RUN_PERSIST,=0A= + DSMSG_LOAD_INHERIT_ENV =3D 0x80=0A= + };=0A= +=20=0A= + enum=0A= + {=0A= + DSMSG_ENV_CLEARARGV,=0A= + DSMSG_ENV_ADDARG,=0A= + DSMSG_ENV_CLEARENV,=0A= + DSMSG_ENV_SETENV,=0A= + DSMSG_ENV_SETENV_MORE=0A= + };=0A= +=20=0A= + enum=0A= + {=0A= + DSMSG_STOP_PID,=0A= + DSMSG_STOP_PIDS=0A= + };=0A= +=20=0A= + enum=0A= + {=0A= + DSMSG_SELECT_SET,=0A= + DSMSG_SELECT_QUERY=0A= + };=0A= +=20=0A= + enum=0A= + {=0A= + DSMSG_KILL_PIDTID,=0A= + DSMSG_KILL_PID,=0A= + DSMSG_KILL_PIDS=0A= + };=0A= +=20=0A= + enum=0A= + {=0A= + DSMSG_MEM_VIRTUAL,=0A= + DSMSG_MEM_PHYSICAL,=0A= + DSMSG_MEM_IO,=0A= + DSMSG_MEM_BASEREL=0A= + };=0A= +=20=0A= + enum=0A= + {=0A= + DSMSG_REG_GENERAL,=0A= + DSMSG_REG_FLOAT,=0A= + DSMSG_REG_SYSTEM,=0A= + DSMSG_REG_ALT=0A= + };=0A= +=20=0A= + enum=0A= + {=0A= + DSMSG_RUN,=0A= + DSMSG_RUN_COUNT,=0A= + DSMSG_RUN_RANGE,=0A= + };=0A= +=20=0A= + enum=0A= + {=0A= + DSMSG_PIDLIST_BEGIN,=0A= + DSMSG_PIDLIST_NEXT,=0A= + DSMSG_PIDLIST_SPECIFIC,=0A= + DSMSG_PIDLIST_SPECIFIC_TID, /* *_TID - send starting tid for the reques= t, */=0A= + }; /* and the response will have total to be sent */=0A= +=20=0A= + enum=0A= + {=0A= + DSMSG_CWD_QUERY,=0A= + DSMSG_CWD_SET,=0A= + };=0A= +=20=0A= + enum=0A= + {=0A= + DSMSG_MAPINFO_BEGIN =3D 0x01,=0A= + DSMSG_MAPINFO_NEXT =3D 0x02,=0A= + DSMSG_MAPINFO_SPECIFIC =3D 0x04,=0A= + DSMSG_MAPINFO_ELF =3D 0x80,=0A= + };=0A= +=20=0A= + enum=0A= + {=0A= + DSMSG_PROTOVER_MINOR =3D 0x000000FF, /* bit field (status & DSMSG_PROTO= VER_MAJOR) */=0A= + DSMSG_PROTOVER_MAJOR =3D 0x0000FF00, /* bit field (status & DSMSG_PROTO= VER_MINOR) */=0A= + };=0A= +=20=0A= + enum=0A= + {=0A= + DSMSG_BRK_EXEC =3D 0x0001, /* execution breakpoint */=0A= + DSMSG_BRK_RD =3D 0x0002, /* read access (fail if not supported) */=0A= + DSMSG_BRK_WR =3D 0x0004, /* write access (fail if not supported) */=0A= + DSMSG_BRK_RW =3D 0x0006, /* read or write access (fail if not supported= ) */=0A= + DSMSG_BRK_MODIFY =3D 0x0008, /* memory modified */=0A= + DSMSG_BRK_RDM =3D 0x000a, /* read access if suported otherwise modified= */=0A= + DSMSG_BRK_WRM =3D 0x000c, /* write access if suported otherwise modifie= d */=0A= + DSMSG_BRK_RWM =3D 0x000e, /* read or write access if suported otherwise= modified */=0A= + DSMSG_BRK_HW =3D 0x0010, /* only use hardware debugging (i.e. no single= step) */=0A= + };=0A= +=20=0A= + enum=0A= + {=0A= + DSMSG_NOTIFY_PIDLOAD, /* 0 */=0A= + DSMSG_NOTIFY_TIDLOAD, /* 1 */=0A= + DSMSG_NOTIFY_DLLLOAD, /* 2 */=0A= + DSMSG_NOTIFY_PIDUNLOAD, /* 3 */=0A= + DSMSG_NOTIFY_TIDUNLOAD, /* 4 */=0A= + DSMSG_NOTIFY_DLLUNLOAD, /* 5 */=0A= + DSMSG_NOTIFY_BRK, /* 6 */=0A= + DSMSG_NOTIFY_STEP, /* 7 */=0A= + DSMSG_NOTIFY_SIGEV, /* 8 */=0A= + DSMSG_NOTIFY_STOPPED /* 9 */=0A= + };=0A= +=20=0A= +=20=0A= +=20=0A= + /* Messages sent to the target. DStMsg_* (t - for target messages) */=0A= +=20=0A= + /* Connect to the agent running on the target */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + unsigned char major;=0A= + unsigned char minor;=0A= + unsigned char spare[2];=0A= + } DStMsg_connect_t;=0A= +=20=0A= +=20=0A= + /* Disconnect from the agent running on the target */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + } DStMsg_disconnect_t;=0A= +=20=0A= +=20=0A= + /* Select a pid, tid for subsequent messages or query their validity */= =0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + int pid;=0A= + int tid;=0A= + } DStMsg_select_t;=0A= +=20=0A= +=20=0A= + /* Return information on what is at the specified virtual address.=0A= + If nothing is there we return info on the next thing in the address. *= /=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + int pid;=0A= + int addr;=0A= + } DStMsg_mapinfo_t;=0A= +=20=0A= +=20=0A= + /* Load a new process into memory for a filesystem */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + int argc;=0A= + int envc;=0A= + char cmdline[DS_DATA_MAX_SIZE];=0A= + } DStMsg_load_t;=0A= +=20=0A= +=20=0A= + /* Attach to an already running process */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + int pid;=0A= + } DStMsg_attach_t;=0A= +=20=0A= +=20=0A= + /* Detach from a running process which was attached to or loaded */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + int pid;=0A= + } DStMsg_detach_t;=0A= +=20=0A= +=20=0A= + /* Set a signal on a process */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + int signo;=0A= + } DStMsg_kill_t;=0A= +=20=0A= +=20=0A= + /* Stop one or more processes/threads */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + } DStMsg_stop_t;=0A= +=20=0A= +=20=0A= + /* Memory read request */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + unsigned spare0;=0A= + unsigned long long addr;=0A= + unsigned short size;=0A= + } DStMsg_memrd_t;=0A= +=20=0A= +=20=0A= + /* Memory write request */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + unsigned spare0;=0A= + unsigned long long addr;=0A= + unsigned char data[DS_DATA_MAX_SIZE];=0A= + } DStMsg_memwr_t;=0A= +=20=0A= +=20=0A= + /* Register read request */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + unsigned short offset;=0A= + unsigned short size;=0A= + } DStMsg_regrd_t;=0A= +=20=0A= +=20=0A= + /* Register write request */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + unsigned short offset;=0A= + unsigned char data[DS_DATA_MAX_SIZE];=0A= + } DStMsg_regwr_t;=0A= +=20=0A= +=20=0A= + /* Run */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + union=0A= + {=0A= + unsigned count;=0A= + unsigned addr[2];=0A= + } step;=0A= + } DStMsg_run_t;=0A= +=20=0A= +=20=0A= + /* Break */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + unsigned addr;=0A= + unsigned size;=0A= + } DStMsg_brk_t;=0A= +=20=0A= +=20=0A= + /* Open a file on the target */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + int mode;=0A= + int perms;=0A= + char pathname[DS_DATA_MAX_SIZE];=0A= + } DStMsg_fileopen_t;=0A= +=20=0A= +=20=0A= + /* Read a file on the target */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + unsigned short size;=0A= + } DStMsg_filerd_t;=0A= +=20=0A= +=20=0A= + /* Write a file on the target */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + unsigned char data[DS_DATA_MAX_SIZE];=0A= + } DStMsg_filewr_t;=0A= +=20=0A= +=20=0A= + /* Close a file on the target */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + int mtime;=0A= + } DStMsg_fileclose_t;=0A= +=20=0A= +=20=0A= + /* Get pids and process names in the system */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + int pid; /* Only valid for type subtype SPECIFIC */=0A= + int tid; /* tid to start reading from */=0A= + } DStMsg_pidlist_t;=0A= +=20=0A= +=20=0A= + /* Set current working directory of process */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + unsigned char path[DS_DATA_MAX_SIZE];=0A= + } DStMsg_cwd_t;=0A= +=20=0A= +=20=0A= + /* clear, set, get environment for new process */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + char data[DS_DATA_MAX_SIZE];=0A= + } DStMsg_env_t;=0A= +=20=0A= +=20=0A= + /* Get the base address of a process */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + } DStMsg_baseaddr_t;=0A= +=20=0A= +=20=0A= + /* Send pdebug protocol version info, get the same in response_ok_status = */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + unsigned char major;=0A= + unsigned char minor;=0A= + } DStMsg_protover_t;=0A= +=20=0A= +=20=0A= + /* Handle signal message. */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + unsigned char signals[QNXNTO_NSIG];=0A= + unsigned sig_to_pass;=0A= + } DStMsg_handlesig_t;=0A= +=20=0A= +=20=0A= + /* Get some cpu info */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + unsigned spare;=0A= + } DStMsg_cpuinfo_t;=0A= +=20=0A= +=20=0A= + /* Messages sent to the host. DStMsg_* (h - for host messages) */=0A= +=20=0A= + /* Notify host that something happened it needs to know about */=0A= + #define NOTIFY_HDR_SIZE offsetof(DShMsg_notify_t, un)=0A= + #define NOTIFY_MEMBER_SIZE(member) sizeof(member)=0A= +=20=0A= + /* Keep this consistant with neutrino syspage.h */=0A= + enum=0A= + {=0A= + CPUTYPE_X86,=0A= + CPUTYPE_PPC,=0A= + CPUTYPE_MIPS,=0A= + CPUTYPE_SPARE,=0A= + CPUTYPE_ARM,=0A= + CPUTYPE_SH=0A= + };=0A= +=20=0A= + enum=0A= + {=0A= + OSTYPE_QNX4,=0A= + OSTYPE_NTO=0A= + };=0A= +=20=0A= + typedef struct aaa=0A= + {=0A= + struct DShdr hdr;=0A= + int pid;=0A= + int tid;=0A= + union=0A= + {=0A= + struct=0A= + {=0A= + unsigned codeoff;=0A= + unsigned dataoff;=0A= + unsigned short ostype;=0A= + unsigned short cputype;=0A= + unsigned cpuid; /* CPU dependant value */=0A= + char name[DS_DATA_MAX_SIZE];=0A= + } pidload;=0A= + struct=0A= + {=0A= + int status;=0A= + } pidunload;=0A= + struct=0A= + {=0A= + int status;=0A= + unsigned char faulted;=0A= + unsigned char reserved[3];=0A= + } pidunload_v3;=0A= + struct=0A= + {=0A= + unsigned ip;=0A= + unsigned dp;=0A= + unsigned flags; /* defined in */=0A= + } brk;=0A= + struct=0A= + {=0A= + unsigned ip;=0A= + unsigned lastip;=0A= + } step;=0A= + struct=0A= + {=0A= + int signo;=0A= + int code;=0A= + int value;=0A= + } sigev;=0A= + } un;=0A= + } DShMsg_notify_t;=0A= +=20=0A= +=20=0A= +=20=0A= + /* Responses to a message. DSrMsg_* (r - for response messages) */=0A= +=20=0A= + /* Error response packet */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + int err;=0A= + } DSrMsg_err_t;=0A= +=20=0A= + /* Simple OK response. */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + } DSrMsg_ok_t;=0A= +=20=0A= +=20=0A= + /* Simple OK response with a result. Used where limited data needs=0A= + to be returned. For example, if the number of bytes which were=0A= + successfully written was less than requested on any write cmd the=0A= + status will be the number actually written.=0A= + The 'subcmd' will always be zero. */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + int status;=0A= + } DSrMsg_okstatus_t;=0A= +=20=0A= +=20=0A= + /* The following structures overlay data[..] on a DSrMsg_okdata_t */=0A= + struct dslinkmap=0A= + {=0A= + unsigned addr;=0A= + unsigned size;=0A= + unsigned flags;=0A= + unsigned debug_vaddr;=0A= + unsigned long long offset;=0A= + };=0A= +=20=0A= + struct dsmapinfo=0A= + {=0A= + struct dsmapinfo *next;=0A= + unsigned spare0;=0A= + unsigned long long ino;=0A= + unsigned dev;=0A= + unsigned spare1;=0A= + struct dslinkmap text;=0A= + struct dslinkmap data;=0A= + char name[256];=0A= + };=0A= +=20=0A= + struct dspidlist=0A= + {=0A= + int pid;=0A= + int num_tids; /* num of threads this pid has */=0A= + int spare[6];=0A= + struct tidinfo=0A= + {=0A= + short tid;=0A= + unsigned char state;=0A= + unsigned char flags;=0A= + } tids[1]; /* Variable length terminated by tid=3D=3D0 */=0A= + char name[1]; /* Variable length terminated by \0 */=0A= + };=0A= +=20=0A= + struct dscpuinfo=0A= + {=0A= + unsigned cpuflags;=0A= + unsigned spare1;=0A= + unsigned spare2;=0A= + unsigned spare3;=0A= + };=0A= +=20=0A= + /* Long OK response with 0..DS_DATA_MAX_SIZE data.=0A= + The 'subcmd' will always be zero. */=0A= + typedef struct=0A= + {=0A= + struct DShdr hdr;=0A= + unsigned char data[DS_DATA_MAX_SIZE];=0A= + } DSrMsg_okdata_t;=0A= +=20=0A= +=20=0A= + /* A union of all possible messages and responses. */=0A= + typedef union=0A= + {=0A= + struct DShdr hdr;=0A= + DStMsg_connect_t connect;=0A= + DStMsg_disconnect_t disconnect;=0A= + DStMsg_select_t select;=0A= + DStMsg_load_t load;=0A= + DStMsg_attach_t attach;=0A= + DStMsg_detach_t detach;=0A= + DStMsg_kill_t kill;=0A= + DStMsg_stop_t stop;=0A= + DStMsg_memrd_t memrd;=0A= + DStMsg_memwr_t memwr;=0A= + DStMsg_regrd_t regrd;=0A= + DStMsg_regwr_t regwr;=0A= + DStMsg_run_t run;=0A= + DStMsg_brk_t brk;=0A= + DStMsg_fileopen_t fileopen;=0A= + DStMsg_filerd_t filerd;=0A= + DStMsg_filewr_t filewr;=0A= + DStMsg_fileclose_t fileclose;=0A= + DStMsg_pidlist_t pidlist;=0A= + DStMsg_mapinfo_t mapinfo;=0A= + DStMsg_cwd_t cwd;=0A= + DStMsg_env_t env;=0A= + DStMsg_baseaddr_t baseaddr;=0A= + DStMsg_protover_t protover;=0A= + DStMsg_handlesig_t handlesig;=0A= + DStMsg_cpuinfo_t cpuinfo;=0A= + DShMsg_notify_t notify;=0A= + DSrMsg_err_t err;=0A= + DSrMsg_ok_t ok;=0A= + DSrMsg_okstatus_t okstatus;=0A= + DSrMsg_okdata_t okdata;=0A= + } DSMsg_union_t;=0A= +=20=0A= +=20=0A= +=20=0A= +=20=0A= +=20=0A= + /* Text channel Messages: TS - Text services */=0A= + #define TS_TEXT_MAX_SIZE 100=0A= +=20=0A= + /* Command types */=0A= + enum=0A= + {=0A= + TSMsg_text, /* 0 */=0A= + TSMsg_done, /* 1 */=0A= + TSMsg_start, /* 2 */=0A= + TSMsg_stop, /* 3 */=0A= + TSMsg_ack, /* 4 */=0A= + };=0A= +=20=0A= +=20=0A= + struct TShdr=0A= + {=0A= + unsigned char cmd;=0A= + unsigned char console;=0A= + unsigned char spare1;=0A= + unsigned char channel;=0A= + };=0A= +=20=0A= +=20=0A= + /* Deliver text. This message can be sent by either side.=0A= + The debugger displays it in a window. The agent gives it to a pty=0A= + which a program may be listening on. */=0A= + typedef struct=0A= + {=0A= + struct TShdr hdr;=0A= + char text[TS_TEXT_MAX_SIZE];=0A= + } TSMsg_text_t;=0A= +=20=0A= +=20=0A= + /* There is no longer a program connected to this console. */=0A= + typedef struct=0A= + {=0A= + struct TShdr hdr;=0A= + } TSMsg_done_t;=0A= +=20=0A= +=20=0A= + /* TextStart or TextStop flow control=FF */=0A= + typedef struct=0A= + {=0A= + struct TShdr hdr;=0A= + } TSMsg_flowctl_t;=0A= +=20=0A= +=20=0A= + /* Ack a flowctl message */=0A= + typedef struct=0A= + {=0A= + struct TShdr hdr;=0A= + } TSMsg_ack_t;=0A= +=20=0A= + #endif=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/nto-tdep.c src.new/gdb/nto-tdep.c=0A= *** src.orig/gdb/nto-tdep.c Wed Dec 31 19:00:00 1969=0A= --- src.new/gdb/nto-tdep.c Fri Feb 14 13:28:11 2003=0A= ***************=0A= *** 0 ****=0A= --- 1,309 ----=0A= + #include =0A= + #include =0A= + #include "nto-tdep.h"=0A= + #include "top.h"=0A= + #include "cli/cli-decode.h"=0A= + #include "cli/cli-cmds.h"=0A= + #include "inferior.h"=0A= + #include "gdbarch.h"=0A= + #include "bfd.h"=0A= + #include "elf-bfd.h"=0A= + #include "solib-svr4.h"=0A= + #include "gdbcore.h"=0A= +=20=0A= + #ifdef __CYGWIN__=0A= + #include =0A= + #endif=0A= +=20=0A= + #ifdef __CYGWIN__=0A= + static char default_nto_target[] =3D "C:\\QNXsdk\\target\\qnx6";=0A= + #elif defined(__sun__) || defined(linux)=0A= + static char default_nto_target[] =3D "/opt/QNXsdk/target/qnx6";=0A= + #else=0A= + static char default_nto_target[] =3D "";=0A= + #endif=0A= +=20=0A= + /* Maintenance debugging flag */=0A= + int nto_internal_debugging;=0A= +=20=0A= + /* Filled in cpu info structure and flag to indicate its validity.=20=0A= + * This is initialized in procfs_attach or nto_start_remote depending on= =0A= + * our host/target. It would only be invalid if we were talking to an=0A= + * older pdebug which didn't support the cpuinfo message. */=0A= + struct dscpuinfo nto_cpuinfo;=0A= + int nto_cpuinfo_valid;=0A= + int nto_ostype =3D -1;=0A= +=20=0A= + static char *=0A= + nto_target (void)=0A= + {=0A= + char *p =3D getenv ("QNX_TARGET");=0A= +=20=0A= + #ifdef __CYGWIN__=0A= + static char buf[PATH_MAX];=0A= + if (p)=0A= + cygwin_conv_to_posix_path (p, buf);=0A= + else=0A= + cygwin_conv_to_posix_path (default_nto_target, buf);=0A= + return buf;=0A= + #else=0A= + return p ? p : default_nto_target;=0A= + #endif=0A= + }=0A= +=20=0A= + void=0A= + nto_init_solib_search_path (void)=0A= + {=0A= + char buf[PATH_MAX * 2], arch_path[PATH_MAX];=0A= + char *nto_root, *endian;=0A= + const char *arch;=0A= + char *solib_search_path, *cmd_name =3D "solib-search-path";=0A= + struct cmd_list_element *c;=0A= +=20=0A= + c =3D lookup_cmd (&cmd_name, setlist, "", 1, 1);=0A= +=20=0A= + if (!c || !c->var)=0A= + return;=0A= +=20=0A= + solib_search_path =3D *((char **) c->var);=0A= +=20=0A= + if (solib_search_path !=3D NULL)=0A= + return;=0A= +=20=0A= + nto_root =3D nto_target ();=0A= + if (strcmp (TARGET_ARCHITECTURE->arch_name, "i386") =3D=3D 0)=0A= + {=0A= + arch =3D "x86";=0A= + endian =3D "";=0A= + }=0A= + else if (strcmp (TARGET_ARCHITECTURE->arch_name, "rs6000") =3D=3D 0)=0A= + {=0A= + arch =3D "ppc";=0A= + endian =3D "be";=0A= + }=0A= + else=0A= + {=0A= + arch =3D TARGET_ARCHITECTURE->arch_name;=0A= + endian =3D TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG ? "be" : "le";= =0A= + }=0A= +=20=0A= + sprintf (arch_path, "%s/%s%s", nto_root, arch, endian);=0A= +=20=0A= + sprintf (buf, "set solib-absolute-prefix %s", arch_path);=0A= + execute_command (buf, 0);=0A= +=20=0A= + sprintf (buf, "%s/lib:%s/usr/lib:%s/usr/photon/lib\=0A= + :%s/usr/photon/dll:%s/lib/dll", arch_path, arch_path, arch_path, arch_pat= h, arch_path);=0A= + /* we already looked up the command...might as well use it */=0A= + *((char **) c->var) =3D xstrdup (buf);=0A= + }=0A= +=20=0A= + char **=0A= + nto_parse_redirection (char *pargv[], char **pin, char **pout, char **per= r)=0A= + {=0A= + char **argv;=0A= + char *in, *out, *err, *p;=0A= + int argc, i, n;=0A= +=20=0A= + for (n =3D 0; pargv[n]; n++);=0A= + if (n =3D=3D 0)=0A= + return NULL;=0A= + in =3D "";=0A= + out =3D "";=0A= + err =3D "";=0A= +=20=0A= + argv =3D xcalloc (n + 1, sizeof argv[0]);=0A= + argc =3D n;=0A= + for (i =3D 0, n =3D 0; n < argc; n++)=0A= + {=0A= + p =3D pargv[n];=0A= + if (*p =3D=3D '>')=0A= + {=0A= + p++;=0A= + if (*p)=0A= + out =3D p;=0A= + else=0A= + out =3D pargv[++n];=0A= + }=0A= + else if (*p =3D=3D '<')=0A= + {=0A= + p++;=0A= + if (*p)=0A= + in =3D p;=0A= + else=0A= + in =3D pargv[++n];=0A= + }=0A= + else if (*p++ =3D=3D '2' && *p++ =3D=3D '>')=0A= + {=0A= + if (*p =3D=3D '&' && *(p + 1) =3D=3D '1')=0A= + err =3D out;=0A= + else if (*p)=0A= + err =3D p;=0A= + else=0A= + err =3D pargv[++n];=0A= + }=0A= + else=0A= + argv[i++] =3D pargv[n];=0A= + }=0A= + *pin =3D in;=0A= + *pout =3D out;=0A= + *perr =3D err;=0A= + return argv;=0A= + }=0A= +=20=0A= + void=0A= + nto_source_extra_gdbinit (char *file)=0A= + {=0A= + char *homedir, *homeinit;=0A= + struct stat statbuf;=0A= +=20=0A= + homedir =3D getenv ("HOME");=0A= +=20=0A= + if (homedir && !inhibit_gdbinit)=0A= + {=0A= + homeinit =3D (char *) alloca (strlen (homedir) + strlen (file) + 10= );=0A= + sprintf (homeinit, "%s/%s", homedir, file);=0A= + if (stat (homeinit, &statbuf) =3D=3D 0)=0A= + catch_command_errors (source_command, homeinit, 0, RETURN_MASK_ALL);=0A= + }=0A= + }=0A= +=20=0A= + /* struct lm_info, LM_ADDR, and nto_truncate_ptr are copied from=0A= + solib-svr4.c to support nto_relocate_section_addresses=0A= + which is different from the svr4 version. */=0A= +=20=0A= + struct lm_info=0A= + {=0A= + /* Pointer to copy of link map from inferior. The type is char *=0A= + rather than void *, so that we may use byte offsets to find the=0A= + various fields without the need for a cast. */=0A= + char *lm;=0A= + };=0A= +=20=0A= + static CORE_ADDR=0A= + LM_ADDR (struct so_list *so)=0A= + {=0A= + struct link_map_offsets *lmo =3D nto_fetch_link_map_offsets ();=0A= +=20=0A= + return (CORE_ADDR) extract_signed_integer (so->lm_info->lm +=0A= + lmo->l_addr_offset,=0A= + lmo->l_addr_size);=0A= + }=0A= +=20=0A= + static CORE_ADDR=0A= + nto_truncate_ptr (CORE_ADDR addr)=0A= + {=0A= + if (TARGET_PTR_BIT =3D=3D sizeof (CORE_ADDR) * 8)=0A= + /* We don't need to truncate anything, and the bit twiddling below=0A= + will fail due to overflow problems. */=0A= + return addr;=0A= + else=0A= + return addr & (((CORE_ADDR) 1 << TARGET_PTR_BIT) - 1);=0A= + }=0A= +=20=0A= + Elf_Internal_Phdr *=0A= + find_load_phdr (bfd *abfd)=0A= + {=0A= + Elf_Internal_Phdr *phdr;=0A= + unsigned int i;=0A= +=20=0A= + if (!elf_tdata (abfd))=0A= + return NULL;=0A= +=20=0A= + phdr =3D elf_tdata (abfd)->phdr;=0A= + for (i =3D 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++)=0A= + {=0A= + if (phdr->p_type =3D=3D PT_LOAD && (phdr->p_flags & PF_X))=0A= + return phdr;=0A= + }=0A= + return NULL;=0A= + }=0A= +=20=0A= + void=0A= + nto_relocate_section_addresses (struct so_list *so, struct section_table = *sec)=0A= + {=0A= + /* On some platforms, (ie. QNXnto, NetBSD) LM_ADDR is the assigned=0A= + address, not the offset.=0A= + The addresses are formed as follows:=0A= + LM_ADDR is the target address where the shared library file=0A= + is mapped, so the actual section start address is LM_ADDR plus=0A= + the section offset within the shared library file. The end=0A= + address is that plus the section length. Note that we pay no=0A= + attention to the section start address as recorded in the=0A= + library header.=0A= + */=0A= + Elf_Internal_Phdr *phdr =3D find_load_phdr (sec->bfd);=0A= + unsigned vaddr =3D phdr ? phdr->p_vaddr : 0;=0A= +=20=0A= + sec->addr =3D nto_truncate_ptr (sec->addr + LM_ADDR (so) - vaddr);=0A= + sec->endaddr =3D nto_truncate_ptr (sec->endaddr + LM_ADDR (so) - vaddr)= ;=0A= + }=0A= +=20=0A= + static void=0A= + fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)=0A= + char *core_reg_sect;=0A= + unsigned core_reg_size;=0A= + int which;=0A= + CORE_ADDR reg_addr;=0A= + {=0A= + nto_gregset_t gregset;=0A= + nto_fpregset_t fpregset;=0A= +=20=0A= + nto_init_solib_search_path ();=0A= +=20=0A= + if (which =3D=3D 0)=0A= + {=0A= + memcpy ((char *) &gregset, core_reg_sect,=0A= + min (core_reg_size, sizeof (gregset)));=0A= + nto_supply_gregset (&gregset);=0A= + }=0A= + else if (which =3D=3D 2)=0A= + {=0A= + memcpy ((char *) &fpregset, core_reg_sect,=0A= + min (core_reg_size, sizeof (fpregset)));=0A= + nto_supply_fpregset (&fpregset);=0A= + }=0A= + }=0A= +=20=0A= + /* Register that we are able to handle ELF file formats using standard=0A= + procfs "regset" structures. */=0A= +=20=0A= + static struct core_fns regset_core_fns =3D {=0A= + bfd_target_elf_flavour, /* core_flavour */=0A= + default_check_format, /* check_format */=0A= + default_core_sniffer, /* core_sniffer */=0A= + fetch_core_registers, /* core_read_registers */=0A= + NULL /* next */=0A= + };=0A= +=20=0A= + void=0A= + _initialize_nto_tdep ()=0A= + {=0A= + add_show_from_set (add_set_cmd ("nto-debug", class_maintenance, var_zin= teger, (char *) &nto_internal_debugging, "Set QNX NTO internal debugging.\n= \=0A= + When non-zero, nto specific debug info is\n\=0A= + displayed. Different information is displayed\n\=0A= + for different positive values.", &setdebuglist),=0A= + &showdebuglist);=0A= +=20=0A= + /* We use SIG45 for pulses, or something, so nostop, noprint=0A= + and pass them. */=0A= + signal_stop_update (target_signal_from_name ("SIG45"), 0);=0A= + signal_print_update (target_signal_from_name ("SIG45"), 0);=0A= + signal_pass_update (target_signal_from_name ("SIG45"), 1);=0A= +=20=0A= + /* by default we don't want to stop on these two, but we do want to pas= s */=0A= + #if defined(SIGSELECT)=0A= + signal_stop_update (SIGSELECT, 0);=0A= + signal_print_update (SIGSELECT, 0);=0A= + signal_pass_update (SIGSELECT, 1);=0A= + #endif=0A= +=20=0A= + #if defined(SIGPHOTON)=0A= + signal_stop_update (SIGPHOTON, 0);=0A= + signal_print_update (SIGPHOTON, 0);=0A= + signal_pass_update (SIGPHOTON, 1);=0A= + #endif=0A= +=20=0A= + /* register core file support */=0A= + add_core_fns (®set_core_fns);=0A= + }=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/nto-tdep.h src.new/gdb/nto-tdep.h=0A= *** src.orig/gdb/nto-tdep.h Wed Dec 31 19:00:00 1969=0A= --- src.new/gdb/nto-tdep.h Fri Feb 14 13:28:11 2003=0A= ***************=0A= *** 0 ****=0A= --- 1,54 ----=0A= + #ifndef _NTO_TDEP_H=0A= + #define _NTO_TDEP_H=0A= +=20=0A= + #include "defs.h"=0A= + #include "nto-share/debug.h"=0A= + #include "nto-share/dsmsgs.h"=0A= + #include "solist.h"=0A= +=20=0A= + /* Generic functions in nto-tdep.c */=0A= +=20=0A= + extern void nto_init_solib_search_path PARAMS ((void));=0A= +=20=0A= + char **nto_parse_redirection=0A= + PARAMS ((char *start_argv[], char **in, char **out, char **err));=0A= +=20=0A= + int proc_iterate_over_mappings PARAMS ((int (*func) (int, CORE_ADDR)));= =0A= +=20=0A= + void nto_source_extra_gdbinit PARAMS ((char *));=0A= +=20=0A= + void nto_relocate_section_addresses=0A= + PARAMS ((struct so_list *, struct section_table *));=0A= +=20=0A= + /* Functions exported from all Neutrino targets (-nto-tdep.c) */= =0A= +=20=0A= + unsigned nto_get_regset_id PARAMS ((int regno));=0A= +=20=0A= + void nto_cpu_regset_fetch PARAMS ((int endian, int regset, void *data));= =0A= +=20=0A= + unsigned nto_get_regset_area PARAMS ((unsigned regset, char *subcmd));=0A= +=20=0A= + unsigned nto_cpu_register_area=0A= + PARAMS ((unsigned first_regno, unsigned last_regno, unsigned char *subcmd= ,=0A= + unsigned *off, unsigned *len));=0A= +=20=0A= + void nto_cpu_register_fetch=0A= + PARAMS ((int endian, unsigned first_regno, unsigned last_regno, void *dat= a));=0A= +=20=0A= + int nto_cpu_register_store=0A= + PARAMS ((int endian, unsigned first_regno, unsigned last_regno, void *dat= a));=0A= +=20=0A= + void nto_supply_gregset PARAMS ((union _debug_gregs *));=0A= +=20=0A= + void nto_supply_fpregset PARAMS ((union _debug_fpregs *));=0A= +=20=0A= + struct link_map_offsets *nto_fetch_link_map_offsets PARAMS ((void));=0A= +=20=0A= + /* Globals */=0A= +=20=0A= + extern int nto_internal_debugging;=0A= + extern struct dscpuinfo nto_cpuinfo;=0A= + extern int nto_cpuinfo_valid;=0A= + extern int nto_ostype;=0A= +=20=0A= + #endif=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/gdb/osabi.c src.new/gdb/osabi.c=0A= *** src.orig/gdb/osabi.c Sat Jan 4 18:47:13 2003=0A= --- src.new/gdb/osabi.c Fri Feb 7 11:27:35 2003=0A= *************** static const char * const gdb_osabi_name=0A= *** 72,77 ****=0A= --- 72,78 ----=0A= "ARM EABI v1",=0A= "ARM EABI v2",=0A= "ARM APCS",=0A= + "QNX Neutrino",=0A= =20=20=0A= ""=0A= };=0A= diff -rc3p -N -x '.#*' -x CVS -x'*.cache' -xMakefile.in -x configure src.or= ig/readline/aclocal.m4 src.new/readline/aclocal.m4=0A= *** src.orig/readline/aclocal.m4 Sun Dec 8 17:31:37 2002=0A= --- src.new/readline/aclocal.m4 Fri Feb 7 11:27:59 2003=0A= *************** AC_CHECK_HEADERS(wchar.h)=0A= *** 1653,1659 ****=0A= AC_CHECK_HEADERS(langinfo.h)=0A= =20=20=0A= AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))=0A= ! AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH))=0A= =20=20=0A= AC_CACHE_CHECK([for mbstate_t], bash_cv_have_mbstate_t,=0A= [AC_TRY_RUN([=0A= --- 1653,1659 ----=0A= AC_CHECK_HEADERS(langinfo.h)=0A= =20=20=0A= AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS))=0A= ! AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH), AC_SUBST(HAVE_WCWIDTH,no)= )=0A= =20=20=0A= AC_CACHE_CHECK([for mbstate_t], bash_cv_have_mbstate_t,=0A= [AC_TRY_RUN([=0A= *** src.orig//readline/Makefile.in Sun Dec 8 17:31:37 2002=0A= --- src.new//readline/Makefile.in Fri Feb 7 11:28:00 2003=0A= *************** GCC_LINT_CFLAGS =3D $(XCCFLAGS) $(GCC_LINT=0A= *** 86,91 ****=0A= --- 86,98 ----=0A= LIBRARY_NAME =3D libreadline.a=0A= STATIC_LIBS =3D libreadline.a libhistory.a=0A= =20=20=0A= + HAVE_WCWIDTH =3D @HAVE_WCWIDTH@=0A= +=20=0A= + ifeq ($(HAVE_WCWIDTH), no)=0A= + WCWIDTH_SRC =3D $(srcdir)/support/wcwidth.c=0A= + WCWIDTH_OBJ =3D wcwidth.o=0A= + endif=0A= +=20=0A= # The C code source files for this library.=0A= CSOURCES =3D $(srcdir)/readline.c $(srcdir)/funmap.c $(srcdir)/keymaps.c = \=0A= $(srcdir)/vi_mode.c $(srcdir)/parens.c $(srcdir)/rltty.c \=0A= *************** CSOURCES =3D $(srcdir)/readline.c $(srcdir=0A= *** 98,104 ****=0A= $(srcdir)/histfile.c $(srcdir)/nls.c $(srcdir)/search.c \=0A= $(srcdir)/shell.c $(srcdir)/savestring.c $(srcdir)/tilde.c \=0A= $(srcdir)/text.c $(srcdir)/misc.c $(srcdir)/compat.c \=0A= ! $(srcdir)/mbutil.c=0A= =20=20=0A= # The header files for this library.=0A= HSOURCES =3D readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h= \=0A= --- 105,111 ----=0A= $(srcdir)/histfile.c $(srcdir)/nls.c $(srcdir)/search.c \=0A= $(srcdir)/shell.c $(srcdir)/savestring.c $(srcdir)/tilde.c \=0A= $(srcdir)/text.c $(srcdir)/misc.c $(srcdir)/compat.c \=0A= ! $(srcdir)/mbutil.c $(WCWIDTH_SRC)=0A= =20=20=0A= # The header files for this library.=0A= HSOURCES =3D readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h= \=0A= *************** TILDEOBJ =3D tilde.o=0A= *** 111,117 ****=0A= OBJECTS =3D readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \= =0A= rltty.o complete.o bind.o isearch.o display.o signals.o \=0A= util.o kill.o undo.o macro.o input.o callback.o terminal.o \=0A= ! text.o nls.o misc.o compat.o xmalloc.o $(HISTOBJ) $(TILDEOBJ)=0A= =20=20=0A= # The texinfo files which document this library.=0A= DOCSOURCE =3D doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo=0A= --- 118,125 ----=0A= OBJECTS =3D readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \= =0A= rltty.o complete.o bind.o isearch.o display.o signals.o \=0A= util.o kill.o undo.o macro.o input.o callback.o terminal.o \=0A= ! text.o nls.o misc.o compat.o xmalloc.o $(HISTOBJ) $(TILDEOBJ) \=0A= ! $(WCWIDTH_OBJ)=0A= =20=20=0A= # The texinfo files which document this library.=0A= DOCSOURCE =3D doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo=0A= *************** libhistory.a: $(HISTOBJ) xmalloc.o=0A= *** 147,152 ****=0A= --- 155,166 ----=0A= $(AR) $(ARFLAGS) $@ $(HISTOBJ) xmalloc.o=0A= -test -n "$(RANLIB)" && $(RANLIB) $@=0A= =20=20=0A= + ifeq ($(HAVE_WCWIDTH), no)=0A= + $(WCWIDTH_OBJ): $(WCWIDTH_SRC)=0A= + $(RM) $@=0A= + $(CC) $(CCFLAGS) -c $(WCWIDTH_SRC)=0A= + endif=0A= +=20=0A= # Since tilde.c is shared between readline and bash, make sure we compile= =0A= # it with the right flags when it's built as part of readline=0A= tilde.o: tilde.c=0A= *** src.orig//readline/shlib/Makefile.in Sun Dec 8 17:31:38 2002=0A= --- src.new//readline/shlib/Makefile.in Fri Feb 7 11:28:00 2003=0A= *************** SHARED_READLINE =3D libreadline.$(SHLIB_LI=0A= *** 103,108 ****=0A= --- 103,115 ----=0A= SHARED_HISTORY =3D libhistory.$(SHLIB_LIBVERSION)=0A= SHARED_LIBS =3D $(SHARED_READLINE) $(SHARED_HISTORY)=0A= =20=20=0A= + HAVE_WCWIDTH =3D @HAVE_WCWIDTH@=0A= +=20=0A= + ifeq ($(HAVE_WCWIDTH), no)=0A= + WCWIDTH_SRC =3D $(srcdir)/support/wcwidth.c=0A= + WCWIDTH_OBJ =3D wcwidth.so=0A= + endif=0A= +=20=0A= # The C code source files for this library.=0A= CSOURCES =3D $(topdir)/readline.c $(topdir)/funmap.c $(topdir)/keymaps.c = \=0A= $(topdir)/vi_mode.c $(topdir)/parens.c $(topdir)/rltty.c \=0A= *************** CSOURCES =3D $(topdir)/readline.c $(topdir=0A= *** 115,121 ****=0A= $(topdir)/histfile.c $(topdir)/nls.c $(topdir)/search.c \=0A= $(topdir)/shell.c $(topdir)/savestring.c $(topdir)/tilde.c \=0A= $(topdir)/text.c $(topdir)/misc.c $(topdir)/compat.c \=0A= ! $(topdir)/mbutil.c=0A= =20=20=0A= # The header files for this library.=0A= HSOURCES =3D readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h= \=0A= --- 122,128 ----=0A= $(topdir)/histfile.c $(topdir)/nls.c $(topdir)/search.c \=0A= $(topdir)/shell.c $(topdir)/savestring.c $(topdir)/tilde.c \=0A= $(topdir)/text.c $(topdir)/misc.c $(topdir)/compat.c \=0A= ! $(topdir)/mbutil.c $(WCWIDTH_SRC)=0A= =20=20=0A= # The header files for this library.=0A= HSOURCES =3D readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h= \=0A= *************** SHARED_OBJ =3D readline.so vi_mode.so funm=0A= *** 129,135 ****=0A= rltty.so complete.so bind.so isearch.so display.so signals.so \=0A= util.so kill.so undo.so macro.so input.so callback.so terminal.so \=0A= text.so nls.so misc.so xmalloc.so $(SHARED_HISTOBJ) $(SHARED_TILDEOBJ)= \=0A= ! compat.so=0A= =20=20=0A= #########################################################################= #=0A= =20=20=0A= --- 136,142 ----=0A= rltty.so complete.so bind.so isearch.so display.so signals.so \=0A= util.so kill.so undo.so macro.so input.so callback.so terminal.so \=0A= text.so nls.so misc.so xmalloc.so $(SHARED_HISTOBJ) $(SHARED_TILDEOBJ)= \=0A= ! compat.so $(WCWIDTH_OBJ)=0A= =20=20=0A= #########################################################################= #=0A= =20=20=0A= *************** $(SHARED_HISTORY): $(SHARED_HISTOBJ) xma=0A= *** 153,158 ****=0A= --- 160,172 ----=0A= $(RM) $@=0A= $(SHOBJ_LD) ${SHOBJ_LDFLAGS} ${SHLIB_XLDFLAGS} -o $@ $(SHARED_HISTOBJ) x= malloc.so $(SHLIB_LIBS)=0A= =20=20=0A= + ifeq ($(HAVE_WCWIDTH), no)=0A= + $(WCWIDTH_OBJ): $(WCWIDTH_SRC)=0A= + $(RM) $@=0A= + $(SHOBJ_CC) -c $(CCFLAGS) $(SHOBJ_FLAGS) -o wcwidth.o $(WCWIDTH_SRC)=0A= + $(MV) wcwidth.o $@=0A= + endif=0A= +=20=0A= # Since tilde.c is shared between readline and bash, make sure we compile= =20=0A= # it with the right flags when it's built as part of readline=0A= tilde.so: tilde.c=0A= ------=_NextPart_000_0677_01C2D69D.20409C70--