ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
Functions
etiss::plugin::gdb::hex Namespace Reference

Functions

uint8_t fromHex (char c)
 convert a character to the hex value it represents(0-15) More...
 
char toHex (uint8_t l)
 converts the lower 4 bits to a representing char More...
 
uint8_t toByte (char h, char l)
 converts 2 hex characters to a byte More...
 
uint8_t toByte (std::string hex, size_t pos=0)
 converts 2 characters from a hex string to one byte More...
 
std::string fromByte (uint8_t byte)
 converts a byte to a hex string (without "0x" prefix); More...
 
void fromByte (std::string &append, uint8_t byte)
 converts a byte to hexadecimal representation and appends it to the passed string More...
 
std::string fromBytes (uint8_t *buf, size_t length)
 converts a sequence of bytes to a representing hex string (without "0x" prefix) More...
 
template<typename INT >
void fromInt (std::string &string, INT val, bool isLittleEndian)
 converts an integer type variable to a hexadecimal representation with the given endianness More...
 
template<typename INT >
INT toInt (const std::string &string, bool isLittleEndian, size_t pos=0)
 convert a string of length (pos + sizeof(INT)) or larger to the represented value. More...
 
template<typename INT >
INT tryInt (std::string &string, unsigned &pos, size_t maxlength=sizeof(INT) *2)
 parses a hex string and returns the result. More...
 

Function Documentation

◆ fromByte() [1/2]

void etiss::plugin::gdb::hex::fromByte ( std::string &  append,
uint8_t  byte 
)

converts a byte to hexadecimal representation and appends it to the passed string

Parameters
append
byte

Definition at line 108 of file Hex.cpp.

References toHex().

Here is the call graph for this function:

◆ fromByte() [2/2]

std::string etiss::plugin::gdb::hex::fromByte ( uint8_t  byte)

converts a byte to a hex string (without "0x" prefix);

Parameters
byte
Returns
a string of length 2 representing the passed byte in hex

Definition at line 100 of file Hex.cpp.

References toHex().

Referenced by fromInt(), etiss::plugin::gdb::Server::handlePacket(), etiss::plugin::gdb::Server::postMemAccessCallback(), etiss::plugin::gdb::Server::preInstructionCallback(), and etiss::plugin::gdb::PacketProtocol::snd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fromBytes()

std::string etiss::plugin::gdb::hex::fromBytes ( uint8_t buf,
size_t  length 
)

converts a sequence of bytes to a representing hex string (without "0x" prefix)

Parameters
buf
length
Returns
hex representation of the passed byte sequence

Definition at line 114 of file Hex.cpp.

References length(), and toHex().

Referenced by etiss::plugin::gdb::Server::handlePacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fromHex()

uint8_t etiss::plugin::gdb::hex::fromHex ( char  c)

convert a character to the hex value it represents(0-15)

Parameters
chex repesentation 0-9,a-f,A-F
Returns
represented hex value or 16 if invalid character

Definition at line 56 of file Hex.cpp.

References c, and uint8_t.

Referenced by etiss::plugin::gdb::Server::handlePacket(), toByte(), and tryInt().

Here is the caller graph for this function:

◆ fromInt()

template<typename INT >
void etiss::plugin::gdb::hex::fromInt ( std::string &  string,
INT  val,
bool  isLittleEndian 
)

converts an integer type variable to a hexadecimal representation with the given endianness

Parameters
stringthe string where hex characters will be appended
valinterger value to convert
isLittleEndiantrue for little endian hex representaion, false for big endian

Definition at line 131 of file Hex.h.

References fromByte(), and uint8_t.

Referenced by etiss::plugin::gdb::Server::handlePacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toByte() [1/2]

uint8_t etiss::plugin::gdb::hex::toByte ( char  h,
char  l 
)

converts 2 hex characters to a byte

h character representing higher 4 bits; may not be invalid

l character representing lower 4 bits; may not be invalid

Returns
represented value

Definition at line 95 of file Hex.cpp.

References fromHex(), and get_metrics::h.

Referenced by etiss::plugin::gdb::Server::handlePacket(), toByte(), toInt(), and etiss::plugin::gdb::PacketProtocol::tryReadPacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toByte() [2/2]

uint8_t etiss::plugin::gdb::hex::toByte ( std::string  hex,
size_t  pos = 0 
)

converts 2 characters from a hex string to one byte

Parameters
hexstring representing a hex value. must be longer than pos+1
posstart position of the hex representation

Definition at line 91 of file Hex.cpp.

References toByte().

Here is the call graph for this function:

◆ toHex()

char etiss::plugin::gdb::hex::toHex ( uint8_t  l)

converts the lower 4 bits to a representing char

Parameters
lwhose lower 4 bits are used. higher bits may not be set
Returns
character 0-9,A-F or '?' if l > 15

Definition at line 75 of file Hex.cpp.

Referenced by fromByte(), and fromBytes().

Here is the caller graph for this function:

◆ toInt()

template<typename INT >
INT etiss::plugin::gdb::hex::toInt ( const std::string &  string,
bool  isLittleEndian,
size_t  pos = 0 
)

convert a string of length (pos + sizeof(INT)) or larger to the represented value.

no error checking will be performed

Definition at line 144 of file Hex.h.

References toByte().

Here is the call graph for this function:

◆ tryInt()

template<typename INT >
INT etiss::plugin::gdb::hex::tryInt ( std::string &  string,
unsigned &  pos,
size_t  maxlength = sizeof(INT) * 2 
)

parses a hex string and returns the result.

the string will be parsed until the end is reached, an invalid character was encountered or maxlength was reached. this function cannot handle a "0x" prefix

Parameters
stringstring to parse;
poscurrent position in the string. will be set to the index of the first character that was not part of the returned value
maxlengthmaximum parse length in characters (may be uneven)

Definition at line 163 of file Hex.h.

References fromHex(), length(), and uint8_t.

Here is the call graph for this function: