/**
* Returns the index of the watchpoint if found, -1 otherwise.
*/
-static int gdb_watch_find(const avr_gdb_watchpoints_t * w, uint32_t addr)
+static int
+gdb_watch_find(
+ const avr_gdb_watchpoints_t * w,
+ uint32_t addr )
{
for (int i = 0; i < w->len; i++) {
if (w->points[i].addr > addr) {
* Contrary to gdb_watch_find, this actually checks the address against
* a watched memory _range_.
*/
-static int gdb_watch_find_range(const avr_gdb_watchpoints_t * w, uint32_t addr)
+static int
+gdb_watch_find_range(
+ const avr_gdb_watchpoints_t * w,
+ uint32_t addr )
{
for (int i = 0; i < w->len; i++) {
if (w->points[i].addr > addr) {
/**
* Returns -1 on error, 0 otherwise.
*/
-static int gdb_watch_add_or_update(avr_gdb_watchpoints_t * w, enum avr_gdb_watch_type kind, uint32_t addr,
- uint32_t size)
+static int
+gdb_watch_add_or_update(
+ avr_gdb_watchpoints_t * w,
+ enum avr_gdb_watch_type kind,
+ uint32_t addr,
+ uint32_t size )
{
/* If the watchpoint exists, update it. */
int i = gdb_watch_find(w, addr);
/**
* Returns -1 on error or if the specified point does not exist, 0 otherwise.
*/
-static int gdb_watch_rm(avr_gdb_watchpoints_t * w, enum avr_gdb_watch_type kind, uint32_t addr)
+static int
+gdb_watch_rm(
+ avr_gdb_watchpoints_t * w,
+ enum avr_gdb_watch_type kind,
+ uint32_t addr )
{
int i = gdb_watch_find(w, addr);
if (i == -1) {
return 0;
}
-static void gdb_watch_clear(avr_gdb_watchpoints_t * w)
+static void
+gdb_watch_clear(
+ avr_gdb_watchpoints_t * w )
{
w->len = 0;
}
-static void gdb_send_reply(avr_gdb_t * g, char * cmd)
+static void
+gdb_send_reply(
+ avr_gdb_t * g,
+ char * cmd )
{
uint8_t reply[1024];
uint8_t * dst = reply;
send(g->s, reply, dst - reply + 3, 0);
}
-static void gdb_send_quick_status(avr_gdb_t * g, uint8_t signal)
+static void
+gdb_send_quick_status(
+ avr_gdb_t * g,
+ uint8_t signal )
{
char cmd[64];
gdb_send_reply(g, cmd);
}
-static int gdb_change_breakpoint(avr_gdb_watchpoints_t * w, int set, enum avr_gdb_watch_type kind,
- uint32_t addr, uint32_t size)
+static int
+gdb_change_breakpoint(
+ avr_gdb_watchpoints_t * w,
+ int set,
+ enum avr_gdb_watch_type kind,
+ uint32_t addr,
+ uint32_t size )
{
DBG(printf("set %d kind %d addr %08x len %d\n", set, kind, addr, len);)
return -1;
}
-static int gdb_write_register(avr_gdb_t * g, int regi, uint8_t * src)
+static int
+gdb_write_register(
+ avr_gdb_t * g,
+ int regi,
+ uint8_t * src )
{
switch (regi) {
case 0 ... 31:
return 1;
}
-static int gdb_read_register(avr_gdb_t * g, int regi, char * rep)
+static int
+gdb_read_register(
+ avr_gdb_t * g,
+ int regi,
+ char * rep )
{
switch (regi) {
case 0 ... 31:
return strlen(rep);
}
-static void gdb_handle_command(avr_gdb_t * g, char * cmd)
+static void
+gdb_handle_command(
+ avr_gdb_t * g,
+ char * cmd )
{
avr_t * avr = g->avr;
char rep[1024];
}
}
-static int gdb_network_handler(avr_gdb_t * g, uint32_t dosleep)
+static int
+gdb_network_handler(
+ avr_gdb_t * g,
+ uint32_t dosleep )
{
fd_set read_set;
int max;
* If an applicable watchpoint exists for addr, stop the cpu and send a status report.
* type is one of AVR_GDB_WATCH_READ, AVR_GDB_WATCH_WRITE depending on the type of access.
*/
-void avr_gdb_handle_watchpoints(avr_t * avr, uint16_t addr, enum avr_gdb_watch_type type)
+void
+avr_gdb_handle_watchpoints(
+ avr_t * avr,
+ uint16_t addr,
+ enum avr_gdb_watch_type type )
{
avr_gdb_t *g = avr->gdb;
5, g->avr->data[R_SREG],
g->avr->data[R_SPL], g->avr->data[R_SPH],
g->avr->pc & 0xff, (g->avr->pc>>8)&0xff, (g->avr->pc>>16)&0xff,
- kind & AVR_GDB_WATCH_ACCESS ? "awatch" : kind & AVR_GDB_WATCH_WRITE ? "watch" : "rwatch",
+ kind & AVR_GDB_WATCH_ACCESS ? "awatch" :
+ kind & AVR_GDB_WATCH_WRITE ? "watch" : "rwatch",
addr | 0x800000);
gdb_send_reply(g, cmd);
}
}
-int avr_gdb_processor(avr_t * avr, int sleep)
+int
+avr_gdb_processor(
+ avr_t * avr,
+ int sleep )
{
if (!avr || !avr->gdb)
return 0;
avr_gdb_t * g = avr->gdb;
- if (avr->state == cpu_Running && gdb_watch_find(&g->breakpoints, avr->pc) != -1) {
+ if (avr->state == cpu_Running &&
+ gdb_watch_find(&g->breakpoints, avr->pc) != -1) {
DBG(printf("avr_gdb_processor hit breakpoint at %08x\n", avr->pc);)
gdb_send_quick_status(g, 0);
avr->state = cpu_Stopped;
}
-int avr_gdb_init(avr_t * avr)
+int
+avr_gdb_init(
+ avr_t * avr )
{
avr_gdb_t * g = malloc(sizeof(avr_gdb_t));
memset(g, 0, sizeof(avr_gdb_t));
return 0;
}
-void avr_deinit_gdb(avr_t * avr)
+void
+avr_deinit_gdb(
+ avr_t * avr )
{
if (avr->gdb->listen != -1)
close(avr->gdb->listen);