1 // gdb.cxx - GDB stub implementation. -*- C++ -*-
3 // Copyright (C) 1999-2002, 2004, 2005, 2006 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.
14 #include "gdbserv-client.h"
15 #include "gdbserv-target.h"
16 #include "gdbserv-utils.h"
17 #include "gdbserv-output.h"
20 // ----------------------------------------------------------------------------
21 // Interface functions to gdbserv code: client side
24 gdbsid_client_write_hook (struct gdbserv *gdbserv, const unsigned char* ch, unsigned len)
26 assert (gdbserv != 0);
28 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
29 g->gdbsid_client_write (ch, len);
34 // ----------------------------------------------------------------------------
35 // Interface functions to gdbserv code: target side
37 extern "C" struct gdbserv_target*
38 gdbsid_target_attach_hook (struct gdbserv *gdbserv, void *globalstate)
40 gdb* g = static_cast<gdb*> (globalstate);
41 return g->gdbsid_target_attach (gdbserv);
45 process_rcmd_hook (struct gdbserv *gdbserv, const char* cmd, int sizeof_cmd)
47 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
48 g->process_rcmd (cmd, sizeof_cmd);
52 process_set_gen_hook (struct gdbserv *gdbserv)
54 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
55 return g->process_set_gen ();
59 process_get_gen_hook (struct gdbserv *gdbserv)
61 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
62 return g->process_get_gen ();
66 process_set_args_hook (struct gdbserv *gdbserv)
68 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
69 return g->process_set_args ();
73 process_set_reg_hook (struct gdbserv *gdbserv, int reg)
75 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
76 return g->process_set_reg (reg);
80 process_set_regs_hook (struct gdbserv *gdbserv)
82 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
83 return g->process_set_regs ();
87 process_get_reg_hook (struct gdbserv *gdbserv, int reg)
89 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
90 return g->process_get_reg (reg);
94 process_get_regs_hook (struct gdbserv *gdbserv)
96 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
97 return g->process_get_regs ();
101 process_get_exp_regs_hook (struct gdbserv *gdbserv)
103 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
104 return g->process_get_exp_regs ();
108 process_get_mem_hook (struct gdbserv *gdbserv,
109 struct gdbserv_reg *reg_addr,
110 struct gdbserv_reg *reg_len)
112 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
113 return g->process_get_mem (reg_addr, reg_len);
117 process_set_mem_hook (struct gdbserv *gdbserv,
118 struct gdbserv_reg *reg_addr,
119 struct gdbserv_reg *reg_len,
122 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
123 return g->process_set_mem (reg_addr, reg_len, binary);
127 process_set_pc_hook (struct gdbserv *gdbserv, struct gdbserv_reg *val)
129 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
130 return g->process_set_pc (val);
134 process_signal_hook (struct gdbserv *gdbserv, int sig)
136 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
137 return g->process_signal (sig);
141 flush_i_cache_hook (struct gdbserv *gdbserv)
143 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
144 return g->flush_i_cache ();
147 extern "C" unsigned long
148 compute_signal_hook (struct gdbserv *gdbserv, unsigned long sig)
150 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
151 return g->compute_signal (sig);
154 extern "C" unsigned long
155 get_trap_number_hook (struct gdbserv *gdbserv)
157 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
158 return g->get_trap_number ();
162 exit_program_hook (struct gdbserv *gdbserv)
164 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
165 return g->exit_program ();
169 break_program_hook (struct gdbserv *gdbserv)
171 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
172 return g->break_program ();
176 restart_program_hook (struct gdbserv *gdbserv)
178 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
179 return g->restart_program ();
183 singlestep_program_hook (struct gdbserv *gdbserv)
185 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
186 return g->singlestep_program ();
190 rangestep_program_hook (struct gdbserv *gdbserv, struct gdbserv_reg *val1,
191 struct gdbserv_reg *val2)
193 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
194 return g->rangestep_program (val1, val2);
199 sigkill_program_hook (struct gdbserv *gdbserv)
201 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
202 g->sigkill_program ();
206 continue_program_hook (struct gdbserv *gdbserv)
208 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
209 return g->continue_program ();
213 remove_breakpoint_hook (struct gdbserv *gdbserv, unsigned long type,
214 struct gdbserv_reg *addr, struct gdbserv_reg* len)
216 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
217 return g->remove_breakpoint (type, addr, len);
221 set_breakpoint_hook (struct gdbserv *gdbserv, unsigned long type,
222 struct gdbserv_reg *addr, struct gdbserv_reg* len)
224 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
225 return g->set_breakpoint (type, addr, len);
229 process_detach_hook (struct gdbserv *gdbserv)
231 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
232 return g->process_detach ();
236 set_exec_direction_hook (struct gdbserv *gdbserv, const char *direction)
238 gdb* g = static_cast<gdb*> (gdbserv_target_data (gdbserv));
239 return g->set_exec_direction (direction);
245 // ----------------------------------------------------------------------------
246 // Implementations for base class.
249 struct gdbserv_target*
250 gdb::gdbsid_target_attach (struct gdbserv *gdbserv)
252 // Do nothing if we're not configured properly.
255 cerr << "Error: Cannot attach to gdb: cpu relationship is not configured." << endl;
259 if (this->gdbserv == 0)
261 struct gdbserv_target* gdbtarget = new ::gdbserv_target();
262 assert (gdbtarget != 0);
263 memset (gdbtarget, 0, sizeof (*gdbtarget)); // XXX: needed?
265 gdbtarget->process_rcmd = process_rcmd_hook;
266 gdbtarget->process_get_gen = process_get_gen_hook;
267 gdbtarget->process_set_gen = process_set_gen_hook;
268 gdbtarget->process_set_args = process_set_args_hook;
269 gdbtarget->process_set_reg = process_set_reg_hook;
270 gdbtarget->process_get_reg = process_get_reg_hook;
271 gdbtarget->process_set_regs = process_set_regs_hook;
272 gdbtarget->process_get_regs = process_get_regs_hook;
273 gdbtarget->process_get_exp_regs = process_get_exp_regs_hook;
274 gdbtarget->process_get_mem = process_get_mem_hook;
275 gdbtarget->process_set_mem = process_set_mem_hook;
276 gdbtarget->process_set_pc = process_set_pc_hook;
277 gdbtarget->process_signal = process_signal_hook;
278 gdbtarget->flush_i_cache = flush_i_cache_hook;
279 gdbtarget->compute_signal = compute_signal_hook;
280 gdbtarget->get_trap_number = get_trap_number_hook;
281 gdbtarget->exit_program = exit_program_hook;
282 gdbtarget->break_program = break_program_hook;
283 gdbtarget->restart_program = restart_program_hook;
284 gdbtarget->singlestep_program = singlestep_program_hook;
285 gdbtarget->rangestep_program = rangestep_program_hook;
286 gdbtarget->sigkill_program = sigkill_program_hook;
287 gdbtarget->continue_program = continue_program_hook;
288 gdbtarget->set_exec_direction = set_exec_direction_hook;
289 gdbtarget->remove_breakpoint = remove_breakpoint_hook;
290 gdbtarget->set_breakpoint = set_breakpoint_hook;
291 gdbtarget->detach = process_detach_hook;
293 // install mutual pointers
294 gdbtarget->data = static_cast<void*>(this);
295 this->gdbserv = gdbserv;
298 cerr << "gdb open" << endl;
301 target_power (false);
304 last_signal = GDBSERV_SIGTRAP;
305 gdbserv_fromtarget_break (gdbserv, last_signal);
311 cerr << "Error: Cannot attach again to gdb." << endl;
318 gdb::process_rcmd (const char *cmd, int sizeof_cmd)
320 string command = string (cmd, sizeof_cmd);
321 vector<string> tokens = sidutil::tokenize (command, " ");
324 cerr << "process_rcmd " << command << endl;
326 if (tokens.size() >= 1 &&
327 tokens[0] == "set" &&
330 // pass command string straight through to cfgroot
331 component::status s = this->cfgroot->set_attribute_value ("config-line!", command);
332 if (s != component::ok)
333 gdbserv_output_string (gdbserv, "E02");
335 gdbserv_output_string (gdbserv, "OK");
340 gdbserv_output_string (gdbserv, "E01");
345 gdb::process_get_gen ()
351 gdb::process_set_gen ()
355 cerr << "process_set_gen" << endl;
362 sizeof_buf = gdbserv_input_size (gdbserv);
365 gdbserv_output_string (gdbserv, "E01");
368 lhs = (char*) alloca (sizeof_buf + 1);
369 gdbserv_input_string (gdbserv, lhs, sizeof_buf + 1);
370 rhs = strchr (lhs, '=');
373 gdbserv_output_string (gdbserv, "E02");
377 // if (this->general_set_func)
378 // gdbsid->general_set_func (gdbsid->general_set_data, lhs, rhs);
384 gdb::process_set_args ()
387 cerr << "process_set_args" << endl;
391 ; // XXX: collect arguments etc.
395 cerr << "Warning: gloss component not configured!" << endl;
404 gdb::process_set_reg (int reg)
409 cerr << "process_set_reg " << reg << " = [" << hex;
411 dbg_register_number_t regno = reg;
412 string reg_name = string("gdb-register-") + make_numeric_attribute(regno);
414 int byte = gdbserv_input_byte (gdbserv);
418 cerr << setw(2) << (unsigned) byte << " ";
420 reg_image += (char) byte;
421 byte = gdbserv_input_byte (gdbserv);
425 cerr << "]" << dec << endl;
427 component::status s = cpu->set_attribute_value (reg_name, reg_image);
428 if (s != component::ok)
436 gdb::process_get_reg (int reg)
439 cerr << "process_get_reg " << reg << endl;
442 gdbserv_output_string (gdbserv, "E01");
447 gdb::process_set_regs ()
450 cerr << "process_set_regs" << endl;
453 gdbserv_output_string (gdbserv, "E01");
460 gdb::process_get_regs ()
463 cerr << "process_get_regs " << endl;
465 dbg_register_number_t num_regs;
466 string num_regs_str = cpu->attribute_value ("gdb-num-registers");
467 component::status s = parse_attribute (num_regs_str, num_regs);
468 if (s != component::ok)
472 cerr << "num_regs=" << num_regs;
473 unsigned num_bytes = 0;
475 for (dbg_register_number_t regno=0; regno<num_regs; regno++)
477 string reg_name = string("gdb-register-")
478 + make_numeric_attribute(regno);
479 string value = cpu->attribute_value (reg_name);
481 for (unsigned i=0; i < value.length(); i++)
483 gdbserv_output_byte (gdbserv, value[i]);
489 cerr << " bytes=" << num_bytes << endl;
494 gdb::process_get_exp_regs ()
497 cerr << "process_get_exp_regs";
499 string exp_regs_str = cpu->attribute_value ("gdb-exp-registers");
501 if (exp_regs_str == "")
504 vector<string> exp_regs_list = tokenize (exp_regs_str, ";");
505 unsigned num_bytes = 0;
507 for (unsigned i=0; i<exp_regs_list.size(); i++)
509 dbg_register_number_t regno;
510 component::status s = parse_attribute (exp_regs_list[i], regno);
511 if (s != component::ok)
515 cerr << " " << regno;
517 string reg_name = string("gdb-register-") + make_numeric_attribute (regno);
518 string value = cpu->attribute_value (reg_name);
520 // encode register number
521 string regno_hex = make_numeric_attribute (regno, ios::hex); // no ios::showbase
522 gdbserv_output_string (gdbserv, regno_hex.c_str());
523 gdbserv_output_char (gdbserv, ':');
526 for (unsigned i=0; i < value.length(); i++)
528 gdbserv_output_byte (gdbserv, value[i]);
531 gdbserv_output_char (gdbserv, ';');
535 cerr << " bytes=" << num_bytes << endl;
542 template <class Type>
544 read_bus_word(gdbserv* gdbserv,
550 bus::status s = bus->read (address, value);
553 for (unsigned i=0; i < sizeof(typename Type::value_type); i++)
554 gdbserv_output_byte (gdbserv, value.read_byte(i));
556 else if (s == bus::misaligned)
558 // Try it one byte at a time
559 for (unsigned i=0; i < sizeof(typename Type::value_type); i++)
561 big_int_1 b; // endianness of a single byte is irrelevent
562 s = bus->read (address + i, b);
564 gdbserv_output_byte (gdbserv, b);
566 gdbserv_output_string (gdbserv, "E05");
570 gdbserv_output_string (gdbserv, "E05");
574 template <class Type>
576 write_bus_word(gdbserv* gdbserv,
584 for (unsigned i=0; i < sizeof(typename Type::value_type); i++)
588 gdbserv_input_escaped_binary (gdbserv, & b, 1);
590 gdbserv_input_bytes (gdbserv, & b, 1);
592 value.write_byte (i, b);
595 bus::status s = bus->write (address, value);
596 if (s == bus::misaligned)
598 // Try it a byte at a time
599 for (unsigned i=0; i < sizeof(typename Type::value_type); i++)
601 // endianness of a single byte is irrelevent
602 big_int_1 b = value.read_byte (i);
603 s = bus->write (address + i, b);
605 gdbserv_output_string (gdbserv, "E05");
608 else if (s != bus::ok)
609 gdbserv_output_string (gdbserv, "E05");
615 gdb::process_get_mem (struct gdbserv_reg *reg_addr,
616 struct gdbserv_reg *reg_len)
618 unsigned long long addr8;
619 gdbserv_reg_to_ulonglong (gdbserv, reg_addr, &addr8);
621 gdbserv_reg_to_ulong (gdbserv, reg_len, &len);
624 cerr << "process_get_mem addr=" << addr8 << " len=" << len << endl;
628 cerr << "No cpu!" << endl;
629 gdbserv_output_string (gdbserv, "E01");
632 sid::bus* memory = cpu->find_bus ("debugger-bus");
635 cerr << "No debugger-bus!" << endl;
636 gdbserv_output_string (gdbserv, "E02");
641 component::status s =
642 parse_attribute (cpu->attribute_value ("endian"), e);
643 if (s != component::ok) assert (e == endian_unknown);
645 // XXX: 64-bit addresses unsupported
646 if (0 && addr8 >= (1ULL << 32))
648 cerr << "Bad address" << endl;
649 gdbserv_output_string (gdbserv, "E03");
652 host_int_4 addr = addr8; // truncate
654 if (len==1 && e==endian_big)
655 read_bus_word (gdbserv, memory, addr, big_int_1());
656 else if (len==1 && e==endian_little)
657 read_bus_word (gdbserv, memory, addr, little_int_1());
658 else if (len==2 && e==endian_big)
659 read_bus_word (gdbserv, memory, addr, big_int_2());
660 else if (len==2 && e==endian_little)
661 read_bus_word (gdbserv, memory, addr, little_int_2());
662 else if (len==4 && e==endian_big)
663 read_bus_word (gdbserv, memory, addr, big_int_4());
664 else if (len==4 && e==endian_little)
665 read_bus_word (gdbserv, memory, addr, little_int_4());
666 else if (len==8 && e==endian_big)
667 read_bus_word (gdbserv, memory, addr, big_int_8());
668 else if (len==8 && e==endian_little)
669 read_bus_word (gdbserv, memory, addr, little_int_8());
670 else if (e==endian_little)
672 for (unsigned long i=0; i<len; i++)
673 read_bus_word (gdbserv, memory, addr + i, little_int_1());
675 else if (e==endian_big)
677 for (unsigned long i=0; i<len; i++)
678 read_bus_word (gdbserv, memory, addr + i, big_int_1());
682 cerr << "Unknown endianness/size combination!" << endl;
683 gdbserv_output_string (gdbserv, "E04");
689 gdb::process_set_mem (struct gdbserv_reg *reg_addr,
690 struct gdbserv_reg *reg_len,
693 unsigned long long addr8;
694 gdbserv_reg_to_ulonglong (gdbserv, reg_addr, &addr8);
697 gdbserv_reg_to_ulong (gdbserv, reg_len, &len);
700 cerr << "process_set_mem"
703 << " binary=" << binary
708 cerr << "No cpu!" << endl;
709 gdbserv_output_string (gdbserv, "E01");
712 sid::bus* memory = cpu->find_bus ("debugger-bus");
715 cerr << "No debugger-bus!" << endl;
716 gdbserv_output_string (gdbserv, "E02");
721 component::status s =
722 parse_attribute (cpu->attribute_value ("endian"), e);
723 if (s != component::ok) assert (e == endian_unknown);
725 // XXX: 64-bit addresses unsupported
726 if (0 && addr8 >= (1ULL << 32))
728 cerr << "Bad address" << endl;
729 gdbserv_output_string (gdbserv, "E03");
732 host_int_4 addr = addr8; // truncate
734 if (len==1 && e==endian_big)
735 write_bus_word (gdbserv, binary, memory, addr, big_int_1());
736 else if (len==1 && e==endian_little)
737 write_bus_word (gdbserv, binary, memory, addr, little_int_1());
738 else if (len==2 && e==endian_big)
739 write_bus_word (gdbserv, binary, memory, addr, big_int_2());
740 else if (len==2 && e==endian_little)
741 write_bus_word (gdbserv, binary, memory, addr, little_int_2());
742 else if (len==4 && e==endian_big)
743 write_bus_word (gdbserv, binary, memory, addr, big_int_4());
744 else if (len==4 && e==endian_little)
745 write_bus_word (gdbserv, binary, memory, addr, little_int_4());
746 else if (len==8 && e==endian_big)
747 write_bus_word (gdbserv, binary, memory, addr, big_int_8());
748 else if (len==8 && e==endian_little)
749 write_bus_word (gdbserv, binary, memory, addr, little_int_8());
750 else if (e==endian_little)
752 for (unsigned long i=0; i<len; i++)
753 write_bus_word (gdbserv, binary, memory, addr + i, little_int_1());
755 else if (e==endian_big)
757 for (unsigned long i=0; i<len; i++)
758 write_bus_word (gdbserv, binary, memory, addr + i, big_int_1());
762 cerr << "Unknown endianness/size combination!" << endl;
763 gdbserv_output_string (gdbserv, "E04");
769 gdb::process_set_pc (struct gdbserv_reg* val)
772 cerr << "process_set_pc ";
775 gdbserv_reg_to_ulonglong (gdbserv, val, & pc);
780 // Handle disharvardization
781 if (this->gdb_pc_mask)
783 pc &= this->gdb_pc_mask;
792 component::status s = cpu->set_attribute_value ("gdb-register-pc",
793 make_numeric_attribute (pc));
794 if (s != component::ok)
796 cerr << "cannot set gdb-register-pc " << pc << endl;
802 gdb::process_signal (int sig)
805 cerr << "process_signal " << sig << endl;
807 // Mark next occurrence of this signal as to be ignored
808 this->pending_signal_counts [sig] ++;
815 gdb::flush_i_cache ()
818 cerr << "flush_i_cache" << endl;
820 this->icache_flush_pin.drive (0);
825 gdb::compute_signal (unsigned long sig)
828 cerr << "compute_signal " << sig << endl;
835 gdb::get_trap_number ()
838 cerr << "get_trap_number " << endl;
848 cerr << "exit_program " << endl;
850 // Turn off the range-stepping!
851 this->step_range_start = 0;
852 this->step_range_end = 0;
855 target_power (false);
858 last_signal = GDBSERV_SIGINT;
859 gdbserv_fromtarget_break (gdbserv, last_signal);
861 // [don't] signal cfgroot to shut down
862 // this->process_signal_pin.drive (1);
869 gdb::break_program ()
872 cerr << "break_program " << endl;
874 // Turn off the range-stepping!
875 this->step_range_start = 0;
876 this->step_range_end = 0;
879 target_power (false);
882 last_signal = GDBSERV_SIGINT;
883 gdbserv_fromtarget_break (gdbserv, last_signal);
889 gdb::restart_program ()
892 cerr << "restart_program " << endl;
894 // Drive restart pin so reset can be performed
895 this->restart_pin.drive (1);
900 gdb::singlestep_program ()
903 cerr << "singlestep_program " << endl;
906 component::status s = cpu->set_attribute_value ("enable-step-trap?", "1");
907 if (s != component::ok)
909 cerr << "Cannot set enable-step-trap? attribute in cpu: status " << (int)s << endl;
912 this->step_range_start = 0;
913 this->step_range_end = 0;
915 // turn on target subsystem
923 gdb::rangestep_program (struct gdbserv_reg* range_start, struct gdbserv_reg* range_end)
925 if (! this->enable_E_packet)
926 return GDBSERV_TARGET_RC_ERROR;
929 cerr << "rangestep_program ";
932 component::status s = cpu->set_attribute_value ("enable-step-trap?", "1");
933 if (s != component::ok)
935 cerr << "Cannot set enable-step-trap? attribute in cpu: status " << (int)s << endl;
938 gdbserv_reg_to_ulonglong (gdbserv, range_start, & this->step_range_start);
939 gdbserv_reg_to_ulonglong (gdbserv, range_end, & this->step_range_end);
942 cerr << "[" << this->step_range_start << "," << this->step_range_end << ")";
944 // Handle disharvardization
945 if (this->gdb_pc_mask)
947 this->step_range_start &= this->gdb_pc_mask;
948 this->step_range_end &= this->gdb_pc_mask;
951 << "[" << this->step_range_start << "," << this->step_range_end << ")";
957 // turn on target subsystem
960 return GDBSERV_TARGET_RC_OK;
965 gdb::sigkill_program ()
968 cerr << "sigkill_program " << endl;
971 last_signal = GDBSERV_SIGKILL;
972 gdbserv_fromtarget_exit (gdbserv, last_signal);
977 gdb::continue_program ()
980 cerr << "continue_program " << endl;
982 // turn off single-stepping
984 component::status s = cpu->set_attribute_value ("enable-step-trap?", "0");
985 if (s != component::ok)
987 cerr << "Cannot clear enable-step-trap? attribute in cpu: status " << (int) s << endl;
990 this->step_range_start = 0;
991 this->step_range_end = 0;
993 // turn on target subsystem
1000 gdb::remove_breakpoint (unsigned long type, struct gdbserv_reg *addr, struct gdbserv_reg *len)
1002 host_int_8 watch_pc;
1003 gdbserv_reg_to_ulonglong (gdbserv, addr, &watch_pc);
1005 unsigned long bp_length;
1006 gdbserv_reg_to_ulong (gdbserv, len, &bp_length);
1009 cerr << "remove_breakpoint"
1011 << " addr " << watch_pc
1012 << " length " << bp_length
1015 if (! enable_Z_packet) return 1;
1016 if (this->cpu == 0) return -1;
1018 int rc = 1; // Not supported
1020 if ((type == GDBSERV_TARGET_BP_HARDWARE) ||
1021 (type == GDBSERV_TARGET_BP_SOFTWARE && force_Z_sw_to_hw))
1022 rc = this->remove_hw_breakpoint (watch_pc, bp_length) ? 0 : -1;
1023 else if ((type == GDBSERV_TARGET_BP_SOFTWARE) ||
1024 (type == GDBSERV_TARGET_BP_HARDWARE && force_Z_hw_to_sw))
1025 rc = this->remove_sw_breakpoint (watch_pc, bp_length) ? 0 : -1;
1026 else if (type == GDBSERV_TARGET_BP_WRITE)
1027 rc = this->remove_hw_watchpoint (watch_pc, bp_length) ? 0 : -1;
1028 // Fail on uses of other breakpoint types (WRITE, READ, ACCESS, UNKNOWN)
1035 gdb::remove_all_hw_breakpoints ()
1039 hw_breakpoints_t::iterator it = this->hw_breakpoints.begin();
1040 if (it == this->hw_breakpoints.end()) break;
1042 // clean up carcass with refcount=0
1043 if (it->second == 0)
1045 this->hw_breakpoints.erase(it);
1049 // decrement refcount
1050 host_int_8 address = it->first;
1051 bool ok = this->remove_hw_breakpoint (address, 0);
1059 gdb::remove_hw_breakpoint (host_int_8 address, host_int_4 length)
1061 if (this->hw_breakpoints[address] <= 0)
1063 cerr << "sw-debug-gdb: duplicate breakpoint count underflow!" << endl;
1067 string watcher_name;
1068 if (this->gdb_pc_mask)
1072 map_watchable_name ("gdb-register-pc") + string (":") +
1073 string ("mask/value:") +
1074 make_numeric_attribute (this->gdb_pc_mask) + string (":") +
1075 make_numeric_attribute (address);
1081 map_watchable_name ("gdb-register-pc") + string (":") +
1083 make_numeric_attribute (address);
1085 // see also ::add_hw_breakpoint()
1087 this->hw_breakpoints[address] --;
1088 if (this->hw_breakpoints[address] == 0)
1090 component::status s = this->cpu->disconnect_pin (watcher_name, & this->trapstop_pin);
1091 return (s == component::ok);
1099 gdb::remove_all_sw_breakpoints ()
1103 sw_breakpoints_t::iterator it = this->sw_breakpoints.begin();
1104 if (it == this->sw_breakpoints.end()) break;
1106 host_int_8 address = it->first;
1107 bool ok = this->remove_hw_breakpoint (address, 0 /* unknown length */);
1115 gdb::remove_sw_breakpoint (host_int_8 address, host_int_4 length)
1117 // see also ::add_sw_breakpoint()
1119 // reject absent entry
1120 if (this->sw_breakpoints.find(address) == this->sw_breakpoints.end())
1121 return fallback_Z_sw_to_hw && this->remove_hw_breakpoint (address, length);
1123 // Beyond this point, don't try to fall back to hw breakpoints.
1124 // That's because only a successful add_sw_breakpoint would pass the
1125 // previous test. If it fails anything beyond this point, then a sw
1126 // breakpoint is already in place, and cannot possibly be removed by
1127 // using hw breakpoints.
1129 sid::bus* memory = cpu->find_bus ("debugger-bus");
1133 string imem = this->sw_breakpoints [address];
1135 if (length != 0 && (imem.length() != length))
1137 // maybe we don't know the removal length any more; update length if so
1139 length = imem.length();
1141 // put back insn memory at given address
1142 for (host_int_4 i=0; i<length; i++)
1144 little_int_1 byte; // == big_int_1
1146 // store back old image
1147 byte = imem[i]; // range already checked above
1148 bus::status s = memory->write (address + i, byte);
1154 this->sw_breakpoints.erase (address);
1160 gdb::remove_all_hw_watchpoints ()
1164 hw_watchpoints_t::iterator it = this->hw_watchpoints.begin();
1165 if (it == this->hw_watchpoints.end()) break;
1167 // clean up carcass with refcount=0
1168 if (it->second == 0)
1170 this->hw_watchpoints.erase(it);
1174 // decrement refcount
1175 string watcher_name = it->first;
1176 bool ok = this->remove_hw_watchpoint (watcher_name);
1184 gdb::remove_hw_watchpoint (const string &watcher_name)
1186 if (this->hw_watchpoints[watcher_name] <= 0)
1188 cerr << "sw-debug-gdb: duplicate watchpoint count underflow!" << endl;
1192 this->hw_watchpoints[watcher_name] --;
1193 if (this->hw_watchpoints[watcher_name] == 0)
1195 component::status s = this->cpu->disconnect_pin (watcher_name, & this->trapstop_pin);
1196 return (s == component::ok);
1204 gdb::remove_hw_watchpoint (host_int_8 address, host_int_4 length)
1206 string watcher_name = string ("watch:")
1207 + map_watchable_name ("gdb-watchpoint-"
1208 + make_numeric_attribute (address)
1210 + make_numeric_attribute (length))
1213 return remove_hw_watchpoint (watcher_name);
1218 gdb::set_breakpoint (unsigned long type, struct gdbserv_reg *addr, struct gdbserv_reg *len)
1220 host_int_8 watch_pc;
1221 gdbserv_reg_to_ulonglong (gdbserv, addr, &watch_pc);
1223 unsigned long bp_length;
1224 gdbserv_reg_to_ulong (gdbserv, len, &bp_length);
1227 cerr << "add_breakpoint"
1229 << " addr " << watch_pc
1230 << " length " << bp_length
1234 if (! enable_Z_packet) return 1;
1235 if (this->cpu == 0) return -1;
1237 int rc = 1; // Not supported
1239 if ((type == GDBSERV_TARGET_BP_HARDWARE) ||
1240 (type == GDBSERV_TARGET_BP_SOFTWARE && force_Z_sw_to_hw))
1241 rc = this->add_hw_breakpoint (watch_pc, bp_length) ? 0 : -1;
1242 else if ((type == GDBSERV_TARGET_BP_SOFTWARE) ||
1243 (type == GDBSERV_TARGET_BP_HARDWARE && force_Z_hw_to_sw))
1244 rc = this->add_sw_breakpoint (watch_pc, bp_length) ? 0 : -1;
1245 else if (type == GDBSERV_TARGET_BP_WRITE)
1246 rc = this->add_hw_watchpoint (watch_pc, bp_length) ? 0 : -1;
1247 // Fail on uses of other breakpoint types (READ, ACCESS, UNKNOWN)
1254 gdb::add_hw_breakpoint (host_int_8 address, host_int_4 length)
1256 // XXX: be sensitive to length
1258 string watcher_name;
1259 if (this->gdb_pc_mask)
1263 map_watchable_name ("gdb-register-pc") + string (":") +
1264 string ("mask/value:") +
1265 make_numeric_attribute (this->gdb_pc_mask) + string (":") +
1266 make_numeric_attribute (address);
1272 map_watchable_name ("gdb-register-pc") + string (":") +
1274 make_numeric_attribute (address);
1276 // see also ::remove_hw_breakpoint()
1278 this->hw_breakpoints[address] ++;
1279 if (this->hw_breakpoints[address] == 1)
1281 component::status s = this->cpu->connect_pin (watcher_name, & this->trapstop_pin);
1282 return (s == component::ok);
1290 gdb::add_sw_breakpoint (host_int_8 address, host_int_4 length)
1292 // see also ::remove_sw_breakpoint()
1295 if (this->sw_breakpoints.find(address) != this->sw_breakpoints.end())
1298 sid::bus* memory = cpu->find_bus ("debugger-bus");
1300 return fallback_Z_sw_to_hw && this->add_hw_breakpoint (address, length);
1302 // fetch cpu sw breakpoint image
1304 component::status s =
1305 parse_attribute (cpu->attribute_value ("endian"), e);
1306 if (s != component::ok) assert (e == endian_unknown);
1307 string bp_attr_name = string("gdb-sw-breakpoint") +
1308 (e == endian_little ? string ("-little") :
1309 e == endian_big ? string ("-big") :
1310 string ("")); // should not happen; will fail when used
1311 string bp = cpu->attribute_value (bp_attr_name);
1312 if (bp.length() != length)
1313 return fallback_Z_sw_to_hw && this->add_hw_breakpoint (address, length);
1315 // fetch insn memory at given address; replace it byte by byte
1317 for (host_int_4 i=0; i<length; i++)
1319 little_int_1 byte; // == big_int_1
1322 bus::status s = memory->read (address + i, byte);
1324 return fallback_Z_sw_to_hw && this->add_hw_breakpoint (address, length);
1328 byte = bp[i]; // range already checked above
1329 s = memory->write (address + i, byte);
1331 return fallback_Z_sw_to_hw && this->add_hw_breakpoint (address, length);
1335 this->sw_breakpoints [address] = imem;
1341 gdb::set_exec_direction (const char *direction)
1344 cerr << "set_exec_direction " << endl;
1347 component::status s = cpu->set_attribute_value ("exec-direction", direction);
1348 if (s != component::ok)
1350 cerr << "Cannot set exec-direction attribute in cpu: status " << (int)s << endl;
1358 gdb::add_hw_watchpoint (host_int_8 address, host_int_4 length)
1360 // XXX: be sensitive to length
1362 string watcher_name = string ("watch:")
1363 + map_watchable_name ("gdb-watchpoint-"
1364 + make_numeric_attribute (address)
1366 + make_numeric_attribute (length))
1369 // see also ::remove_hw_watchpoint()
1371 this->hw_watchpoints[watcher_name] ++;
1372 if (this->hw_watchpoints[watcher_name] == 1)
1374 component::status s = this->cpu->connect_pin (watcher_name, & this->trapstop_pin);
1375 return (s == component::ok);
1383 gdb::process_detach ()
1386 cerr << "process_detach " << endl;
1389 this->remove_all_hw_breakpoints () &&
1390 this->remove_all_sw_breakpoints () &&
1391 this->remove_all_hw_watchpoints ();
1394 cerr << "sw-debug-gdb: cannot clean up breakpoints" << endl;
1397 // Decouple from gdbserv; caller will free it.
1400 // Conditionally stop sim.
1401 if (this->exit_on_detach)
1404 target_power (false);
1405 // signal cfgroot to shut down
1406 this->process_signal_pin.drive (1);
1410 // Don't resume target subsystem. It may be halted on purpose,
1411 // such as after having executed an exit(). A gdb re-attach may
1412 // bring the target back to life.
1416 // Increment a given attribute value, interpreted as a plain `int'.
1418 increment_attribute (sid::component* comp, const string& attr, int increment)
1421 string valstr = comp->attribute_value (attr);
1423 component::status s = parse_attribute(valstr, num);
1424 if (s != component::ok)
1426 cerr << "Cannot parse " << attr << " attribute: string " << valstr
1427 << " status " << (int) s << endl;
1433 valstr = make_numeric_attribute (num);
1435 s = comp->set_attribute_value (attr, valstr);
1436 if (s != component::ok)
1438 cerr << "Cannot set " << attr << " attribute: string " << valstr
1439 << " status " << (int) s << endl;
1445 gdb::target_power (bool on)
1448 cerr << "target_power " << on << endl;
1450 // clear signal cause
1451 last_signal = GDBSERV_SIGNONE;
1453 // signal target system to yield
1454 this->yield_pin.drive (0);
1456 // increment/decrement enabled? attribute of target schedulers when 'on'
1457 // is true/false respectively. Do not increment/decrement the attribute
1458 // if the scheduler is already enabled/disabled from our point of view.
1459 int incr = on ? 1 : -1;
1460 for (unsigned i=0; i<target_schedulers.size(); i++)
1462 bool enabled = target_schedulers_enabled[i];
1464 cerr << " Target scheduler " << i << " enabled==" << enabled << endl;
1467 increment_attribute (target_schedulers[i], "enabled?", incr);
1468 target_schedulers_enabled[i] = on;
1472 // increment/decrement enabled? attribute of host schedulers when 'on'
1473 // is false/true respectively. Do not increment/decrement the attribute
1474 // if the scheduler is already enabled/disabled from our point of view.
1475 for (unsigned j=0; j<host_schedulers.size(); j++)
1477 bool yielded = host_schedulers_host_time_yielded[j];
1479 cerr << " Host scheduler " << j << " yielded==" << yielded << endl;
1482 increment_attribute (host_schedulers[j], "yield-host-time?", -incr);
1483 host_schedulers_host_time_yielded[j] = ! on;
1489 // ----------------------------------------------------------------------------
1490 // Interface functions to gdbserv / client code
1494 gdb::gdbsid_client_write (const unsigned char* ch, unsigned len)
1496 if (! this->connected_p)
1498 cerr << "gdb: warning: writing but not yet connected" << endl;
1501 for (unsigned i = 0; i < len; i++)
1503 this->remote_tx_pin.drive (ch[i]);
1509 gdb::remote_rx_eof_handler ()
1511 if (this->trace_gdbserv)
1512 cout << "gdb: disconnect" << endl;
1514 if (! this->connected_p)
1516 cerr << "gdb: unexpected disconnection." << endl;
1520 this->connected_p = false;
1522 gdbserv_fromclient_detach (this->gdbserv);
1524 assert (this->gdbserv_client != 0);
1525 delete this->gdbserv_client;
1526 this->gdbserv_client = 0;
1531 gdb::remote_rx_handler (host_int_4 value)
1533 // dispatch to EOF handler
1534 if (value & ~0x00FF)
1535 return this->remote_rx_eof_handler ();
1537 // first byte coming from a connection?
1538 if (! this->connected_p)
1540 if (this->trace_gdbserv)
1541 cout << "gdb: connect" << endl;
1543 this->connected_p = true;
1545 assert (this->gdbserv_client == 0);
1546 this->gdbserv_client = new ::gdbserv_client();
1547 this->gdbserv_client->write = & gdbsid_client_write_hook;
1548 this->gdbserv_client->data = static_cast<void*>(this);
1550 // Attach to gdbserv engine. NB: This calls back into this
1551 // object through the attach_hook.
1552 struct gdbserv* serv = gdbserv_fromclient_attach (this->gdbserv_client,
1553 & gdbsid_target_attach_hook,
1554 static_cast<void*>(this));
1557 // This shouldn't happen, since
1558 cerr << "gdb: refusing connection" << endl;
1559 this->connected_p = false;
1560 delete this->gdbserv_client;
1561 this->gdbserv_client = 0;
1562 this->remote_tx_pin.drive (~0); // send EOF
1567 // forward the byte to gdbserv-input.
1568 assert (this->gdbserv != 0);
1570 char data = (value & 0x00FF);
1571 gdbserv_fromclient_data (this->gdbserv, & data, 1);
1575 // ----------------------------------------------------------------------------
1576 // Interface functions to sid code
1579 init_pin (this, & gdb::init_handler),
1580 deinit_pin (this, & gdb::deinit_handler),
1581 connected_p (false),
1582 remote_rx_pin (this, & gdb::remote_rx_handler),
1585 cpu_trap_ipin (this, & gdb::cpu_trap_handler),
1586 gloss_process_signal_pin (this, & gdb::gloss_signal_handler),
1587 target_tx_pin (this, & gdb::target_tx_handler),
1588 stop_pin (this, & gdb::stop_handler),
1589 trapstop_pin (this, & gdb::trapstop_handler),
1590 start_pin (this, & gdb::start_handler),
1594 add_pin ("init", & init_pin);
1595 add_attribute ("init", & init_pin, "pin");
1596 add_pin ("deinit", & deinit_pin);
1597 add_attribute ("deinit", & deinit_pin, "pin");
1598 add_pin ("trap-code", & cpu_trap_code_pin);
1599 add_pin ("process-signal", & process_signal_pin);
1600 add_pin ("restart", & restart_pin);
1601 add_pin ("gloss-process-signal", & gloss_process_signal_pin);
1602 add_pin ("remote-rx", & remote_rx_pin);
1603 add_attribute ("remote-rx", & remote_rx_pin, "pin");
1604 add_pin ("remote-tx", & remote_tx_pin);
1605 add_attribute ("remote-tx", & remote_tx_pin, "pin");
1606 add_pin ("target-tx", & target_tx_pin);
1607 add_attribute ("target-tx", & target_tx_pin, "pin");
1608 add_pin ("trap", & cpu_trap_ipin, & cpu_trap_opin);
1609 add_pin ("yield", & yield_pin);
1610 add_attribute ("yield", & yield_pin, "pin");
1611 add_pin ("flush-icache", & icache_flush_pin);
1612 add_attribute ("flush-icache", & icache_flush_pin, "pin");
1613 add_pin ("stop-target", & stop_pin);
1614 add_attribute ("stop-target", & stop_pin, "pin");
1615 add_pin ("start-target", & start_pin);
1616 add_attribute ("start-target", & start_pin, "pin");
1618 // NB: We don't have to register the stoptrap_pin as an externally
1619 // visible input pin.
1620 // add_pin ("stop-target-trap", & stoptrap_pin);
1622 this->connected_p = false;
1623 add_attribute_ro ("connected?", & this->connected_p, "register");
1628 add_uni_relation ("cfgroot", & cfgroot);
1629 add_uni_relation ("cpu", & cpu);
1630 add_uni_relation ("gloss", & gloss);
1631 add_multi_relation ("target-schedulers", & target_schedulers);
1632 add_multi_relation ("host-schedulers", & host_schedulers);
1635 trace_gdbserv = false;
1636 trace_gdbsid = false;
1637 exit_on_detach = false;
1638 enable_Z_packet = true;
1639 force_Z_sw_to_hw = false;
1640 force_Z_hw_to_sw = false;
1641 fallback_Z_sw_to_hw = true;
1642 enable_E_packet = true;
1643 operating_mode_p = true;
1645 step_range_start = 0;
1648 add_attribute_notify ("trace-gdbserv?", & trace_gdbserv,
1649 this, & gdb::update_trace_flags, "setting");
1650 add_attribute_notify ("trace-gdbsid?", & trace_gdbsid,
1651 this, & gdb::update_trace_flags, "setting");
1652 add_attribute ("exit-on-detach?", & exit_on_detach, "setting");
1653 add_attribute ("enable-Z-packet?", & enable_Z_packet, "setting");
1654 add_attribute ("force-Z-hw-to-sw?", & force_Z_sw_to_hw, "setting");
1655 add_attribute ("force-Z-sw-to-hw?", & force_Z_hw_to_sw, "setting");
1656 add_attribute ("fallback-Z-sw-to-hw?", & fallback_Z_sw_to_hw, "setting");
1657 add_attribute ("enable-E-packet?", & enable_E_packet, "setting");
1658 add_attribute ("operating-mode?", & operating_mode_p, "setting");
1659 add_attribute ("gdb-pc-mask", & gdb_pc_mask, "setting");
1660 add_attribute_alias ("Z-packet-pc-mask", "gdb-pc-mask"); // backward compat.
1666 gdb::init_handler (host_int_4)
1670 cerr << "sid-gdb: no debug cpu specified." << endl;
1674 // Initialize vectors representing the state of each host/target scheduler.
1675 for (unsigned i=0; i<target_schedulers.size(); i++)
1676 target_schedulers_enabled.push_back (true);
1677 for (unsigned j=0; j<host_schedulers.size(); j++)
1678 host_schedulers_host_time_yielded.push_back (false);
1680 // suspend down target system
1681 target_power (false);
1686 gdb::deinit_handler (host_int_4)
1688 // disconnect if needed
1689 if (this->connected_p)
1692 target_power (false);
1694 gdbserv_fromtarget_exit (gdbserv, 0);
1695 this->remote_rx_eof_handler ();
1702 gdb::update_trace_flags()
1704 gdbserv_state_trace = trace_gdbserv ? stderr : NULL;
1708 // Some sid-side component would like the target CPU to stop and hand
1709 // control to the debugger.
1711 gdb::stop_handler (host_int_4)
1714 cerr << "stop_handler" << endl;
1716 // Turn off the range-stepping!
1717 this->step_range_start = 0;
1718 this->step_range_end = 0;
1720 // ignore if signal is pending
1721 if (this->pending_signal_counts [GDBSERV_SIGINT] > 0)
1723 this->pending_signal_counts [GDBSERV_SIGINT] --;
1728 target_power (false);
1731 if (this->gdbserv == 0)
1733 // XXX: Is this warning useful?
1734 cerr << "gdb: warning: stopping without attached debugger!" << endl;
1739 last_signal = GDBSERV_SIGINT;
1740 gdbserv_fromtarget_break (gdbserv, last_signal);
1745 // The "target-stop-trap" pin was tickled, presumably because the CPU has
1746 // hit an hardware breakpoint, emulated by a PC triggerpoint.
1748 gdb::trapstop_handler (host_int_4)
1751 cerr << "trapstop_handler" << endl;
1753 // ignore if signal is pending
1754 if (this->pending_signal_counts [GDBSERV_SIGTRAP] > 0)
1756 this->pending_signal_counts [GDBSERV_SIGTRAP] --;
1760 // Turn off the range-stepping!
1761 this->step_range_start = 0;
1762 this->step_range_end = 0;
1765 target_power (false);
1768 if (this->gdbserv == 0)
1770 // XXX: Is this warning useful?
1771 cerr << "gdb: warning: stopping without attached debugger!" << endl;
1776 last_signal = GDBSERV_SIGTRAP;
1777 gdbserv_fromtarget_break (gdbserv, last_signal);
1782 // Some sid-side component would like the target CPU to start again.
1783 // NB: This could upset an attached external debugger.
1785 gdb::start_handler (host_int_4)
1788 cerr << "start_handler" << endl;
1791 target_power (true);
1794 if (this->gdbserv != 0)
1796 // We may already be halted, or running. But there is no way to
1797 // inform gdb that we are about to resume running.
1798 cerr << "gdb: warning: starting without informing attached debugger!" << endl;
1804 // The GLOSS emulator is signalling that a process exit signal
1807 gdb::gloss_signal_handler (host_int_4 value)
1810 cerr << "gloss_signal " << value << endl;
1813 target_power (false);
1816 if (this->gdbserv == 0)
1819 this->process_signal_pin.drive (value);
1824 last_signal = value & 0xff;
1825 gdbserv_fromtarget_exit (gdbserv, value >> 8);
1830 // The CPU is signalling that a trap of some sort is in progress.
1832 gdb::cpu_trap_handler (host_int_4 trap_type)
1835 cerr << "cpu_trap_handler t=" << trap_type << endl;
1837 // Don't handle CPU traps in operating mode, except for:
1838 // - single-stepping
1839 if (this->operating_mode_p &&
1840 (trap_type != sidutil::cpu_trap_stepped))
1843 // Handle pending step-out-of-range packet
1844 if (trap_type == sidutil::cpu_trap_stepped &&
1845 this->step_range_end)
1848 string pcval = cpu->attribute_value ("gdb-register-pc");
1849 component::status s = parse_attribute (pcval, pc);
1850 if (s != component::ok)
1852 cerr << "cannot parse gdb-register-pc " << pcval << endl;
1856 // Handle disharvardization
1857 if (this->gdb_pc_mask)
1858 pc &= this->gdb_pc_mask;
1860 // Note the [start, end) interpretation!
1861 if (pc >= this->step_range_start && pc < this->step_range_end)
1864 cerr << "(pc=" << pc << " - resuming)" << endl;
1865 this->cpu_trap_opin.drive (cpu_trap_handled);
1869 // Turn off the range-stepping!
1870 this->step_range_start = 0;
1871 this->step_range_end = 0;
1875 host_int_4 trapsig =
1876 trap_type == sidutil::cpu_trap_software ? GDBSERV_SIGTRAP :
1877 trap_type == sidutil::cpu_trap_breakpoint ? GDBSERV_SIGTRAP :
1878 trap_type == sidutil::cpu_trap_syscall ? GDBSERV_SIGTRAP :
1879 trap_type == sidutil::cpu_trap_invalid_insn ? GDBSERV_SIGILL :
1880 trap_type == sidutil::cpu_trap_memory_fault ? GDBSERV_SIGSEGV:
1881 trap_type == sidutil::cpu_trap_overflow ? GDBSERV_SIGFPE :
1882 trap_type == sidutil::cpu_trap_stepped ? GDBSERV_SIGTRAP :
1886 if (this->gdbserv == 0)
1889 target_power (false);
1891 this->process_signal_pin.drive (trap_type);
1895 // ignore if signal is pending
1896 if (this->pending_signal_counts [trapsig] > 0)
1898 this->pending_signal_counts [trapsig] --;
1903 this->cpu_trap_opin.drive (cpu_trap_handled);
1905 target_power (false);
1907 if (last_signal == GDBSERV_SIGNONE)
1908 last_signal = trapsig;
1909 gdbserv_fromtarget_break (gdbserv, last_signal);
1915 // A 'standard output' character came in from the target. Send it on
1916 // to gdb via a "O" packet. Each will pile up a pending '+' ACK in
1919 gdb::target_tx_handler (host_int_4 value)
1922 if (this->gdbserv == 0)
1928 gdbserv_output_discard (gdbserv);
1929 gdbserv_output_char (gdbserv, 'O');
1930 gdbserv_output_byte (gdbserv, ((int) value) & 0xFF);
1931 gdbserv_output_packet (gdbserv);
1932 gdbserv_output_discard (gdbserv);
1938 gdb::configure (const string &config)
1940 // Call up to the base class first
1941 configurable_component::configure (config);
1943 // Now handle relevent configuration for us.
1944 if (config.size () <= 8)
1946 if (config.substr (0, 8) == "verbose=")
1948 bool verbose_p = (config.substr (8) == "true");
1949 trace_gdbserv = verbose_p;
1950 trace_gdbsid = verbose_p;
1958 // Do nothing here; disconnection and gdbserv memory cleanup ought
1959 // to have occurred during deinit / detach earlier.
1964 // ----------------------------------------------------------------------------
1966 // Standard DLL wrapper-stuff
1968 static vector<string>
1971 vector<string> types;
1972 types.push_back ("sw-debug-gdb");
1977 gdb_create (const string& name)
1979 if (name == "sw-debug-gdb")
1986 gdb_delete (component* c)
1988 delete dynamic_cast<gdb*>(c);
1992 DLLEXPORT extern const component_library gdb_component_library;
1994 const component_library gdb_component_library = {
1995 COMPONENT_LIBRARY_MAGIC,