@@ -93,7 +93,6 @@ static const std::string JSON_ASYNC_TYPE_KEY_NAME("type");
93
93
std::setfill (' ' ) << std::setw((iword_idx)) << ""
94
94
#define INDENT_WITH_TABS (iword_idx ) \
95
95
std::setfill (' \t ' ) << std::setw((iword_idx)) << ""
96
- // Class to handle communications via gdb remote protocol.
97
96
98
97
// If `ch` is a meta character as per the binary packet convention in the
99
98
// 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,
163
162
return arg;
164
163
}
165
164
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 ) {
168
167
nub_addr_t addr = strtoull (p, end, 16 );
169
168
if (addr == 0 && errno != 0 )
170
169
return fail_value;
171
170
return addr;
172
171
}
173
172
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) {
176
175
int i;
177
176
const uint8_t *p = (const uint8_t *)buf;
178
177
if (swap) {
@@ -184,7 +183,7 @@ void append_hex_value(std::ostream &ostrm, const void *buf, size_t buf_size,
184
183
}
185
184
}
186
185
187
- std::string cstring_to_asciihex_string (const char *str) {
186
+ static std::string cstring_to_asciihex_string (const char *str) {
188
187
std::string hex_str;
189
188
hex_str.reserve (strlen (str) * 2 );
190
189
while (str && *str) {
@@ -196,7 +195,8 @@ std::string cstring_to_asciihex_string(const char *str) {
196
195
return hex_str;
197
196
}
198
197
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) {
200
200
size_t string_size = string.size ();
201
201
const char *string_buf = string.c_str ();
202
202
for (size_t i = 0 ; i < string_size; i++) {
@@ -1051,8 +1051,6 @@ rnb_err_t RNBRemote::HandleAsyncPacket(PacketEnum *type) {
1051
1051
rnb_err_t RNBRemote::HandleReceivedPacket (PacketEnum *type) {
1052
1052
static DNBTimer g_packetTimer (true );
1053
1053
1054
- // DNBLogThreadedIf (LOG_RNB_REMOTE, "%8u RNBRemote::%s",
1055
- // (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__);
1056
1054
rnb_err_t err = rnb_err;
1057
1055
std::string packet_data;
1058
1056
RNBRemote::Packet packet_info;
@@ -1308,8 +1306,7 @@ static cpu_type_t best_guess_cpu_type() {
1308
1306
LEN is the number of bytes to be processed. If a character is escaped,
1309
1307
it is 2 characters for LEN. A LEN of -1 means decode-until-nul-byte
1310
1308
(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) {
1313
1310
std::vector<uint8_t > bytes;
1314
1311
if (len == 0 ) {
1315
1312
return bytes;
@@ -1331,8 +1328,7 @@ std::vector<uint8_t> decode_binary_data(const char *str, size_t len) {
1331
1328
// If the value side of a key-value pair in JSON is a string,
1332
1329
// and that string has a " character in it, the " character must
1333
1330
// 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) {
1336
1332
if (s.find (' "' ) == std::string::npos)
1337
1333
return s;
1338
1334
@@ -1466,15 +1462,6 @@ bool RNBRemote::InitializeRegisters(bool force) {
1466
1462
}
1467
1463
}
1468
1464
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
-
1478
1465
g_reg_entries = g_dynamic_register_map.data ();
1479
1466
g_num_reg_entries = g_dynamic_register_map.size ();
1480
1467
}
@@ -1723,7 +1710,7 @@ rnb_err_t RNBRemote::HandlePacket_qThreadExtraInfo(const char *p) {
1723
1710
return SendPacket (" " );
1724
1711
}
1725
1712
1726
- const char *k_space_delimiters = " \t " ;
1713
+ static const char *k_space_delimiters = " \t " ;
1727
1714
static void skip_spaces (std::string &line) {
1728
1715
if (!line.empty ()) {
1729
1716
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) {
2028
2015
QSetLogging:bitmask=LOG_ALL;mode=asl;
2029
2016
*/
2030
2017
2031
- rnb_err_t set_logging (const char *p) {
2018
+ static rnb_err_t set_logging (const char *p) {
2032
2019
int bitmask = 0 ;
2033
2020
while (p && *p != ' \0 ' ) {
2034
2021
if (strncmp (p, " bitmask=" , sizeof (" bitmask=" ) - 1 ) == 0 ) {
@@ -2572,11 +2559,10 @@ rnb_err_t RNBRemote::HandlePacket_QSetProcessEvent(const char *p) {
2572
2559
2573
2560
// If a fail_value is provided, a correct-length reply is always provided,
2574
2561
// 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) {
2580
2566
if (reg != NULL ) {
2581
2567
std::unique_ptr<DNBRegisterValue> reg_value =
2582
2568
std::make_unique<DNBRegisterValue>();
@@ -2603,7 +2589,7 @@ bool register_value_in_hex_fixed_width(std::ostream &ostrm, nub_process_t pid,
2603
2589
return false ;
2604
2590
}
2605
2591
2606
- void debugserver_regnum_with_fixed_width_hex_register_value (
2592
+ static void debugserver_regnum_with_fixed_width_hex_register_value (
2607
2593
std::ostream &ostrm, nub_process_t pid, nub_thread_t tid,
2608
2594
const register_map_entry_t *reg, const DNBRegisterValue *reg_value_ptr,
2609
2595
std::optional<uint8_t > fail_value) {
@@ -4894,52 +4880,31 @@ rnb_err_t RNBRemote::HandlePacket_qHostInfo(const char *p) {
4894
4880
return SendPacket (strm.str ());
4895
4881
}
4896
4882
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) {
4899
4885
if (indent)
4900
4886
s << INDENT_WITH_SPACES (indent);
4901
4887
s << ' <' << name;
4902
4888
if (!has_attributes)
4903
4889
s << ' >' << std::endl;
4904
4890
}
4905
4891
4906
- void XMLElementStartEndAttributes (std::ostringstream &s, bool empty) {
4892
+ static void XMLElementStartEndAttributes (std::ostringstream &s, bool empty) {
4907
4893
if (empty)
4908
4894
s << ' /' ;
4909
4895
s << ' >' << std::endl;
4910
4896
}
4911
4897
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) {
4913
4900
if (indent)
4914
4901
s << INDENT_WITH_SPACES (indent);
4915
4902
s << ' <' << ' /' << name << ' >' << std::endl;
4916
4903
}
4917
4904
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 ) {
4943
4908
if (value) {
4944
4909
if (default_value && strcmp (value, default_value) == 0 )
4945
4910
return ; // No need to emit the attribute because it matches the default
@@ -4948,15 +4913,16 @@ void XMLAttributeString(std::ostringstream &s, const char *name,
4948
4913
}
4949
4914
}
4950
4915
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) {
4953
4918
s << ' ' << name << " =\" " << DECIMAL << value << " \" " ;
4954
4919
}
4955
4920
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 ®) {
4960
4926
const char *default_lldb_encoding = " uint" ;
4961
4927
const char *lldb_encoding = default_lldb_encoding;
4962
4928
const char *gdb_group = " general" ;
@@ -5127,7 +5093,7 @@ void GenerateTargetXMLRegister(std::ostringstream &s, const uint32_t reg_num,
5127
5093
XMLElementStartEndAttributes (s, true );
5128
5094
}
5129
5095
5130
- void GenerateTargetXMLRegisters (std::ostringstream &s) {
5096
+ static void GenerateTargetXMLRegisters (std::ostringstream &s) {
5131
5097
nub_size_t num_reg_sets = 0 ;
5132
5098
const DNBRegisterSetInfo *reg_sets = DNBGetRegisterSetInfo (&num_reg_sets);
5133
5099
@@ -5166,7 +5132,7 @@ static const char *g_target_xml_footer = "</target>";
5166
5132
5167
5133
static std::string g_target_xml;
5168
5134
5169
- void UpdateTargetXML () {
5135
+ static void UpdateTargetXML () {
5170
5136
std::ostringstream s;
5171
5137
s << g_target_xml_header << std::endl;
5172
5138
@@ -5301,8 +5267,9 @@ rnb_err_t RNBRemote::HandlePacket_jGetDyldProcessState(const char *p) {
5301
5267
// a one-level-deep JSON dictionary of key-value pairs. e.g.
5302
5268
// jThreadExtendedInfo:{"plo_pthread_tsd_base_address_offset":0,"plo_pthread_tsd_base_offset":224,"plo_pthread_tsd_entry_size":8,"thread":144305}]
5303
5269
//
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) {
5306
5273
uint64_t retval = INVALID_NUB_ADDRESS;
5307
5274
std::string key_with_quotes = " \" " ;
5308
5275
key_with_quotes += key;
@@ -5338,9 +5305,9 @@ uint64_t get_integer_value_for_key_name_from_json(const char *key,
5338
5305
// Returns true if it was able to find the key name, and sets the 'value'
5339
5306
// argument to the value found.
5340
5307
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) {
5344
5311
std::string key_with_quotes = " \" " ;
5345
5312
key_with_quotes += key;
5346
5313
key_with_quotes += " \" " ;
@@ -5377,7 +5344,7 @@ bool get_boolean_value_for_key_name_from_json(const char *key,
5377
5344
// Returns true if it was able to find the key name, false if it did not.
5378
5345
// "ints" will have all integers found in the array appended to it.
5379
5346
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 (
5381
5348
const char *key, const char *json_string, std::vector<uint64_t > &ints) {
5382
5349
std::string key_with_quotes = " \" " ;
5383
5350
key_with_quotes += key;
0 commit comments