1 // gdb.h - description. -*- C++ -*-
3 // Copyright (C) 1999, 2000 Red Hat.
4 // This file is part of SID and is licensed under the GPL.
5 // See the file COPYING.SID for conditions for redistribution.
12 #include <sidcomputil.h>
13 #include <sidpinutil.h>
14 #include <sidattrutil.h>
15 #include <sidcpuutil.h>
16 #include <sidpinattrutil.h>
17 #include <sidmiscutil.h>
18 #include <sidwatchutil.h>
35 using sid::host_int_4;
36 using sid::host_int_8;
37 using sid::host_int_2;
42 using sid::little_int_1;
43 using sid::little_int_2;
44 using sid::little_int_4;
45 using sid::little_int_8;
46 using sid::component_library;
47 using sid::COMPONENT_LIBRARY_MAGIC;
49 using sidutil::make_attribute;
50 using sidutil::make_numeric_attribute;
51 using sidutil::fixed_attribute_map_component;
52 using sidutil::no_bus_component;
53 using sidutil::no_accessor_component;
54 using sidutil::fixed_relation_map_component;
55 using sidutil::fixed_pin_map_component;
56 using sidutil::callback_pin;
57 using sidutil::output_pin;
58 using sidutil::input_pin;
59 using sidutil::cpu_trap_handled;
60 using sidutil::parse_attribute;
61 using sidutil::endian;
62 using sidutil::endian_unknown;
63 using sidutil::endian_big;
64 using sidutil::endian_little;
65 using sidutil::map_watchable_name;
66 using sidutil::tokenize;
68 class gdb: public virtual component,
69 public fixed_attribute_map_component,
70 public fixed_pin_map_component,
71 public no_bus_component,
72 public no_accessor_component,
73 public fixed_relation_map_component
80 friend class callback_pin<gdb>;
82 // match cpu for attribute conversion convenience
83 typedef host_int_2 dbg_register_number_t;
85 // initialization connections
86 callback_pin<gdb> init_pin;
87 void init_handler (host_int_4);
88 callback_pin<gdb> deinit_pin;
89 void deinit_handler (host_int_4);
91 // socket<->gdb connections
93 callback_pin<gdb> remote_rx_pin;
94 void remote_rx_eof_handler();
95 void remote_rx_handler(host_int_4 value);
96 output_pin remote_tx_pin;
98 // cpu/gloss<->gdb connections
101 input_pin cpu_trap_code_pin;
102 callback_pin<gdb> cpu_trap_ipin;
103 output_pin cpu_trap_opin;
104 unsigned long last_signal;
105 void cpu_trap_handler (host_int_4 value);
106 callback_pin<gdb> gloss_process_signal_pin; // signal from gloss
107 void gloss_signal_handler (host_int_4 value);
108 callback_pin<gdb> target_tx_pin; // signal from pin
109 void target_tx_handler (host_int_4 value);
110 output_pin icache_flush_pin; // signal to cpu
112 // cpu<->target system connections
113 output_pin yield_pin; // signal to target subsystem
114 vector<component*> target_schedulers;
115 vector<component*> host_schedulers;
116 // turn target subsystem on/off
117 output_pin process_signal_pin; // signal to cfgroot
118 void target_power (bool on);
120 // hw breakpoint tracking
121 typedef map<host_int_8,int> hw_breakpoints_t;
122 hw_breakpoints_t hw_breakpoints; // address -> insertion-count
123 bool add_hw_breakpoint (host_int_8);
124 bool remove_hw_breakpoint (host_int_8);
125 bool remove_all_hw_breakpoints ();
127 // pending signal tracking
128 typedef map<int,int> pending_signal_counts_t;
129 pending_signal_counts_t pending_signal_counts;
131 // sid<->gdb target control
132 callback_pin<gdb> stop_pin; // special-purpose "interrupt target" pin
133 void stop_handler (host_int_4);
134 callback_pin<gdb> trapstop_pin; // special-purpose "breakpoint target" pin
135 void trapstop_handler (host_int_4);
136 callback_pin<gdb> start_pin; // special-purpose "resume target" pin
137 void start_handler (host_int_4);
143 void update_trace_flags();
144 bool enable_Z_packet;
145 bool operating_mode_p;
148 struct gdbserv* gdbserv;
149 struct gdbserv_client* gdbserv_client;
152 // gdbserv_client<->gdb callback hooks
153 void gdbsid_client_write (const unsigned char* ch, unsigned len);
154 // gdbserv<->gdb callback hooks
155 struct gdbserv_target* gdbsid_target_attach (struct gdbserv *gdbserv);
156 void process_get_gen ();
157 void process_set_gen ();
158 void process_set_args ();
159 int process_set_reg (int reg);
160 int process_set_regs ();
161 void process_get_reg (int reg);
162 void process_get_regs ();
163 void process_get_exp_regs ();
164 void process_get_mem (struct gdbserv_reg *reg_addr, struct gdbserv_reg *reg_len);
165 void process_set_mem (struct gdbserv_reg *reg_addr, struct gdbserv_reg *reg_len, int binary);
166 void process_set_pc (struct gdbserv_reg *val);
167 int process_signal (int sigval);
168 void flush_i_cache();
169 unsigned long compute_signal (unsigned long sig);
170 unsigned long get_trap_number ();
171 void supply_expedited_regs ();
173 int break_program ();
174 void restart_program ();
175 int singlestep_program ();
176 void sigkill_program ();
177 int continue_program ();
178 int Z_breakpoint_ok_p (unsigned long type, struct gdbserv_reg *addr, struct gdbserv_reg *len);
179 int remove_breakpoint (unsigned long type, struct gdbserv_reg *addr, struct gdbserv_reg *len);
180 int set_breakpoint (unsigned long type, struct gdbserv_reg *addr, struct gdbserv_reg *len);
181 void process_detach ();
186 extern "C" struct gdbserv_target* gdbsid_target_attach_hook (struct gdbserv *gdbserv,
188 extern "C" void process_get_gen_hook (struct gdbserv *gdbserv);
189 extern "C" void process_set_gen_hook (struct gdbserv *gdbserv);
190 extern "C" void process_set_args_hook (struct gdbserv *gdbserv);
191 extern "C" int process_set_reg_hook (struct gdbserv *gdbserv, int reg);
192 extern "C" int process_set_regs_hook (struct gdbserv *gdbserv);
193 extern "C" void process_get_reg_hook (struct gdbserv *gdbserv, int reg);
194 extern "C" void process_get_regs_hook (struct gdbserv *gdbserv);
195 extern "C" void process_get_exp_regs_hook (struct gdbserv *gdbserv);
196 extern "C" unsigned long get_trap_number_hook (struct gdbserv *gdbserv);
197 extern "C" void process_get_mem_hook (struct gdbserv *gdbserv,
198 struct gdbserv_reg *reg_addr,
199 struct gdbserv_reg *reg_len);
200 extern "C" void process_set_mem_hook (struct gdbserv *gdbserv,
201 struct gdbserv_reg *reg_addr,
202 struct gdbserv_reg *reg_len,
204 extern "C" void process_set_pc_hook (struct gdbserv *gdbserv, struct gdbserv_reg *val);
205 extern "C" int process_signal_hook (struct gdbserv *gdbserv, int sig);
206 extern "C" void flush_i_cache_hook (struct gdbserv *gdbserv );
207 extern "C" unsigned long compute_signal_hook (struct gdbserv *gdbserv, unsigned long sig);
208 extern "C" int exit_program_hook (struct gdbserv *gdbserv);
209 extern "C" int break_program_hook (struct gdbserv *gdbserv);
210 extern "C" void restart_program_hook (struct gdbserv *gdbserv);
211 extern "C" int singlestep_program_hook (struct gdbserv *gdbserv);
212 extern "C" void sigkill_program_hook (struct gdbserv *gdbserv);
213 extern "C" int continue_program_hook (struct gdbserv *gdbserv );
214 extern "C" int remove_breakpoint_hook (struct gdbserv *gdbserv, unsigned long type,
215 struct gdbserv_reg *addr, struct gdbserv_reg *len);
216 extern "C" int set_breakpoint_hook (struct gdbserv *gdbserv, unsigned long type,
217 struct gdbserv_reg *addr, struct gdbserv_reg *len);
218 extern "C" void process_detach_hook (struct gdbserv *gdbserv);