diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2017-11-24 10:40:13 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2017-11-24 10:40:15 -0500 |
commit | 21fe1c752e254167d953fa8c846280f63a3a5290 (patch) | |
tree | 034d38fd6ff84feda067824bc3cf8f71342357c7 /gdb/common | |
parent | 089354bb0613ca1559813f0a79fbe73655113785 (diff) | |
download | gdb-21fe1c752e254167d953fa8c846280f63a3a5290.zip gdb-21fe1c752e254167d953fa8c846280f63a3a5290.tar.gz gdb-21fe1c752e254167d953fa8c846280f63a3a5290.tar.bz2 |
remote: C++ify thread_item and threads_listing_context
This patch C++ifies the thread_item and threads_listing_context
structures in remote.c. thread_item::{extra,name} are changed to
std::string. As a result, there's a bit of awkwardness in
remote_update_thread_list, where we have to xstrdup those strings when
filling the private_thread_info structure. This is removed in the
following patch, where private_thread_info is also C++ified and its
corresponding fields made std::string too. The xstrdup then becomes an
std::move.
Other than that there's nothing really special, it's a usual day-to-day
VEC -> vector and char* -> std::string change. It allows removing a
cleanup in remote_update_thread_list.
Note that an overload of hex2bin that returns a gdb::byte_vector is
added, with corresponding selftests.
gdb/ChangeLog:
* remote.c (struct thread_item): Add constructor, disable copy
construction and copy assignment, define default move
construction and move assignment.
<extra, name>: Change type to std::string.
<core>: Initialize.
<thread_handle>: Make non-pointer.
(thread_item_t): Remove typedef.
(DEF_VEC_O(thread_item_t)): Remove.
(threads_listing_context) <contains_thread>: New method.
<remove_thread>: New method.
<items>: Change type to std::vector.
(clear_threads_listing_context): Remove.
(threads_listing_context_remove): Remove.
(remote_newthread_step): Use thread_item constructor, adjust to
change to std::vector.
(start_thread): Use thread_item constructor, adjust to change to
std::vector.
(end_thread): Adjust to change to std::vector and std::string.
(remote_get_threads_with_qthreadinfo): Use thread_item
constructor, adjust to std::vector.
(remote_update_thread_list): Adjust to change to std::vector and
std::string, use threads_listing_context methods.
(remove_child_of_pending_fork): Adjust.
(remove_new_fork_children): Adjust.
* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add rsp-low-selftests.c.
(SUBDIR_UNITTESTS_OBS): Add rsp-low-selftests.o.
* unittests/rsp-low-selftests.c: New file.
* common/rsp-low.h: Include common/byte-vector.h.
(hex2bin): New overload.
* common/rsp-low.c (hex2bin): New overload.
Diffstat (limited to 'gdb/common')
-rw-r--r-- | gdb/common/rsp-low.c | 13 | ||||
-rw-r--r-- | gdb/common/rsp-low.h | 6 |
2 files changed, 19 insertions, 0 deletions
diff --git a/gdb/common/rsp-low.c b/gdb/common/rsp-low.c index 85987f7..9948fbb 100644 --- a/gdb/common/rsp-low.c +++ b/gdb/common/rsp-low.c @@ -132,6 +132,19 @@ hex2bin (const char *hex, gdb_byte *bin, int count) /* See rsp-low.h. */ +gdb::byte_vector +hex2bin (const char *hex) +{ + size_t bin_len = strlen (hex) / 2; + gdb::byte_vector bin (bin_len); + + hex2bin (hex, bin.data (), bin_len); + + return bin; +} + +/* See rsp-low.h. */ + std::string hex2str (const char *hex) { diff --git a/gdb/common/rsp-low.h b/gdb/common/rsp-low.h index 99dc93f..039f19c 100644 --- a/gdb/common/rsp-low.h +++ b/gdb/common/rsp-low.h @@ -20,6 +20,8 @@ #ifndef COMMON_RSP_LOW_H #define COMMON_RSP_LOW_H +#include "common/byte-vector.h" + /* Convert hex digit A to a number, or throw an exception. */ extern int fromhex (int a); @@ -52,6 +54,10 @@ extern const char *unpack_varlen_hex (const char *buff, ULONGEST *result); extern int hex2bin (const char *hex, gdb_byte *bin, int count); +/* Like the above, but return a gdb::byte_vector. */ + +gdb::byte_vector hex2bin (const char *hex); + /* Like hex2bin, but return a std::string. */ extern std::string hex2str (const char *hex); |