Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
target_gdb_rsp.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 The University of Utah
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef __TARGET_GDB_RSP_H__
20 #define __TARGET_GDB_RSP_H__
21 
22 #include "config.h"
23 
24 #include "common.h"
25 #include "regcache.h"
26 #include "target_gdb.h"
27 
28 typedef enum {
30  GDB_PACKET = 1 << 0,
31  GDB_NOTIFICATION = 1 << 1,
32  GDB_ACK = 1 << 2,
33  GDB_NAK = 1 << 3,
34  GDB_INTERRUPT = 1 << 4,
35 } gdb_ptype_t;
36 
37 /*
38  * This allows a multi-packet command-response pattern. If the handler
39  * returns -1, there was an error. If the handler returns 1, it means
40  * it expects more packets. If the handler returns 0, it has reached
41  * the end of its sequence. If it returns 2, it could not interpret the
42  * message as the proper response to its command (then the default
43  * handler will try to handle it).
44  */
45 typedef enum {
51 
53  char *data,unsigned int len,
54  void *handler_data);
55 typedef enum {
66  /*
67  * NB: we don't bother supporting this "stop status"... sigh.
68  */
69  /* GDB_RSP_STOP_CONSOLE_OUTPUT = 9, */
71 
73  uint8_t has_pid:1,
74  has_tid:1,
75  has_core:1;
77  unsigned long signal;
78  long int pid;
79  long int tid;
80  unsigned long core;
81  unsigned long exit_status;
83  /*
84  * NB: right now, we don't bother to read any register values it
85  * sends us.
86  */
87 };
88 
89 typedef enum {
96 
97 /*
98  * Prototypes.
99  */
100 int gdb_rsp_connect(struct target *target);
101 int gdb_rsp_close(struct target *target,int stay_paused);
102 int gdb_rsp_recv(struct target *target,int blocking,int only_one,
103  gdb_ptype_t *ptype);
104 int gdb_rsp_recv_until_handled(struct target *target,
105  gdb_rsp_handler_t handler,
106  gdb_rsp_handler_ret_t *handler_ret);
107 
108 int gdb_rsp_interrupt(struct target *target);
109 int gdb_rsp_ack(struct target *target);
110 int gdb_rsp_nak(struct target *target);
111 int gdb_rsp_send_packet(struct target *target,
112  char *data,unsigned int len,
113  gdb_rsp_handler_t handler,void *handler_data);
114 //int gdb_rsp_send_notification(struct target *target,
115 // char *data,unsigned int len);
116 
117 target_status_t gdb_rsp_load_status(struct target *target);
118 
119 int gdb_rsp_pause(struct target *target);
120 int gdb_rsp_resume(struct target *target);
121 int gdb_rsp_step(struct target *target);
122 
123 int gdb_rsp_read_regs(struct target *target,struct regcache *regcache);
124 int gdb_rsp_write_regs(struct target *target,struct regcache *regcache);
125 
126 /* Memory access. Only virtual addresses. */
128  char *buf;
129  unsigned long length;
130  int error;
131 };
132 int gdb_rsp_read_mem(struct target *target,ADDR addr,
133  unsigned long length,unsigned char *buf);
134 int gdb_rsp_write_mem(struct target *target,ADDR addr,
135  unsigned long length,unsigned char *buf);
136 
137 int gdb_rsp_insert_break(struct target *target,ADDR addr,
138  gdb_rsp_break_t bt,int kind);
139 int gdb_rsp_remove_break(struct target *target,ADDR addr,
140  gdb_rsp_break_t bt,int kind);
141 
142 #endif /* __TARGET_GDB_RSP_H__ */
int gdb_rsp_nak(struct target *target)
int gdb_rsp_send_packet(struct target *target, char *data, unsigned int len, gdb_rsp_handler_t handler, void *handler_data)
target_status_t gdb_rsp_load_status(struct target *target)
target_status_t
Definition: target_api.h:197
int gdb_rsp_resume(struct target *target)
int gdb_rsp_read_regs(struct target *target, struct regcache *regcache)
int gdb_rsp_write_mem(struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
int gdb_rsp_recv_until_handled(struct target *target, gdb_rsp_handler_t handler, gdb_rsp_handler_ret_t *handler_ret)
int gdb_rsp_step(struct target *target)
unsigned long signal
int gdb_rsp_recv(struct target *target, int blocking, int only_one, gdb_ptype_t *ptype)
unsigned long exit_status
int gdb_rsp_remove_break(struct target *target, ADDR addr, gdb_rsp_break_t bt, int kind)
int gdb_rsp_insert_break(struct target *target, ADDR addr, gdb_rsp_break_t bt, int kind)
gdb_rsp_stop_reason_t reason
gdb_rsp_break_t
unsigned long core
gdb_rsp_handler_ret_t
gdb_rsp_handler_ret_t(* gdb_rsp_handler_t)(struct target *target, char *data, unsigned int len, void *handler_data)
int len
Definition: dumptarget.c:52
gdb_ptype_t
int gdb_rsp_write_regs(struct target *target, struct regcache *regcache)
int gdb_rsp_pause(struct target *target)
int gdb_rsp_read_mem(struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
int gdb_rsp_connect(struct target *target)
uint32_t ADDR
Definition: common.h:64
int gdb_rsp_ack(struct target *target)
int gdb_rsp_interrupt(struct target *target)
gdb_rsp_stop_reason_t
int gdb_rsp_close(struct target *target, int stay_paused)