@@ -93,7 +93,6 @@ static const std::string JSON_ASYNC_TYPE_KEY_NAME("type");
9393 std::setfill (' ' ) << std::setw((iword_idx)) << ""
9494#define INDENT_WITH_TABS (iword_idx ) \
9595 std::setfill (' \t ' ) << std::setw((iword_idx)) << ""
96- // Class to handle communications via gdb remote protocol.
9796
9897// If `ch` is a meta character as per the binary packet convention in the
9998// gdb-remote protocol, quote it and write it into `stream`, otherwise write it
@@ -163,16 +162,16 @@ static std::string decode_hex_ascii_string(const char *p,
163162 return arg;
164163}
165164
166- uint64_t decode_uint64 (const char *p, int base, char **end = nullptr ,
167- uint64_t fail_value = 0 ) {
165+ static uint64_t decode_uint64 (const char *p, int base, char **end = nullptr ,
166+ uint64_t fail_value = 0 ) {
168167 nub_addr_t addr = strtoull (p, end, 16 );
169168 if (addr == 0 && errno != 0 )
170169 return fail_value;
171170 return addr;
172171}
173172
174- void append_hex_value (std::ostream &ostrm, const void *buf, size_t buf_size ,
175- bool swap) {
173+ static void append_hex_value (std::ostream &ostrm, const void *buf,
174+ size_t buf_size, bool swap) {
176175 int i;
177176 const uint8_t *p = (const uint8_t *)buf;
178177 if (swap) {
@@ -184,7 +183,7 @@ void append_hex_value(std::ostream &ostrm, const void *buf, size_t buf_size,
184183 }
185184}
186185
187- std::string cstring_to_asciihex_string (const char *str) {
186+ static std::string cstring_to_asciihex_string (const char *str) {
188187 std::string hex_str;
189188 hex_str.reserve (strlen (str) * 2 );
190189 while (str && *str) {
@@ -196,7 +195,8 @@ std::string cstring_to_asciihex_string(const char *str) {
196195 return hex_str;
197196}
198197
199- void append_hexified_string (std::ostream &ostrm, const std::string &string) {
198+ static void append_hexified_string (std::ostream &ostrm,
199+ const std::string &string) {
200200 size_t string_size = string.size ();
201201 const char *string_buf = string.c_str ();
202202 for (size_t i = 0 ; i < string_size; i++) {
@@ -1051,8 +1051,6 @@ rnb_err_t RNBRemote::HandleAsyncPacket(PacketEnum *type) {
10511051rnb_err_t RNBRemote::HandleReceivedPacket (PacketEnum *type) {
10521052 static DNBTimer g_packetTimer (true );
10531053
1054- // DNBLogThreadedIf (LOG_RNB_REMOTE, "%8u RNBRemote::%s",
1055- // (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__);
10561054 rnb_err_t err = rnb_err;
10571055 std::string packet_data;
10581056 RNBRemote::Packet packet_info;
@@ -1308,8 +1306,7 @@ static cpu_type_t best_guess_cpu_type() {
13081306 LEN is the number of bytes to be processed. If a character is escaped,
13091307 it is 2 characters for LEN. A LEN of -1 means decode-until-nul-byte
13101308 (end of string). */
1311-
1312- std::vector<uint8_t > decode_binary_data (const char *str, size_t len) {
1309+ static std::vector<uint8_t > decode_binary_data (const char *str, size_t len) {
13131310 std::vector<uint8_t > bytes;
13141311 if (len == 0 ) {
13151312 return bytes;
@@ -1331,8 +1328,7 @@ std::vector<uint8_t> decode_binary_data(const char *str, size_t len) {
13311328// If the value side of a key-value pair in JSON is a string,
13321329// and that string has a " character in it, the " character must
13331330// be escaped.
1334-
1335- std::string json_string_quote_metachars (const std::string &s) {
1331+ static std::string json_string_quote_metachars (const std::string &s) {
13361332 if (s.find (' "' ) == std::string::npos)
13371333 return s;
13381334
@@ -1466,15 +1462,6 @@ bool RNBRemote::InitializeRegisters(bool force) {
14661462 }
14671463 }
14681464
1469- // for (auto ®_entry: g_dynamic_register_map)
1470- // {
1471- // DNBLogThreaded("%4i: size = %3u, pseudo = %i, name = %s",
1472- // reg_entry.offset,
1473- // reg_entry.nub_info.size,
1474- // reg_entry.nub_info.value_regs != NULL,
1475- // reg_entry.nub_info.name);
1476- // }
1477-
14781465 g_reg_entries = g_dynamic_register_map.data ();
14791466 g_num_reg_entries = g_dynamic_register_map.size ();
14801467 }
@@ -1723,7 +1710,7 @@ rnb_err_t RNBRemote::HandlePacket_qThreadExtraInfo(const char *p) {
17231710 return SendPacket (" " );
17241711}
17251712
1726- const char *k_space_delimiters = " \t " ;
1713+ static const char *k_space_delimiters = " \t " ;
17271714static void skip_spaces (std::string &line) {
17281715 if (!line.empty ()) {
17291716 size_t space_pos = line.find_first_not_of (k_space_delimiters);
@@ -2028,7 +2015,7 @@ rnb_err_t RNBRemote::HandlePacket_qRegisterInfo(const char *p) {
20282015 QSetLogging:bitmask=LOG_ALL;mode=asl;
20292016 */
20302017
2031- rnb_err_t set_logging (const char *p) {
2018+ static rnb_err_t set_logging (const char *p) {
20322019 int bitmask = 0 ;
20332020 while (p && *p != ' \0 ' ) {
20342021 if (strncmp (p, " bitmask=" , sizeof (" bitmask=" ) - 1 ) == 0 ) {
@@ -2572,11 +2559,10 @@ rnb_err_t RNBRemote::HandlePacket_QSetProcessEvent(const char *p) {
25722559
25732560// If a fail_value is provided, a correct-length reply is always provided,
25742561// even if the register cannot be read right now on this thread.
2575- bool register_value_in_hex_fixed_width (std::ostream &ostrm, nub_process_t pid,
2576- nub_thread_t tid,
2577- const register_map_entry_t *reg,
2578- const DNBRegisterValue *reg_value_ptr,
2579- std::optional<uint8_t > fail_value) {
2562+ static bool register_value_in_hex_fixed_width (
2563+ std::ostream &ostrm, nub_process_t pid, nub_thread_t tid,
2564+ const register_map_entry_t *reg, const DNBRegisterValue *reg_value_ptr,
2565+ std::optional<uint8_t > fail_value) {
25802566 if (reg != NULL ) {
25812567 std::unique_ptr<DNBRegisterValue> reg_value =
25822568 std::make_unique<DNBRegisterValue>();
@@ -2603,7 +2589,7 @@ bool register_value_in_hex_fixed_width(std::ostream &ostrm, nub_process_t pid,
26032589 return false ;
26042590}
26052591
2606- void debugserver_regnum_with_fixed_width_hex_register_value (
2592+ static void debugserver_regnum_with_fixed_width_hex_register_value (
26072593 std::ostream &ostrm, nub_process_t pid, nub_thread_t tid,
26082594 const register_map_entry_t *reg, const DNBRegisterValue *reg_value_ptr,
26092595 std::optional<uint8_t > fail_value) {
@@ -4894,52 +4880,31 @@ rnb_err_t RNBRemote::HandlePacket_qHostInfo(const char *p) {
48944880 return SendPacket (strm.str ());
48954881}
48964882
4897- void XMLElementStart (std::ostringstream &s, uint32_t indent, const char *name ,
4898- bool has_attributes) {
4883+ static void XMLElementStart (std::ostringstream &s, uint32_t indent,
4884+ const char *name, bool has_attributes) {
48994885 if (indent)
49004886 s << INDENT_WITH_SPACES (indent);
49014887 s << ' <' << name;
49024888 if (!has_attributes)
49034889 s << ' >' << std::endl;
49044890}
49054891
4906- void XMLElementStartEndAttributes (std::ostringstream &s, bool empty) {
4892+ static void XMLElementStartEndAttributes (std::ostringstream &s, bool empty) {
49074893 if (empty)
49084894 s << ' /' ;
49094895 s << ' >' << std::endl;
49104896}
49114897
4912- void XMLElementEnd (std::ostringstream &s, uint32_t indent, const char *name) {
4898+ static void XMLElementEnd (std::ostringstream &s, uint32_t indent,
4899+ const char *name) {
49134900 if (indent)
49144901 s << INDENT_WITH_SPACES (indent);
49154902 s << ' <' << ' /' << name << ' >' << std::endl;
49164903}
49174904
4918- void XMLElementWithStringValue (std::ostringstream &s, uint32_t indent,
4919- const char *name, const char *value,
4920- bool close = true ) {
4921- if (value) {
4922- if (indent)
4923- s << INDENT_WITH_SPACES (indent);
4924- s << ' <' << name << ' >' << value;
4925- if (close)
4926- XMLElementEnd (s, 0 , name);
4927- }
4928- }
4929-
4930- void XMLElementWithUnsignedValue (std::ostringstream &s, uint32_t indent,
4931- const char *name, uint64_t value,
4932- bool close = true ) {
4933- if (indent)
4934- s << INDENT_WITH_SPACES (indent);
4935-
4936- s << ' <' << name << ' >' << DECIMAL << value;
4937- if (close)
4938- XMLElementEnd (s, 0 , name);
4939- }
4940-
4941- void XMLAttributeString (std::ostringstream &s, const char *name,
4942- const char *value, const char *default_value = NULL ) {
4905+ static void XMLAttributeString (std::ostringstream &s, const char *name,
4906+ const char *value,
4907+ const char *default_value = NULL ) {
49434908 if (value) {
49444909 if (default_value && strcmp (value, default_value) == 0 )
49454910 return ; // No need to emit the attribute because it matches the default
@@ -4948,15 +4913,16 @@ void XMLAttributeString(std::ostringstream &s, const char *name,
49484913 }
49494914}
49504915
4951- void XMLAttributeUnsignedDecimal (std::ostringstream &s, const char *name,
4952- uint64_t value) {
4916+ static void XMLAttributeUnsignedDecimal (std::ostringstream &s, const char *name,
4917+ uint64_t value) {
49534918 s << ' ' << name << " =\" " << DECIMAL << value << " \" " ;
49544919}
49554920
4956- void GenerateTargetXMLRegister (std::ostringstream &s, const uint32_t reg_num,
4957- nub_size_t num_reg_sets,
4958- const DNBRegisterSetInfo *reg_set_info,
4959- const register_map_entry_t ®) {
4921+ static void GenerateTargetXMLRegister (std::ostringstream &s,
4922+ const uint32_t reg_num,
4923+ nub_size_t num_reg_sets,
4924+ const DNBRegisterSetInfo *reg_set_info,
4925+ const register_map_entry_t ®) {
49604926 const char *default_lldb_encoding = " uint" ;
49614927 const char *lldb_encoding = default_lldb_encoding;
49624928 const char *gdb_group = " general" ;
@@ -5127,7 +5093,7 @@ void GenerateTargetXMLRegister(std::ostringstream &s, const uint32_t reg_num,
51275093 XMLElementStartEndAttributes (s, true );
51285094}
51295095
5130- void GenerateTargetXMLRegisters (std::ostringstream &s) {
5096+ static void GenerateTargetXMLRegisters (std::ostringstream &s) {
51315097 nub_size_t num_reg_sets = 0 ;
51325098 const DNBRegisterSetInfo *reg_sets = DNBGetRegisterSetInfo (&num_reg_sets);
51335099
@@ -5166,7 +5132,7 @@ static const char *g_target_xml_footer = "</target>";
51665132
51675133static std::string g_target_xml;
51685134
5169- void UpdateTargetXML () {
5135+ static void UpdateTargetXML () {
51705136 std::ostringstream s;
51715137 s << g_target_xml_header << std::endl;
51725138
@@ -5301,8 +5267,9 @@ rnb_err_t RNBRemote::HandlePacket_jGetDyldProcessState(const char *p) {
53015267// a one-level-deep JSON dictionary of key-value pairs. e.g.
53025268// jThreadExtendedInfo:{"plo_pthread_tsd_base_address_offset":0,"plo_pthread_tsd_base_offset":224,"plo_pthread_tsd_entry_size":8,"thread":144305}]
53035269//
5304- uint64_t get_integer_value_for_key_name_from_json (const char *key,
5305- const char *json_string) {
5270+ static uint64_t
5271+ get_integer_value_for_key_name_from_json (const char *key,
5272+ const char *json_string) {
53065273 uint64_t retval = INVALID_NUB_ADDRESS;
53075274 std::string key_with_quotes = " \" " ;
53085275 key_with_quotes += key;
@@ -5338,9 +5305,9 @@ uint64_t get_integer_value_for_key_name_from_json(const char *key,
53385305// Returns true if it was able to find the key name, and sets the 'value'
53395306// argument to the value found.
53405307
5341- bool get_boolean_value_for_key_name_from_json (const char *key,
5342- const char *json_string,
5343- bool &value) {
5308+ static bool get_boolean_value_for_key_name_from_json (const char *key,
5309+ const char *json_string,
5310+ bool &value) {
53445311 std::string key_with_quotes = " \" " ;
53455312 key_with_quotes += key;
53465313 key_with_quotes += " \" " ;
@@ -5377,7 +5344,7 @@ bool get_boolean_value_for_key_name_from_json(const char *key,
53775344// Returns true if it was able to find the key name, false if it did not.
53785345// "ints" will have all integers found in the array appended to it.
53795346
5380- bool get_array_of_ints_value_for_key_name_from_json (
5347+ static bool get_array_of_ints_value_for_key_name_from_json (
53815348 const char *key, const char *json_string, std::vector<uint64_t > &ints) {
53825349 std::string key_with_quotes = " \" " ;
53835350 key_with_quotes += key;
0 commit comments