/*
* May be copied or modified under the terms of the GNU General Public
* License. See linux/COPYING for more information.
*
* Containes extracts from code by Glenn Engel, Jim Kingdon,
* David Grothe <dave@gcom.com>, Tigran Aivazian <tigran@sco.com>,
* Amit S. Kale <akale@veritas.com>, William Gatliff <bgat@open-widgets.com>,
* Ben Lee, Steve Chamberlain and Benoit Miller <fulg@iname.com>.
*
* This version by Henry Bell <henry.bell@st.com>
* Minor modifications by Jeremy Siegel <jsiegel@mvista.com>
*
* Contains low-level support for remote debug using GDB.
*
* To enable debugger support, two things need to happen. A call to
* set_debug_traps() is necessary in order to allow any breakpoints
* or error conditions to be properly intercepted and reported to gdb.
* A breakpoint also needs to be generated to begin communication. This
* is most easily accomplished by a call to breakpoint() which does
* a trapa if the initialisation phase has been successfully completed.
*
* In this case, set_debug_traps() is not used to "take over" exceptions;
* other kernel code is modified instead to enter the kgdb functions here
* when appropriate (see entry.S for breakpoint traps and NMI interrupts,
* see traps.c for kernel error exceptions).
*
* The following gdb commands are supported:
*
* Command Function Return value
*
* g return the value of the CPU registers hex data or ENN
* G set the value of the CPU registers OK or ENN
*
* mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN
* MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN
* XAA..AA,LLLL: Same, but data is binary (not hex) OK or ENN
*
* c Resume at current address SNN ( signal NN)
* cAA..AA Continue at address AA..AA SNN
* CNN; Resume at current address with signal SNN
* CNN;AA..AA Resume at address AA..AA with signal SNN
*
* s Step one instruction SNN
* sAA..AA Step one instruction from AA..AA SNN
* SNN; Step one instruction with signal SNN
* SNNAA..AA Step one instruction from AA..AA w/NN SNN
*
* k kill (Detach GDB)
*
* d Toggle debug flag
* D Detach GDB
*
* Hct Set thread t for operations, OK or ENN
* c = 'c' (step, cont), c = 'g' (other
* operations)
*
* qC Query current thread ID QCpid
* qfThreadInfo Get list of current threads (first) m<id>
* qsThreadInfo " " " " " (subsequent)
* qOffsets Get section offsets Text=x;Data=y;Bss=z
*
* TXX Find if thread XX is alive OK or ENN
* ? What was the last sigval ? SNN (signal NN)
* O Output to GDB console
*
* Remote communication protocol.
*
* A debug packet whose contents are <data> is encapsulated for
* transmission in the form:
*
* $ <data> # CSUM1 CSUM2
*
* <data> must be ASCII alphanumeric and cannot include characters
* '$' or '#'. If <data> starts with two characters followed by
* ':', then the existing stubs interpret this as a sequence number.
*
* CSUM1 and CSUM2 are ascii hex representation of an 8-bit
* checksum of <data>, the most significant nibble is sent first.
* the hex digits 0-9,a-f are used.
*