gdb/common/rsp-low.h - gdb

Macros defined

Source code

  1. /* Low-level RSP routines for GDB, the GNU debugger.

  2.    Copyright (C) 1988-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #ifndef COMMON_RSP_LOW_H
  15. #define COMMON_RSP_LOW_H

  16. /* Convert hex digit A to a number, or throw an exception.  */

  17. extern int fromhex (int a);

  18. /* Convert number NIB to a hex digit.  */

  19. extern int tohex (int nib);

  20. /* Write a character representing the low order four bits of NIBBLE in
  21.    hex to *BUF.  Returns BUF+1.  */

  22. extern char *pack_nibble (char *buf, int nibble);

  23. /* Write the low byte of BYTE in hex to *BUF.  Returns BUF+2.  */

  24. extern char *pack_hex_byte (char *pkt, int byte);

  25. /* Read hex digits from BUFF and convert to a number, which is stored
  26.    in RESULT.  Reads until a non-hex digit is seen.  Returns a pointer
  27.    to the terminating character.  */

  28. extern char *unpack_varlen_hex (char *buff, ULONGEST *result);

  29. /* HEX is a string of characters representing hexadecimal digits.
  30.    Convert pairs of hex digits to bytes and store sequentially into
  31.    BIN.  COUNT is the maximum number of characters to convert.  This
  32.    will convert fewer characters if the number of hex characters
  33.    actually seen is odd, or if HEX terminates before COUNT characters.
  34.    Returns the number of characters actually converted.  */

  35. extern int hex2bin (const char *hex, gdb_byte *bin, int count);

  36. /* Convert some bytes to a hexadecimal representation.  BIN holds the
  37.    bytes to convert.  COUNT says how many bytes to convert.  The
  38.    resulting characters are stored in HEX, followed by a NUL
  39.    character.  Returns the number of bytes actually converted.  */

  40. extern int bin2hex (const gdb_byte *bin, char *hex, int count);

  41. /* Convert BUFFER, binary data at least LEN bytes long, into escaped
  42.    binary data in OUT_BUF.  Set *OUT_LEN to the length of the data
  43.    encoded in OUT_BUF, and return the number of bytes in OUT_BUF
  44.    (which may be more than *OUT_LEN due to escape characters).  The
  45.    total number of bytes in the output buffer will be at most
  46.    OUT_MAXLEN.  This function properly escapes '*', and so is suitable
  47.    for the server side as well as the client.  */

  48. extern int remote_escape_output (const gdb_byte *buffer, int len,
  49.                                  gdb_byte *out_buf, int *out_len,
  50.                                  int out_maxlen);

  51. /* Convert BUFFER, escaped data LEN bytes long, into binary data
  52.    in OUT_BUF.  Return the number of bytes written to OUT_BUF.
  53.    Raise an error if the total number of bytes exceeds OUT_MAXLEN.

  54.    This function reverses remote_escape_output.  */

  55. extern int remote_unescape_input (const gdb_byte *buffer, int len,
  56.                                   gdb_byte *out_buf, int out_maxlen);

  57. #endif /* COMMON_RSP_LOW_H */