a9333fb665245a868512838a824423b51298b662
[binutils-gdb.git] / gdb / nlm / i386.c
1 #include <dfs.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <stdlib.h>
5 #include <ctype.h>
6 #include <time.h>
7 #include <conio.h>
8 #include <advanced.h>
9 #include <debugapi.h>
10 #include <process.h>
11 #include <errno.h>
12 #include "i386.h"
13
14 /* Get the registers out of the frame information. */
15
16 static void
17 frame_to_registers (frame, regs)
18 struct StackFrame *frame;
19 char *regs;
20 {
21 /* Copy EAX -> EDI */
22 mem2hex (&frame->ExceptionEAX, &regs[0 * 4 * 2], 4 * 8, 0);
23
24 /* Copy EIP & PS */
25 mem2hex (&frame->ExceptionPC, &regs[8 * 4 * 2], 4 * 2, 0);
26
27 /* Copy CS, SS, DS */
28 mem2hex (&frame->ExceptionCS, &regs[10 * 4 * 2], 4 * 3, 0);
29
30 /* Copy ES */
31 mem2hex (&frame->ExceptionES, &regs[13 * 4 * 2], 4 * 1, 0);
32
33 /* Copy FS & GS */
34 mem2hex (&frame->ExceptionFS, &regs[14 * 4 * 2], 4 * 2, 0);
35 }
36
37 /* Put the registers back into the frame information. */
38
39 static void
40 registers_to_frame (regs, frame)
41 char *regs;
42 struct StackFrame *frame;
43 {
44 /* Copy EAX -> EDI */
45 hex2mem (&regs[0 * 4 * 2], &frame->ExceptionEAX, 4 * 8, 0);
46
47 /* Copy EIP & PS */
48 hex2mem (&regs[8 * 4 * 2], &frame->ExceptionPC, 4 * 2, 0);
49
50 /* Copy CS, SS, DS */
51 hex2mem (&regs[10 * 4 * 2], &frame->ExceptionCS, 4 * 3, 0);
52
53 /* Copy ES */
54 hex2mem (&regs[13 * 4 * 2], &frame->ExceptionES, 4 * 1, 0);
55
56 /* Copy FS & GS */
57 hex2mem (&regs[14 * 4 * 2], &frame->ExceptionFS, 4 * 2, 0);
58 }
59
60 static void
61 set_step_traps (frame)
62 struct StackFrame *frame;
63 {
64 frame->ExceptionSystemFlags |= 0x100;
65 }
66
67 static void
68 clear_step_traps (frame)
69 struct StackFrame *frame;
70 {
71 frame->ExceptionSystemFlags &= ~0x100;
72 }
73
74 static void
75 do_status (ptr, frame)
76 char *ptr;
77 struct StackFrame *frame;
78 {
79 int sigval;
80
81 sigval = computeSignal (frame->ExceptionNumber);
82
83 sprintf (ptr, "T%02x", sigval);
84 ptr += 3;
85
86 sprintf (ptr, "%02x:", PC_REGNUM);
87 ptr = mem2hex (&frame->ExceptionPC, ptr + 3, 4, 0);
88 *ptr++ = ';';
89
90 sprintf (ptr, "%02x:", SP_REGNUM);
91 ptr = mem2hex (&frame->ExceptionESP, ptr + 3, 4, 0);
92 *ptr++ = ';';
93
94 sprintf (ptr, "%02x:", FP_REGNUM);
95 ptr = mem2hex (&frame->ExceptionEBP, ptr + 3, 4, 0);
96 *ptr++ = ';';
97
98 *ptr = '\000';
99 }