1 | with Ada.Text_IO; use Ada.Text_IO; |
---|
2 | with System.Machine_Code; use System.Machine_Code; |
---|
3 | |
---|
4 | package body Serial_Debug is |
---|
5 | |
---|
6 | ---------------- |
---|
7 | -- Breakpoint -- |
---|
8 | ---------------- |
---|
9 | |
---|
10 | procedure Breakpoint is |
---|
11 | begin |
---|
12 | Asm ("int $3", |
---|
13 | No_Output_Operands, |
---|
14 | No_Input_Operands, |
---|
15 | Volatile => True); |
---|
16 | end Breakpoint; |
---|
17 | |
---|
18 | |
---|
19 | -- This type is from uart.h |
---|
20 | -- Equivalent to an int, with (COM1, COM2) => (0, 1) |
---|
21 | |
---|
22 | type BSP_Uart is (COM1, COM2); |
---|
23 | pragma Convention (C, BSP_Uart); |
---|
24 | |
---|
25 | |
---|
26 | -- The serial port currently used for console I/O |
---|
27 | |
---|
28 | BSP_Console_Port: BSP_Uart; |
---|
29 | pragma Import (C, BSP_Console_Port, "BSPConsolePort"); |
---|
30 | |
---|
31 | |
---|
32 | -- C utility routines to set up serial-port debugging |
---|
33 | |
---|
34 | procedure I386_Stub_Glue_Init (Debug_Port: in BSP_Uart); |
---|
35 | pragma Import (C, I386_Stub_Glue_Init, "i386_stub_glue_init"); |
---|
36 | |
---|
37 | procedure Set_Debug_Traps; |
---|
38 | pragma Import (C, Set_Debug_Traps, "set_debug_traps"); |
---|
39 | |
---|
40 | procedure I386_Stub_Glue_Init_Breakin; |
---|
41 | pragma Import (C, I386_Stub_Glue_Init_Breakin, |
---|
42 | "i386_stub_glue_init_breakin"); |
---|
43 | |
---|
44 | begin |
---|
45 | |
---|
46 | if BSP_Console_Port /= COM2 |
---|
47 | then |
---|
48 | I386_Stub_Glue_Init (COM2); |
---|
49 | |
---|
50 | Put_Line ("Remote GDB using COM2..."); |
---|
51 | else |
---|
52 | I386_Stub_Glue_Init (COM1); |
---|
53 | |
---|
54 | Put_Line ("Remote GDB using COM1..."); |
---|
55 | end if; |
---|
56 | |
---|
57 | Put_Line ("Remote GDB setting traps..."); |
---|
58 | |
---|
59 | Set_Debug_Traps; |
---|
60 | |
---|
61 | Put_Line ("Remote GDB waiting for connection..."); |
---|
62 | |
---|
63 | I386_Stub_Glue_Init_Breakin; |
---|
64 | |
---|
65 | end Serial_Debug; |
---|
66 | |
---|