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 <amitkale@linsyssoft.com>
11 * Copyright (C) 2004-2006 Tom Rini <trini@kernel.crashing.org>
12 * Copyright (C) 2004-2006 LinSysSoft Technologies Pvt. Ltd.
13 * Copyright (C) 2005-2009 Wind River Systems, Inc.
50 sizeof(unsigned long) - 1) /
60 int ret = -1;
82 int ret = dbg_io_ops->read_char();
84 ret = dbg_io_ops->read_char();
88 /* scan for the sequence $<data>#<checksum> */
106 xmitcsum = -1;
113 while (count < (BUFMAX - 1)) {
128 dbg_io_ops->write_char('-');
131 dbg_io_ops->write_char('+');
132 if (dbg_io_ops->flush)
133 dbg_io_ops->flush();
140 * Send the packet in buffer.
153 dbg_io_ops->write_char('$');
158 dbg_io_ops->write_char(ch);
163 dbg_io_ops->write_char('#');
164 dbg_io_ops->write_char(hex_asc_hi(checksum));
165 dbg_io_ops->write_char(hex_asc_lo(checksum));
166 if (dbg_io_ops->flush)
167 dbg_io_ops->flush();
182 * the packet being sent, and stop trying to send this
186 dbg_io_ops->write_char('-');
187 if (dbg_io_ops->flush)
188 dbg_io_ops->flush();
208 /* Fill and send buffers... */
213 if ((len << 1) > (BUFMAX - 2))
214 wcount = (BUFMAX - 2) >> 1;
225 len -= wcount;
254 count--;
277 tmp_hex = tmp_raw - 1;
279 tmp_raw--;
280 *tmp_raw = hex_to_bin(*tmp_hex--);
281 *tmp_raw |= hex_to_bin(*tmp_hex--) << 4;
299 if (**ptr == '-') {
314 *long_val = -*long_val;
321 * 0x7d escaped with 0x7d. Return -EFAULT on failure or 0 on success.
329 while (count-- > 0) {
386 return -EINVAL;
391 error = -error;
434 * Non-positive TIDs are remapped to the cpu shadow information
436 if (tid == 0 || tid == -1)
437 tid = -atomic_read(&kgdb_active) - 2;
438 if (tid < -1 && tid > -NR_CPUS - 2) {
439 if (kgdb_info[-tid - 2].task)
440 return kgdb_info[-tid - 2].task;
442 return idle_task(-tid - 2);
452 * but is nicely RCU locked - hence is a pretty resilient
461 * CPU shadow threads are mapped to -CPU - 2
468 return -raw_smp_processor_id() - 2;
483 * we clear out our breakpoints now in case
489 hex_byte_pack(&remcom_out_buffer[1], ks->signo);
500 thread = kgdb_info[ks->cpu].task;
501 local_debuggerinfo = kgdb_info[ks->cpu].debuggerinfo;
548 error_packet(remcom_out_buffer, -EINVAL);
550 gdb_regs_to_pt_regs(gdb_regs, ks->linux_regs);
567 error_packet(remcom_out_buffer, -EINVAL);
569 error_packet(remcom_out_buffer, -EINVAL);
585 static char *gdb_hex_reg_helper(int regnum, char *out)
592 return kgdb_mem2hex((char *)gdb_regs + offset, out,
604 error_packet(remcom_out_buffer, -EINVAL);
621 !dbg_get_reg(regnum, gdb_regs, ks->linux_regs)) {
622 error_packet(remcom_out_buffer, -EINVAL);
633 dbg_set_reg(regnum, gdb_regs, ks->linux_regs);
718 ks->thr_query = 0;
719 int_to_threadref(thref, -cpu - 2);
727 if (i >= ks->thr_query && !finished) {
728 int_to_threadref(thref, p->pid);
731 ks->thr_query++;
732 if (ks->thr_query % KGDB_MAX_THREAD_QUERY == 0)
738 *(--ptr) = '\0';
744 ks->threadid = shadow_pid(current->pid);
745 int_to_threadref(thref, ks->threadid);
752 ks->threadid = 0;
754 kgdb_hex2long(&ptr, &ks->threadid);
755 if (!getthread(ks->linux_regs, ks->threadid)) {
756 error_packet(remcom_out_buffer, -EINVAL);
759 if ((int)ks->threadid > 0) {
760 kgdb_mem2hex(getthread(ks->linux_regs,
761 ks->threadid)->comm,
767 (int)(-ks->threadid - 2));
818 kgdb_hex2long(&ptr, &ks->threadid);
819 thread = getthread(ks->linux_regs, ks->threadid);
820 if (!thread && ks->threadid > 0) {
821 error_packet(remcom_out_buffer, -EINVAL);
825 ks->kgdb_usethreadid = ks->threadid;
830 kgdb_hex2long(&ptr, &ks->threadid);
831 if (!ks->threadid) {
834 thread = getthread(ks->linux_regs, ks->threadid);
835 if (!thread && ks->threadid > 0) {
836 error_packet(remcom_out_buffer, -EINVAL);
852 kgdb_hex2long(&ptr, &ks->threadid);
853 thread = getthread(ks->linux_regs, ks->threadid);
857 error_packet(remcom_out_buffer, -EINVAL);
864 * Since GDB-5.3, it's been drafted that '0' is a software
892 error_packet(remcom_out_buffer, -EINVAL);
896 error_packet(remcom_out_buffer, -EINVAL);
901 error_packet(remcom_out_buffer, -EINVAL);
911 (int)length, *bpt_type - '0');
914 (int) length, *bpt_type - '0');
930 ks->pass_exception = 1;
935 ks->pass_exception = 1;
949 return -1;
962 kgdb_usethread = kgdb_info[ks->cpu].task;
963 ks->kgdb_usethreadid = shadow_pid(kgdb_info[ks->cpu].task->pid);
964 ks->pass_exception = 0;
973 ptr = hex_byte_pack(ptr, ks->signo);
975 int_to_threadref(thref, shadow_pid(current->pid));
984 /* Clear the out buffer. */
996 case 'G': /* set the value of the CPU registers - return OK */
1059 error_packet(remcom_out_buffer, -EINVAL);
1065 error = kgdb_arch_handle_exception(ks->ex_vector,
1066 ks->signo,
1067 ks->err_code,
1070 ks->linux_regs);
1088 if (ks->pass_exception)
1099 error = kgdb_arch_handle_exception(ks->ex_vector,
1100 ks->signo,
1101 ks->err_code,
1104 ks->linux_regs);
1116 dbg_io_ops->write_char('+');
1122 * gdbstub_exit - Send an exit message to GDB
1141 dbg_io_ops->write_char('$');
1147 dbg_io_ops->write_char(ch);
1150 dbg_io_ops->write_char('#');
1151 dbg_io_ops->write_char(hex_asc_hi(checksum));
1152 dbg_io_ops->write_char(hex_asc_lo(checksum));
1155 if (dbg_io_ops->flush)
1156 dbg_io_ops->flush();