1 /* Defintions to support the remote debugging interface.
2    Copyright 2001, 2003 Brian R. Gaeke.
3 
4 This file is part of VMIPS.
5 
6 VMIPS is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2 of the License, or (at your
9 option) any later version.
10 
11 VMIPS is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15 
16 You should have received a copy of the GNU General Public License along
17 with VMIPS; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
19 
20 #ifndef _DEBUG_H_
21 #define _DEBUG_H_
22 
23 #include "deviceexc.h"
24 #include <set>
25 class CPU;
26 class Mapper;
27 
28 class Debug : public DeviceExc {
29 private:
30 	CPU *cpu;
31 	Mapper *mem;
32 	int signo;
33 	int listener;
34 	long threadno_step;
35 	long threadno_gen;
36 	uint32 rom_baseaddr;
37 	uint32 rom_nwords;
38 	typedef std::set<uint32> wordset;
39 	wordset bp_set;
40 	bool opt_bigendian;
41 	bool debug_verbose;
42 
43 public:
44 	Debug (CPU &c_, Mapper &m_);
~Debug()45 	virtual ~Debug () { }
46 	bool got_interrupt;
47 
48 	uint32 packet_pop_word(char **packet);
49 	uint8 packet_pop_byte(char **packet);
50 
51 	int setup(uint32 baseaddr, uint32 nwords);
52 	int serverloop(void);
53 	void exception(uint16 excCode, int mode, int coprocno);
54 
55 private:
56 	int setup_listener_socket(void);
57 	int set_nonblocking(int fd);
58 	void print_local_name(int s);
59 	void targetloop(void);
60 	char *rawpacket(const char *str);
61 	char *hexpacket(const char *str);
62 	char *error_packet(int error_code);
63 	char *signal_packet(int signal);
64 	char *target_query(char *pkt);
65 	char *target_kill(char *pkt);
66 	char *target_set_thread(char *pkt);
67 	char *target_poll_thread(char *pkt);
68 	char *target_read_registers(char *pkt);
69 	char *target_write_registers(char *pkt);
70 	char *target_read_memory(char *pkt);
71 	char *target_write_memory(char *pkt);
72 	uint8 single_step(void);
73 	char *target_continue(char *pkt);
74 	char *target_detach(char *pkt);
75 	char *target_step(char *pkt);
76 	char *target_last_signal(char *pkt);
77 	char *target_unimplemented(char *pkt);
78 	int exccode_to_signal(int exccode);
79 	/* Breakpoint support methods. */
80 	bool breakpoint_exists(uint32 addr);
81 	void declare_breakpoint(uint32 addr);
82 	void remove_breakpoint(uint32 addr);
83 	bool address_in_rom(uint32 addr);
84 	void get_breakpoint_bitmap_entry(uint32 addr, uint8 *&entry, uint8 &bitno);
85 	bool is_breakpoint_insn(char *packetptr);
86 	char *target_set_or_remove_breakpoint(char *pkt, bool setting);
87 };
88 
89 #endif /* _DEBUG_H_ */
90