gdb_packet.c (218825) | gdb_packet.c (271173) |
---|---|
1/*- 2 * Copyright (c) 2004 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2004 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/gdb/gdb_packet.c 218825 2011-02-18 22:25:11Z mdf $"); | 28__FBSDID("$FreeBSD: head/sys/gdb/gdb_packet.c 271173 2014-09-05 16:40:47Z benno $"); |
29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/ctype.h> 33#include <sys/kdb.h> | 29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/ctype.h> 33#include <sys/kdb.h> |
34#include <sys/libkern.h> |
|
34#include <sys/ttydefaults.h> 35 36#include <machine/gdb_machdep.h> 37#include <machine/kdb.h> 38 39#include <gdb/gdb.h> 40#include <gdb/gdb_int.h> 41 --- 273 unchanged lines hidden (view full) --- 315 /* Register unavailable. */ 316 while (regsz--) { 317 gdb_tx_char('x'); 318 gdb_tx_char('x'); 319 } 320 } else 321 gdb_tx_mem(regp, regsz); 322} | 35#include <sys/ttydefaults.h> 36 37#include <machine/gdb_machdep.h> 38#include <machine/kdb.h> 39 40#include <gdb/gdb.h> 41#include <gdb/gdb_int.h> 42 --- 273 unchanged lines hidden (view full) --- 316 /* Register unavailable. */ 317 while (regsz--) { 318 gdb_tx_char('x'); 319 gdb_tx_char('x'); 320 } 321 } else 322 gdb_tx_mem(regp, regsz); 323} |
324 325/* Read binary data up until the end of the packet or until we have datalen decoded bytes */ 326int 327gdb_rx_bindata(unsigned char *data, size_t datalen, size_t *amt) 328{ 329 int c; 330 331 *amt = 0; 332 333 while (*amt < datalen) { 334 c = gdb_rx_char(); 335 /* End of packet? */ 336 if (c == -1) 337 break; 338 /* Escaped character up next */ 339 if (c == '}') { 340 /* Truncated packet? Bail out */ 341 if ((c = gdb_rx_char()) == -1) 342 return (1); 343 c ^= 0x20; 344 } 345 *(data++) = c & 0xff; 346 (*amt)++; 347 } 348 349 return (0); 350} 351 352int 353gdb_search_mem(const unsigned char *addr, size_t size, const unsigned char *pat, size_t patlen, const unsigned char **found) 354{ 355 void *prev; 356 jmp_buf jb; 357 int ret; 358 359 prev = kdb_jmpbuf(jb); 360 ret = setjmp(jb); 361 if (ret == 0) 362 *found = memmem(addr, size, pat, patlen); 363 364 (void)kdb_jmpbuf(prev); 365 return ((ret == 0) ? 1 : 0); 366} |
|