2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Nathan Binkert
32 * Copyright (c) 1990, 1993 The Regents of the University of California
35 * This software was developed by the Computer Systems Engineering group
36 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
37 * contributed to Berkeley.
39 * All advertising materials mentioning features or use of this software
40 * must display the following acknowledgement:
41 * This product includes software developed by the University of
42 * California, Lawrence Berkeley Laboratories.
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * This product includes software developed by the University of
55 * California, Berkeley and its contributors.
56 * 4. Neither the name of the University nor the names of its contributors
57 * may be used to endorse or promote products derived from this software
58 * without specific prior written permission.
60 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94
76 * Copyright (c) 2001 The NetBSD Foundation, Inc.
77 * All rights reserved.
79 * This code is derived from software contributed to The NetBSD Foundation
82 * Redistribution and use in source and binary forms, with or without
83 * modification, are permitted provided that the following conditions
85 * 1. Redistributions of source code must retain the above copyright
86 * notice, this list of conditions and the following disclaimer.
87 * 2. Redistributions in binary form must reproduce the above copyright
88 * notice, this list of conditions and the following disclaimer in the
89 * documentation and/or other materials provided with the distribution.
90 * 3. All advertising materials mentioning features or use of this software
91 * must display the following acknowledgement:
92 * This product includes software developed by the NetBSD
93 * Foundation, Inc. and its contributors.
94 * 4. Neither the name of The NetBSD Foundation nor the names of its
95 * contributors may be used to endorse or promote products derived
96 * from this software without specific prior written permission.
98 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
99 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
100 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
101 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
102 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
103 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
104 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
105 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
106 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
107 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
108 * POSSIBILITY OF SUCH DAMAGE.
112 * $NetBSD: kgdb_stub.c,v 1.8 2001/07/07 22:58:00 wdk Exp $
116 * "Stub" to allow remote cpu to debug over a serial line using gdb.
119 #include <sys/signal.h>
125 #include "config/full_system.hh"
128 #include "arch/vtophys.hh"
129 #include "mem/fs_translating_port_proxy.hh"
132 #include "base/intmath.hh"
133 #include "base/remote_gdb.hh"
134 #include "base/socket.hh"
135 #include "base/trace.hh"
136 #include "config/the_isa.hh"
137 #include "cpu/static_inst.hh"
138 #include "cpu/thread_context.hh"
139 #include "debug/GDBAll.hh"
140 #include "mem/port.hh"
141 #include "mem/se_translating_port_proxy.hh"
142 #include "sim/system.hh"
145 using namespace Debug
;
146 using namespace TheISA
;
149 vector
<BaseRemoteGDB
*> debuggers
;
154 static int current_debugger
= -1;
155 if (current_debugger
>= 0 && current_debugger
< (int)debuggers
.size()) {
156 BaseRemoteGDB
*gdb
= debuggers
[current_debugger
];
157 if (!gdb
->isattached())
158 gdb
->listener
->accept();
159 if (gdb
->isattached())
165 ///////////////////////////////////////////////////////////
170 GDBListener::Event::Event(GDBListener
*l
, int fd
, int e
)
171 : PollEvent(fd
, e
), listener(l
)
175 GDBListener::Event::process(int revent
)
180 GDBListener::GDBListener(BaseRemoteGDB
*g
, int p
)
181 : event(NULL
), gdb(g
), port(p
)
183 assert(!gdb
->listener
);
184 gdb
->listener
= this;
187 GDBListener::~GDBListener()
196 return gdb
->name() + ".listener";
200 GDBListener::listen()
202 if (ListenSocket::allDisabled()) {
203 warn_once("Sockets disabled, not accepting gdb connections");
207 while (!listener
.listen(port
, true)) {
208 DPRINTF(GDBMisc
, "Can't bind port %d\n", port
);
212 event
= new Event(this, listener
.getfd(), POLLIN
);
213 pollQueue
.schedule(event
);
216 gdb
->number
= debuggers
.size();
217 debuggers
.push_back(gdb
);
221 ccprintf(cerr
, "%d: %s: listening for remote gdb #%d on port %d\n",
222 curTick(), name(), gdb
->number
, port
);
224 ccprintf(cerr
, "%d: %s: listening for remote gdb on port %d\n",
225 curTick(), name(), port
);
230 GDBListener::accept()
232 if (!listener
.islistening())
233 panic("GDBListener::accept(): cannot accept if we're not listening!");
235 int sfd
= listener
.accept(true);
238 if (gdb
->isattached())
245 BaseRemoteGDB::Event::Event(BaseRemoteGDB
*g
, int fd
, int e
)
246 : PollEvent(fd
, e
), gdb(g
)
250 BaseRemoteGDB::Event::process(int revent
)
254 else if (revent
& POLLNVAL
)
258 BaseRemoteGDB::BaseRemoteGDB(System
*_system
, ThreadContext
*c
, size_t cacheSize
)
259 : event(NULL
), listener(NULL
), number(-1), fd(-1),
260 active(false), attached(false),
261 system(_system
), pmem(_system
->physmem
), context(c
),
264 memset(gdbregs
.regs
, 0, gdbregs
.bytes());
267 BaseRemoteGDB::~BaseRemoteGDB()
274 BaseRemoteGDB::name()
276 return system
->name() + ".remote_gdb";
280 BaseRemoteGDB::isattached()
284 BaseRemoteGDB::attach(int f
)
288 event
= new Event(this, fd
, POLLIN
);
289 pollQueue
.schedule(event
);
292 DPRINTFN("remote gdb attached\n");
296 BaseRemoteGDB::detach()
302 pollQueue
.remove(event
);
303 DPRINTFN("remote gdb detached\n");
307 BaseRemoteGDB::gdb_command(char cmd
)
310 case GDBSignal
: return "KGDB_SIGNAL";
311 case GDBSetBaud
: return "KGDB_SET_BAUD";
312 case GDBSetBreak
: return "KGDB_SET_BREAK";
313 case GDBCont
: return "KGDB_CONT";
314 case GDBAsyncCont
: return "KGDB_ASYNC_CONT";
315 case GDBDebug
: return "KGDB_DEBUG";
316 case GDBDetach
: return "KGDB_DETACH";
317 case GDBRegR
: return "KGDB_REG_R";
318 case GDBRegW
: return "KGDB_REG_W";
319 case GDBSetThread
: return "KGDB_SET_THREAD";
320 case GDBCycleStep
: return "KGDB_CYCLE_STEP";
321 case GDBSigCycleStep
: return "KGDB_SIG_CYCLE_STEP";
322 case GDBKill
: return "KGDB_KILL";
323 case GDBMemW
: return "KGDB_MEM_W";
324 case GDBMemR
: return "KGDB_MEM_R";
325 case GDBSetReg
: return "KGDB_SET_REG";
326 case GDBReadReg
: return "KGDB_READ_REG";
327 case GDBQueryVar
: return "KGDB_QUERY_VAR";
328 case GDBSetVar
: return "KGDB_SET_VAR";
329 case GDBReset
: return "KGDB_RESET";
330 case GDBStep
: return "KGDB_STEP";
331 case GDBAsyncStep
: return "KGDB_ASYNC_STEP";
332 case GDBThreadAlive
: return "KGDB_THREAD_ALIVE";
333 case GDBTargetExit
: return "KGDB_TARGET_EXIT";
334 case GDBBinaryDload
: return "KGDB_BINARY_DLOAD";
335 case GDBClrHwBkpt
: return "KGDB_CLR_HW_BKPT";
336 case GDBSetHwBkpt
: return "KGDB_SET_HW_BKPT";
337 case GDBStart
: return "KGDB_START";
338 case GDBEnd
: return "KGDB_END";
339 case GDBGoodP
: return "KGDB_GOODP";
340 case GDBBadP
: return "KGDB_BADP";
341 default: return "KGDB_UNKNOWN";
345 /////////////////////////
350 BaseRemoteGDB::getbyte()
353 if (::read(fd
, &b
, 1) != 1)
354 warn("could not read byte from debugger");
359 BaseRemoteGDB::putbyte(uint8_t b
)
361 if (::write(fd
, &b
, 1) != 1)
362 warn("could not write byte to debugger");
365 // Send a packet to gdb
367 BaseRemoteGDB::send(const char *bp
)
372 DPRINTF(GDBSend
, "send: %s\n", bp
);
376 //Start sending a packet
378 //Send the contents, and also keep a check sum.
379 for (csum
= 0; (c
= *p
); p
++) {
383 //Send the ending character.
386 putbyte(i2digit(csum
>> 4));
387 putbyte(i2digit(csum
));
388 //Try transmitting over and over again until the other end doesn't send an
390 } while ((c
= getbyte() & 0x7f) == GDBBadP
);
393 // Receive a packet from gdb
395 BaseRemoteGDB::recv(char *bp
, int maxlen
)
404 //Find the beginning of a packet
405 while ((c
= getbyte()) != GDBStart
)
408 //Read until you find the end of the data in the packet, and keep
409 //track of the check sum.
410 while ((c
= getbyte()) != GDBEnd
&& len
< maxlen
) {
417 //Mask the check sum, and terminate the command string.
421 //If the command was too long, report an error.
427 //Bring in the checksum. If the check sum matches, csum will be 0.
428 csum
-= digit2i(getbyte()) * 16;
429 csum
-= digit2i(getbyte());
431 //If the check sum was correct
433 //Report that the packet was received correctly
440 memcpy(bp
, bp
+3, len
);
444 //Otherwise, report that there was a mistake.
448 DPRINTF(GDBRecv
, "recv: %s: %s\n", gdb_command(*bp
), bp
);
453 // Read bytes from kernel address space for debugger.
455 BaseRemoteGDB::read(Addr vaddr
, size_t size
, char *data
)
457 static Addr lastaddr
= 0;
458 static size_t lastsize
= 0;
461 DPRINTF(GDBRead
, "read: reading memory location zero!\n");
462 vaddr
= lastaddr
+ lastsize
;
465 DPRINTF(GDBRead
, "read: addr=%#x, size=%d", vaddr
, size
);
468 FSTranslatingPortProxy
*port
= context
->getVirtProxy();
470 SETranslatingPortProxy
*port
= context
->getMemProxy();
472 port
->readBlob(vaddr
, (uint8_t*)data
, size
);
475 if (DTRACE(GDBRead
)) {
476 if (DTRACE(GDBExtra
)) {
478 mem2hex(buf
, data
, size
);
479 DPRINTFNR(": %s\n", buf
);
488 // Write bytes to kernel address space for debugger.
490 BaseRemoteGDB::write(Addr vaddr
, size_t size
, const char *data
)
492 static Addr lastaddr
= 0;
493 static size_t lastsize
= 0;
496 DPRINTF(GDBWrite
, "write: writing memory location zero!\n");
497 vaddr
= lastaddr
+ lastsize
;
500 if (DTRACE(GDBWrite
)) {
501 DPRINTFN("write: addr=%#x, size=%d", vaddr
, size
);
502 if (DTRACE(GDBExtra
)) {
504 mem2hex(buf
, data
, size
);
505 DPRINTFNR(": %s\n", buf
);
510 FSTranslatingPortProxy
*port
= context
->getVirtProxy();
512 SETranslatingPortProxy
*port
= context
->getMemProxy();
514 port
->writeBlob(vaddr
, (uint8_t*)data
, size
);
522 PCEventQueue
*BaseRemoteGDB::getPcEventQueue()
524 return &system
->pcEventQueue
;
527 BaseRemoteGDB::HardBreakpoint::HardBreakpoint(BaseRemoteGDB
*_gdb
, Addr pc
)
528 : PCEvent(_gdb
->getPcEventQueue(), "HardBreakpoint Event", pc
),
529 gdb(_gdb
), refcount(0)
531 DPRINTF(GDBMisc
, "creating hardware breakpoint at %#x\n", evpc
);
535 BaseRemoteGDB::HardBreakpoint::process(ThreadContext
*tc
)
537 DPRINTF(GDBMisc
, "handling hardware breakpoint at %#x\n", pc());
539 if (tc
== gdb
->context
)
544 BaseRemoteGDB::insertSoftBreak(Addr addr
, size_t len
)
546 if (len
!= sizeof(TheISA::MachInst
))
547 panic("invalid length\n");
549 return insertHardBreak(addr
, len
);
553 BaseRemoteGDB::removeSoftBreak(Addr addr
, size_t len
)
555 if (len
!= sizeof(MachInst
))
556 panic("invalid length\n");
558 return removeHardBreak(addr
, len
);
562 BaseRemoteGDB::insertHardBreak(Addr addr
, size_t len
)
564 if (len
!= sizeof(MachInst
))
565 panic("invalid length\n");
567 DPRINTF(GDBMisc
, "inserting hardware breakpoint at %#x\n", addr
);
569 HardBreakpoint
*&bkpt
= hardBreakMap
[addr
];
571 bkpt
= new HardBreakpoint(this, addr
);
579 BaseRemoteGDB::removeHardBreak(Addr addr
, size_t len
)
581 if (len
!= sizeof(MachInst
))
582 panic("invalid length\n");
584 DPRINTF(GDBMisc
, "removing hardware breakpoint at %#x\n", addr
);
586 break_iter_t i
= hardBreakMap
.find(addr
);
587 if (i
== hardBreakMap
.end())
590 HardBreakpoint
*hbp
= (*i
).second
;
591 if (--hbp
->refcount
== 0) {
593 hardBreakMap
.erase(i
);
600 BaseRemoteGDB::setTempBreakpoint(Addr bkpt
)
602 DPRINTF(GDBMisc
, "setTempBreakpoint: addr=%#x\n", bkpt
);
603 insertHardBreak(bkpt
, sizeof(TheISA::MachInst
));
607 BaseRemoteGDB::clearTempBreakpoint(Addr
&bkpt
)
609 DPRINTF(GDBMisc
, "setTempBreakpoint: addr=%#x\n", bkpt
);
610 removeHardBreak(bkpt
, sizeof(TheISA::MachInst
));
615 BaseRemoteGDB::break_type(char c
)
618 case '0': return "software breakpoint";
619 case '1': return "hardware breakpoint";
620 case '2': return "write watchpoint";
621 case '3': return "read watchpoint";
622 case '4': return "access watchpoint";
623 default: return "unknown breakpoint/watchpoint";
627 // This function does all command processing for interfacing to a
628 // remote gdb. Note that the error codes are ignored by gdb at
629 // present, but might eventually become meaningful. (XXX) It might
630 // makes sense to use POSIX errno values, because that is what the
631 // gdb/remote.c functions want to return.
633 BaseRemoteGDB::trap(int type
)
637 char data
[GDBPacketBufLen
+ 1];
641 char command
, subcmd
;
648 bufferSize
= gdbregs
.bytes() * 2 + 256;
649 buffer
= (char*)malloc(bufferSize
);
651 DPRINTF(GDBMisc
, "trap: PC=%s\n", context
->pcState());
656 * The first entry to this function is normally through
657 * a breakpoint trap in kgdb_connect(), in which case we
658 * must advance past the breakpoint because gdb will not.
660 * On the first entry here, we expect that gdb is not yet
661 * listening to us, so just enter the interaction loop.
662 * After the debugger is "active" (connected) it will be
663 * waiting for a "signaled" message from us.
668 // Tell remote host that an exception has occurred.
669 snprintf((char *)buffer
, bufferSize
, "S%02x", type
);
672 // Stick frame regs into our reg cache.
676 datalen
= recv(data
, sizeof(data
));
677 data
[sizeof(data
) - 1] = 0; // Sentinel
684 // if this command came from a running gdb, answer it --
685 // the other guy has no way of knowing if we're in or out
686 // of this loop when he issues a "remote-signal".
687 snprintf((char *)buffer
, bufferSize
,
693 if (2 * gdbregs
.bytes() > bufferSize
)
694 panic("buffer too small");
696 mem2hex(buffer
, gdbregs
.regs
, gdbregs
.bytes());
701 p
= hex2mem(gdbregs
.regs
, p
, gdbregs
.bytes());
702 if (p
== NULL
|| *p
!= '\0')
717 if (val
< 0 && val
>= KGDB_NUMREGS
) {
722 gdbregs
.regs
[val
] = hex2i(&p
);
740 if (len
> bufferSize
) {
744 if (!acc(val
, len
)) {
749 if (read(val
, (size_t)len
, (char *)buffer
)) {
750 // variable length array would be nice, but C++ doesn't
751 // officially support those...
752 char *temp
= new char[2*len
+1];
753 mem2hex(temp
, buffer
, len
);
772 if (len
> datalen
- (p
- data
)) {
776 p
= hex2mem(buffer
, p
, bufferSize
);
781 if (!acc(val
, len
)) {
785 if (write(val
, (size_t)len
, (char *)buffer
))
811 context
->pcState(val
);
817 if (p
- data
< (ptrdiff_t)datalen
) {
819 context
->pcState(val
);
828 context
->pcState(val
);
834 if (p
- data
< (ptrdiff_t)datalen
) {
836 context
->pcState(val
);
843 if (*p
++ != ',') send("E0D");
845 if (*p
++ != ',') send("E0D");
848 DPRINTF(GDBMisc
, "clear %s, addr=%#x, len=%d\n",
849 break_type(subcmd
), val
, len
);
854 case '0': // software breakpoint
855 ret
= removeSoftBreak(val
, len
);
858 case '1': // hardware breakpoint
859 ret
= removeHardBreak(val
, len
);
862 case '2': // write watchpoint
863 case '3': // read watchpoint
864 case '4': // access watchpoint
870 send(ret
? "OK" : "E0C");
875 if (*p
++ != ',') send("E0D");
877 if (*p
++ != ',') send("E0D");
880 DPRINTF(GDBMisc
, "set %s, addr=%#x, len=%d\n",
881 break_type(subcmd
), val
, len
);
886 case '0': // software breakpoint
887 ret
= insertSoftBreak(val
, len
);
890 case '1': // hardware breakpoint
891 ret
= insertHardBreak(val
, len
);
894 case '2': // write watchpoint
895 case '3': // read watchpoint
896 case '4': // access watchpoint
902 send(ret
? "OK" : "E0C");
906 var
= string(p
, datalen
- 1);
917 case GDBSigCycleStep
:
924 // Unsupported command
925 DPRINTF(GDBMisc
, "Unsupported command: %s\n",
926 gdb_command(command
));
927 DDUMP(GDBMisc
, (uint8_t *)data
, datalen
);
933 DPRINTF(GDBMisc
, "Unknown command: %c(%#x)\n",
947 // Convert a hex digit into an integer.
948 // This returns -1 if the argument passed is no valid hex digit.
950 BaseRemoteGDB::digit2i(char c
)
952 if (c
>= '0' && c
<= '9')
954 else if (c
>= 'a' && c
<= 'f')
955 return (c
- 'a' + 10);
956 else if (c
>= 'A' && c
<= 'F')
958 return (c
- 'A' + 10);
963 // Convert the low 4 bits of an integer into an hex digit.
965 BaseRemoteGDB::i2digit(int n
)
967 return ("0123456789abcdef"[n
& 0x0f]);
970 // Convert a byte array into an hex string.
972 BaseRemoteGDB::mem2hex(void *vdst
, const void *vsrc
, int len
)
974 char *dst
= (char *)vdst
;
975 const char *src
= (const char *)vsrc
;
978 *dst
++ = i2digit(*src
>> 4);
979 *dst
++ = i2digit(*src
++);
984 // Convert an hex string into a byte array.
985 // This returns a pointer to the character following the last valid
986 // hex digit. If the string ends in the middle of a byte, NULL is
989 BaseRemoteGDB::hex2mem(void *vdst
, const char *src
, int maxlen
)
991 char *dst
= (char *)vdst
;
994 while (*src
&& maxlen
--) {
995 msb
= digit2i(*src
++);
998 lsb
= digit2i(*src
++);
1001 *dst
++ = (msb
<< 4) | lsb
;
1006 // Convert an hex string into an integer.
1007 // This returns a pointer to the character following the last valid
1010 BaseRemoteGDB::hex2i(const char **srcp
)
1012 const char *src
= *srcp
;
1016 while ((nibble
= digit2i(*src
)) >= 0) {