#include "config.h"
#include <target/breakpoints.h>
#include <target/target_request.h>
#include <target/register.h>
#include <target/target.h>
#include <target/target_type.h>
#include <target/semihosting_common.h>
#include "server.h"
#include <flash/nor/core.h>
#include "gdb_server.h"
#include <target/image.h>
#include <jtag/jtag.h>
#include "rtos/rtos.h"
#include "target/smp.h"
gdb_output_flag
GDB_OUTPUT_NO
GDB_OUTPUT_NOTIF
GDB_OUTPUT_ALL
target_desc_format
tdesc
tdesc_length
gdb_connection
buffer
buf_p
buf_cnt
ctrl_c
frontend_state
vflash_image
closed
busy
noack_mode
sync
mem_write_error
attached
extended_protocol
target_desc
thread_list
output_flag
unique_index
#define _DEBUG_GDB_IO_
current_gdb_connection
gdb_breakpoint_override
gdb_breakpoint_override_type
gdb_port
gdb_port_next
gdb_actual_connections
gdb_use_memory_map
gdb_flash_program
gdb_report_data_abort
gdb_report_register_access_error
gdb_use_target_description
gdb_running_type
gdb_last_signal(struct target *)
switch
(target->debug_reason)
case
DBG_REASON_DBGRQ:
case
DBG_REASON_BREAKPOINT:
case
DBG_REASON_WATCHPOINT:
case
DBG_REASON_WPTANDBKPT:
case
DBG_REASON_SINGLESTEP:
case
DBG_REASON_EXC_CATCH:
case
DBG_REASON_NOTHALTED:
default
check_pending(struct connection *, int, int *)
if
(gdb_con->buf_cnt > 0)
if
(socket_select(connection->fd + 1, &read_fds, NULL, NULL, &tv) == 0)
gdb_get_char_inner(struct connection *, int *)
for
(;;)
else
if
(gdb_con->buf_cnt == 0)
if
(retry)
else
gdb_get_char_fast(struct connection *, int *, char **, int *)
if
((*buf_cnt)-- > 0)
gdb_get_char(struct connection *, int *)
gdb_putback_char(struct connection *, int)
if
(gdb_con->buf_p > gdb_con->buffer)
gdb_write(struct connection *, void *, int)
if
(gdb_con->closed)
gdb_log_incoming_packet(struct connection *, char *)
if
(nonprint)
if
(packet_prefix_printable)
else
else
gdb_log_outgoing_packet(struct connection *, char *, unsigned int, unsigned char)
gdb_put_packet_inner(struct connection *, char *, int)
for
(;;)
if
(reply == '$')
while
(1)
if
((size_t)len + 4 <= sizeof(local_buffer))
else
if
(reply == '+')
else if
(reply == '-')
else if
(reply == 0x3)
if
(reply == '+')
else if
(reply == '-')
else if
(reply == '$')
else
else if
(reply == '$')
else
gdb_put_packet(struct connection *, char *, int)
fetch_packet(struct connection *, int *, int, int *, char *)
for
(;;)
if
((buf_cnt > 2) && ((buf_cnt + count) < *len))
while
(i < run)
if
(character == '#')
if
(character == '}')
else
if
(count > *len)
if
(character == '}')
else
gdb_get_packet_inner(struct connection *, char *, int *)
while
(1)
switch
(character)
case
'$':
case
'+':
if
(gdb_con->noack_mode > 1)
else if
(gdb_con->noack_mode)
case
'-':
case
0x3:
default
if
(gdb_con->noack_mode)
else
if
(gdb_con->noack_mode)
if
(checksum_ok)
gdb_get_packet(struct connection *, char *, int *)
gdb_output_con(struct connection *, const char *)
gdb_output(struct command_context *, const char *)
gdb_signal_reply(struct target *, struct connection *)
if
(target->debug_reason == DBG_REASON_EXIT)
else
if
(target->rtos)
else
if
(gdb_connection->ctrl_c)
if
(ct->debug_reason == DBG_REASON_WATCHPOINT)
if
(watchpoint_hit(ct, &hit_wp_type, &hit_wp_address) == ERROR_OK)
switch
(hit_wp_type)
case
WPT_WRITE:
case
WPT_READ:
case
WPT_ACCESS:
default
gdb_fileio_reply(struct target *, struct connection *)
else if
(strcmp(target->fileio_info->identifier, "exit") == 0)
else
if
(program_exited)
else
gdb_frontend_halted(struct target *, struct connection *)
if
(gdb_connection->frontend_state == TARGET_RUNNING)
gdb_target_callback_event_handler(struct target *, enum target_event, void *)
switch
(event)
case
TARGET_EVENT_GDB_HALT:
case
TARGET_EVENT_HALTED:
default
gdb_new_connection(struct connection *)
if
(target->rtos)
if
(gdb_use_memory_map)
for
(unsigned int i = 0; i < flash_get_bank_count(); i++)
if
(retval != ERROR_OK)
if
(!target_was_examined(target))
gdb_connection_closed(struct connection *)
if
(gdb_connection->vflash_image)
gdb_send_error(struct connection *, uint8_t)
gdb_last_signal_packet(struct connection *, const char *, int)
if
(!gdb_con->attached)
gdb_reg_pos(struct target *, int, int)
gdb_str_to_target(struct target *, char *, struct reg *)
for
(i = 0; i < buf_len; i++)
gdb_target_to_reg(struct target *, const char *, int, uint8_t *)
if
(str_len % 2)
for
(i = 0; i < str_len; i += 2)
if
(sscanf(tstr + i, "%02x", &t) != 1)
gdb_get_reg_value_as_str(struct target *, char *, struct reg *)
switch
(retval)
case
ERROR_OK:
case
ERROR_TARGET_RESOURCE_NOT_AVAILABLE:
gdb_get_registers_packet(struct connection *, const char *, int)
for
(i = 0; i < reg_list_size; i++)
for
(i = 0; i < reg_list_size; i++)
if
(retval != ERROR_OK && gdb_report_register_access_error)
gdb_set_registers_packet(struct connection *, const char *, int)
if
(packet_size % 2)
for
(i = 0; i < reg_list_size; i++)
if
(retval != ERROR_OK && gdb_report_register_access_error)
gdb_get_register_packet(struct connection *, const char *, int)
if
((reg_list_size <= reg_num) || !reg_list[reg_num] || !reg_list[reg_num]->exist || reg_list[reg_num]->hidden)
if
(retval != ERROR_OK && gdb_report_register_access_error)
gdb_set_register_packet(struct connection *, const char *, int)
if
(*separator != '=')
if
((target->rtos) && (rtos_set_reg(connection, reg_num, bin_buf) == ERROR_OK))
if
(retval != ERROR_OK)
if
((reg_list_size <= reg_num) || !reg_list[reg_num] || !reg_list[reg_num]->exist || reg_list[reg_num]->hidden)
if
(chars != (DIV_ROUND_UP(reg_list[reg_num]->size, 8) * 2))
if
(retval != ERROR_OK && gdb_report_register_access_error)
gdb_error(struct connection *, int)
gdb_read_memory_packet(struct connection *, const char *, int)
if
(*separator != ',')
if
(!len)
if
((retval != ERROR_OK) && !gdb_report_data_abort)
if
(retval == ERROR_OK)
gdb_write_memory_packet(struct connection *, const char *, int)
if
(*separator != ',')
if
(*(separator++) != ':')
gdb_write_memory_binary_packet(struct connection *, const char *, int)
if
(*separator != ',')
if
(*(separator++) != ':')
if
(retval == ERROR_OK)
if
(len >= fast_limit)
else
if
(len)
if
(len < fast_limit)
if
(retval != ERROR_OK)
else
gdb_step_continue_packet(struct connection *, const char *, int)
if
(target->frozen && target->smp)
foreach_smp_target
(head, target->smp_targets)
if
(!pThisTarget->frozen)
if
(packet[0] == 'c')
else if
(packet[0] == 's')
gdb_breakpoint_watchpoint_packet(struct connection *, const char *, int)
else
if
(*separator != ',')
if
(*separator != ',')
switch
(type)
case
0:
case
1:
if
(packet[0] == 'Z')
if
(retval == ERROR_NOT_IMPLEMENTED)
else if
(retval != ERROR_OK)
else
case
2:
case
3:
case
4:
if
(packet[0] == 'Z')
if
(retval == ERROR_NOT_IMPLEMENTED)
else if
(retval != ERROR_OK)
else
default
xml_printf(int *, char **, int *, int *, const char *, ...)
for
(;;)
if
((!*xml) || (!first))
if
(!*xml)
if
((ret > 0) && ((ret + 1) < *size - *pos))
decode_xfer_read(const char *, char **, int *, unsigned int *)
if
(annex)
compare_bank(const void *, const void *)
extend_address_for_gdb(struct target *, target_addr_t)
if
(target->gdb_sign_extends_addresses)
gdb_memory_map(struct connection *, const char *, int)
for
(unsigned int i = 0; i < flash_get_bank_count(); i++)
if
(retval != ERROR_OK)
for
(unsigned int i = 0; i < target_flash_banks; i++)
for
(unsigned int j = 0; j < p->num_sectors; j++)
if
(sector_size == 0)
if
(p->sectors[j].offset + p->sectors[j].size > p->size)
else
if
(retval != ERROR_OK)
gdb_get_reg_type_name(enum reg_type)
switch
(type)
case
REG_TYPE_BOOL:
case
REG_TYPE_INT:
case
REG_TYPE_INT8:
case
REG_TYPE_INT16:
case
REG_TYPE_INT32:
case
REG_TYPE_INT64:
case
REG_TYPE_INT128:
case
REG_TYPE_UINT:
case
REG_TYPE_UINT8:
case
REG_TYPE_UINT16:
case
REG_TYPE_UINT32:
case
REG_TYPE_UINT64:
case
REG_TYPE_UINT128:
case
REG_TYPE_CODE_PTR:
case
REG_TYPE_DATA_PTR:
case
REG_TYPE_FLOAT:
case
REG_TYPE_IEEE_SINGLE:
case
REG_TYPE_IEEE_DOUBLE:
case
REG_TYPE_ARCH_DEFINED:
lookup_add_arch_defined_types(const char ***, const char *, int *)
if
(type_id && (strcmp(type_id, "")))
for
(int j = 0; j < (tbl_sz + 1); j++)
if
(!((*arch_defined_types_list)[j]))
else
gdb_generate_reg_type_description(struct target *, char **, int *, int *, struct reg_data_type *, const char ***, int *)
if
(type->type_class == REG_TYPE_CLASS_VECTOR)
if
(data_type->type == REG_TYPE_ARCH_DEFINED)
else if
(type->type_class == REG_TYPE_CLASS_UNION)
while
(field)
if
(data_type->type == REG_TYPE_ARCH_DEFINED)
while
(field)
else if
(type->type_class == REG_TYPE_CLASS_STRUCT)
if
(field->use_bitfields)
while
(field)
else
while
(field)
if
(data_type->type == REG_TYPE_ARCH_DEFINED)
while
(field)
else if
(type->type_class == REG_TYPE_CLASS_FLAGS)
while
(field)
get_reg_features_list(struct target *, const char ***, int *, struct reg **, int)
for
(int i = 0; i < reg_list_size; i++)
if
(reg_list[i]->feature && reg_list[i]->feature->name && (strcmp(reg_list[i]->feature->name, "")))
for
(int j = 0; j < (tbl_sz + 1); j++)
if
(!((*feature_list)[j]))
else
smp_reg_list_noread(struct target *, struct reg ***, int *, enum target_register_class)
if
(!local_list)
foreach_smp_target
(head, target->smp_targets)
if
(result != ERROR_OK)
for
(int i = 0; i < reg_list_size; i++)
if
(a->exist)
for
(unsigned int j = 0; j < local_list_size; j++)
if
(!strcmp(a->name, b->name))
if
(a->size != b->size)
if
(!found)
if
(local_list_size >= combined_allocated)
if
(!local_list)
if
(local_list_size == 0)
foreach_smp_target
(head, target->smp_targets)
if
(result != ERROR_OK)
for
(unsigned int i = 0; i < local_list_size; i++)
for
(int j = 0; j < reg_list_size; j++)
if
(b->exist && !strcmp(a->name, b->name))
if
(!found)
gdb_generate_target_description(struct target *, char **)
if
(retval != ERROR_OK)
if
(reg_list_size <= 0)
if
(retval != ERROR_OK)
if
(features)
while
(features[current_feature])
for
(i = 0; i < reg_list_size; i++)
if
(reg_list[i]->reg_data_type)
if
(reg_list[i]->reg_data_type->type == REG_TYPE_ARCH_DEFINED)
else
else
gdb_get_target_description_chunk(struct target *, struct target_desc_format *, char **, int32_t, uint32_t)
if
(!target_desc)
if
(!tdesc)
if
(retval != ERROR_OK)
if
(!*chunk)
if
(transfer_type == 'm')
else
gdb_target_description_supported(struct target *, bool *)
if
(retval != ERROR_OK)
if
(reg_list_size <= 0)
if
(retval != ERROR_OK)
if
(supported)
gdb_generate_thread_list(struct target *, char **)
if
(rtos)
for
(int i = 0; i < rtos->thread_count; i++)
if
(thread_detail->extra_info_str)
gdb_get_thread_list_chunk(struct target *, char **, char **, int32_t, uint32_t)
if
(!*thread_list)
if
(retval != ERROR_OK)
if
(!*chunk)
if
(transfer_type == 'l')
gdb_query_packet(struct connection *, const char *, int)
if
(strncmp(packet, "qRcmd,", 6) == 0)
if
(packet_size > 6)
if
(retval == JIM_OK)
if
(lenmsg && cretmsg[lenmsg - 1] != '\n')
else
if
(retval == JIM_OK)
if
(lenmsg)
if
(!hex_buffer)
else
else
else if
(strncmp(packet, "qCRC:", 5) == 0)
if
(packet_size > 5)
if
(*separator != ',')
if
(retval == ERROR_OK)
else
else if
(strncmp(packet, "qSupported", 10) == 0)
if
(retval != ERROR_OK)
if
(!gdb_use_target_description)
if
(retval != ERROR_OK)
else if
(strncmp(packet, "qXfer:features:read:", 20) == 0)
if
(decode_xfer_read(packet, NULL, &offset, &length) < 0)
if
(retval != ERROR_OK)
else if
(strncmp(packet, "qXfer:threads:read:", 19) == 0)
if
(decode_xfer_read(packet, NULL, &offset, &length) < 0)
if
(retval != ERROR_OK)
else if
(strncmp(packet, "QStartNoAckMode", 15) == 0)
else if
(target->type->gdb_query_custom)
gdb_handle_vcont_packet(struct connection *, const char *, int)
if
(parse[0] == '?')
if
(target->type->step)
if
(parse[0] == ';')
if
(parse[0] == 'c')
if
(retval != ERROR_OK)
if
(parse[0] == 's')
if
(parse[0] == ':')
if
(endp)
else
if
(target->rtos)
if
(parse[0] == ';')
if
(parse[0] == 'c')
if
(parse[0] == ':')
if
(tid == thread_id)
if
(fake_step)
if
(gdb_connection->sync)
if
(ct->state == TARGET_HALTED)
if
(retval == ERROR_OK)
next_hex_encoded_field(const char **, char)
if
(hexlen % 2 != 0)
if
(converted != count)
gdb_restart_inferior(struct connection *, const char *, int)
gdb_handle_vrun_packet(struct connection *, const char *, int)
while
(cmdline)
if
(cmdline)
if
(target->semihosting)
else
gdb_v_packet(struct connection *, const char *, int)
if
(strncmp(packet, "vCont", 5) == 0)
if
(strncmp(packet, "vRun", 4) == 0)
if
(!gdb_flash_program)
if
(strncmp(packet, "vFlashErase:", 12) == 0)
if
(*parse == '\0')
if
(*(parse++) != ',' || *parse == '\0')
if
(*parse != '\0')
if
(get_target_from_connection(connection)->report_flash_progress)
if
(result != ERROR_OK)
if
(strncmp(packet, "vFlashWrite:", 12) == 0)
if
(*parse == '\0')
if
(*(parse++) != ':')
if
(!gdb_connection->vflash_image)
if
(strncmp(packet, "vFlashDone", 10) == 0)
if
(!gdb_connection->vflash_image)
if
(result != ERROR_OK)
else
gdb_detach(struct connection *)
gdb_fileio_response_packet(struct connection *, const char *, int)
if
(*separator == ',')
if
(*separator == ',')
if
(*(separator + 1) == 'C')
gdb_log_callback(void *, const char *, unsigned int, const char *, const char *)
if
(gdb_con->busy)
gdb_sig_halted(struct connection *)
gdb_input_inner(struct connection *)
if
(packet_size > 0)
switch
(packet[0])
case
'T':
case
'H':
case
'q':
case
'Q':
case
'g':
case
'G':
case
'p':
case
'P':
case
'm':
case
'M':
case
'z':
case
'Z':
case
'?':
if
(!warn_use_ext && !gdb_con->extended_protocol)
case
'c':
case
's':
if
(gdb_con->mem_write_error)
if
(target->state == TARGET_RUNNING)
else if
(target->state != TARGET_HALTED)
else if
((packet[0] == 's') && gdb_con->sync)
if
(!already_running && nostep)
else
if
(!already_running)
if
(retval != ERROR_OK)
case
'v':
case
'D':
case
'X':
case
'k':
if
(gdb_con->extended_protocol)
case
'!':
case
'R':
case
'j':
case
'J':
case
'F':
default
if
(gdb_con->ctrl_c)
if
(target->state == TARGET_RUNNING)
else
gdb_input(struct connection *)
gdb_async_notif(struct connection *)
gdb_keep_client_alive(struct connection *)
switch
(gdb_con->output_flag)
case
GDB_OUTPUT_NO:
case
GDB_OUTPUT_NOTIF:
case
GDB_OUTPUT_ALL:
default
gdb_service_driver
gdb_target_start(struct target *, const char *)
foreach_smp_target
(head, target->smp_targets)
gdb_target_add_one(struct target *)
if
(!target_supports_gdb_connection(target))
if
(target->gdb_port_override)
if
(strcmp(target->gdb_port_override, "disabled") == 0)
if
(strcmp(gdb_port_next, "disabled") == 0)
if
(retval == ERROR_OK)
if
(!*end)
if
(parse_long(gdb_port_next, &portnumber) == ERROR_OK)
if
(portnumber)
else
else if
(strcmp(gdb_port_next, "pipe") == 0)
gdb_target_add_all(struct target *)
if
(!target)
while
(target)
handle_gdb_sync_command(struct command_invocation *)
if
(!current_gdb_connection)
handle_gdb_port_command(struct command_invocation *)
if
(retval == ERROR_OK)
handle_gdb_memory_map_command(struct command_invocation *)
handle_gdb_flash_program_command(struct command_invocation *)
handle_gdb_report_data_abort_command(struct command_invocation *)
handle_gdb_report_register_access_error(struct command_invocation *)
handle_gdb_breakpoint_override_command(struct command_invocation *)
if
(CMD_ARGC == 0)
else if
(CMD_ARGC == 1)
handle_gdb_target_description_command(struct command_invocation *)
handle_gdb_save_tdesc_command(struct command_invocation *)
if
(retval != ERROR_OK)
if
(!tdesc_filename)
if
(retval != ERROR_OK)
gdb_subcommand_handlers
gdb_command_handlers
gdb_register_commands(struct command_context *)
gdb_service_free()
gdb_get_actual_connections()