Lines Matching +full:send +full:- +full:flush +full:- +full:out +full:- +full:sequence

1 // SPDX-License-Identifier: GPL-2.0-only
7 * Copyright (C) 2000-2001 VERITAS Software Corporation.
8 * Copyright (C) 2002-2004 Timesys Corporation
9 * Copyright (C) 2003-2004 Amit S. Kale <[email protected]>
11 * Copyright (C) 2004-2006 Tom Rini <[email protected]>
12 * Copyright (C) 2004-2006 LinSysSoft Technologies Pvt. Ltd.
13 * Copyright (C) 2005-2009 Wind River Systems, Inc.
49 sizeof(unsigned long) - 1) /
59 int ret = -1; in gdbstub_read_wait()
81 int ret = dbg_io_ops->read_char(); in gdbstub_read_wait()
83 ret = dbg_io_ops->read_char(); in gdbstub_read_wait()
87 /* scan for the sequence $<data>#<checksum> */
105 xmitcsum = -1; in get_packet()
112 while (count < (BUFMAX - 1)) { in get_packet()
127 dbg_io_ops->write_char('-'); in get_packet()
130 dbg_io_ops->write_char('+'); in get_packet()
131 if (dbg_io_ops->flush) in get_packet()
132 dbg_io_ops->flush(); in get_packet()
139 * Send the packet in buffer.
152 dbg_io_ops->write_char('$'); in put_packet()
157 dbg_io_ops->write_char(ch); in put_packet()
162 dbg_io_ops->write_char('#'); in put_packet()
163 dbg_io_ops->write_char(hex_asc_hi(checksum)); in put_packet()
164 dbg_io_ops->write_char(hex_asc_lo(checksum)); in put_packet()
165 if (dbg_io_ops->flush) in put_packet()
166 dbg_io_ops->flush(); in put_packet()
181 * the packet being sent, and stop trying to send this in put_packet()
185 dbg_io_ops->write_char('-'); in put_packet()
186 if (dbg_io_ops->flush) in put_packet()
187 dbg_io_ops->flush(); in put_packet()
207 /* Fill and send buffers... */ in gdbstub_msg_write()
212 if ((len << 1) > (BUFMAX - 2)) in gdbstub_msg_write()
213 wcount = (BUFMAX - 2) >> 1; in gdbstub_msg_write()
224 len -= wcount; in gdbstub_msg_write()
253 count--; in kgdb_mem2hex()
276 tmp_hex = tmp_raw - 1; in kgdb_hex2mem()
278 tmp_raw--; in kgdb_hex2mem()
279 *tmp_raw = hex_to_bin(*tmp_hex--); in kgdb_hex2mem()
280 *tmp_raw |= hex_to_bin(*tmp_hex--) << 4; in kgdb_hex2mem()
298 if (**ptr == '-') { in kgdb_hex2long()
313 *long_val = -*long_val; in kgdb_hex2long()
320 * 0x7d escaped with 0x7d. Return -EFAULT on failure or 0 on success.
328 while (count-- > 0) { in kgdb_ebin2mem()
385 return -EINVAL; in write_mem_msg()
390 error = -error; in error_packet()
433 * Non-positive TIDs are remapped to the cpu shadow information in getthread()
435 if (tid == 0 || tid == -1) in getthread()
436 tid = -atomic_read(&kgdb_active) - 2; in getthread()
437 if (tid < -1 && tid > -NR_CPUS - 2) { in getthread()
438 if (kgdb_info[-tid - 2].task) in getthread()
439 return kgdb_info[-tid - 2].task; in getthread()
441 return idle_task(-tid - 2); in getthread()
451 * but is nicely RCU locked - hence is a pretty resilient in getthread()
460 * CPU shadow threads are mapped to -CPU - 2
467 return -raw_smp_processor_id() - 2; in shadow_pid()
482 * we clear out our breakpoints now in case in gdb_cmd_status()
488 hex_byte_pack(&remcom_out_buffer[1], ks->signo); in gdb_cmd_status()
499 thread = kgdb_info[ks->cpu].task; in gdb_get_regs_helper()
500 local_debuggerinfo = kgdb_info[ks->cpu].debuggerinfo; in gdb_get_regs_helper()
547 error_packet(remcom_out_buffer, -EINVAL); in gdb_cmd_setregs()
549 gdb_regs_to_pt_regs(gdb_regs, ks->linux_regs); in gdb_cmd_setregs()
566 error_packet(remcom_out_buffer, -EINVAL); in gdb_cmd_memread()
568 error_packet(remcom_out_buffer, -EINVAL); in gdb_cmd_memread()
584 static char *gdb_hex_reg_helper(int regnum, char *out) in gdb_hex_reg_helper() argument
591 return kgdb_mem2hex((char *)gdb_regs + offset, out, in gdb_hex_reg_helper()
603 error_packet(remcom_out_buffer, -EINVAL); in gdb_cmd_reg_get()
620 !dbg_get_reg(regnum, gdb_regs, ks->linux_regs)) { in gdb_cmd_reg_set()
621 error_packet(remcom_out_buffer, -EINVAL); in gdb_cmd_reg_set()
632 dbg_set_reg(regnum, gdb_regs, ks->linux_regs); in gdb_cmd_reg_set()
717 ks->thr_query = 0; in gdb_cmd_query()
718 int_to_threadref(thref, -cpu - 2); in gdb_cmd_query()
726 if (i >= ks->thr_query && !finished) { in gdb_cmd_query()
727 int_to_threadref(thref, p->pid); in gdb_cmd_query()
730 ks->thr_query++; in gdb_cmd_query()
731 if (ks->thr_query % KGDB_MAX_THREAD_QUERY == 0) in gdb_cmd_query()
737 *(--ptr) = '\0'; in gdb_cmd_query()
743 ks->threadid = shadow_pid(current->pid); in gdb_cmd_query()
744 int_to_threadref(thref, ks->threadid); in gdb_cmd_query()
751 ks->threadid = 0; in gdb_cmd_query()
753 kgdb_hex2long(&ptr, &ks->threadid); in gdb_cmd_query()
754 if (!getthread(ks->linux_regs, ks->threadid)) { in gdb_cmd_query()
755 error_packet(remcom_out_buffer, -EINVAL); in gdb_cmd_query()
758 if ((int)ks->threadid > 0) { in gdb_cmd_query()
759 kgdb_mem2hex(getthread(ks->linux_regs, in gdb_cmd_query()
760 ks->threadid)->comm, in gdb_cmd_query()
766 (int)(-ks->threadid - 2)); in gdb_cmd_query()
817 kgdb_hex2long(&ptr, &ks->threadid); in gdb_cmd_task()
818 thread = getthread(ks->linux_regs, ks->threadid); in gdb_cmd_task()
819 if (!thread && ks->threadid > 0) { in gdb_cmd_task()
820 error_packet(remcom_out_buffer, -EINVAL); in gdb_cmd_task()
824 ks->kgdb_usethreadid = ks->threadid; in gdb_cmd_task()
829 kgdb_hex2long(&ptr, &ks->threadid); in gdb_cmd_task()
830 if (!ks->threadid) { in gdb_cmd_task()
833 thread = getthread(ks->linux_regs, ks->threadid); in gdb_cmd_task()
834 if (!thread && ks->threadid > 0) { in gdb_cmd_task()
835 error_packet(remcom_out_buffer, -EINVAL); in gdb_cmd_task()
851 kgdb_hex2long(&ptr, &ks->threadid); in gdb_cmd_thread()
852 thread = getthread(ks->linux_regs, ks->threadid); in gdb_cmd_thread()
856 error_packet(remcom_out_buffer, -EINVAL); in gdb_cmd_thread()
863 * Since GDB-5.3, it's been drafted that '0' is a software in gdb_cmd_break()
891 error_packet(remcom_out_buffer, -EINVAL); in gdb_cmd_break()
895 error_packet(remcom_out_buffer, -EINVAL); in gdb_cmd_break()
900 error_packet(remcom_out_buffer, -EINVAL); in gdb_cmd_break()
910 (int)length, *bpt_type - '0'); in gdb_cmd_break()
913 (int) length, *bpt_type - '0'); in gdb_cmd_break()
929 ks->pass_exception = 1; in gdb_cmd_exception_pass()
934 ks->pass_exception = 1; in gdb_cmd_exception_pass()
948 return -1; in gdb_cmd_exception_pass()
961 kgdb_usethread = kgdb_info[ks->cpu].task; in gdb_serial_stub()
962 ks->kgdb_usethreadid = shadow_pid(kgdb_info[ks->cpu].task->pid); in gdb_serial_stub()
963 ks->pass_exception = 0; in gdb_serial_stub()
972 ptr = hex_byte_pack(ptr, ks->signo); in gdb_serial_stub()
974 int_to_threadref(thref, shadow_pid(current->pid)); in gdb_serial_stub()
983 /* Clear the out buffer. */ in gdb_serial_stub()
995 case 'G': /* set the value of the CPU registers - return OK */ in gdb_serial_stub()
1058 error_packet(remcom_out_buffer, -EINVAL); in gdb_serial_stub()
1064 error = kgdb_arch_handle_exception(ks->ex_vector, in gdb_serial_stub()
1065 ks->signo, in gdb_serial_stub()
1066 ks->err_code, in gdb_serial_stub()
1069 ks->linux_regs); in gdb_serial_stub()
1087 if (ks->pass_exception) in gdb_serial_stub()
1098 error = kgdb_arch_handle_exception(ks->ex_vector, in gdbstub_state()
1099 ks->signo, in gdbstub_state()
1100 ks->err_code, in gdbstub_state()
1103 ks->linux_regs); in gdbstub_state()
1115 dbg_io_ops->write_char('+'); in gdbstub_state()
1121 * gdbstub_exit - Send an exit message to GDB
1140 dbg_io_ops->write_char('$'); in gdbstub_exit()
1146 dbg_io_ops->write_char(ch); in gdbstub_exit()
1149 dbg_io_ops->write_char('#'); in gdbstub_exit()
1150 dbg_io_ops->write_char(hex_asc_hi(checksum)); in gdbstub_exit()
1151 dbg_io_ops->write_char(hex_asc_lo(checksum)); in gdbstub_exit()
1154 if (dbg_io_ops->flush) in gdbstub_exit()
1155 dbg_io_ops->flush(); in gdbstub_exit()