Esempio n. 1
0
/* Return 0 if the reply was successfully received, !0 otherwise. */
void 
gdb_send_packet(struct gdb_context *ctx)
{
    char buf[3];
    int count;

    snprintf(buf, sizeof(buf), "%.02x\n", ctx->out_csum);

    gdb_write_to_packet_char('#', ctx);
    gdb_write_to_packet(buf, 2, ctx);

    count = 0;
    do {
        gdb_io_write(ctx->out_buf, ctx->out_offset, ctx);
    } while ( !gdb_check_ack(ctx) && (count++ < GDB_RETRY_MAX) );

    if ( count == GDB_RETRY_MAX )
        dbg_printk("WARNING: %s reached max retry %d\n",
                   __func__, GDB_RETRY_MAX);
}
Esempio n. 2
0
void gdb_send_packet()
{
   uint8_t *pkt;
   size_t  sz;

   if(!gdb_acked())
   {
      debug(GDBSTUB_PKT, "adding ACK byte\n");
      pkt = &gdb_answer[0];
      sz = gdb_buffer.sz + GDB_ACKPKT_SZ;
   }
   else
   {
      debug(GDBSTUB_PKT, "already ACKed\n");
      pkt = &gdb_answer[1];
      gdb_set_ack(0);
      sz = gdb_buffer.sz + GDB_PKT_SZ;
   }

   if(gdb_buffer.sz > (GDB_ANSWER_SZ - GDB_ACKPKT_SZ))
   {
      debug(GDBSTUB_PKT, "can not send pkt with 0x%X bytes\n", gdb_buffer.sz);
      gdb_unsupported();
      return;
   }

   gdb_answer[gdb_buffer.sz + 2] = GDB_END_BYTE;
   gdb_checksum(gdb_buffer.data.u8, gdb_buffer.sz, &gdb_answer[gdb_buffer.sz+3]);
   gdb_io_write(pkt, sz);

   debug(GDBSTUB_PKT, "gdb sent (%D): [", sz);
#ifdef CONFIG_GDBSTUB_PKT_DBG
   debug_write(pkt, sz);
   debug_write((uint8_t*)"]\n", 2);
#endif
}
Esempio n. 3
0
static int
gdb_io_write_char(u8 data, struct gdb_context *ctx)
{
    return gdb_io_write((char*)&data, 1, ctx);
}
Esempio n. 4
0
void gdb_nak()
{
   uint8_t x = GDB_NAK_BYTE;
   gdb_io_write(&x, 1);
}
Esempio n. 5
0
void gdb_ack()
{
   uint8_t x = GDB_ACK_BYTE;
   gdb_io_write(&x, 1);
   gdb_set_ack(1);
}