Okay, I think AT&T syntax is fixed.
I added Ulrich's code to decode.c and
it appears to work. Note that I haven't
double-checked it with the objdump code,
I'll delay that 'till the weekend.
I also added a documentation file to the
ICE that describes the remote debugging
protocol (stripped from gdb's remote.c).
I tested the ICE with the new flags
patch, it seems to work fine -- I can
step through the code, set breakpoints,
etc. without any problems (except
that breakpoints claim they're SIGSEGV,
but that's understandable). What I did
notice though was that the segment
registers aren't reported correctly in
my version of gdb. I think the remote
protocol changed slightly between gdb
4.16 and 4.17 -- I stripped gdbserver
from the 4.16 source distribution,
but I use gdb 4.17. However, I will
have to trace the GDB changelogs (I'll
do this soon) in order to check whether
this is the problem, and what to do about
it.
A patch is attached.
-- Ramon
diff -Nur freemware-old/user/decode.c freemware/user/decode.c
--- freemware-old/user/decode.c Mon Jan 10 21:57:24 2000
+++ freemware/user/decode.c Mon Jan 10 23:23:16 2000
@@ -2527,36 +2527,36 @@
"",
/* Data Transfer */
- "mov",
- "cmove", "cmovne", "cmovp", "cmovnp",
- "cmova", "cmovae", "cmovb", "cmovbe",
- "cmovg", "cmovge", "cmovl", "cmovle",
- "cmovo", "cmovno", "cmovs", "cmovns",
- "xchg", "bswap", "xadd", "cmpxchg", "cmpxchg8b",
- "push", "pusha", "pushad",
- "pop", "popa", "popad",
- "in", "out",
- "cwtd", "cltd", "cbtw", "cwtl",
- "movs", "movz",
+ "movD",
+ "cmoveD", "cmovneD", "cmovpD", "cmovnpD",
+ "cmovaD", "cmovaeD", "cmovbD", "cmovbeD",
+ "cmovgD", "cmovgeD", "cmovlD", "cmovleD",
+ "cmovoD", "cmovnoD", "cmovsD", "cmovnsD",
+ "xchgD", "bswap", "xaddD", "cmpxchgD", "cmpxchg8b",
+ "pushS", "pusha", "pushad",
+ "popS", "popa", "popad",
+ "inD", "outS",
+ "cwtd", "cltd", "cbtw", "cwtl",
+ "movsSD", "movzSD",
/* Binary Arithmetic */
- "add", "adc", "sub", "sbb",
- "imul", "mul", "idiv", "div",
- "inc", "dec", "neg", "cmp",
+ "addD", "adcD", "subD", "sbbD",
+ "imulD", "mulD", "idivD", "divD",
+ "incS", "decS", "negS", "cmpD",
/* Decimal Arithmetic */
"daa", "das",
"aaa", "aas", "aam", "aad",
/* Logic */
- "and", "or", "not", "xor",
+ "andD", "orD", "notD", "xorD",
/* Shift and Rotate */
- "sar", "shr", "sal", "shl", "shld", "shrd",
- "ror", "rol", "rcr", "rcl",
+ "sarD", "shrD", "salD", "shlD", "shldD", "shrdD",
+ "rorD", "rolD", "rcrD", "rclD",
/* Bit and Byte */
- "bt", "bts", "btr", "btc", "bsf", "bsr",
- "sete", "setne", "setp", "setnp",
- "seta", "setae", "setb", "setbe",
- "setg", "setge", "setl", "setle",
- "seto", "setno", "sets", "setns",
- "test",
+ "btD", "btsD", "btrD", "btcD", "bsfD", "bsrD",
+ "seteD", "setneD", "setpD", "setnpD",
+ "setaD", "setaeD", "setbD", "setbeD",
+ "setgD", "setgeD", "setlD", "setleD",
+ "setoD", "setnoD", "setsD", "setnsD",
+ "testD",
/* Control Transfer */
"jmp",
"je", "jne", "jp", "jnp",
@@ -2566,27 +2566,27 @@
"jcxz", "jecxz",
"loop", "loope", "loopne",
"call", "ret", "lret", "iret",
- "int", "into", "bound",
+ "int", "into", "boundD",
"enter", "leave",
/* String */
- "movs", "cmps", "scas", "lods", "stos",
+ "movsD", "cmpsD", "scasD", "lodsD", "stosD",
"rep", "repe", "repne",
- "ins", "outs",
+ "insD", "outsS",
/* Flag Control */
"stc", "clc", "cmc", "std", "cld",
"lahf", "sahf",
"pushf", "pushfd", "popf", "popfd",
"sti", "cli",
/* Segment Register Operations */
- "lds", "les", "lfs", "lgs", "lss",
+ "ldsD", "lesD", "lfsD", "lgsD", "lssD",
/* Miscellaneous */
- "lea", "nop", "ud2", "xlat",
+ "leaD", "nop", "ud2", "xlatO",
"cpuid",
/* Systems Instructions */
"lgdt", "sgdt", "lldt", "sldt",
"ltr", "str", "lidt", "sidt",
"lmsw", "smsw", "clts",
- "arpl", "lar", "lsl", "verr", "verw",
+ "arpl", "larD", "lslD", "verr", "verw",
"invd", "wbinvd", "invlpg",
"lock", "hlt", "rsm",
"rdmsr", "wrmsr", "rdpmc", "rdtsc",
@@ -2713,20 +2713,32 @@
strcat(string, InsNamesATT[dc->instruction]);
/* Operand size */
- if ( dc->instruction == INS_movsx || dc->instruction == INS_movzx )
- {
- switch (dc->op[1].size)
+ for ( i = 0; string[i]; i++ )
+ switch ( string[i] )
+ {
+
+ case 'D': switch ( dc->op[0].size )
{
- case 1: strcat(string, "b"); break;
- case 2: strcat(string, "w"); break;
- case 4: strcat(string, "l"); break;
+ case 1: string[i] = 'b'; break;
+ case 2: string[i] = 'w'; break;
+ case 4: string[i] = 'l'; break;
}
- }
- switch (dc->operand_size)
- {
- case 1: strcat(string, "b"); break;
- case 2: strcat(string, "w"); break;
- case 4: strcat(string, "l"); break;
+ break;
+
+ case 'S': switch ( dc->op[1].size )
+ {
+ case 1: string[i] = 'b'; break;
+ case 2: string[i] = 'w'; break;
+ case 4: string[i] = 'l'; break;
+ }
+ break;
+
+ case 'O': switch ( dc->operand_size )
+ {
+ case 2: string[i] = 'w'; break;
+ case 4: string[i] = 'l'; break;
+ }
+ break;
}
/* Formatting */
@@ -2750,7 +2762,10 @@
struct i386_decode_operand *da;
/* Get operand */
- da = dc->op + i;
+ if ( dc->instruction == INS_enter )
+ da = dc->op + 2 - i;
+ else
+ da = dc->op + i;
if (!da->type) continue;
strcat(string, k? ", " : " ");
diff -Nur freemware-old/user/plugins/ice/PROTOCOL freemware/user/plugins/ice/PROTOCOL
--- freemware-old/user/plugins/ice/PROTOCOL Thu Jan 1 01:00:00 1970
+++ freemware/user/plugins/ice/PROTOCOL Mon Jan 10 22:11:08 2000
@@ -0,0 +1,157 @@
+ GDB 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.
+
+ Receiver responds with:
+
+ + - if CSUM is correct and ready for next packet
+ - - if CSUM is incorrect
+
+ <data> is as follows:
+ Most values are encoded in ascii hex digits. Signal numbers are according
+ to the numbering in target.h.
+
+ Request Packet
+
+ set thread Hct... Set thread for subsequent operations.
+ c = 'c' for thread used in step and
+ continue; t... can be -1 for all
+ threads.
+ c = 'g' for thread used in other
+ operations. If zero, pick a thread,
+ any thread.
+ reply OK for success
+ ENN for an error.
+
+ read registers g
+ reply XX....X Each byte of register data
+ is described by two hex digits.
+ Registers are in the internal order
+ for GDB, and the bytes in a register
+ are in the same order the machine uses.
+ or ENN for an error.
+
+ write regs GXX..XX Each byte of register data
+ is described by two hex digits.
+ reply OK for success
+ ENN for an error
+
+ write reg Pn...=r... Write register n... with value r...,
+ which contains two hex digits for each
+ byte in the register (target byte
+ order).
+ reply OK for success
+ ENN for an error
+ (not supported by all stubs).
+
+ read mem mAA..AA,LLLL AA..AA is address, LLLL is length.
+ reply XX..XX XX..XX is mem contents
+ Can be fewer bytes than requested
+ if able to read only part of the data.
+ or ENN NN is errno
+
+ write mem MAA..AA,LLLL:XX..XX
+ AA..AA is address,
+ LLLL is number of bytes,
+ XX..XX is data
+ reply OK for success
+ ENN for an error (this includes the case
+ where only part of the data was
+ written).
+
+ continue cAA..AA AA..AA is address to resume
+ If AA..AA is omitted,
+ resume at same address.
+
+ step sAA..AA AA..AA is address to resume
+ If AA..AA is omitted,
+ resume at same address.
+
+ continue with Csig;AA Continue with signal sig (hex signal
+ signal number).
+
+ step with Ssig;AA Like 'C' but step not continue.
+ signal
+
+ last signal ? Reply the current reason for stopping.
+ This is the same reply as is generated
+ for step or cont : SAA where AA is the
+ signal number.
+
+ detach D Reply OK.
+
+ There is no immediate reply to step or cont.
+ The reply comes when the machine stops.
+ It is SAA AA is the signal number.
+
+ or... TAAn...:r...;n...:r...;n...:r...;
+ AA = signal number
+ n... = register number (hex)
+ r... = register contents
+ n... = `thread'
+ r... = thread process ID. This is
+ a hex integer.
+ n... = other string not starting
+ with valid hex digit.
+ gdb should ignore this n,r pair
+ and go on to the next. This way
+ we can extend the protocol.
+ or... WAA The process exited, and AA is
+ the exit status. This is only
+ applicable for certains sorts of
+ targets.
+ or... XAA The process terminated with signal
+ AA.
+ or... OXX..XX XX..XX is hex encoding of ASCII data. This
+ can happen at any time while the program is
+ running and the debugger should
+ continue to wait for 'W', 'T', etc.
+
+ thread alive TXX Find out if the thread XX is alive.
+ reply OK thread is still alive
+ ENN thread is dead
+
+ remote restart RXX Restart the remote server
+
+ extended ops ! Use the extended remote protocol.
+ Sticky -- only needs to be set once.
+
+ kill request k
+
+ toggle debug d toggle debug flag (see 386 & 68k stubs)
+ reset r reset -- see sparc stub.
+ reserved <other> On other requests, the stub should
+ ignore the request and send an empty
+ response ($#<checksum>). This way
+ we can extend the protocol and GDB
+ can tell whether the stub it is
+ talking to uses the old or the new.
+ search tAA:PP,MM Search backwards starting at address
+ AA for a match with pattern PP and
+ mask MM. PP and MM are 4 bytes.
+ Not supported by all stubs.
+
+ general query qXXXX Request info about XXXX.
+ general set QXXXX=yyyy Set value of XXXX to yyyy.
+ query sect offs qOffsets Get section offsets. Reply is
+ Text=xxx;Data=yyy;Bss=zzz
+
+ Responses can be run-length encoded to save space. A '*' means that
+ the next character is an ASCII encoding giving a repeat count which
+ stands for that many repititions of the character preceding the '*'.
+ The encoding is n+29, yielding a printable character where n >=3
+ (which is where rle starts to win). Don't use an n > 126.
+
+ So
+ "0* " means the same as "0000".