aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport
diff options
context:
space:
mode:
Diffstat (limited to 'gdbsupport')
-rw-r--r--gdbsupport/agent.cc79
-rw-r--r--gdbsupport/agent.h10
-rw-r--r--gdbsupport/alt-stack.h3
-rw-r--r--gdbsupport/array-view.h107
-rw-r--r--gdbsupport/block-signals.h3
-rw-r--r--gdbsupport/break-common.h12
-rw-r--r--gdbsupport/btrace-common.cc118
-rw-r--r--gdbsupport/btrace-common.h20
-rw-r--r--gdbsupport/buffer.cc169
-rw-r--r--gdbsupport/buffer.h8
-rw-r--r--gdbsupport/buildargv.h70
-rw-r--r--gdbsupport/byte-vector.h3
-rw-r--r--gdbsupport/cleanups.cc11
-rw-r--r--gdbsupport/common-debug.cc4
-rw-r--r--gdbsupport/common-debug.h128
-rw-r--r--gdbsupport/common-defs.h28
-rw-r--r--gdbsupport/common-exceptions.cc113
-rw-r--r--gdbsupport/common-exceptions.h101
-rw-r--r--gdbsupport/common-gdbthread.h2
-rw-r--r--gdbsupport/common-inferior.cc108
-rw-r--r--gdbsupport/common-inferior.h3
-rw-r--r--gdbsupport/common-regcache.cc4
-rw-r--r--gdbsupport/common-regcache.h21
-rw-r--r--gdbsupport/common-types.h7
-rw-r--r--gdbsupport/common-utils.cc116
-rw-r--r--gdbsupport/common-utils.h28
-rw-r--r--gdbsupport/def-vector.h7
-rw-r--r--gdbsupport/default-init-alloc.h9
-rw-r--r--gdbsupport/eintr.h2
-rw-r--r--gdbsupport/enum-flags.h420
-rw-r--r--gdbsupport/environ.cc8
-rw-r--r--gdbsupport/environ.h5
-rw-r--r--gdbsupport/errors.cc34
-rw-r--r--gdbsupport/errors.h41
-rw-r--r--gdbsupport/event-loop.cc491
-rw-r--r--gdbsupport/event-loop.h29
-rw-r--r--gdbsupport/event-pipe.h11
-rw-r--r--gdbsupport/fileio.cc175
-rw-r--r--gdbsupport/fileio.h143
-rw-r--r--gdbsupport/filestuff.cc156
-rw-r--r--gdbsupport/filestuff.h14
-rw-r--r--gdbsupport/filtered-iterator.h16
-rw-r--r--gdbsupport/format.cc639
-rw-r--r--gdbsupport/format.h43
-rw-r--r--gdbsupport/forward-scope-exit.h23
-rw-r--r--gdbsupport/function-view.h114
-rw-r--r--gdbsupport/gdb-checked-static-cast.h6
-rw-r--r--gdbsupport/gdb-dlfcn.cc18
-rw-r--r--gdbsupport/gdb-dlfcn.h2
-rw-r--r--gdbsupport/gdb-hashtab.h5
-rw-r--r--gdbsupport/gdb-sigmask.h1
-rw-r--r--gdbsupport/gdb-xfree.h6
-rw-r--r--gdbsupport/gdb_assert.h17
-rw-r--r--gdbsupport/gdb_binary_search.h12
-rw-r--r--gdbsupport/gdb_file.h5
-rw-r--r--gdbsupport/gdb_locale.h20
-rw-r--r--gdbsupport/gdb_obstack.cc2
-rw-r--r--gdbsupport/gdb_obstack.h42
-rw-r--r--gdbsupport/gdb_optional.h104
-rw-r--r--gdbsupport/gdb_proc_service.h74
-rw-r--r--gdbsupport/gdb_ref_ptr.h81
-rw-r--r--gdbsupport/gdb_regex.cc11
-rw-r--r--gdbsupport/gdb_regex.h14
-rw-r--r--gdbsupport/gdb_select.h9
-rw-r--r--gdbsupport/gdb_setjmp.h12
-rw-r--r--gdbsupport/gdb_splay_tree.h10
-rw-r--r--gdbsupport/gdb_string_view.h1014
-rw-r--r--gdbsupport/gdb_sys_time.h4
-rw-r--r--gdbsupport/gdb_tilde_expand.cc34
-rw-r--r--gdbsupport/gdb_unique_ptr.h10
-rw-r--r--gdbsupport/gdb_unlinker.h16
-rw-r--r--gdbsupport/gdb_vecs.cc24
-rw-r--r--gdbsupport/gdb_vecs.h14
-rw-r--r--gdbsupport/gdb_wait.cc48
-rw-r--r--gdbsupport/gdb_wait.h80
-rw-r--r--gdbsupport/hash_enum.h3
-rw-r--r--gdbsupport/host-defs.h14
-rw-r--r--gdbsupport/intrusive_list.h157
-rw-r--r--gdbsupport/iterator-range.h27
-rw-r--r--gdbsupport/job-control.cc4
-rw-r--r--gdbsupport/netstuff.cc93
-rw-r--r--gdbsupport/netstuff.h11
-rw-r--r--gdbsupport/new-op.cc30
-rw-r--r--gdbsupport/next-iterator.h18
-rw-r--r--gdbsupport/observable.h74
-rw-r--r--gdbsupport/offset-type.h71
-rw-r--r--gdbsupport/packed.h86
-rw-r--r--gdbsupport/parallel-for.h223
-rw-r--r--gdbsupport/pathstuff.cc22
-rw-r--r--gdbsupport/pathstuff.h9
-rw-r--r--gdbsupport/poison.h39
-rw-r--r--gdbsupport/preprocessor.h2
-rw-r--r--gdbsupport/print-utils.cc92
-rw-r--r--gdbsupport/print-utils.h4
-rw-r--r--gdbsupport/ptid.h54
-rw-r--r--gdbsupport/range-chain.h46
-rw-r--r--gdbsupport/refcounted-object.h10
-rw-r--r--gdbsupport/reference-to-pointer-iterator.h29
-rw-r--r--gdbsupport/rsp-low.cc91
-rw-r--r--gdbsupport/rsp-low.h6
-rw-r--r--gdbsupport/run-time-clock.cc2
-rw-r--r--gdbsupport/run-time-clock.h2
-rw-r--r--gdbsupport/safe-iterator.h26
-rw-r--r--gdbsupport/scope-exit.h55
-rw-r--r--gdbsupport/scoped_fd.h16
-rw-r--r--gdbsupport/scoped_ignore_signal.h44
-rw-r--r--gdbsupport/scoped_ignore_sigttou.h10
-rw-r--r--gdbsupport/scoped_mmap.cc5
-rw-r--r--gdbsupport/scoped_mmap.h10
-rw-r--r--gdbsupport/scoped_restore.h23
-rw-r--r--gdbsupport/search.cc78
-rw-r--r--gdbsupport/search.h12
-rw-r--r--gdbsupport/selftest.cc42
-rw-r--r--gdbsupport/selftest.h27
-rw-r--r--gdbsupport/signals-state-save-restore.cc47
-rw-r--r--gdbsupport/signals.cc278
-rw-r--r--gdbsupport/symbol.h2
-rw-r--r--gdbsupport/tdesc.cc187
-rw-r--r--gdbsupport/tdesc.h165
-rw-r--r--gdbsupport/thread-pool.cc57
-rw-r--r--gdbsupport/thread-pool.h17
-rw-r--r--gdbsupport/traits.h77
-rw-r--r--gdbsupport/valid-expr.h81
-rw-r--r--gdbsupport/x86-xstate.h82
-rw-r--r--gdbsupport/xml-utils.cc188
125 files changed, 3906 insertions, 4193 deletions
diff --git a/gdbsupport/agent.cc b/gdbsupport/agent.cc
index 531807b..56f1a9f 100644
--- a/gdbsupport/agent.cc
+++ b/gdbsupport/agent.cc
@@ -30,8 +30,7 @@ bool debug_agent = false;
/* A stdarg wrapper for debug_vprintf. */
-static void ATTRIBUTE_PRINTF (1, 2)
-debug_agent_printf (const char *fmt, ...)
+static void ATTRIBUTE_PRINTF (1, 2) debug_agent_printf (const char *fmt, ...)
{
va_list ap;
@@ -66,9 +65,9 @@ static struct
const char *name;
int offset;
} symbol_list[] = {
- IPA_SYM(helper_thread_id),
- IPA_SYM(cmd_buf),
- IPA_SYM(capability),
+ IPA_SYM (helper_thread_id),
+ IPA_SYM (cmd_buf),
+ IPA_SYM (capability),
};
static struct ipa_sym_addresses_common ipa_sym_addrs;
@@ -91,16 +90,16 @@ agent_look_up_symbols (void *arg)
for (int i = 0; i < sizeof (symbol_list) / sizeof (symbol_list[0]); i++)
{
- CORE_ADDR *addrp =
- (CORE_ADDR *) ((char *) &ipa_sym_addrs + symbol_list[i].offset);
+ CORE_ADDR *addrp
+ = (CORE_ADDR *) ((char *) &ipa_sym_addrs + symbol_list[i].offset);
struct objfile *objfile = (struct objfile *) arg;
- if (find_minimal_symbol_address (symbol_list[i].name, addrp,
- objfile) != 0)
- {
- DEBUG_AGENT ("symbol `%s' not found\n", symbol_list[i].name);
- return -1;
- }
+ if (find_minimal_symbol_address (symbol_list[i].name, addrp, objfile)
+ != 0)
+ {
+ DEBUG_AGENT ("symbol `%s' not found\n", symbol_list[i].name);
+ return -1;
+ }
}
all_agent_symbols_looked_up = true;
@@ -110,11 +109,11 @@ agent_look_up_symbols (void *arg)
static unsigned int
agent_get_helper_thread_id (void)
{
- if (helper_thread_id == 0)
+ if (helper_thread_id == 0)
{
if (target_read_uint32 (ipa_sym_addrs.addr_helper_thread_id,
- &helper_thread_id))
- warning (_("Error reading helper thread's id in lib"));
+ &helper_thread_id))
+ warning (_ ("Error reading helper thread's id in lib"));
}
return helper_thread_id;
@@ -126,7 +125,7 @@ agent_get_helper_thread_id (void)
#define SOCK_DIR P_tmpdir
#ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX sizeof(((struct sockaddr_un *) NULL)->sun_path)
+#define UNIX_PATH_MAX sizeof (((struct sockaddr_un *) NULL)->sun_path)
#endif
#endif
@@ -149,7 +148,7 @@ gdb_connect_sync_socket (int pid)
res = fd = gdb_socket_cloexec (PF_UNIX, SOCK_STREAM, 0);
if (res == -1)
{
- warning (_("error opening sync socket: %s"), safe_strerror (errno));
+ warning (_ ("error opening sync socket: %s"), safe_strerror (errno));
return -1;
}
@@ -158,7 +157,7 @@ gdb_connect_sync_socket (int pid)
res = xsnprintf (addr.sun_path, UNIX_PATH_MAX, "%s", path);
if (res >= UNIX_PATH_MAX)
{
- warning (_("string overflow allocating socket name"));
+ warning (_ ("string overflow allocating socket name"));
close (fd);
return -1;
}
@@ -166,9 +165,9 @@ gdb_connect_sync_socket (int pid)
res = connect (fd, (struct sockaddr *) &addr, sizeof (addr));
if (res == -1)
{
- warning (_("error connecting sync socket (%s): %s. "
- "Make sure the directory exists and that it is writable."),
- path, safe_strerror (errno));
+ warning (_ ("error connecting sync socket (%s): %s. "
+ "Make sure the directory exists and that it is writable."),
+ path, safe_strerror (errno));
close (fd);
return -1;
}
@@ -192,12 +191,12 @@ agent_run_command (int pid, const char *cmd, int len)
int tid = agent_get_helper_thread_id ();
ptid_t ptid = ptid_t (pid, tid);
- int ret = target_write_memory (ipa_sym_addrs.addr_cmd_buf,
- (gdb_byte *) cmd, len);
+ int ret
+ = target_write_memory (ipa_sym_addrs.addr_cmd_buf, (gdb_byte *) cmd, len);
if (ret != 0)
{
- warning (_("unable to write"));
+ warning (_ ("unable to write"));
return -1;
}
@@ -214,16 +213,18 @@ agent_run_command (int pid, const char *cmd, int len)
DEBUG_AGENT ("agent: signalling helper thread\n");
do
- {
- ret = write (fd, buf, 1);
- } while (ret == -1 && errno == EINTR);
+ {
+ ret = write (fd, buf, 1);
+ }
+ while (ret == -1 && errno == EINTR);
- DEBUG_AGENT ("agent: waiting for helper thread's response\n");
+ DEBUG_AGENT ("agent: waiting for helper thread's response\n");
do
- {
- ret = read (fd, buf, 1);
- } while (ret == -1 && errno == EINTR);
+ {
+ ret = read (fd, buf, 1);
+ }
+ while (ret == -1 && errno == EINTR);
close (fd);
@@ -243,11 +244,11 @@ agent_run_command (int pid, const char *cmd, int len)
if (fd >= 0)
{
if (target_read_memory (ipa_sym_addrs.addr_cmd_buf, (gdb_byte *) cmd,
- IPA_CMD_BUF_SIZE))
- {
- warning (_("Error reading command response"));
- return -1;
- }
+ IPA_CMD_BUF_SIZE))
+ {
+ warning (_ ("Error reading command response"));
+ return -1;
+ }
}
return 0;
@@ -264,8 +265,8 @@ agent_capability_check (enum agent_capa agent_capa)
if (agent_capability == 0)
{
if (target_read_uint32 (ipa_sym_addrs.addr_capability,
- &agent_capability))
- warning (_("Error reading capability of agent"));
+ &agent_capability))
+ warning (_ ("Error reading capability of agent"));
}
return (agent_capability & agent_capa) != 0;
}
diff --git a/gdbsupport/agent.h b/gdbsupport/agent.h
index dceb33f..cf181f2 100644
--- a/gdbsupport/agent.h
+++ b/gdbsupport/agent.h
@@ -26,16 +26,16 @@ int agent_run_command (int pid, const char *cmd, int len);
int agent_look_up_symbols (void *);
-#define IPA_SYM_EXPORTED_NAME(SYM) gdb_agent_ ## SYM
+#define IPA_SYM_EXPORTED_NAME(SYM) gdb_agent_##SYM
/* Define an entry in an IPA symbol list array. If IPA_SYM is used, the macro
IPA_SYM_STRUCT_NAME must be defined to the structure name holding the IPA
symbol addresses in that particular file, before including
gdbsupport/agent.h. */
-#define IPA_SYM(SYM) \
- { \
- STRINGIFY (IPA_SYM_EXPORTED_NAME (SYM)), \
- offsetof (IPA_SYM_STRUCT_NAME, addr_ ## SYM) \
+#define IPA_SYM(SYM) \
+ { \
+ STRINGIFY (IPA_SYM_EXPORTED_NAME (SYM)), \
+ offsetof (IPA_SYM_STRUCT_NAME, addr_##SYM) \
}
/* The size in bytes of the buffer used to talk to the IPA helper
diff --git a/gdbsupport/alt-stack.h b/gdbsupport/alt-stack.h
index 1424793..e921f60 100644
--- a/gdbsupport/alt-stack.h
+++ b/gdbsupport/alt-stack.h
@@ -58,13 +58,12 @@ public:
DISABLE_COPY_AND_ASSIGN (alternate_signal_stack);
private:
-
#ifdef HAVE_SIGALTSTACK
gdb::unique_xmalloc_ptr<char> m_stack;
stack_t m_old_stack;
#endif
};
-}
+} // namespace gdb
#endif /* GDBSUPPORT_ALT_STACK_H */
diff --git a/gdbsupport/array-view.h b/gdbsupport/array-view.h
index 3d8248b..9dd3fab 100644
--- a/gdbsupport/array-view.h
+++ b/gdbsupport/array-view.h
@@ -64,23 +64,24 @@
You can find unit tests covering the whole API in
unittests/array-view-selftests.c. */
-namespace gdb {
+namespace gdb
+{
-template <typename T>
+template<typename T>
class array_view
{
/* True iff decayed T is the same as decayed U. E.g., we want to
say that 'T&' is the same as 'const T'. */
- template <typename U>
+ template<typename U>
using IsDecayedT = typename std::is_same<typename std::decay<T>::type,
- typename std::decay<U>::type>;
+ typename std::decay<U>::type>;
/* True iff decayed T is the same as decayed U, and 'U *' is
implicitly convertible to 'T *'. This is a requirement for
several methods. */
- template <typename U>
- using DecayedConvertible = gdb::And<IsDecayedT<U>,
- std::is_convertible<U *, T *>>;
+ template<typename U>
+ using DecayedConvertible
+ = gdb::And<IsDecayedT<U>, std::is_convertible<U *, T *>>;
public:
using value_type = T;
@@ -89,68 +90,66 @@ public:
using size_type = size_t;
/* Default construction creates an empty view. */
- constexpr array_view () noexcept
- : m_array (nullptr), m_size (0)
- {}
+ constexpr array_view () noexcept : m_array (nullptr), m_size (0) {}
/* Create an array view over a single object of the type of an
array_view element. The created view as size==1. This is
templated on U to allow constructing a array_view<const T> over a
(non-const) T. The "convertible" requirement makes sure that you
can't create an array_view<T> over a const T. */
- template<typename U,
- typename = Requires<DecayedConvertible<U>>>
- constexpr array_view (U &elem) noexcept
- : m_array (&elem), m_size (1)
- {}
+ template<typename U, typename = Requires<DecayedConvertible<U>>>
+ constexpr array_view (U &elem) noexcept : m_array (&elem),
+ m_size (1)
+ {
+ }
/* Same as above, for rvalue references. */
- template<typename U,
- typename = Requires<DecayedConvertible<U>>>
- constexpr array_view (U &&elem) noexcept
- : m_array (&elem), m_size (1)
- {}
+ template<typename U, typename = Requires<DecayedConvertible<U>>>
+ constexpr array_view (U &&elem) noexcept : m_array (&elem),
+ m_size (1)
+ {
+ }
/* Create an array view from a pointer to an array and an element
count. */
- template<typename U,
- typename = Requires<DecayedConvertible<U>>>
+ template<typename U, typename = Requires<DecayedConvertible<U>>>
constexpr array_view (U *array, size_t size) noexcept
- : m_array (array), m_size (size)
- {}
+ : m_array (array),
+ m_size (size)
+ {
+ }
/* Create an array view from a range. This is templated on both U
an V to allow passing in a mix of 'const T *' and 'T *'. */
- template<typename U, typename V,
- typename = Requires<DecayedConvertible<U>>,
- typename = Requires<DecayedConvertible<V>>>
+ template<typename U, typename V, typename = Requires<DecayedConvertible<U>>,
+ typename = Requires<DecayedConvertible<V>>>
constexpr array_view (U *begin, V *end) noexcept
- : m_array (begin), m_size (end - begin)
- {}
+ : m_array (begin),
+ m_size (end - begin)
+ {
+ }
/* Create an array view from an array. */
- template<typename U, size_t Size,
- typename = Requires<DecayedConvertible<U>>>
+ template<typename U, size_t Size, typename = Requires<DecayedConvertible<U>>>
constexpr array_view (U (&array)[Size]) noexcept
- : m_array (array), m_size (Size)
- {}
+ : m_array (array),
+ m_size (Size)
+ {
+ }
/* Create an array view from a contiguous container. E.g.,
std::vector and std::array. */
template<typename Container,
- typename = Requires<gdb::Not<IsDecayedT<Container>>>,
- typename
- = Requires<DecayedConvertible
- <typename std::remove_pointer
- <decltype (std::declval<Container> ().data ())
- >::type>>,
- typename
- = Requires<std::is_convertible
- <decltype (std::declval<Container> ().size ()),
- size_type>>>
+ typename = Requires<gdb::Not<IsDecayedT<Container>>>,
+ typename = Requires<DecayedConvertible<typename std::remove_pointer<
+ decltype (std::declval<Container> ().data ())>::type>>,
+ typename = Requires<std::is_convertible<
+ decltype (std::declval<Container> ().size ()), size_type>>>
constexpr array_view (Container &&c) noexcept
- : m_array (c.data ()), m_size (c.size ())
- {}
+ : m_array (c.data ()),
+ m_size (c.size ())
+ {
+ }
/* Observer methods. Some of these can't be constexpr until we
require C++14. */
@@ -184,12 +183,13 @@ public:
/* Slice an array view. */
/* Return a new array view over SIZE elements starting at START. */
- constexpr array_view<T> slice (size_type start, size_type size) const noexcept
+ constexpr array_view<T> slice (size_type start,
+ size_type size) const noexcept
{
#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L
gdb_assert (start + size <= m_size);
#endif
- return {m_array + start, size};
+ return { m_array + start, size };
}
/* Return a new array view over all the elements after START,
@@ -199,7 +199,7 @@ public:
#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L
gdb_assert (start <= m_size);
#endif
- return {m_array + start, size () - start};
+ return { m_array + start, size () - start };
}
private:
@@ -211,8 +211,9 @@ private:
The two array views must have the same length. */
-template <typename U, typename T>
-void copy (gdb::array_view<U> src, gdb::array_view<T> dest)
+template<typename U, typename T>
+void
+copy (gdb::array_view<U> src, gdb::array_view<T> dest)
{
gdb_assert (dest.size () == src.size ());
if (dest.data () < src.data ())
@@ -225,7 +226,7 @@ void copy (gdb::array_view<U> src, gdb::array_view<T> dest)
RHS have the same sizes, and whether each pair of elements of LHS
and RHS at the same position compares equal. */
-template <typename T>
+template<typename T>
bool
operator== (const gdb::array_view<T> &lhs, const gdb::array_view<T> &rhs)
{
@@ -241,7 +242,7 @@ operator== (const gdb::array_view<T> &lhs, const gdb::array_view<T> &rhs)
/* Compare two array_views for inequality. */
-template <typename T>
+template<typename T>
bool
operator!= (const gdb::array_view<T> &lhs, const gdb::array_view<T> &rhs)
{
@@ -287,7 +288,7 @@ template<typename U>
constexpr inline array_view<U>
make_array_view (U *array, size_t size) noexcept
{
- return {array, size};
+ return { array, size };
}
} /* namespace gdb */
diff --git a/gdbsupport/block-signals.h b/gdbsupport/block-signals.h
index fe0900b..853d7e3 100644
--- a/gdbsupport/block-signals.h
+++ b/gdbsupport/block-signals.h
@@ -57,12 +57,11 @@ public:
DISABLE_COPY_AND_ASSIGN (block_signals);
private:
-
#ifdef HAVE_SIGPROCMASK
sigset_t m_old_mask;
#endif
};
-}
+} // namespace gdb
#endif /* GDBSUPPORT_BLOCK_SIGNALS_H */
diff --git a/gdbsupport/break-common.h b/gdbsupport/break-common.h
index 82a9b3e..33a24aa 100644
--- a/gdbsupport/break-common.h
+++ b/gdbsupport/break-common.h
@@ -21,11 +21,11 @@
#define COMMON_BREAK_COMMON_H
enum target_hw_bp_type
- {
- hw_write = 0, /* Common HW watchpoint */
- hw_read = 1, /* Read HW watchpoint */
- hw_access = 2, /* Access HW watchpoint */
- hw_execute = 3 /* Execute HW breakpoint */
- };
+{
+ hw_write = 0, /* Common HW watchpoint */
+ hw_read = 1, /* Read HW watchpoint */
+ hw_access = 2, /* Access HW watchpoint */
+ hw_execute = 3 /* Execute HW breakpoint */
+};
#endif /* COMMON_BREAK_COMMON_H */
diff --git a/gdbsupport/btrace-common.cc b/gdbsupport/btrace-common.cc
index 932a118..26ac5c6 100644
--- a/gdbsupport/btrace-common.cc
+++ b/gdbsupport/btrace-common.cc
@@ -20,7 +20,6 @@
#include "common-defs.h"
#include "btrace-common.h"
-
/* See btrace-common.h. */
const char *
@@ -29,16 +28,16 @@ btrace_format_string (enum btrace_format format)
switch (format)
{
case BTRACE_FORMAT_NONE:
- return _("No or unknown format");
+ return _ ("No or unknown format");
case BTRACE_FORMAT_BTS:
- return _("Branch Trace Store");
+ return _ ("Branch Trace Store");
case BTRACE_FORMAT_PT:
- return _("Intel Processor Trace");
+ return _ ("Intel Processor Trace");
}
- internal_error (_("Unknown branch trace format"));
+ internal_error (_ ("Unknown branch trace format"));
}
/* See btrace-common.h. */
@@ -58,7 +57,7 @@ btrace_format_short_string (enum btrace_format format)
return "pt";
}
- internal_error (_("Unknown branch trace format"));
+ internal_error (_ ("Unknown branch trace format"));
}
/* See btrace-common.h. */
@@ -82,7 +81,7 @@ btrace_data::fini ()
return;
}
- internal_error (_("Unkown branch trace format."));
+ internal_error (_ ("Unkown branch trace format."));
}
/* See btrace-common.h. */
@@ -102,7 +101,7 @@ btrace_data::empty () const
return (variant.pt.size == 0);
}
- internal_error (_("Unkown branch trace format."));
+ internal_error (_ ("Unkown branch trace format."));
}
/* See btrace-common.h. */
@@ -117,8 +116,7 @@ btrace_data::clear ()
/* See btrace-common.h. */
int
-btrace_data_append (struct btrace_data *dst,
- const struct btrace_data *src)
+btrace_data_append (struct btrace_data *dst, const struct btrace_data *src)
{
switch (src->format)
{
@@ -127,65 +125,65 @@ btrace_data_append (struct btrace_data *dst,
case BTRACE_FORMAT_BTS:
switch (dst->format)
- {
- default:
- return -1;
+ {
+ default:
+ return -1;
- case BTRACE_FORMAT_NONE:
- dst->format = BTRACE_FORMAT_BTS;
- dst->variant.bts.blocks = new std::vector<btrace_block>;
+ case BTRACE_FORMAT_NONE:
+ dst->format = BTRACE_FORMAT_BTS;
+ dst->variant.bts.blocks = new std::vector<btrace_block>;
- /* Fall-through. */
- case BTRACE_FORMAT_BTS:
- {
- unsigned int blk;
+ /* Fall-through. */
+ case BTRACE_FORMAT_BTS:
+ {
+ unsigned int blk;
- /* We copy blocks in reverse order to have the oldest block at
+ /* We copy blocks in reverse order to have the oldest block at
index zero. */
- blk = src->variant.bts.blocks->size ();
- while (blk != 0)
- {
- const btrace_block &block
- = src->variant.bts.blocks->at (--blk);
- dst->variant.bts.blocks->push_back (block);
- }
- }
- }
+ blk = src->variant.bts.blocks->size ();
+ while (blk != 0)
+ {
+ const btrace_block &block
+ = src->variant.bts.blocks->at (--blk);
+ dst->variant.bts.blocks->push_back (block);
+ }
+ }
+ }
return 0;
case BTRACE_FORMAT_PT:
switch (dst->format)
- {
- default:
- return -1;
-
- case BTRACE_FORMAT_NONE:
- dst->format = BTRACE_FORMAT_PT;
- dst->variant.pt.data = NULL;
- dst->variant.pt.size = 0;
-
- /* fall-through. */
- case BTRACE_FORMAT_PT:
- {
- gdb_byte *data;
- size_t size;
-
- size = src->variant.pt.size + dst->variant.pt.size;
- data = (gdb_byte *) xmalloc (size);
-
- if (dst->variant.pt.size > 0)
- memcpy (data, dst->variant.pt.data, dst->variant.pt.size);
- memcpy (data + dst->variant.pt.size, src->variant.pt.data,
- src->variant.pt.size);
-
- xfree (dst->variant.pt.data);
-
- dst->variant.pt.data = data;
- dst->variant.pt.size = size;
- }
- }
+ {
+ default:
+ return -1;
+
+ case BTRACE_FORMAT_NONE:
+ dst->format = BTRACE_FORMAT_PT;
+ dst->variant.pt.data = NULL;
+ dst->variant.pt.size = 0;
+
+ /* fall-through. */
+ case BTRACE_FORMAT_PT:
+ {
+ gdb_byte *data;
+ size_t size;
+
+ size = src->variant.pt.size + dst->variant.pt.size;
+ data = (gdb_byte *) xmalloc (size);
+
+ if (dst->variant.pt.size > 0)
+ memcpy (data, dst->variant.pt.data, dst->variant.pt.size);
+ memcpy (data + dst->variant.pt.size, src->variant.pt.data,
+ src->variant.pt.size);
+
+ xfree (dst->variant.pt.data);
+
+ dst->variant.pt.data = data;
+ dst->variant.pt.size = size;
+ }
+ }
return 0;
}
- internal_error (_("Unkown branch trace format."));
+ internal_error (_ ("Unkown branch trace format."));
}
diff --git a/gdbsupport/btrace-common.h b/gdbsupport/btrace-common.h
index e287c93..2e1654b 100644
--- a/gdbsupport/btrace-common.h
+++ b/gdbsupport/btrace-common.h
@@ -43,9 +43,7 @@ struct btrace_block
CORE_ADDR end;
/* Simple constructor. */
- btrace_block (CORE_ADDR begin, CORE_ADDR end)
- : begin (begin),
- end (end)
+ btrace_block (CORE_ADDR begin, CORE_ADDR end) : begin (begin), end (end)
{
/* Nothing. */
}
@@ -172,19 +170,16 @@ struct btrace_data
{
btrace_data () = default;
- ~btrace_data ()
- {
- fini ();
- }
+ ~btrace_data () { fini (); }
btrace_data &operator= (btrace_data &&other)
{
if (this != &other)
{
- fini ();
- format = other.format;
- variant = other.variant;
- other.format = BTRACE_FORMAT_NONE;
+ fini ();
+ format = other.format;
+ variant = other.variant;
+ other.format = BTRACE_FORMAT_NONE;
}
return *this;
}
@@ -207,7 +202,6 @@ struct btrace_data
} variant;
private:
-
DISABLE_COPY_AND_ASSIGN (btrace_data);
void fini ();
@@ -258,6 +252,6 @@ extern const char *btrace_format_short_string (enum btrace_format format);
Both SRC and DST must use the same format.
Returns zero on success; a negative number otherwise. */
extern int btrace_data_append (struct btrace_data *dst,
- const struct btrace_data *src);
+ const struct btrace_data *src);
#endif /* COMMON_BTRACE_COMMON_H */
diff --git a/gdbsupport/buffer.cc b/gdbsupport/buffer.cc
index da6f3af6..f50c1e6 100644
--- a/gdbsupport/buffer.cc
+++ b/gdbsupport/buffer.cc
@@ -62,7 +62,7 @@ buffer_init (struct buffer *buffer)
memset (buffer, 0, sizeof (*buffer));
}
-char*
+char *
buffer_finish (struct buffer *buffer)
{
char *ret = buffer->buffer;
@@ -86,93 +86,92 @@ buffer_xml_printf (struct buffer *buffer, const char *format, ...)
for (f = format; *f; f++)
{
if (percent)
- {
- char buf[32];
- char *str = buf;
- const char *f_old = f;
-
- switch (*f)
- {
- case 's':
- str = va_arg (ap, char *);
- break;
- case 'd':
- sprintf (str, "%d", va_arg (ap, int));
- break;
- case 'u':
- sprintf (str, "%u", va_arg (ap, unsigned int));
- break;
- case 'x':
- sprintf (str, "%x", va_arg (ap, unsigned int));
- break;
- case 'o':
- sprintf (str, "%o", va_arg (ap, unsigned int));
- break;
- case 'l':
- f++;
- switch (*f)
- {
- case 'd':
- sprintf (str, "%ld", va_arg (ap, long));
- break;
- case 'u':
- sprintf (str, "%lu", va_arg (ap, unsigned long));
- break;
- case 'x':
- sprintf (str, "%lx", va_arg (ap, unsigned long));
- break;
- case 'o':
- sprintf (str, "%lo", va_arg (ap, unsigned long));
- break;
- case 'l':
- f++;
- switch (*f)
- {
- case 'd':
- sprintf (str, "%" PRId64,
- (int64_t) va_arg (ap, long long));
- break;
- case 'u':
- sprintf (str, "%" PRIu64,
- (uint64_t) va_arg (ap, unsigned long long));
- break;
- case 'x':
- sprintf (str, "%" PRIx64,
- (uint64_t) va_arg (ap, unsigned long long));
- break;
- case 'o':
- sprintf (str, "%" PRIo64,
- (uint64_t) va_arg (ap, unsigned long long));
- break;
- default:
- str = 0;
- break;
- }
- break;
- default:
- str = 0;
- break;
- }
- break;
- default:
- str = 0;
- break;
- }
-
- if (str)
- {
- buffer_grow (buffer, prev, f_old - prev - 1);
- std::string p = xml_escape_text (str);
- buffer_grow_str (buffer, p.c_str ());
- prev = f + 1;
- }
- percent = 0;
- }
+ {
+ char buf[32];
+ char *str = buf;
+ const char *f_old = f;
+
+ switch (*f)
+ {
+ case 's':
+ str = va_arg (ap, char *);
+ break;
+ case 'd':
+ sprintf (str, "%d", va_arg (ap, int));
+ break;
+ case 'u':
+ sprintf (str, "%u", va_arg (ap, unsigned int));
+ break;
+ case 'x':
+ sprintf (str, "%x", va_arg (ap, unsigned int));
+ break;
+ case 'o':
+ sprintf (str, "%o", va_arg (ap, unsigned int));
+ break;
+ case 'l':
+ f++;
+ switch (*f)
+ {
+ case 'd':
+ sprintf (str, "%ld", va_arg (ap, long));
+ break;
+ case 'u':
+ sprintf (str, "%lu", va_arg (ap, unsigned long));
+ break;
+ case 'x':
+ sprintf (str, "%lx", va_arg (ap, unsigned long));
+ break;
+ case 'o':
+ sprintf (str, "%lo", va_arg (ap, unsigned long));
+ break;
+ case 'l':
+ f++;
+ switch (*f)
+ {
+ case 'd':
+ sprintf (str, "%" PRId64,
+ (int64_t) va_arg (ap, long long));
+ break;
+ case 'u':
+ sprintf (str, "%" PRIu64,
+ (uint64_t) va_arg (ap, unsigned long long));
+ break;
+ case 'x':
+ sprintf (str, "%" PRIx64,
+ (uint64_t) va_arg (ap, unsigned long long));
+ break;
+ case 'o':
+ sprintf (str, "%" PRIo64,
+ (uint64_t) va_arg (ap, unsigned long long));
+ break;
+ default:
+ str = 0;
+ break;
+ }
+ break;
+ default:
+ str = 0;
+ break;
+ }
+ break;
+ default:
+ str = 0;
+ break;
+ }
+
+ if (str)
+ {
+ buffer_grow (buffer, prev, f_old - prev - 1);
+ std::string p = xml_escape_text (str);
+ buffer_grow_str (buffer, p.c_str ());
+ prev = f + 1;
+ }
+ percent = 0;
+ }
else if (*f == '%')
- percent = 1;
+ percent = 1;
}
buffer_grow_str (buffer, prev);
va_end (ap);
}
-
diff --git a/gdbsupport/buffer.h b/gdbsupport/buffer.h
index 7323c3a..f9d11b3 100644
--- a/gdbsupport/buffer.h
+++ b/gdbsupport/buffer.h
@@ -24,7 +24,7 @@ struct buffer
{
char *buffer;
size_t buffer_size; /* allocated size */
- size_t used_size; /* actually used size */
+ size_t used_size; /* actually used size */
};
/* Append DATA of size SIZE to the end of BUFFER. Grows the buffer to
@@ -49,7 +49,7 @@ void buffer_init (struct buffer *buffer);
/* Return a pointer into BUFFER data, effectively transferring
ownership of the buffer memory to the caller. Calling buffer_free
afterwards has no effect on the returned data. */
-char* buffer_finish (struct buffer *buffer);
+char *buffer_finish (struct buffer *buffer);
/* Simple printf to buffer function. Current implemented formatters:
%s - grow an xml escaped text in BUFFER.
@@ -60,9 +60,9 @@ char* buffer_finish (struct buffer *buffer);
void buffer_xml_printf (struct buffer *buffer, const char *format, ...)
ATTRIBUTE_PRINTF (2, 3);
-#define buffer_grow_str(BUFFER,STRING) \
+#define buffer_grow_str(BUFFER, STRING) \
buffer_grow (BUFFER, STRING, strlen (STRING))
-#define buffer_grow_str0(BUFFER,STRING) \
+#define buffer_grow_str0(BUFFER, STRING) \
buffer_grow (BUFFER, STRING, strlen (STRING) + 1)
#endif /* COMMON_BUFFER_H */
diff --git a/gdbsupport/buildargv.h b/gdbsupport/buildargv.h
index 03e0288..8c87b69 100644
--- a/gdbsupport/buildargv.h
+++ b/gdbsupport/buildargv.h
@@ -28,29 +28,18 @@
class gdb_argv
{
public:
-
/* A constructor that initializes to NULL. */
- gdb_argv ()
- : m_argv (NULL)
- {
- }
+ gdb_argv () : m_argv (NULL) {}
/* A constructor that calls buildargv on STR. STR may be NULL, in
which case this object is initialized with a NULL array. */
- explicit gdb_argv (const char *str)
- : m_argv (NULL)
- {
- reset (str);
- }
+ explicit gdb_argv (const char *str) : m_argv (NULL) { reset (str); }
/* A constructor that takes ownership of an existing array. */
- explicit gdb_argv (char **array)
- : m_argv (array)
- {
- }
+ explicit gdb_argv (char **array) : m_argv (array) {}
gdb_argv (const gdb_argv &) = delete;
gdb_argv &operator= (const gdb_argv &) = delete;
@@ -69,10 +58,7 @@ public:
other.m_argv = nullptr;
}
- ~gdb_argv ()
- {
- freeargv (m_argv);
- }
+ ~gdb_argv () { freeargv (m_argv); }
/* Call buildargv on STR, storing the result in this object. Any
previous state is freed. STR may be NULL, in which case this
@@ -90,15 +76,9 @@ public:
/* Return the underlying array. */
- char **get ()
- {
- return m_argv;
- }
+ char **get () { return m_argv; }
- const char * const * get () const
- {
- return m_argv;
- }
+ const char *const *get () const { return m_argv; }
/* Return the underlying array, transferring ownership to the
caller. */
@@ -112,10 +92,7 @@ public:
/* Return the number of items in the array. */
- int count () const
- {
- return countargv (m_argv);
- }
+ int count () const { return countargv (m_argv); }
/* Index into the array. */
@@ -132,9 +109,9 @@ public:
return gdb::array_view<char *> (this->get (), this->count ());
}
- gdb::array_view<const char * const> as_array_view () const
+ gdb::array_view<const char *const> as_array_view () const
{
- return gdb::array_view<const char * const> (this->get (), this->count ());
+ return gdb::array_view<const char *const> (this->get (), this->count ());
}
/* Append arguments to this array. */
@@ -146,10 +123,10 @@ public:
for (int argi = 0; argi < argc; argi++)
{
- /* Transfer ownership of the string. */
- m_argv[size++] = other.m_argv[argi];
- /* Ensure that destruction of OTHER works correctly. */
- other.m_argv[argi] = nullptr;
+ /* Transfer ownership of the string. */
+ m_argv[size++] = other.m_argv[argi];
+ /* Ensure that destruction of OTHER works correctly. */
+ other.m_argv[argi] = nullptr;
}
m_argv[size] = nullptr;
}
@@ -172,30 +149,17 @@ public:
/* Return an iterator pointing to the start of the array. */
- iterator begin ()
- {
- return m_argv;
- }
+ iterator begin () { return m_argv; }
/* Return an iterator pointing to the end of the array. */
- iterator end ()
- {
- return m_argv + count ();
- }
+ iterator end () { return m_argv + count (); }
- bool operator!= (std::nullptr_t)
- {
- return m_argv != NULL;
- }
+ bool operator!= (std::nullptr_t) { return m_argv != NULL; }
- bool operator== (std::nullptr_t)
- {
- return m_argv == NULL;
- }
+ bool operator== (std::nullptr_t) { return m_argv == NULL; }
private:
-
/* The wrapped array. */
char **m_argv;
diff --git a/gdbsupport/byte-vector.h b/gdbsupport/byte-vector.h
index 6de60c9..c3c9a5b 100644
--- a/gdbsupport/byte-vector.h
+++ b/gdbsupport/byte-vector.h
@@ -20,7 +20,8 @@
#include "gdbsupport/def-vector.h"
-namespace gdb {
+namespace gdb
+{
/* byte_vector is a gdb_byte std::vector with a custom allocator that
unlike std::vector<gdb_byte> does not zero-initialize new elements
diff --git a/gdbsupport/cleanups.cc b/gdbsupport/cleanups.cc
index 4e49daf..f10fb24 100644
--- a/gdbsupport/cleanups.cc
+++ b/gdbsupport/cleanups.cc
@@ -73,7 +73,7 @@ static struct cleanup *final_cleanup_chain = SENTINEL_CLEANUP;
static struct cleanup *
make_my_cleanup2 (struct cleanup **pmy_chain, make_cleanup_ftype *function,
- void *arg, void (*free_arg) (void *))
+ void *arg, void (*free_arg) (void *))
{
struct cleanup *newobj = XNEW (struct cleanup);
struct cleanup *old_chain = *pmy_chain;
@@ -98,7 +98,7 @@ make_my_cleanup2 (struct cleanup **pmy_chain, make_cleanup_ftype *function,
static struct cleanup *
make_my_cleanup (struct cleanup **pmy_chain, make_cleanup_ftype *function,
- void *arg)
+ void *arg)
{
return make_my_cleanup2 (pmy_chain, function, arg, NULL);
}
@@ -120,17 +120,16 @@ make_final_cleanup (make_cleanup_ftype *function, void *arg)
Cleanups are performed until we get back to the old end of the chain. */
static void
-do_my_cleanups (struct cleanup **pmy_chain,
- struct cleanup *old_chain)
+do_my_cleanups (struct cleanup **pmy_chain, struct cleanup *old_chain)
{
struct cleanup *ptr;
while ((ptr = *pmy_chain) != old_chain)
{
- *pmy_chain = ptr->next; /* Do this first in case of recursion. */
+ *pmy_chain = ptr->next; /* Do this first in case of recursion. */
(*ptr->function) (ptr->arg);
if (ptr->free_arg)
- (*ptr->free_arg) (ptr->arg);
+ (*ptr->free_arg) (ptr->arg);
xfree (ptr);
}
}
diff --git a/gdbsupport/common-debug.cc b/gdbsupport/common-debug.cc
index 08d2be3..7d08fb5 100644
--- a/gdbsupport/common-debug.cc
+++ b/gdbsupport/common-debug.cc
@@ -40,7 +40,7 @@ debug_printf (const char *fmt, ...)
void
debug_prefixed_printf (const char *module, const char *func,
- const char *format, ...)
+ const char *format, ...)
{
va_list ap;
@@ -53,7 +53,7 @@ debug_prefixed_printf (const char *module, const char *func,
void
debug_prefixed_vprintf (const char *module, const char *func,
- const char *format, va_list args)
+ const char *format, va_list args)
{
if (func != nullptr)
debug_printf ("%*s[%s] %s: ", debug_print_depth * 2, "", module, func);
diff --git a/gdbsupport/common-debug.h b/gdbsupport/common-debug.h
index 33b15a0..5e6fb44 100644
--- a/gdbsupport/common-debug.h
+++ b/gdbsupport/common-debug.h
@@ -33,27 +33,28 @@ extern bool show_debug_regs;
/* Print a formatted message to the appropriate channel for
debugging output for the client. */
-extern void debug_printf (const char *format, ...)
- ATTRIBUTE_PRINTF (1, 2);
+extern void debug_printf (const char *format, ...) ATTRIBUTE_PRINTF (1, 2);
/* Print a formatted message to the appropriate channel for
debugging output for the client. This function must be
provided by the client. */
extern void debug_vprintf (const char *format, va_list ap)
- ATTRIBUTE_PRINTF (1, 0);
+ ATTRIBUTE_PRINTF (1, 0);
/* Print a debug statement prefixed with the module and function name, and
with a newline at the end. */
-extern void ATTRIBUTE_PRINTF (3, 4) debug_prefixed_printf
- (const char *module, const char *func, const char *format, ...);
+extern void ATTRIBUTE_PRINTF (3, 4)
+ debug_prefixed_printf (const char *module, const char *func,
+ const char *format, ...);
/* Print a debug statement prefixed with the module and function name, and
with a newline at the end. */
-extern void ATTRIBUTE_PRINTF (3, 0) debug_prefixed_vprintf
- (const char *module, const char *func, const char *format, va_list args);
+extern void ATTRIBUTE_PRINTF (3, 0)
+ debug_prefixed_vprintf (const char *module, const char *func,
+ const char *format, va_list args);
/* Helper to define "_debug_print" macros.
@@ -64,19 +65,20 @@ extern void ATTRIBUTE_PRINTF (3, 0) debug_prefixed_vprintf
forwarded to debug_prefixed_printf. */
#define debug_prefixed_printf_cond(debug_enabled_cond, module, fmt, ...) \
- do \
- { \
- if (debug_enabled_cond) \
- debug_prefixed_printf (module, __func__, fmt, ##__VA_ARGS__); \
- } \
+ do \
+ { \
+ if (debug_enabled_cond) \
+ debug_prefixed_printf (module, __func__, fmt, ##__VA_ARGS__); \
+ } \
while (0)
-#define debug_prefixed_printf_cond_nofunc(debug_enabled_cond, module, fmt, ...) \
- do \
- { \
- if (debug_enabled_cond) \
- debug_prefixed_printf (module, nullptr, fmt, ##__VA_ARGS__); \
- } \
+#define debug_prefixed_printf_cond_nofunc(debug_enabled_cond, module, fmt, \
+ ...) \
+ do \
+ { \
+ if (debug_enabled_cond) \
+ debug_prefixed_printf (module, nullptr, fmt, ##__VA_ARGS__); \
+ } \
while (0)
/* Nesting depth of scoped_debug_start_end objects. */
@@ -110,10 +112,9 @@ struct scoped_debug_start_end
for the message on exit. */
scoped_debug_start_end (PT &debug_enabled, const char *module,
- const char *func, const char *start_prefix,
- const char *end_prefix, const char *fmt,
- va_list args)
- ATTRIBUTE_NULL_PRINTF (7, 0)
+ const char *func, const char *start_prefix,
+ const char *end_prefix, const char *fmt,
+ va_list args) ATTRIBUTE_NULL_PRINTF (7, 0)
: m_debug_enabled (debug_enabled),
m_module (module),
m_func (func),
@@ -122,17 +123,17 @@ struct scoped_debug_start_end
{
if (is_debug_enabled ())
{
- if (fmt != nullptr)
- {
- m_msg = string_vprintf (fmt, args);
- debug_prefixed_printf (m_module, m_func, "%s: %s",
- start_prefix, m_msg->c_str ());
- }
- else
- debug_prefixed_printf (m_module, m_func, "%s", start_prefix);
-
- ++debug_print_depth;
- m_must_decrement_print_depth = true;
+ if (fmt != nullptr)
+ {
+ m_msg = string_vprintf (fmt, args);
+ debug_prefixed_printf (m_module, m_func, "%s: %s", start_prefix,
+ m_msg->c_str ());
+ }
+ else
+ debug_prefixed_printf (m_module, m_func, "%s", start_prefix);
+
+ ++debug_print_depth;
+ m_must_decrement_print_depth = true;
}
}
@@ -159,33 +160,34 @@ struct scoped_debug_start_end
if (m_must_decrement_print_depth)
{
- gdb_assert (debug_print_depth > 0);
- --debug_print_depth;
+ gdb_assert (debug_print_depth > 0);
+ --debug_print_depth;
}
if (is_debug_enabled ())
{
- if (m_with_format)
- {
- if (m_msg.has_value ())
- debug_prefixed_printf (m_module, m_func, "%s: %s",
- m_end_prefix, m_msg->c_str ());
- else
- {
- /* A format string was passed to the constructor, but debug
+ if (m_with_format)
+ {
+ if (m_msg.has_value ())
+ debug_prefixed_printf (m_module, m_func, "%s: %s", m_end_prefix,
+ m_msg->c_str ());
+ else
+ {
+ /* A format string was passed to the constructor, but debug
control variable wasn't set at the time, so we don't have the
rendering of the format string. */
- debug_prefixed_printf (m_module, m_func, "%s: <%s debugging was not enabled on entry>",
- m_end_prefix, m_module);
- }
- }
- else
- debug_prefixed_printf (m_module, m_func, "%s", m_end_prefix);
+ debug_prefixed_printf (
+ m_module, m_func,
+ "%s: <%s debugging was not enabled on entry>", m_end_prefix,
+ m_module);
+ }
+ }
+ else
+ debug_prefixed_printf (m_module, m_func, "%s", m_end_prefix);
}
}
private:
-
/* This function is specialized based on the type PT. Returns true if
M_DEBUG_ENABLED indicates this debug setting is enabled, otherwise,
return false. */
@@ -240,14 +242,14 @@ scoped_debug_start_end<bool &>::is_debug_enabled () const
template<typename PT>
static inline scoped_debug_start_end<PT &> ATTRIBUTE_NULL_PRINTF (6, 7)
-make_scoped_debug_start_end (PT &&pred, const char *module, const char *func,
- const char *start_prefix,
- const char *end_prefix, const char *fmt, ...)
+ make_scoped_debug_start_end (PT &&pred, const char *module, const char *func,
+ const char *start_prefix,
+ const char *end_prefix, const char *fmt, ...)
{
va_list args;
va_start (args, fmt);
auto res = scoped_debug_start_end<PT &> (pred, module, func, start_prefix,
- end_prefix, fmt, args);
+ end_prefix, fmt, args);
va_end (args);
return res;
@@ -255,20 +257,18 @@ make_scoped_debug_start_end (PT &&pred, const char *module, const char *func,
/* Helper to define a module-specific start/end debug macro. */
-#define scoped_debug_start_end(debug_enabled, module, fmt, ...) \
- auto CONCAT(scoped_debug_start_end, __LINE__) \
- = make_scoped_debug_start_end (debug_enabled, module, \
- __func__, "start", "end", \
- fmt, ##__VA_ARGS__)
+#define scoped_debug_start_end(debug_enabled, module, fmt, ...) \
+ auto CONCAT (scoped_debug_start_end, __LINE__) \
+ = make_scoped_debug_start_end (debug_enabled, module, __func__, "start", \
+ "end", fmt, ##__VA_ARGS__)
/* Helper to define a module-specific enter/exit debug macro. This is a special
case of `scoped_debug_start_end` where the start and end messages are "enter"
and "exit", to denote entry and exit of a function. */
-#define scoped_debug_enter_exit(debug_enabled, module) \
- auto CONCAT(scoped_debug_start_end, __LINE__) \
- = make_scoped_debug_start_end (debug_enabled, module, \
- __func__, "enter", "exit", \
- nullptr)
+#define scoped_debug_enter_exit(debug_enabled, module) \
+ auto CONCAT (scoped_debug_start_end, __LINE__) \
+ = make_scoped_debug_start_end (debug_enabled, module, __func__, "enter", \
+ "exit", nullptr)
#endif /* COMMON_COMMON_DEBUG_H */
diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
index 5e529f6..b359ff8 100644
--- a/gdbsupport/common-defs.h
+++ b/gdbsupport/common-defs.h
@@ -73,16 +73,16 @@
expose the required symbols.
NOTE: this must be kept in sync with common.m4. */
-#if defined (__MINGW32__) || defined (__CYGWIN__)
-# ifdef _WIN32_WINNT
-# if _WIN32_WINNT < 0x0501
-# undef _WIN32_WINNT
-# define _WIN32_WINNT 0x0501
-# endif
-# else
-# define _WIN32_WINNT 0x0501
-# endif
-#endif /* __MINGW32__ || __CYGWIN__ */
+#if defined(__MINGW32__) || defined(__CYGWIN__)
+#ifdef _WIN32_WINNT
+#if _WIN32_WINNT < 0x0501
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0501
+#endif
+#else
+#define _WIN32_WINNT 0x0501
+#endif
+#endif /* __MINGW32__ || __CYGWIN__ */
#include <stdarg.h>
#include <stdio.h>
@@ -96,7 +96,7 @@
#include <stdint.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
-#include <strings.h> /* for strcasecmp and strncasecmp */
+#include <strings.h> /* for strcasecmp and strncasecmp */
#endif
#include <errno.h>
#if HAVE_ALLOCA_H
@@ -215,7 +215,9 @@
#include "gdbsupport/poison.h"
#define EXTERN_C extern "C"
-#define EXTERN_C_PUSH extern "C" {
+#define EXTERN_C_PUSH \
+ extern "C" \
+ {
#define EXTERN_C_POP }
/* Pull in gdb::unique_xmalloc_ptr. */
@@ -226,7 +228,7 @@
that always returns a pointer to a 4MB section reserved for
that. */
-#if defined (HAVE_SBRK) && !__APPLE__
+#if defined(HAVE_SBRK) && !__APPLE__
#define HAVE_USEFUL_SBRK 1
#endif
diff --git a/gdbsupport/common-exceptions.cc b/gdbsupport/common-exceptions.cc
index d0dd808..51af437 100644
--- a/gdbsupport/common-exceptions.cc
+++ b/gdbsupport/common-exceptions.cc
@@ -22,7 +22,8 @@
#include <forward_list>
/* Possible catcher states. */
-enum catcher_state {
+enum catcher_state
+{
/* Initial state, a new catcher has just been created. */
CATCHER_CREATED,
/* The catch code is running. */
@@ -33,7 +34,8 @@ enum catcher_state {
};
/* Possible catcher actions. */
-enum catcher_action {
+enum catcher_action
+{
CATCH_ITER,
CATCH_ITER_1,
CATCH_THROWING
@@ -68,67 +70,66 @@ exceptions_state_mc (enum catcher_action action)
{
case CATCHER_CREATED:
switch (action)
- {
- case CATCH_ITER:
- /* Allow the code to run the catcher. */
- catchers.front ().state = CATCHER_RUNNING;
- return 1;
- default:
- internal_error (_("bad state"));
- }
+ {
+ case CATCH_ITER:
+ /* Allow the code to run the catcher. */
+ catchers.front ().state = CATCHER_RUNNING;
+ return 1;
+ default:
+ internal_error (_ ("bad state"));
+ }
case CATCHER_RUNNING:
switch (action)
- {
- case CATCH_ITER:
- /* No error/quit has occured. */
- return 0;
- case CATCH_ITER_1:
- catchers.front ().state = CATCHER_RUNNING_1;
- return 1;
- case CATCH_THROWING:
- catchers.front ().state = CATCHER_ABORTING;
- /* See also throw_exception. */
- return 1;
- default:
- internal_error (_("bad switch"));
- }
+ {
+ case CATCH_ITER:
+ /* No error/quit has occured. */
+ return 0;
+ case CATCH_ITER_1:
+ catchers.front ().state = CATCHER_RUNNING_1;
+ return 1;
+ case CATCH_THROWING:
+ catchers.front ().state = CATCHER_ABORTING;
+ /* See also throw_exception. */
+ return 1;
+ default:
+ internal_error (_ ("bad switch"));
+ }
case CATCHER_RUNNING_1:
switch (action)
- {
- case CATCH_ITER:
- /* The did a "break" from the inner while loop. */
- return 0;
- case CATCH_ITER_1:
- catchers.front ().state = CATCHER_RUNNING;
- return 0;
- case CATCH_THROWING:
- catchers.front ().state = CATCHER_ABORTING;
- /* See also throw_exception. */
- return 1;
- default:
- internal_error (_("bad switch"));
- }
+ {
+ case CATCH_ITER:
+ /* The did a "break" from the inner while loop. */
+ return 0;
+ case CATCH_ITER_1:
+ catchers.front ().state = CATCHER_RUNNING;
+ return 0;
+ case CATCH_THROWING:
+ catchers.front ().state = CATCHER_ABORTING;
+ /* See also throw_exception. */
+ return 1;
+ default:
+ internal_error (_ ("bad switch"));
+ }
case CATCHER_ABORTING:
switch (action)
- {
- case CATCH_ITER:
- {
- /* Exit normally if this catcher can handle this
+ {
+ case CATCH_ITER:
+ {
+ /* Exit normally if this catcher can handle this
exception. The caller analyses the func return
values. */
- return 0;
- }
- default:
- internal_error (_("bad state"));
- }
+ return 0;
+ }
+ default:
+ internal_error (_ ("bad state"));
+ }
default:
- internal_error (_("bad switch"));
+ internal_error (_ ("bad switch"));
}
}
int
-exceptions_state_mc_catch (struct gdb_exception *exception,
- int mask)
+exceptions_state_mc_catch (struct gdb_exception *exception, int mask)
{
*exception = std::move (catchers.front ().exception);
catchers.pop_front ();
@@ -136,11 +137,11 @@ exceptions_state_mc_catch (struct gdb_exception *exception,
if (exception->reason < 0)
{
if (mask & RETURN_MASK (exception->reason))
- {
- /* Exit normally and let the caller handle the
+ {
+ /* Exit normally and let the caller handle the
exception. */
- return 1;
- }
+ return 1;
+ }
/* The caller didn't request that the event be caught, relay the
event to the next exception_catch/CATCH_SJLJ. */
@@ -191,8 +192,8 @@ throw_exception (gdb_exception &&exception)
}
static void ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 0)
-throw_it (enum return_reason reason, enum errors error, const char *fmt,
- va_list ap)
+ throw_it (enum return_reason reason, enum errors error, const char *fmt,
+ va_list ap)
{
if (reason == RETURN_QUIT)
throw gdb_exception_quit (fmt, ap);
diff --git a/gdbsupport/common-exceptions.h b/gdbsupport/common-exceptions.h
index a2a4f5a..acc857a 100644
--- a/gdbsupport/common-exceptions.h
+++ b/gdbsupport/common-exceptions.h
@@ -31,14 +31,14 @@
use as the return value from an initial setjmp(). */
enum return_reason
- {
- /* User interrupt. */
- RETURN_QUIT = -2,
- /* Any other error. */
- RETURN_ERROR
- };
+{
+ /* User interrupt. */
+ RETURN_QUIT = -2,
+ /* Any other error. */
+ RETURN_ERROR
+};
-#define RETURN_MASK(reason) (1 << (int)(-reason))
+#define RETURN_MASK(reason) (1 << (int) (-reason))
typedef enum
{
@@ -49,7 +49,8 @@ typedef enum
/* Describe all exceptions. */
-enum errors {
+enum errors
+{
GDB_NO_ERROR,
/* Any generic error, the corresponding text is in
@@ -113,21 +114,14 @@ enum errors {
struct gdb_exception
{
- gdb_exception ()
- : reason ((enum return_reason) 0),
- error (GDB_NO_ERROR)
- {
- }
+ gdb_exception () : reason ((enum return_reason) 0), error (GDB_NO_ERROR) {}
- gdb_exception (enum return_reason r, enum errors e)
- : reason (r),
- error (e)
+ gdb_exception (enum return_reason r, enum errors e) : reason (r), error (e)
{
}
- gdb_exception (enum return_reason r, enum errors e,
- const char *fmt, va_list ap)
- ATTRIBUTE_PRINTF (4, 0)
+ gdb_exception (enum return_reason r, enum errors e, const char *fmt,
+ va_list ap) ATTRIBUTE_PRINTF (4, 0)
: reason (r),
error (e),
message (std::make_shared<std::string> (string_vprintf (fmt, ap)))
@@ -161,10 +155,7 @@ struct gdb_exception
/* Return the contents of the exception message, as a C string. The
string remains owned by the exception object. */
- const char *what () const noexcept
- {
- return message->c_str ();
- }
+ const char *what () const noexcept { return message->c_str (); }
/* Compare two exceptions. */
bool operator== (const gdb_exception &other) const
@@ -172,9 +163,8 @@ struct gdb_exception
const char *msg1 = message == nullptr ? "" : what ();
const char *msg2 = other.message == nullptr ? "" : other.what ();
- return (reason == other.reason
- && error == other.error
- && strcmp (msg1, msg2) == 0);
+ return (reason == other.reason && error == other.error
+ && strcmp (msg1, msg2) == 0);
}
/* Compare two exceptions. */
@@ -199,12 +189,12 @@ struct hash<gdb_exception>
{
size_t result = exc.reason + exc.error;
if (exc.message != nullptr)
- result += std::hash<std::string> {} (*exc.message);
+ result += std::hash<std::string> {}(*exc.message);
return result;
}
};
-}
+} // namespace std
/* Functions to drive the sjlj-based exceptions state machine. Though
declared here by necessity, these functions should be considered
@@ -243,22 +233,20 @@ extern int exceptions_state_mc_catch (struct gdb_exception *, int);
need to cross third-party library code compiled without exceptions
support (e.g., readline). */
-#define TRY_SJLJ \
- { \
- jmp_buf *buf = \
- exceptions_state_mc_init (); \
- setjmp (*buf); \
- } \
- while (exceptions_state_mc_action_iter ()) \
- while (exceptions_state_mc_action_iter_1 ())
-
-#define CATCH_SJLJ(EXCEPTION, MASK) \
- { \
- struct gdb_exception EXCEPTION; \
+#define TRY_SJLJ \
+ { \
+ jmp_buf *buf = exceptions_state_mc_init (); \
+ setjmp (*buf); \
+ } \
+ while (exceptions_state_mc_action_iter ()) \
+ while (exceptions_state_mc_action_iter_1 ())
+
+#define CATCH_SJLJ(EXCEPTION, MASK) \
+ { \
+ struct gdb_exception EXCEPTION; \
if (exceptions_state_mc_catch (&(EXCEPTION), MASK))
-#define END_CATCH_SJLJ \
- }
+#define END_CATCH_SJLJ }
/* The exception types client code may catch. They're just shims
around gdb_exception that add nothing but type info. Which is used
@@ -281,8 +269,7 @@ struct gdb_exception_error : public gdb_exception
struct gdb_exception_quit : public gdb_exception
{
- gdb_exception_quit (const char *fmt, va_list ap)
- ATTRIBUTE_PRINTF (2, 0)
+ gdb_exception_quit (const char *fmt, va_list ap) ATTRIBUTE_PRINTF (2, 0)
: gdb_exception (RETURN_QUIT, GDB_NO_ERROR, fmt, ap)
{
}
@@ -300,9 +287,7 @@ struct gdb_exception_quit : public gdb_exception
allocation error to be caught by all the CATCH/RETURN_MASK_ALL
spread around the codebase. */
-struct gdb_quit_bad_alloc
- : public gdb_exception_quit,
- public std::bad_alloc
+struct gdb_quit_bad_alloc : public gdb_exception_quit, public std::bad_alloc
{
explicit gdb_quit_bad_alloc (gdb_exception &&ex) noexcept
: gdb_exception_quit (std::move (ex)),
@@ -316,25 +301,25 @@ struct gdb_quit_bad_alloc
/* Throw an exception (as described by "struct gdb_exception"),
landing in the inner most containing exception handler established
using TRY/CATCH. */
-extern void throw_exception (gdb_exception &&exception)
- ATTRIBUTE_NORETURN;
+extern void throw_exception (gdb_exception &&exception) ATTRIBUTE_NORETURN;
/* Throw an exception by executing a LONG JUMP to the inner most
containing exception handler established using TRY_SJLJ. Necessary
in some cases where we need to throw GDB exceptions across
third-party library code (e.g., readline). */
extern void throw_exception_sjlj (const struct gdb_exception &exception)
- ATTRIBUTE_NORETURN;
+ ATTRIBUTE_NORETURN;
/* Convenience wrappers around throw_exception that throw GDB
errors. */
-extern void throw_verror (enum errors, const char *fmt, va_list ap)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 0);
-extern void throw_vquit (const char *fmt, va_list ap)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 0);
-extern void throw_error (enum errors error, const char *fmt, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 3);
-extern void throw_quit (const char *fmt, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
+extern void throw_verror (enum errors, const char *fmt,
+ va_list ap) ATTRIBUTE_NORETURN
+ ATTRIBUTE_PRINTF (2, 0);
+extern void throw_vquit (const char *fmt, va_list ap) ATTRIBUTE_NORETURN
+ ATTRIBUTE_PRINTF (1, 0);
+extern void throw_error (enum errors error, const char *fmt,
+ ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 3);
+extern void throw_quit (const char *fmt, ...) ATTRIBUTE_NORETURN
+ ATTRIBUTE_PRINTF (1, 2);
#endif /* COMMON_COMMON_EXCEPTIONS_H */
diff --git a/gdbsupport/common-gdbthread.h b/gdbsupport/common-gdbthread.h
index a0368c3..052b787 100644
--- a/gdbsupport/common-gdbthread.h
+++ b/gdbsupport/common-gdbthread.h
@@ -23,6 +23,6 @@ struct process_stratum_target;
/* Switch from one thread to another. */
extern void switch_to_thread (process_stratum_target *proc_target,
- ptid_t ptid);
+ ptid_t ptid);
#endif /* COMMON_COMMON_GDBTHREAD_H */
diff --git a/gdbsupport/common-inferior.cc b/gdbsupport/common-inferior.cc
index 55149ec..4f9c0e6 100644
--- a/gdbsupport/common-inferior.cc
+++ b/gdbsupport/common-inferior.cc
@@ -28,7 +28,7 @@ bool startup_with_shell = true;
/* See common-inferior.h. */
std::string
-construct_inferior_arguments (gdb::array_view<char * const> argv)
+construct_inferior_arguments (gdb::array_view<char *const> argv)
{
std::string result;
@@ -47,78 +47,78 @@ construct_inferior_arguments (gdb::array_view<char * const> argv)
static const char quote = '\'';
#endif
for (int i = 0; i < argv.size (); ++i)
- {
- if (i > 0)
- result += ' ';
+ {
+ if (i > 0)
+ result += ' ';
- /* Need to handle empty arguments specially. */
- if (argv[i][0] == '\0')
- {
- result += quote;
- result += quote;
- }
- else
- {
+ /* Need to handle empty arguments specially. */
+ if (argv[i][0] == '\0')
+ {
+ result += quote;
+ result += quote;
+ }
+ else
+ {
#ifdef __MINGW32__
- bool quoted = false;
+ bool quoted = false;
- if (strpbrk (argv[i], special))
- {
- quoted = true;
- result += quote;
- }
+ if (strpbrk (argv[i], special))
+ {
+ quoted = true;
+ result += quote;
+ }
#endif
- for (char *cp = argv[i]; *cp; ++cp)
- {
- if (*cp == '\n')
- {
- /* A newline cannot be quoted with a backslash (it
+ for (char *cp = argv[i]; *cp; ++cp)
+ {
+ if (*cp == '\n')
+ {
+ /* A newline cannot be quoted with a backslash (it
just disappears), only by putting it inside
quotes. */
- result += quote;
- result += '\n';
- result += quote;
- }
- else
- {
+ result += quote;
+ result += '\n';
+ result += quote;
+ }
+ else
+ {
#ifdef __MINGW32__
- if (*cp == quote)
+ if (*cp == quote)
#else
- if (strchr (special, *cp) != NULL)
+ if (strchr (special, *cp) != NULL)
#endif
- result += '\\';
- result += *cp;
- }
- }
+ result += '\\';
+ result += *cp;
+ }
+ }
#ifdef __MINGW32__
- if (quoted)
- result += quote;
+ if (quoted)
+ result += quote;
#endif
- }
- }
+ }
+ }
}
else
{
/* In this case we can't handle arguments that contain spaces,
tabs, or newlines -- see breakup_args(). */
for (char *arg : argv)
- {
- char *cp = strchr (arg, ' ');
- if (cp == NULL)
- cp = strchr (arg, '\t');
- if (cp == NULL)
- cp = strchr (arg, '\n');
- if (cp != NULL)
- error (_("can't handle command-line "
- "argument containing whitespace"));
- }
+ {
+ char *cp = strchr (arg, ' ');
+ if (cp == NULL)
+ cp = strchr (arg, '\t');
+ if (cp == NULL)
+ cp = strchr (arg, '\n');
+ if (cp != NULL)
+ error (_ ("can't handle command-line "
+ "argument containing whitespace"));
+ }
for (int i = 0; i < argv.size (); ++i)
- {
- if (i > 0)
- result += " ";
- result += argv[i];
- }
+ {
+ if (i > 0)
+ result += " ";
+ result += argv[i];
+ }
}
return result;
diff --git a/gdbsupport/common-inferior.h b/gdbsupport/common-inferior.h
index c468c7b..0b5b487 100644
--- a/gdbsupport/common-inferior.h
+++ b/gdbsupport/common-inferior.h
@@ -59,7 +59,6 @@ extern bool startup_with_shell;
/* Compute command-line string given argument vector. This does the
same shell processing as fork_inferior. */
-extern std::string
-construct_inferior_arguments (gdb::array_view<char * const>);
+extern std::string construct_inferior_arguments (gdb::array_view<char *const>);
#endif /* COMMON_COMMON_INFERIOR_H */
diff --git a/gdbsupport/common-regcache.cc b/gdbsupport/common-regcache.cc
index 3515bed..c2d2b9a 100644
--- a/gdbsupport/common-regcache.cc
+++ b/gdbsupport/common-regcache.cc
@@ -30,7 +30,7 @@ regcache_raw_get_unsigned (struct regcache *regcache, int regnum)
status = regcache_raw_read_unsigned (regcache, regnum, &value);
if (status == REG_UNAVAILABLE)
- throw_error (NOT_AVAILABLE_ERROR,
- _("Register %d is not available"), regnum);
+ throw_error (NOT_AVAILABLE_ERROR, _ ("Register %d is not available"),
+ regnum);
return value;
}
diff --git a/gdbsupport/common-regcache.h b/gdbsupport/common-regcache.h
index e462f53..551b769 100644
--- a/gdbsupport/common-regcache.h
+++ b/gdbsupport/common-regcache.h
@@ -23,22 +23,22 @@
/* This header is a stopgap until we have an independent regcache. */
enum register_status : signed char
- {
- /* The register value is not in the cache, and we don't know yet
+{
+ /* The register value is not in the cache, and we don't know yet
whether it's available in the target (or traceframe). */
- REG_UNKNOWN = 0,
+ REG_UNKNOWN = 0,
- /* The register value is valid and cached. */
- REG_VALID = 1,
+ /* The register value is valid and cached. */
+ REG_VALID = 1,
- /* The register value is unavailable. E.g., we're inspecting a
+ /* The register value is unavailable. E.g., we're inspecting a
traceframe, and this register wasn't collected. Note that this
is different a different "unavailable" from saying the register
does not exist in the target's architecture --- in that case,
the target should have given us a target description that does
not include the register in the first place. */
- REG_UNAVAILABLE = -1
- };
+ REG_UNAVAILABLE = -1
+};
/* Return a pointer to the register cache associated with the
thread specified by PTID. This function must be provided by
@@ -62,8 +62,9 @@ extern CORE_ADDR regcache_read_pc (struct regcache *regcache);
extern CORE_ADDR regcache_read_pc_protected (regcache *regcache);
/* Read a raw register into a unsigned integer. */
-extern enum register_status regcache_raw_read_unsigned
- (struct regcache *regcache, int regnum, ULONGEST *val);
+extern enum register_status
+regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
+ ULONGEST *val);
ULONGEST regcache_raw_get_unsigned (struct regcache *regcache, int regnum);
diff --git a/gdbsupport/common-types.h b/gdbsupport/common-types.h
index e863d65..8d39a15 100644
--- a/gdbsupport/common-types.h
+++ b/gdbsupport/common-types.h
@@ -39,6 +39,11 @@ typedef uint64_t ULONGEST;
/* * The largest ULONGEST value. */
#define ULONGEST_MAX (~(ULONGEST) 0)
-enum tribool { TRIBOOL_UNKNOWN = -1, TRIBOOL_FALSE = 0, TRIBOOL_TRUE = 1 };
+enum tribool
+{
+ TRIBOOL_UNKNOWN = -1,
+ TRIBOOL_FALSE = 0,
+ TRIBOOL_TRUE = 1
+};
#endif /* COMMON_COMMON_TYPES_H */
diff --git a/gdbsupport/common-utils.cc b/gdbsupport/common-utils.cc
index e382fb2..e6ea18a 100644
--- a/gdbsupport/common-utils.cc
+++ b/gdbsupport/common-utils.cc
@@ -54,7 +54,7 @@ xstrvprintf (const char *format, va_list ap)
status (the printed length) with a non-NULL buffer should never
happen, but just to be sure. */
if (ret == NULL || status < 0)
- internal_error (_("vasprintf call failed"));
+ internal_error (_ ("vasprintf call failed"));
return gdb::unique_xmalloc_ptr<char> (ret);
}
@@ -75,7 +75,7 @@ xsnprintf (char *str, size_t size, const char *format, ...)
/* See documentation in common-utils.h. */
std::string
-string_printf (const char* fmt, ...)
+string_printf (const char *fmt, ...)
{
va_list vp;
int size;
@@ -89,7 +89,7 @@ string_printf (const char* fmt, ...)
/* C++11 and later guarantee std::string uses contiguous memory and
always includes the terminating '\0'. */
va_start (vp, fmt);
- vsprintf (&str[0], fmt, vp); /* ARI: vsprintf */
+ vsprintf (&str[0], fmt, vp); /* ARI: vsprintf */
va_end (vp);
return str;
@@ -98,7 +98,7 @@ string_printf (const char* fmt, ...)
/* See documentation in common-utils.h. */
std::string
-string_vprintf (const char* fmt, va_list args)
+string_vprintf (const char *fmt, va_list args)
{
va_list vp;
size_t size;
@@ -116,7 +116,6 @@ string_vprintf (const char* fmt, va_list args)
return str;
}
-
/* See documentation in common-utils.h. */
std::string &
@@ -131,7 +130,6 @@ string_appendf (std::string &str, const char *fmt, ...)
return str;
}
-
/* See documentation in common-utils.h. */
std::string &
@@ -182,41 +180,41 @@ extract_string_maybe_quoted (const char **arg)
while (*p != '\0')
{
if (ISSPACE (*p) && !squote && !dquote && !bsquote)
- break;
+ break;
else
- {
- if (bsquote)
- {
- bsquote = false;
- result += *p;
- }
- else if (*p == '\\')
- bsquote = true;
- else if (squote)
- {
- if (*p == '\'')
- squote = false;
- else
- result += *p;
- }
- else if (dquote)
- {
- if (*p == '"')
- dquote = false;
- else
- result += *p;
- }
- else
- {
- if (*p == '\'')
- squote = true;
- else if (*p == '"')
- dquote = true;
- else
- result += *p;
- }
- p++;
- }
+ {
+ if (bsquote)
+ {
+ bsquote = false;
+ result += *p;
+ }
+ else if (*p == '\\')
+ bsquote = true;
+ else if (squote)
+ {
+ if (*p == '\'')
+ squote = false;
+ else
+ result += *p;
+ }
+ else if (dquote)
+ {
+ if (*p == '"')
+ dquote = false;
+ else
+ result += *p;
+ }
+ else
+ {
+ if (*p == '\'')
+ squote = true;
+ else if (*p == '"')
+ dquote = true;
+ else
+ result += *p;
+ }
+ p++;
+ }
}
*arg = p;
@@ -277,11 +275,11 @@ strtoulst (const char *num, const char **trailer, int base)
if (base == 0 || base == 16)
{
if (num[i] == '0' && (num[i + 1] == 'x' || num[i + 1] == 'X'))
- {
- i += 2;
- if (base == 0)
- base = 16;
- }
+ {
+ i += 2;
+ if (base == 0)
+ base = 16;
+ }
}
if (base == 0 && num[i] == '0')
@@ -303,13 +301,13 @@ strtoulst (const char *num, const char **trailer, int base)
high_part = high_part * base + (unsigned int) (result >> HIGH_BYTE_POSN);
result &= ((ULONGEST) 1 << HIGH_BYTE_POSN) - 1;
if (high_part > 0xff)
- {
- errno = ERANGE;
- result = ~ (ULONGEST) 0;
- high_part = 0;
- minus = 0;
- break;
- }
+ {
+ errno = ERANGE;
+ result = ~(ULONGEST) 0;
+ high_part = 0;
+ minus = 0;
+ break;
+ }
}
if (trailer != NULL)
@@ -383,7 +381,7 @@ ULONGEST
align_up (ULONGEST v, int n)
{
/* Check that N is really a power of two. */
- gdb_assert (n && (n & (n-1)) == 0);
+ gdb_assert (n && (n & (n - 1)) == 0);
return (v + n - 1) & -n;
}
@@ -393,7 +391,7 @@ ULONGEST
align_down (ULONGEST v, int n)
{
/* Check that N is really a power of two. */
- gdb_assert (n && (n & (n-1)) == 0);
+ gdb_assert (n && (n & (n - 1)) == 0);
return (v & -n);
}
@@ -409,7 +407,7 @@ fromhex (int a)
else if (a >= 'A' && a <= 'F')
return a - 'A' + 10;
else
- error (_("Invalid hex digit %d"), a);
+ error (_ ("Invalid hex digit %d"), a);
}
/* See gdbsupport/common-utils.h. */
@@ -422,11 +420,11 @@ hex2bin (const char *hex, gdb_byte *bin, int count)
for (i = 0; i < count; i++)
{
if (hex[0] == 0 || hex[1] == 0)
- {
- /* Hex string is short, or of uneven length.
+ {
+ /* Hex string is short, or of uneven length.
Return the count that has been converted so far. */
- return i;
- }
+ return i;
+ }
*bin++ = fromhex (hex[0]) * 16 + fromhex (hex[1]);
hex += 2;
}
diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h
index 97dcb9f..b171c3b 100644
--- a/gdbsupport/common-utils.h
+++ b/gdbsupport/common-utils.h
@@ -28,9 +28,9 @@
#include "gdb_string_view.h"
#if defined HAVE_LIBXXHASH
-# include <xxhash.h>
+#include <xxhash.h>
#else
-# include "hashtab.h"
+#include "hashtab.h"
#endif
/* xmalloc(), xrealloc() and xcalloc() have already been declared in
@@ -42,29 +42,28 @@ void *xzalloc (size_t);
/* Like asprintf and vasprintf, but return the string, throw an error
if no memory. */
gdb::unique_xmalloc_ptr<char> xstrprintf (const char *format, ...)
- ATTRIBUTE_PRINTF (1, 2);
+ ATTRIBUTE_PRINTF (1, 2);
gdb::unique_xmalloc_ptr<char> xstrvprintf (const char *format, va_list ap)
- ATTRIBUTE_PRINTF (1, 0);
+ ATTRIBUTE_PRINTF (1, 0);
/* Like snprintf, but throw an error if the output buffer is too small. */
int xsnprintf (char *str, size_t size, const char *format, ...)
- ATTRIBUTE_PRINTF (3, 4);
+ ATTRIBUTE_PRINTF (3, 4);
/* Returns a std::string built from a printf-style format string. */
-std::string string_printf (const char* fmt, ...)
- ATTRIBUTE_PRINTF (1, 2);
+std::string string_printf (const char *fmt, ...) ATTRIBUTE_PRINTF (1, 2);
/* Like string_printf, but takes a va_list. */
-std::string string_vprintf (const char* fmt, va_list args)
+std::string string_vprintf (const char *fmt, va_list args)
ATTRIBUTE_PRINTF (1, 0);
/* Like string_printf, but appends to DEST instead of returning a new
std::string. */
-std::string &string_appendf (std::string &dest, const char* fmt, ...)
+std::string &string_appendf (std::string &dest, const char *fmt, ...)
ATTRIBUTE_PRINTF (2, 3);
/* Like string_appendf, but takes a va_list. */
-std::string &string_vappendf (std::string &dest, const char* fmt, va_list args)
+std::string &string_vappendf (std::string &dest, const char *fmt, va_list args)
ATTRIBUTE_PRINTF (2, 0);
/* Make a copy of the string at PTR with LEN characters
@@ -96,7 +95,8 @@ static inline bool
startswith (gdb::string_view string, gdb::string_view pattern)
{
return (string.length () >= pattern.length ()
- && strncmp (string.data (), pattern.data (), pattern.length ()) == 0);
+ && strncmp (string.data (), pattern.data (), pattern.length ())
+ == 0);
}
/* Return true if the strings are equal. */
@@ -141,7 +141,7 @@ extern void free_vector_argv (std::vector<char *> &v);
/* Return true if VALUE is in [LOW, HIGH]. */
-template <typename T>
+template<typename T>
static bool
in_inclusive_range (T value, T low, T high)
{
@@ -221,7 +221,9 @@ namespace gdb
struct string_view_hash
{
std::size_t operator() (gdb::string_view view) const
- { return fast_hash (view.data (), view.length ()); }
+ {
+ return fast_hash (view.data (), view.length ());
+ }
};
} /* namespace gdb */
diff --git a/gdbsupport/def-vector.h b/gdbsupport/def-vector.h
index 4d1df41..bdbf2d8 100644
--- a/gdbsupport/def-vector.h
+++ b/gdbsupport/def-vector.h
@@ -21,15 +21,16 @@
#include <vector>
#include "gdbsupport/default-init-alloc.h"
-namespace gdb {
+namespace gdb
+{
/* A vector that uses an allocator that default constructs using
default-initialization rather than value-initialization. The idea
is to use this when you don't want zero-initialization of elements
of vectors of trivial types. E.g., byte buffers. */
-template<typename T> using def_vector
- = std::vector<T, gdb::default_init_allocator<T>>;
+template<typename T>
+using def_vector = std::vector<T, gdb::default_init_allocator<T>>;
} /* namespace gdb */
diff --git a/gdbsupport/default-init-alloc.h b/gdbsupport/default-init-alloc.h
index 9c8b5a2..79fc709 100644
--- a/gdbsupport/default-init-alloc.h
+++ b/gdbsupport/default-init-alloc.h
@@ -18,7 +18,8 @@
#ifndef COMMON_DEFAULT_INIT_ALLOC_H
#define COMMON_DEFAULT_INIT_ALLOC_H
-namespace gdb {
+namespace gdb
+{
/* An allocator that default constructs using default-initialization
rather than value-initialization. The idea is to use this when you
@@ -54,9 +55,9 @@ public:
/* .. and provide an override/overload for the case of default
construction (i.e., no arguments). This is where we construct
with default-init. */
- template <typename U>
- void construct (U *ptr)
- noexcept (std::is_nothrow_default_constructible<U>::value)
+ template<typename U>
+ void
+ construct (U *ptr) noexcept (std::is_nothrow_default_constructible<U>::value)
{
::new ((void *) ptr) U; /* default-init */
}
diff --git a/gdbsupport/eintr.h b/gdbsupport/eintr.h
index f78d0ec..3bb7693 100644
--- a/gdbsupport/eintr.h
+++ b/gdbsupport/eintr.h
@@ -51,7 +51,7 @@ namespace gdb
template<typename ErrorValType, typename Fun, typename... Args>
inline auto
-handle_eintr (ErrorValType errval, const Fun &f, const Args &... args)
+handle_eintr (ErrorValType errval, const Fun &f, const Args &...args)
-> decltype (f (args...))
{
decltype (f (args...)) ret;
diff --git a/gdbsupport/enum-flags.h b/gdbsupport/enum-flags.h
index 700037f..da24b41 100644
--- a/gdbsupport/enum-flags.h
+++ b/gdbsupport/enum-flags.h
@@ -56,8 +56,8 @@
/* Use this to mark an enum as flags enum. It defines FLAGS_TYPE as
enum_flags wrapper class for ENUM, and enables the global operator
overloads for ENUM. */
-#define DEF_ENUM_FLAGS_TYPE(enum_type, flags_type) \
- typedef enum_flags<enum_type> flags_type; \
+#define DEF_ENUM_FLAGS_TYPE(enum_type, flags_type) \
+ typedef enum_flags<enum_type> flags_type; \
void is_enum_flags_enum_type (enum_type *)
/* To enable the global enum_flags operators for enum, declare an
@@ -78,22 +78,57 @@
/* Note that std::underlying_type<enum_type> is not what we want here,
since that returns unsigned int even when the enum decays to signed
int. */
-template<int size, bool sign> class integer_for_size { typedef void type; };
-template<> struct integer_for_size<1, 0> { typedef uint8_t type; };
-template<> struct integer_for_size<2, 0> { typedef uint16_t type; };
-template<> struct integer_for_size<4, 0> { typedef uint32_t type; };
-template<> struct integer_for_size<8, 0> { typedef uint64_t type; };
-template<> struct integer_for_size<1, 1> { typedef int8_t type; };
-template<> struct integer_for_size<2, 1> { typedef int16_t type; };
-template<> struct integer_for_size<4, 1> { typedef int32_t type; };
-template<> struct integer_for_size<8, 1> { typedef int64_t type; };
+template<int size, bool sign>
+class integer_for_size
+{
+ typedef void type;
+};
+template<>
+struct integer_for_size<1, 0>
+{
+ typedef uint8_t type;
+};
+template<>
+struct integer_for_size<2, 0>
+{
+ typedef uint16_t type;
+};
+template<>
+struct integer_for_size<4, 0>
+{
+ typedef uint32_t type;
+};
+template<>
+struct integer_for_size<8, 0>
+{
+ typedef uint64_t type;
+};
+template<>
+struct integer_for_size<1, 1>
+{
+ typedef int8_t type;
+};
+template<>
+struct integer_for_size<2, 1>
+{
+ typedef int16_t type;
+};
+template<>
+struct integer_for_size<4, 1>
+{
+ typedef int32_t type;
+};
+template<>
+struct integer_for_size<8, 1>
+{
+ typedef int64_t type;
+};
template<typename T>
struct enum_underlying_type
{
- typedef typename
- integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
- type;
+ typedef typename integer_for_size<sizeof (T), static_cast<bool> (
+ T (-1) < T (0))>::type type;
};
namespace enum_flags_detail
@@ -114,16 +149,16 @@ namespace enum_flags_detail
struct zero_type;
/* gdb::Requires trait helpers. */
-template <typename enum_type>
+template<typename enum_type>
using EnumIsUnsigned
= std::is_unsigned<typename enum_underlying_type<enum_type>::type>;
-template <typename enum_type>
+template<typename enum_type>
using EnumIsSigned
= std::is_signed<typename enum_underlying_type<enum_type>::type>;
-}
+} // namespace enum_flags_detail
-template <typename E>
+template<typename E>
class enum_flags
{
public:
@@ -139,24 +174,24 @@ public:
/* Convenience for to_string implementations, to build a
string_mapping array. */
-#define MAP_ENUM_FLAG(ENUM_FLAG) { ENUM_FLAG, #ENUM_FLAG }
+#define MAP_ENUM_FLAG(ENUM_FLAG) \
+ { \
+ ENUM_FLAG, #ENUM_FLAG \
+ }
public:
/* Allow default construction. */
- constexpr enum_flags ()
- : m_enum_value ((enum_type) 0)
- {}
+ constexpr enum_flags () : m_enum_value ((enum_type) 0) {}
/* The default move/copy ctor/assignment do the right thing. */
/* If you get an error saying these two overloads are ambiguous,
then you tried to mix values of different enum types. */
- constexpr enum_flags (enum_type e)
- : m_enum_value (e)
- {}
+ constexpr enum_flags (enum_type e) : m_enum_value (e) {}
constexpr enum_flags (enum_flags_detail::zero_type *zero)
: m_enum_value ((enum_type) 0)
- {}
+ {
+ }
enum_flags &operator&= (enum_flags e) &
{
@@ -180,16 +215,10 @@ public:
void operator^= (enum_flags e) && = delete;
/* Like raw enums, allow conversion to the underlying type. */
- constexpr operator underlying_type () const
- {
- return m_enum_value;
- }
+ constexpr operator underlying_type () const { return m_enum_value; }
/* Get the underlying value as a raw enum. */
- constexpr enum_type raw () const
- {
- return m_enum_value;
- }
+ constexpr enum_type raw () const { return m_enum_value; }
/* Binary operations involving some unrelated type (which would be a
bug) are implemented as non-members, and deleted. */
@@ -212,7 +241,7 @@ private:
enum_type m_enum_value;
};
-template <typename E>
+template<typename E>
using is_enum_flags_enum_type_t
= decltype (is_enum_flags_enum_type (std::declval<E *> ()));
@@ -220,60 +249,69 @@ using is_enum_flags_enum_type_t
/* Generate binary operators. */
-#define ENUM_FLAGS_GEN_BINOP(OPERATOR_OP, OP) \
- \
- /* Raw enum on both LHS/RHS. Returns raw enum type. */ \
- template <typename enum_type, \
- typename = is_enum_flags_enum_type_t<enum_type>> \
- constexpr enum_type \
- OPERATOR_OP (enum_type e1, enum_type e2) \
- { \
- using underlying = typename enum_flags<enum_type>::underlying_type; \
- return (enum_type) (underlying (e1) OP underlying (e2)); \
- } \
- \
- /* enum_flags on the LHS. */ \
- template <typename enum_type, \
- typename = is_enum_flags_enum_type_t<enum_type>> \
- constexpr enum_flags<enum_type> \
- OPERATOR_OP (enum_flags<enum_type> e1, enum_type e2) \
- { return e1.raw () OP e2; } \
- \
- /* enum_flags on the RHS. */ \
- template <typename enum_type, \
- typename = is_enum_flags_enum_type_t<enum_type>> \
- constexpr enum_flags<enum_type> \
- OPERATOR_OP (enum_type e1, enum_flags<enum_type> e2) \
- { return e1 OP e2.raw (); } \
- \
- /* enum_flags on both LHS/RHS. */ \
- template <typename enum_type, \
- typename = is_enum_flags_enum_type_t<enum_type>> \
- constexpr enum_flags<enum_type> \
- OPERATOR_OP (enum_flags<enum_type> e1, enum_flags<enum_type> e2) \
- { return e1.raw () OP e2.raw (); } \
- \
- /* Delete cases involving unrelated types. */ \
- \
- template <typename enum_type, typename unrelated_type, \
- typename = is_enum_flags_enum_type_t<enum_type>> \
- constexpr enum_flags<enum_type> \
- OPERATOR_OP (enum_type e1, unrelated_type e2) = delete; \
- \
- template <typename enum_type, typename unrelated_type, \
- typename = is_enum_flags_enum_type_t<enum_type>> \
- constexpr enum_flags<enum_type> \
- OPERATOR_OP (unrelated_type e1, enum_type e2) = delete; \
- \
- template <typename enum_type, typename unrelated_type, \
- typename = is_enum_flags_enum_type_t<enum_type>> \
- constexpr enum_flags<enum_type> \
- OPERATOR_OP (enum_flags<enum_type> e1, unrelated_type e2) = delete; \
- \
- template <typename enum_type, typename unrelated_type, \
- typename = is_enum_flags_enum_type_t<enum_type>> \
- constexpr enum_flags<enum_type> \
- OPERATOR_OP (unrelated_type e1, enum_flags<enum_type> e2) = delete;
+#define ENUM_FLAGS_GEN_BINOP(OPERATOR_OP, OP) \
+ \
+ /* Raw enum on both LHS/RHS. Returns raw enum type. */ \
+ template<typename enum_type, \
+ typename = is_enum_flags_enum_type_t<enum_type>> \
+ constexpr enum_type OPERATOR_OP (enum_type e1, enum_type e2) \
+ { \
+ using underlying = typename enum_flags<enum_type>::underlying_type; \
+ return (enum_type) (underlying (e1) OP underlying (e2)); \
+ } \
+ \
+ /* enum_flags on the LHS. */ \
+ template<typename enum_type, \
+ typename = is_enum_flags_enum_type_t<enum_type>> \
+ constexpr enum_flags<enum_type> OPERATOR_OP (enum_flags<enum_type> e1, \
+ enum_type e2) \
+ { \
+ return e1.raw () OP e2; \
+ } \
+ \
+ /* enum_flags on the RHS. */ \
+ template<typename enum_type, \
+ typename = is_enum_flags_enum_type_t<enum_type>> \
+ constexpr enum_flags<enum_type> OPERATOR_OP (enum_type e1, \
+ enum_flags<enum_type> e2) \
+ { \
+ return e1 OP e2.raw (); \
+ } \
+ \
+ /* enum_flags on both LHS/RHS. */ \
+ template<typename enum_type, \
+ typename = is_enum_flags_enum_type_t<enum_type>> \
+ constexpr enum_flags<enum_type> OPERATOR_OP (enum_flags<enum_type> e1, \
+ enum_flags<enum_type> e2) \
+ { \
+ return e1.raw () OP e2.raw (); \
+ } \
+ \
+ /* Delete cases involving unrelated types. */ \
+ \
+ template<typename enum_type, typename unrelated_type, \
+ typename = is_enum_flags_enum_type_t<enum_type>> \
+ constexpr enum_flags<enum_type> OPERATOR_OP (enum_type e1, \
+ unrelated_type e2) \
+ = delete; \
+ \
+ template<typename enum_type, typename unrelated_type, \
+ typename = is_enum_flags_enum_type_t<enum_type>> \
+ constexpr enum_flags<enum_type> OPERATOR_OP (unrelated_type e1, \
+ enum_type e2) \
+ = delete; \
+ \
+ template<typename enum_type, typename unrelated_type, \
+ typename = is_enum_flags_enum_type_t<enum_type>> \
+ constexpr enum_flags<enum_type> OPERATOR_OP (enum_flags<enum_type> e1, \
+ unrelated_type e2) \
+ = delete; \
+ \
+ template<typename enum_type, typename unrelated_type, \
+ typename = is_enum_flags_enum_type_t<enum_type>> \
+ constexpr enum_flags<enum_type> OPERATOR_OP (unrelated_type e1, \
+ enum_flags<enum_type> e2) \
+ = delete;
/* Generate non-member compound assignment operators. Only the raw
enum versions are defined here. The enum_flags versions are
@@ -295,31 +333,30 @@ using is_enum_flags_enum_type_t
If you really need to 'or' enumerators of different flag types,
cast to integer first.
*/
-#define ENUM_FLAGS_GEN_COMPOUND_ASSIGN(OPERATOR_OP, OP) \
- /* lval reference version. */ \
- template <typename enum_type, \
- typename = is_enum_flags_enum_type_t<enum_type>> \
- constexpr enum_type & \
- OPERATOR_OP (enum_type &e1, enum_type e2) \
- { return e1 = e1 OP e2; } \
- \
- /* rval reference version. */ \
- template <typename enum_type, \
- typename = is_enum_flags_enum_type_t<enum_type>> \
- void \
- OPERATOR_OP (enum_type &&e1, enum_type e2) = delete; \
- \
- /* Delete compound assignment from unrelated types. */ \
- \
- template <typename enum_type, typename other_enum_type, \
- typename = is_enum_flags_enum_type_t<enum_type>> \
- constexpr enum_type & \
- OPERATOR_OP (enum_type &e1, other_enum_type e2) = delete; \
- \
- template <typename enum_type, typename other_enum_type, \
- typename = is_enum_flags_enum_type_t<enum_type>> \
- void \
- OPERATOR_OP (enum_type &&e1, other_enum_type e2) = delete;
+#define ENUM_FLAGS_GEN_COMPOUND_ASSIGN(OPERATOR_OP, OP) \
+ /* lval reference version. */ \
+ template<typename enum_type, \
+ typename = is_enum_flags_enum_type_t<enum_type>> \
+ constexpr enum_type &OPERATOR_OP (enum_type &e1, enum_type e2) \
+ { \
+ return e1 = e1 OP e2; \
+ } \
+ \
+ /* rval reference version. */ \
+ template<typename enum_type, \
+ typename = is_enum_flags_enum_type_t<enum_type>> \
+ void OPERATOR_OP (enum_type &&e1, enum_type e2) = delete; \
+ \
+ /* Delete compound assignment from unrelated types. */ \
+ \
+ template<typename enum_type, typename other_enum_type, \
+ typename = is_enum_flags_enum_type_t<enum_type>> \
+ constexpr enum_type &OPERATOR_OP (enum_type &e1, other_enum_type e2) \
+ = delete; \
+ \
+ template<typename enum_type, typename other_enum_type, \
+ typename = is_enum_flags_enum_type_t<enum_type>> \
+ void OPERATOR_OP (enum_type &&e1, other_enum_type e2) = delete;
ENUM_FLAGS_GEN_BINOP (operator|, |)
ENUM_FLAGS_GEN_BINOP (operator&, &)
@@ -338,46 +375,50 @@ ENUM_FLAGS_GEN_COMPOUND_ASSIGN (operator^=, ^)
convertion to underlying type too, would trigger the built-in 'bool
operator==(unsigned, int)' operator. */
-#define ENUM_FLAGS_GEN_COMP(OPERATOR_OP, OP) \
- \
- /* enum_flags OP enum_flags */ \
- \
- template <typename enum_type> \
- constexpr bool \
- OPERATOR_OP (enum_flags<enum_type> lhs, enum_flags<enum_type> rhs) \
- { return lhs.raw () OP rhs.raw (); } \
- \
- /* enum_flags OP other */ \
- \
- template <typename enum_type> \
- constexpr bool \
- OPERATOR_OP (enum_flags<enum_type> lhs, enum_type rhs) \
- { return lhs.raw () OP rhs; } \
- \
- template <typename enum_type> \
- constexpr bool \
- OPERATOR_OP (enum_flags<enum_type> lhs, int rhs) \
- { return lhs.raw () OP rhs; } \
- \
- template <typename enum_type, typename U> \
- constexpr bool \
- OPERATOR_OP (enum_flags<enum_type> lhs, U rhs) = delete; \
- \
- /* other OP enum_flags */ \
- \
- template <typename enum_type> \
- constexpr bool \
- OPERATOR_OP (enum_type lhs, enum_flags<enum_type> rhs) \
- { return lhs OP rhs.raw (); } \
- \
- template <typename enum_type> \
- constexpr bool \
- OPERATOR_OP (int lhs, enum_flags<enum_type> rhs) \
- { return lhs OP rhs.raw (); } \
- \
- template <typename enum_type, typename U> \
- constexpr bool \
- OPERATOR_OP (U lhs, enum_flags<enum_type> rhs) = delete;
+#define ENUM_FLAGS_GEN_COMP(OPERATOR_OP, OP) \
+ \
+ /* enum_flags OP enum_flags */ \
+ \
+ template<typename enum_type> \
+ constexpr bool OPERATOR_OP (enum_flags<enum_type> lhs, \
+ enum_flags<enum_type> rhs) \
+ { \
+ return lhs.raw () OP rhs.raw (); \
+ } \
+ \
+ /* enum_flags OP other */ \
+ \
+ template<typename enum_type> \
+ constexpr bool OPERATOR_OP (enum_flags<enum_type> lhs, enum_type rhs) \
+ { \
+ return lhs.raw () OP rhs; \
+ } \
+ \
+ template<typename enum_type> \
+ constexpr bool OPERATOR_OP (enum_flags<enum_type> lhs, int rhs) \
+ { \
+ return lhs.raw () OP rhs; \
+ } \
+ \
+ template<typename enum_type, typename U> \
+ constexpr bool OPERATOR_OP (enum_flags<enum_type> lhs, U rhs) = delete; \
+ \
+ /* other OP enum_flags */ \
+ \
+ template<typename enum_type> \
+ constexpr bool OPERATOR_OP (enum_type lhs, enum_flags<enum_type> rhs) \
+ { \
+ return lhs OP rhs.raw (); \
+ } \
+ \
+ template<typename enum_type> \
+ constexpr bool OPERATOR_OP (int lhs, enum_flags<enum_type> rhs) \
+ { \
+ return lhs OP rhs.raw (); \
+ } \
+ \
+ template<typename enum_type, typename U> \
+ constexpr bool OPERATOR_OP (U lhs, enum_flags<enum_type> rhs) = delete;
ENUM_FLAGS_GEN_COMP (operator==, ==)
ENUM_FLAGS_GEN_COMP (operator!=, !=)
@@ -388,54 +429,50 @@ ENUM_FLAGS_GEN_COMP (operator!=, !=)
if it were not unsigned, undefined behavior could result. However,
asserting this in the class itself would require too many
unnecessary changes to usages of otherwise OK enum types. */
-template <typename enum_type,
- typename = is_enum_flags_enum_type_t<enum_type>,
- typename
- = gdb::Requires<enum_flags_detail::EnumIsUnsigned<enum_type>>>
+template<typename enum_type, typename = is_enum_flags_enum_type_t<enum_type>,
+ typename
+ = gdb::Requires<enum_flags_detail::EnumIsUnsigned<enum_type>>>
constexpr enum_type
-operator~ (enum_type e)
+operator~(enum_type e)
{
using underlying = typename enum_flags<enum_type>::underlying_type;
return (enum_type) ~underlying (e);
}
-template <typename enum_type,
- typename = is_enum_flags_enum_type_t<enum_type>,
- typename = gdb::Requires<enum_flags_detail::EnumIsSigned<enum_type>>>
-constexpr void operator~ (enum_type e) = delete;
+template<typename enum_type, typename = is_enum_flags_enum_type_t<enum_type>,
+ typename = gdb::Requires<enum_flags_detail::EnumIsSigned<enum_type>>>
+constexpr void operator~(enum_type e) = delete;
-template <typename enum_type,
- typename = is_enum_flags_enum_type_t<enum_type>,
- typename
- = gdb::Requires<enum_flags_detail::EnumIsUnsigned<enum_type>>>
+template<typename enum_type, typename = is_enum_flags_enum_type_t<enum_type>,
+ typename
+ = gdb::Requires<enum_flags_detail::EnumIsUnsigned<enum_type>>>
constexpr enum_flags<enum_type>
-operator~ (enum_flags<enum_type> e)
+operator~(enum_flags<enum_type> e)
{
using underlying = typename enum_flags<enum_type>::underlying_type;
return (enum_type) ~underlying (e);
}
-template <typename enum_type,
- typename = is_enum_flags_enum_type_t<enum_type>,
- typename = gdb::Requires<enum_flags_detail::EnumIsSigned<enum_type>>>
-constexpr void operator~ (enum_flags<enum_type> e) = delete;
+template<typename enum_type, typename = is_enum_flags_enum_type_t<enum_type>,
+ typename = gdb::Requires<enum_flags_detail::EnumIsSigned<enum_type>>>
+constexpr void operator~(enum_flags<enum_type> e) = delete;
/* Delete operator<< and operator>>. */
-template <typename enum_type, typename any_type,
- typename = is_enum_flags_enum_type_t<enum_type>>
+template<typename enum_type, typename any_type,
+ typename = is_enum_flags_enum_type_t<enum_type>>
void operator<< (const enum_type &, const any_type &) = delete;
-template <typename enum_type, typename any_type,
- typename = is_enum_flags_enum_type_t<enum_type>>
+template<typename enum_type, typename any_type,
+ typename = is_enum_flags_enum_type_t<enum_type>>
void operator<< (const enum_flags<enum_type> &, const any_type &) = delete;
-template <typename enum_type, typename any_type,
- typename = is_enum_flags_enum_type_t<enum_type>>
+template<typename enum_type, typename any_type,
+ typename = is_enum_flags_enum_type_t<enum_type>>
void operator>> (const enum_type &, const any_type &) = delete;
-template <typename enum_type, typename any_type,
- typename = is_enum_flags_enum_type_t<enum_type>>
+template<typename enum_type, typename any_type,
+ typename = is_enum_flags_enum_type_t<enum_type>>
void operator>> (const enum_flags<enum_type> &, const any_type &) = delete;
template<typename E>
@@ -451,20 +488,20 @@ enum_flags<E>::to_string (const string_mapping (&mapping)[N]) const
for (const auto &entry : mapping)
{
if ((flags & entry.flag) != 0)
- {
- /* Work with an unsigned version of the underlying type,
+ {
+ /* Work with an unsigned version of the underlying type,
because if enum_type's underlying type is signed, op~
won't be defined for it, and, bitwise operations on
signed types are implementation defined. */
- using uns = typename std::make_unsigned<underlying_type>::type;
- flags &= (enum_type) ~(uns) entry.flag;
+ using uns = typename std::make_unsigned<underlying_type>::type;
+ flags &= (enum_type) ~(uns) entry.flag;
- if (need_space)
- res += " ";
- res += entry.str;
+ if (need_space)
+ res += " ";
+ res += entry.str;
- need_space = true;
- }
+ need_space = true;
+ }
}
/* If there were flags not included in the mapping, print them as
@@ -472,7 +509,7 @@ enum_flags<E>::to_string (const string_mapping (&mapping)[N]) const
if (flags != 0)
{
if (need_space)
- res += " ";
+ res += " ";
res += hex_string (flags);
}
@@ -485,8 +522,7 @@ enum_flags<E>::to_string (const string_mapping (&mapping)[N]) const
/* In C, the flags type is just a typedef for the enum type. */
-#define DEF_ENUM_FLAGS_TYPE(enum_type, flags_type) \
- typedef enum_type flags_type
+#define DEF_ENUM_FLAGS_TYPE(enum_type, flags_type) typedef enum_type flags_type
#endif /* __cplusplus */
diff --git a/gdbsupport/environ.cc b/gdbsupport/environ.cc
index d4d8129..36c8e56 100644
--- a/gdbsupport/environ.cc
+++ b/gdbsupport/environ.cc
@@ -43,7 +43,8 @@ gdb_environ::operator= (gdb_environ &&e)
/* See gdbsupport/environ.h. */
-gdb_environ gdb_environ::from_host_environ ()
+gdb_environ
+gdb_environ::from_host_environ ()
{
extern char **environ;
gdb_environ e;
@@ -55,7 +56,7 @@ gdb_environ gdb_environ::from_host_environ ()
{
/* Make sure we add the element before the last (NULL). */
e.m_environ_vector.insert (e.m_environ_vector.end () - 1,
- xstrdup (environ[i]));
+ xstrdup (environ[i]));
}
return e;
@@ -137,8 +138,7 @@ gdb_environ::unset (const char *var, bool update_unset_list)
/* We iterate until '.end () - 1' because the last element is
always NULL. */
for (it_env = m_environ_vector.begin ();
- it_env != m_environ_vector.end () - 1;
- ++it_env)
+ it_env != m_environ_vector.end () - 1; ++it_env)
if (match_var_in_string (*it_env, var, len))
break;
diff --git a/gdbsupport/environ.h b/gdbsupport/environ.h
index b6d30ce..df844bc 100644
--- a/gdbsupport/environ.h
+++ b/gdbsupport/environ.h
@@ -35,10 +35,7 @@ public:
m_environ_vector.push_back (NULL);
}
- ~gdb_environ ()
- {
- clear ();
- }
+ ~gdb_environ () { clear (); }
/* Move constructor. */
gdb_environ (gdb_environ &&e)
diff --git a/gdbsupport/errors.cc b/gdbsupport/errors.cc
index 566be37..b5b9cf9 100644
--- a/gdbsupport/errors.cc
+++ b/gdbsupport/errors.cc
@@ -19,7 +19,7 @@
#include "common-defs.h"
#include "errors.h"
-#if defined (USE_WIN32API) || defined(__CYGWIN__)
+#if defined(USE_WIN32API) || defined(__CYGWIN__)
#include <windows.h>
#endif /* USE_WIN32API */
@@ -71,7 +71,7 @@ internal_warning_loc (const char *file, int line, const char *fmt, ...)
va_end (ap);
}
-#if defined (USE_WIN32API) || defined(__CYGWIN__)
+#if defined(USE_WIN32API) || defined(__CYGWIN__)
/* See errors.h. */
@@ -82,29 +82,23 @@ strwinerror (ULONGEST error)
TCHAR *msgbuf;
DWORD lasterr = GetLastError ();
DWORD chars = FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM
- | FORMAT_MESSAGE_ALLOCATE_BUFFER,
- NULL,
- error,
- 0, /* Default language */
- (LPTSTR) &msgbuf,
- 0,
- NULL);
+ | FORMAT_MESSAGE_ALLOCATE_BUFFER,
+ NULL, error, 0, /* Default language */
+ (LPTSTR) &msgbuf, 0, NULL);
if (chars != 0)
{
/* If there is an \r\n appended, zap it. */
- if (chars >= 2
- && msgbuf[chars - 2] == '\r'
- && msgbuf[chars - 1] == '\n')
- {
- chars -= 2;
- msgbuf[chars] = 0;
- }
+ if (chars >= 2 && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n')
+ {
+ chars -= 2;
+ msgbuf[chars] = 0;
+ }
if (chars > ARRAY_SIZE (buf) - 1)
- {
- chars = ARRAY_SIZE (buf) - 1;
- msgbuf [chars] = 0;
- }
+ {
+ chars = ARRAY_SIZE (buf) - 1;
+ msgbuf[chars] = 0;
+ }
#ifdef UNICODE
wcstombs (buf, msgbuf, chars + 1);
diff --git a/gdbsupport/errors.h b/gdbsupport/errors.h
index 2304bc1..5dc2d69 100644
--- a/gdbsupport/errors.h
+++ b/gdbsupport/errors.h
@@ -25,22 +25,20 @@
vprintf-style argument list. The function "vwarning" must be
provided by the client. */
-extern void warning (const char *fmt, ...)
- ATTRIBUTE_PRINTF (1, 2);
+extern void warning (const char *fmt, ...) ATTRIBUTE_PRINTF (1, 2);
-extern void vwarning (const char *fmt, va_list args)
- ATTRIBUTE_PRINTF (1, 0);
+extern void vwarning (const char *fmt, va_list args) ATTRIBUTE_PRINTF (1, 0);
/* A non-predictable, non-fatal error was detected. The requested
operation cannot proceed. An error message is constructed using
a printf- or vprintf-style argument list. These functions do not
return. The function "verror" must be provided by the client. */
-extern void error (const char *fmt, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
+extern void error (const char *fmt, ...) ATTRIBUTE_NORETURN
+ ATTRIBUTE_PRINTF (1, 2);
-extern void verror (const char *fmt, va_list args)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 0);
+extern void verror (const char *fmt, va_list args) ATTRIBUTE_NORETURN
+ ATTRIBUTE_PRINTF (1, 0);
/* An internal error was detected. Internal errors indicate
programming errors such as assertion failures, as opposed to
@@ -53,16 +51,16 @@ extern void verror (const char *fmt, va_list args)
automatically. The function "internal_verror" must be provided
by the client. */
-extern void internal_error_loc (const char *file, int line,
- const char *fmt, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 4);
+extern void internal_error_loc (const char *file, int line, const char *fmt,
+ ...) ATTRIBUTE_NORETURN
+ ATTRIBUTE_PRINTF (3, 4);
-#define internal_error(fmt, ...) \
+#define internal_error(fmt, ...) \
internal_error_loc (__FILE__, __LINE__, fmt, ##__VA_ARGS__)
-extern void internal_verror (const char *file, int line,
- const char *fmt, va_list args)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 0);
+extern void internal_verror (const char *file, int line, const char *fmt,
+ va_list args) ATTRIBUTE_NORETURN
+ ATTRIBUTE_PRINTF (3, 0);
/* An internal problem was detected, but the requested operation can
still proceed. Internal warnings indicate programming errors as
@@ -71,17 +69,14 @@ extern void internal_verror (const char *file, int line,
argument list. The function "internal_vwarning" must be provided
by the client. */
-extern void internal_warning_loc (const char *file, int line,
- const char *fmt, ...)
- ATTRIBUTE_PRINTF (3, 4);
+extern void internal_warning_loc (const char *file, int line, const char *fmt,
+ ...) ATTRIBUTE_PRINTF (3, 4);
-#define internal_warning(fmt, ...) \
+#define internal_warning(fmt, ...) \
internal_warning_loc (__FILE__, __LINE__, fmt, ##__VA_ARGS__)
-extern void internal_vwarning (const char *file, int line,
- const char *fmt, va_list args)
- ATTRIBUTE_PRINTF (3, 0);
-
+extern void internal_vwarning (const char *file, int line, const char *fmt,
+ va_list args) ATTRIBUTE_PRINTF (3, 0);
/* Like "error", but the error message is constructed by combining
STRING with the system error message for errno. This function does
diff --git a/gdbsupport/event-loop.cc b/gdbsupport/event-loop.cc
index 52e7fd2..f9260f7 100644
--- a/gdbsupport/event-loop.cc
+++ b/gdbsupport/event-loop.cc
@@ -23,9 +23,9 @@
#include <chrono>
#ifdef HAVE_POLL
-#if defined (HAVE_POLL_H)
+#if defined(HAVE_POLL_H)
#include <poll.h>
-#elif defined (HAVE_SYS_POLL_H)
+#elif defined(HAVE_SYS_POLL_H)
#include <sys/poll.h>
#endif
#endif
@@ -43,9 +43,9 @@ debug_event_loop_kind debug_event_loop;
/* Tell create_file_handler what events we are interested in.
This is used by the select version of the event loop. */
-#define GDB_READABLE (1<<1)
-#define GDB_WRITABLE (1<<2)
-#define GDB_EXCEPTION (1<<3)
+#define GDB_READABLE (1 << 1)
+#define GDB_WRITABLE (1 << 2)
+#define GDB_EXCEPTION (1 << 3)
/* Information about each file descriptor we register with the event
loop. */
@@ -101,81 +101,79 @@ static bool use_poll = true;
in, for each fd. */
static struct
- {
- /* Ptr to head of file handler list. */
- file_handler *first_file_handler;
+{
+ /* Ptr to head of file handler list. */
+ file_handler *first_file_handler;
- /* Next file handler to handle, for the select variant. To level
+ /* Next file handler to handle, for the select variant. To level
the fairness across event sources, we serve file handlers in a
round-robin-like fashion. The number and order of the polled
file handlers may change between invocations, but this is good
enough. */
- file_handler *next_file_handler;
+ file_handler *next_file_handler;
#ifdef HAVE_POLL
- /* Ptr to array of pollfd structures. */
- struct pollfd *poll_fds;
+ /* Ptr to array of pollfd structures. */
+ struct pollfd *poll_fds;
- /* Next file descriptor to handle, for the poll variant. To level
+ /* Next file descriptor to handle, for the poll variant. To level
the fairness across event sources, we poll the file descriptors
in a round-robin-like fashion. The number and order of the
polled file descriptors may change between invocations, but
this is good enough. */
- int next_poll_fds_index;
+ int next_poll_fds_index;
- /* Timeout in milliseconds for calls to poll(). */
- int poll_timeout;
+ /* Timeout in milliseconds for calls to poll(). */
+ int poll_timeout;
#endif
- /* Masks to be used in the next call to select.
+ /* Masks to be used in the next call to select.
Bits are set in response to calls to create_file_handler. */
- fd_set check_masks[3];
+ fd_set check_masks[3];
- /* What file descriptors were found ready by select. */
- fd_set ready_masks[3];
+ /* What file descriptors were found ready by select. */
+ fd_set ready_masks[3];
- /* Number of file descriptors to monitor (for poll). */
- /* Number of valid bits (highest fd value + 1) (for select). */
- int num_fds;
+ /* Number of file descriptors to monitor (for poll). */
+ /* Number of valid bits (highest fd value + 1) (for select). */
+ int num_fds;
- /* Time structure for calls to select(). */
- struct timeval select_timeout;
+ /* Time structure for calls to select(). */
+ struct timeval select_timeout;
- /* Flag to tell whether the timeout should be used. */
- int timeout_valid;
- }
-gdb_notifier;
+ /* Flag to tell whether the timeout should be used. */
+ int timeout_valid;
+} gdb_notifier;
/* Structure associated with a timer. PROC will be executed at the
first occasion after WHEN. */
struct gdb_timer
- {
- std::chrono::steady_clock::time_point when;
- int timer_id;
- struct gdb_timer *next;
- timer_handler_func *proc; /* Function to call to do the work. */
- gdb_client_data client_data; /* Argument to async_handler_func. */
- };
+{
+ std::chrono::steady_clock::time_point when;
+ int timer_id;
+ struct gdb_timer *next;
+ timer_handler_func *proc; /* Function to call to do the work. */
+ gdb_client_data client_data; /* Argument to async_handler_func. */
+};
/* List of currently active timers. It is sorted in order of
increasing timers. */
static struct
- {
- /* Pointer to first in timer list. */
- struct gdb_timer *first_timer;
+{
+ /* Pointer to first in timer list. */
+ struct gdb_timer *first_timer;
- /* Id of the last timer created. */
- int num_timers;
- }
-timer_list;
+ /* Id of the last timer created. */
+ int num_timers;
+} timer_list;
static void create_file_handler (int fd, int mask, handler_func *proc,
- gdb_client_data client_data,
- std::string &&name, bool is_ui);
+ gdb_client_data client_data,
+ std::string &&name, bool is_ui);
static int gdb_wait_for_event (int);
static int update_wait_timeout (void);
static int poll_timers (void);
-
+
/* Process one high level event. If nothing is ready at this time,
wait at most MSTIMEOUT milliseconds for something to happen (via
gdb_wait_for_event), then process it. Returns >0 if something was
@@ -206,35 +204,35 @@ gdb_do_one_event (int mstimeout)
int res;
switch (event_source_head)
- {
- case 0:
- /* Are any timers that are ready? */
- res = poll_timers ();
- break;
- case 1:
- /* Are there events already waiting to be collected on the
+ {
+ case 0:
+ /* Are any timers that are ready? */
+ res = poll_timers ();
+ break;
+ case 1:
+ /* Are there events already waiting to be collected on the
monitored file descriptors? */
- res = gdb_wait_for_event (0);
- break;
- case 2:
- /* Are there any asynchronous event handlers ready? */
- res = check_async_event_handlers ();
- break;
- default:
- internal_error ("unexpected event_source_head %d",
- event_source_head);
- }
+ res = gdb_wait_for_event (0);
+ break;
+ case 2:
+ /* Are there any asynchronous event handlers ready? */
+ res = check_async_event_handlers ();
+ break;
+ default:
+ internal_error ("unexpected event_source_head %d",
+ event_source_head);
+ }
event_source_head++;
if (event_source_head == number_of_sources)
- event_source_head = 0;
+ event_source_head = 0;
if (res > 0)
- return 1;
+ return 1;
}
if (mstimeout == 0)
- return 0; /* 0ms timeout: do not wait for an event. */
+ return 0; /* 0ms timeout: do not wait for an event. */
/* Block waiting for a new event. If gdb_wait_for_event returns -1,
we should get out because this means that there are no event
@@ -248,19 +246,17 @@ gdb_do_one_event (int mstimeout)
gdb::optional<int> timer_id;
- SCOPE_EXIT
- {
- if (timer_id.has_value ())
- delete_timer (*timer_id);
- };
+ SCOPE_EXIT
+ {
+ if (timer_id.has_value ())
+ delete_timer (*timer_id);
+ };
if (mstimeout > 0)
- timer_id = create_timer (mstimeout,
- [] (gdb_client_data arg)
- {
- ((gdb::optional<int> *) arg)->reset ();
- },
- &timer_id);
+ timer_id = create_timer (
+ mstimeout,
+ [] (gdb_client_data arg) { ((gdb::optional<int> *) arg)->reset (); },
+ &timer_id);
return gdb_wait_for_event (1);
}
@@ -268,7 +264,7 @@ gdb_do_one_event (int mstimeout)
void
add_file_handler (int fd, handler_func *proc, gdb_client_data client_data,
- std::string &&name, bool is_ui)
+ std::string &&name, bool is_ui)
{
#ifdef HAVE_POLL
if (use_poll)
@@ -283,17 +279,17 @@ add_file_handler (int fd, handler_func *proc, gdb_client_data client_data,
fds.fd = fd;
fds.events = POLLIN;
if (poll (&fds, 1, 0) == 1 && (fds.revents & POLLNVAL))
- use_poll = false;
+ use_poll = false;
}
if (use_poll)
{
create_file_handler (fd, POLLIN, proc, client_data, std::move (name),
- is_ui);
+ is_ui);
}
else
#endif /* HAVE_POLL */
- create_file_handler (fd, GDB_READABLE | GDB_EXCEPTION,
- proc, client_data, std::move (name), is_ui);
+ create_file_handler (fd, GDB_READABLE | GDB_EXCEPTION, proc, client_data,
+ std::move (name), is_ui);
}
/* Helper for add_file_handler.
@@ -308,9 +304,9 @@ add_file_handler (int fd, handler_func *proc, gdb_client_data client_data,
occurs for FD. CLIENT_DATA is the argument to pass to PROC. */
static void
-create_file_handler (int fd, int mask, handler_func * proc,
- gdb_client_data client_data, std::string &&name,
- bool is_ui)
+create_file_handler (int fd, int mask, handler_func *proc,
+ gdb_client_data client_data, std::string &&name,
+ bool is_ui)
{
file_handler *file_ptr;
@@ -320,7 +316,7 @@ create_file_handler (int fd, int mask, handler_func * proc,
file_ptr = file_ptr->next_file)
{
if (file_ptr->fd == fd)
- break;
+ break;
}
/* It is a new file descriptor. Add it to the list. Otherwise, just
@@ -335,41 +331,40 @@ create_file_handler (int fd, int mask, handler_func * proc,
#ifdef HAVE_POLL
if (use_poll)
- {
- gdb_notifier.num_fds++;
- if (gdb_notifier.poll_fds)
- gdb_notifier.poll_fds =
- (struct pollfd *) xrealloc (gdb_notifier.poll_fds,
- (gdb_notifier.num_fds
- * sizeof (struct pollfd)));
- else
- gdb_notifier.poll_fds =
- XNEW (struct pollfd);
- (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->fd = fd;
- (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->events = mask;
- (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->revents = 0;
- }
+ {
+ gdb_notifier.num_fds++;
+ if (gdb_notifier.poll_fds)
+ gdb_notifier.poll_fds
+ = (struct pollfd *) xrealloc (gdb_notifier.poll_fds,
+ (gdb_notifier.num_fds
+ * sizeof (struct pollfd)));
+ else
+ gdb_notifier.poll_fds = XNEW (struct pollfd);
+ (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->fd = fd;
+ (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->events = mask;
+ (gdb_notifier.poll_fds + gdb_notifier.num_fds - 1)->revents = 0;
+ }
else
#endif /* HAVE_POLL */
- {
- if (mask & GDB_READABLE)
- FD_SET (fd, &gdb_notifier.check_masks[0]);
- else
- FD_CLR (fd, &gdb_notifier.check_masks[0]);
-
- if (mask & GDB_WRITABLE)
- FD_SET (fd, &gdb_notifier.check_masks[1]);
- else
- FD_CLR (fd, &gdb_notifier.check_masks[1]);
-
- if (mask & GDB_EXCEPTION)
- FD_SET (fd, &gdb_notifier.check_masks[2]);
- else
- FD_CLR (fd, &gdb_notifier.check_masks[2]);
-
- if (gdb_notifier.num_fds <= fd)
- gdb_notifier.num_fds = fd + 1;
- }
+ {
+ if (mask & GDB_READABLE)
+ FD_SET (fd, &gdb_notifier.check_masks[0]);
+ else
+ FD_CLR (fd, &gdb_notifier.check_masks[0]);
+
+ if (mask & GDB_WRITABLE)
+ FD_SET (fd, &gdb_notifier.check_masks[1]);
+ else
+ FD_CLR (fd, &gdb_notifier.check_masks[1]);
+
+ if (mask & GDB_EXCEPTION)
+ FD_SET (fd, &gdb_notifier.check_masks[2]);
+ else
+ FD_CLR (fd, &gdb_notifier.check_masks[2]);
+
+ if (gdb_notifier.num_fds <= fd)
+ gdb_notifier.num_fds = fd + 1;
+ }
}
file_ptr->proc = proc;
@@ -418,7 +413,7 @@ delete_file_handler (int fd)
file_ptr = file_ptr->next_file)
{
if (file_ptr->fd == fd)
- break;
+ break;
}
if (file_ptr == NULL)
@@ -433,20 +428,20 @@ delete_file_handler (int fd)
/* Create a new poll_fds array by copying every fd's information
but the one we want to get rid of. */
- new_poll_fds = (struct pollfd *)
- xmalloc ((gdb_notifier.num_fds - 1) * sizeof (struct pollfd));
+ new_poll_fds = (struct pollfd *) xmalloc ((gdb_notifier.num_fds - 1)
+ * sizeof (struct pollfd));
for (i = 0, j = 0; i < gdb_notifier.num_fds; i++)
- {
- if ((gdb_notifier.poll_fds + i)->fd != fd)
- {
- (new_poll_fds + j)->fd = (gdb_notifier.poll_fds + i)->fd;
- (new_poll_fds + j)->events = (gdb_notifier.poll_fds + i)->events;
- (new_poll_fds + j)->revents
- = (gdb_notifier.poll_fds + i)->revents;
- j++;
- }
- }
+ {
+ if ((gdb_notifier.poll_fds + i)->fd != fd)
+ {
+ (new_poll_fds + j)->fd = (gdb_notifier.poll_fds + i)->fd;
+ (new_poll_fds + j)->events = (gdb_notifier.poll_fds + i)->events;
+ (new_poll_fds + j)->revents
+ = (gdb_notifier.poll_fds + i)->revents;
+ j++;
+ }
+ }
xfree (gdb_notifier.poll_fds);
gdb_notifier.poll_fds = new_poll_fds;
gdb_notifier.num_fds--;
@@ -455,26 +450,26 @@ delete_file_handler (int fd)
#endif /* HAVE_POLL */
{
if (file_ptr->mask & GDB_READABLE)
- FD_CLR (fd, &gdb_notifier.check_masks[0]);
+ FD_CLR (fd, &gdb_notifier.check_masks[0]);
if (file_ptr->mask & GDB_WRITABLE)
- FD_CLR (fd, &gdb_notifier.check_masks[1]);
+ FD_CLR (fd, &gdb_notifier.check_masks[1]);
if (file_ptr->mask & GDB_EXCEPTION)
- FD_CLR (fd, &gdb_notifier.check_masks[2]);
+ FD_CLR (fd, &gdb_notifier.check_masks[2]);
/* Find current max fd. */
if ((fd + 1) == gdb_notifier.num_fds)
- {
- gdb_notifier.num_fds--;
- for (i = gdb_notifier.num_fds; i; i--)
- {
- if (FD_ISSET (i - 1, &gdb_notifier.check_masks[0])
- || FD_ISSET (i - 1, &gdb_notifier.check_masks[1])
- || FD_ISSET (i - 1, &gdb_notifier.check_masks[2]))
- break;
- }
- gdb_notifier.num_fds = i;
- }
+ {
+ gdb_notifier.num_fds--;
+ for (i = gdb_notifier.num_fds; i; i--)
+ {
+ if (FD_ISSET (i - 1, &gdb_notifier.check_masks[0])
+ || FD_ISSET (i - 1, &gdb_notifier.check_masks[1])
+ || FD_ISSET (i - 1, &gdb_notifier.check_masks[2]))
+ break;
+ }
+ gdb_notifier.num_fds = i;
+ }
}
/* Deactivate the file descriptor, by clearing its mask,
@@ -487,10 +482,10 @@ delete_file_handler (int fd)
if (gdb_notifier.next_file_handler == file_ptr)
{
if (file_ptr->next_file == NULL
- && file_ptr == gdb_notifier.first_file_handler)
- gdb_notifier.next_file_handler = NULL;
+ && file_ptr == gdb_notifier.first_file_handler)
+ gdb_notifier.next_file_handler = NULL;
else
- get_next_file_handler_to_handle_and_advance ();
+ get_next_file_handler_to_handle_and_advance ();
}
/* Get rid of the file handler in the file handler list. */
@@ -499,9 +494,8 @@ delete_file_handler (int fd)
else
{
for (prev_ptr = gdb_notifier.first_file_handler;
- prev_ptr->next_file != file_ptr;
- prev_ptr = prev_ptr->next_file)
- ;
+ prev_ptr->next_file != file_ptr; prev_ptr = prev_ptr->next_file)
+ ;
prev_ptr->next_file = file_ptr->next_file;
}
@@ -537,30 +531,28 @@ handle_file_event (file_handler *file_ptr, int ready_mask)
mask = ready_mask & (file_ptr->mask | error_mask);
if ((mask & (POLLERR | POLLNVAL)) != 0)
- {
- /* Work in progress. We may need to tell somebody
+ {
+ /* Work in progress. We may need to tell somebody
what kind of error we had. */
- if (mask & POLLERR)
- warning (_("Error detected on fd %d"), file_ptr->fd);
- if (mask & POLLNVAL)
- warning (_("Invalid or non-`poll'able fd %d"),
- file_ptr->fd);
- file_ptr->error = 1;
- }
+ if (mask & POLLERR)
+ warning (_ ("Error detected on fd %d"), file_ptr->fd);
+ if (mask & POLLNVAL)
+ warning (_ ("Invalid or non-`poll'able fd %d"), file_ptr->fd);
+ file_ptr->error = 1;
+ }
else
- file_ptr->error = 0;
+ file_ptr->error = 0;
}
else
#endif /* HAVE_POLL */
{
if (ready_mask & GDB_EXCEPTION)
- {
- warning (_("Exception condition detected on fd %d"),
- file_ptr->fd);
- file_ptr->error = 1;
- }
+ {
+ warning (_ ("Exception condition detected on fd %d"), file_ptr->fd);
+ file_ptr->error = 1;
+ }
else
- file_ptr->error = 0;
+ file_ptr->error = 0;
mask = ready_mask & file_ptr->mask;
}
@@ -568,8 +560,8 @@ handle_file_event (file_handler *file_ptr, int ready_mask)
if (mask != 0)
{
event_loop_ui_debug_printf (file_ptr->is_ui,
- "invoking fd file handler `%s`",
- file_ptr->name.c_str ());
+ "invoking fd file handler `%s`",
+ file_ptr->name.c_str ());
file_ptr->proc (file_ptr->error, file_ptr->client_data);
}
}
@@ -602,17 +594,17 @@ gdb_wait_for_event (int block)
int timeout;
if (block)
- timeout = gdb_notifier.timeout_valid ? gdb_notifier.poll_timeout : -1;
+ timeout = gdb_notifier.timeout_valid ? gdb_notifier.poll_timeout : -1;
else
- timeout = 0;
+ timeout = 0;
num_found = poll (gdb_notifier.poll_fds,
- (unsigned long) gdb_notifier.num_fds, timeout);
+ (unsigned long) gdb_notifier.num_fds, timeout);
/* Don't print anything if we get out of poll because of a
signal. */
if (num_found == -1 && errno != EINTR)
- perror_with_name (("poll"));
+ perror_with_name (("poll"));
}
else
#endif /* HAVE_POLL */
@@ -621,47 +613,46 @@ gdb_wait_for_event (int block)
struct timeval *timeout_p;
if (block)
- timeout_p = gdb_notifier.timeout_valid
- ? &gdb_notifier.select_timeout : NULL;
+ timeout_p
+ = gdb_notifier.timeout_valid ? &gdb_notifier.select_timeout : NULL;
else
- {
- memset (&select_timeout, 0, sizeof (select_timeout));
- timeout_p = &select_timeout;
- }
+ {
+ memset (&select_timeout, 0, sizeof (select_timeout));
+ timeout_p = &select_timeout;
+ }
gdb_notifier.ready_masks[0] = gdb_notifier.check_masks[0];
gdb_notifier.ready_masks[1] = gdb_notifier.check_masks[1];
gdb_notifier.ready_masks[2] = gdb_notifier.check_masks[2];
- num_found = gdb_select (gdb_notifier.num_fds,
- &gdb_notifier.ready_masks[0],
- &gdb_notifier.ready_masks[1],
- &gdb_notifier.ready_masks[2],
- timeout_p);
+ num_found
+ = gdb_select (gdb_notifier.num_fds, &gdb_notifier.ready_masks[0],
+ &gdb_notifier.ready_masks[1],
+ &gdb_notifier.ready_masks[2], timeout_p);
/* Clear the masks after an error from select. */
if (num_found == -1)
- {
- FD_ZERO (&gdb_notifier.ready_masks[0]);
- FD_ZERO (&gdb_notifier.ready_masks[1]);
- FD_ZERO (&gdb_notifier.ready_masks[2]);
+ {
+ FD_ZERO (&gdb_notifier.ready_masks[0]);
+ FD_ZERO (&gdb_notifier.ready_masks[1]);
+ FD_ZERO (&gdb_notifier.ready_masks[2]);
- /* Dont print anything if we got a signal, let gdb handle
+ /* Dont print anything if we got a signal, let gdb handle
it. */
- if (errno != EINTR)
- perror_with_name (("select"));
- }
+ if (errno != EINTR)
+ perror_with_name (("select"));
+ }
}
/* Avoid looking at poll_fds[i]->revents if no event fired. */
if (num_found <= 0)
return 0;
- /* Run event handlers. We always run just one handler and go back
+ /* Run event handlers. We always run just one handler and go back
to polling, in case a handler changes the notifier list. Since
events for sources we haven't consumed yet wake poll/select
immediately, no event is lost. */
- /* To level the fairness across event descriptors, we handle them in
+ /* To level the fairness across event descriptors, we handle them in
a round-robin-like fashion. The number and order of descriptors
may change between invocations, but this is good enough. */
#ifdef HAVE_POLL
@@ -671,23 +662,22 @@ gdb_wait_for_event (int block)
int mask;
while (1)
- {
- if (gdb_notifier.next_poll_fds_index >= gdb_notifier.num_fds)
- gdb_notifier.next_poll_fds_index = 0;
- i = gdb_notifier.next_poll_fds_index++;
-
- gdb_assert (i < gdb_notifier.num_fds);
- if ((gdb_notifier.poll_fds + i)->revents)
- break;
- }
-
- for (file_ptr = gdb_notifier.first_file_handler;
- file_ptr != NULL;
- file_ptr = file_ptr->next_file)
- {
- if (file_ptr->fd == (gdb_notifier.poll_fds + i)->fd)
- break;
- }
+ {
+ if (gdb_notifier.next_poll_fds_index >= gdb_notifier.num_fds)
+ gdb_notifier.next_poll_fds_index = 0;
+ i = gdb_notifier.next_poll_fds_index++;
+
+ gdb_assert (i < gdb_notifier.num_fds);
+ if ((gdb_notifier.poll_fds + i)->revents)
+ break;
+ }
+
+ for (file_ptr = gdb_notifier.first_file_handler; file_ptr != NULL;
+ file_ptr = file_ptr->next_file)
+ {
+ if (file_ptr->fd == (gdb_notifier.poll_fds + i)->fd)
+ break;
+ }
gdb_assert (file_ptr != NULL);
mask = (gdb_notifier.poll_fds + i)->revents;
@@ -701,16 +691,16 @@ gdb_wait_for_event (int block)
int mask = 0;
do
- {
- file_ptr = get_next_file_handler_to_handle_and_advance ();
-
- if (FD_ISSET (file_ptr->fd, &gdb_notifier.ready_masks[0]))
- mask |= GDB_READABLE;
- if (FD_ISSET (file_ptr->fd, &gdb_notifier.ready_masks[1]))
- mask |= GDB_WRITABLE;
- if (FD_ISSET (file_ptr->fd, &gdb_notifier.ready_masks[2]))
- mask |= GDB_EXCEPTION;
- }
+ {
+ file_ptr = get_next_file_handler_to_handle_and_advance ();
+
+ if (FD_ISSET (file_ptr->fd, &gdb_notifier.ready_masks[0]))
+ mask |= GDB_READABLE;
+ if (FD_ISSET (file_ptr->fd, &gdb_notifier.ready_masks[1]))
+ mask |= GDB_WRITABLE;
+ if (FD_ISSET (file_ptr->fd, &gdb_notifier.ready_masks[2]))
+ mask |= GDB_EXCEPTION;
+ }
while (mask == 0);
handle_file_event (file_ptr, mask);
@@ -718,15 +708,14 @@ gdb_wait_for_event (int block)
}
return 0;
}
-
+
/* Create a timer that will expire in MS milliseconds from now. When
the timer is ready, PROC will be executed. At creation, the timer
is added to the timers queue. This queue is kept sorted in order
of increasing timers. Return a handle to the timer struct. */
int
-create_timer (int ms, timer_handler_func *proc,
- gdb_client_data client_data)
+create_timer (int ms, timer_handler_func *proc, gdb_client_data client_data)
{
using namespace std::chrono;
struct gdb_timer *timer_ptr, *timer_index, *prev_timer;
@@ -743,26 +732,23 @@ create_timer (int ms, timer_handler_func *proc,
/* Now add the timer to the timer queue, making sure it is sorted in
increasing order of expiration. */
- for (timer_index = timer_list.first_timer;
- timer_index != NULL;
+ for (timer_index = timer_list.first_timer; timer_index != NULL;
timer_index = timer_index->next)
{
if (timer_index->when > timer_ptr->when)
- break;
+ break;
}
if (timer_index == timer_list.first_timer)
{
timer_ptr->next = timer_list.first_timer;
timer_list.first_timer = timer_ptr;
-
}
else
{
for (prev_timer = timer_list.first_timer;
- prev_timer->next != timer_index;
- prev_timer = prev_timer->next)
- ;
+ prev_timer->next != timer_index; prev_timer = prev_timer->next)
+ ;
prev_timer->next = timer_ptr;
timer_ptr->next = timer_index;
@@ -785,7 +771,7 @@ delete_timer (int id)
timer_ptr = timer_ptr->next)
{
if (timer_ptr->timer_id == id)
- break;
+ break;
}
if (timer_ptr == NULL)
@@ -795,10 +781,9 @@ delete_timer (int id)
timer_list.first_timer = timer_ptr->next;
else
{
- for (prev_timer = timer_list.first_timer;
- prev_timer->next != timer_ptr;
- prev_timer = prev_timer->next)
- ;
+ for (prev_timer = timer_list.first_timer; prev_timer->next != timer_ptr;
+ prev_timer = prev_timer->next)
+ ;
prev_timer->next = timer_ptr->next;
}
delete timer_ptr;
@@ -835,31 +820,31 @@ update_wait_timeout (void)
struct timeval timeout;
if (timer_list.first_timer->when < time_now)
- {
- /* It expired already. */
- timeout.tv_sec = 0;
- timeout.tv_usec = 0;
- }
+ {
+ /* It expired already. */
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+ }
else
- {
- steady_clock::duration d = timer_list.first_timer->when - time_now;
- timeout = duration_cast_timeval (d);
- }
+ {
+ steady_clock::duration d = timer_list.first_timer->when - time_now;
+ timeout = duration_cast_timeval (d);
+ }
- /* Update the timeout for select/ poll. */
+ /* Update the timeout for select/ poll. */
#ifdef HAVE_POLL
if (use_poll)
- gdb_notifier.poll_timeout = timeout.tv_sec * 1000;
+ gdb_notifier.poll_timeout = timeout.tv_sec * 1000;
else
#endif /* HAVE_POLL */
- {
- gdb_notifier.select_timeout.tv_sec = timeout.tv_sec;
- gdb_notifier.select_timeout.tv_usec = timeout.tv_usec;
- }
+ {
+ gdb_notifier.select_timeout.tv_sec = timeout.tv_sec;
+ gdb_notifier.select_timeout.tv_usec = timeout.tv_usec;
+ }
gdb_notifier.timeout_valid = 1;
if (timer_list.first_timer->when < time_now)
- return 1;
+ return 1;
}
else
gdb_notifier.timeout_valid = 0;
diff --git a/gdbsupport/event-loop.h b/gdbsupport/event-loop.h
index c931374..a53bdf7 100644
--- a/gdbsupport/event-loop.h
+++ b/gdbsupport/event-loop.h
@@ -89,12 +89,11 @@ extern void delete_file_handler (int fd);
If IS_UI is set, this file descriptor is used for a user interface. */
extern void add_file_handler (int fd, handler_func *proc,
- gdb_client_data client_data,
- std::string &&name, bool is_ui = false);
+ gdb_client_data client_data, std::string &&name,
+ bool is_ui = false);
-extern int create_timer (int milliseconds,
- timer_handler_func *proc,
- gdb_client_data client_data);
+extern int create_timer (int milliseconds, timer_handler_func *proc,
+ gdb_client_data client_data);
extern void delete_timer (int id);
/* Must be defined by client. */
@@ -128,21 +127,21 @@ extern debug_event_loop_kind debug_event_loop;
/* Print an "event loop" debug statement. */
-#define event_loop_debug_printf(fmt, ...) \
+#define event_loop_debug_printf(fmt, ...) \
debug_prefixed_printf_cond (debug_event_loop != debug_event_loop_kind::OFF, \
- "event-loop", fmt, ##__VA_ARGS__)
+ "event-loop", fmt, ##__VA_ARGS__)
/* Print an "event loop" debug statement that is know to come from a UI-related
event (e.g. calling the event handler for the fd of the CLI). */
-#define event_loop_ui_debug_printf(is_ui, fmt, ...) \
- do \
- { \
- if (debug_event_loop == debug_event_loop_kind::ALL \
- || (debug_event_loop == debug_event_loop_kind::ALL_EXCEPT_UI \
- && !is_ui)) \
- debug_prefixed_printf ("event-loop", __func__, fmt, ##__VA_ARGS__); \
- } \
+#define event_loop_ui_debug_printf(is_ui, fmt, ...) \
+ do \
+ { \
+ if (debug_event_loop == debug_event_loop_kind::ALL \
+ || (debug_event_loop == debug_event_loop_kind::ALL_EXCEPT_UI \
+ && !is_ui)) \
+ debug_prefixed_printf ("event-loop", __func__, fmt, ##__VA_ARGS__); \
+ } \
while (0)
#endif /* EVENT_LOOP_H */
diff --git a/gdbsupport/event-pipe.h b/gdbsupport/event-pipe.h
index 999dd4b..a6e2a6a 100644
--- a/gdbsupport/event-pipe.h
+++ b/gdbsupport/event-pipe.h
@@ -28,8 +28,8 @@
class event_pipe
{
public:
- event_pipe() = default;
- ~event_pipe();
+ event_pipe () = default;
+ ~event_pipe ();
DISABLE_COPY_AND_ASSIGN (event_pipe);
@@ -40,19 +40,18 @@ public:
void close_pipe ();
/* True if the event pipe has been opened. */
- bool is_open () const
- { return m_fds[0] != -1; }
+ bool is_open () const { return m_fds[0] != -1; }
/* The file descriptor of the waitable file to use in the event
loop. */
- int event_fd () const
- { return m_fds[0]; }
+ int event_fd () const { return m_fds[0]; }
/* Flush the event pipe. */
void flush ();
/* Put something in the pipe, so the event loop wakes up. */
void mark ();
+
private:
int m_fds[2] = { -1, -1 };
};
diff --git a/gdbsupport/fileio.cc b/gdbsupport/fileio.cc
index 5f4a3ee..e4302e3 100644
--- a/gdbsupport/fileio.cc
+++ b/gdbsupport/fileio.cc
@@ -29,48 +29,48 @@ host_to_fileio_error (int error)
{
switch (error)
{
- case EPERM:
- return FILEIO_EPERM;
- case ENOENT:
- return FILEIO_ENOENT;
- case EINTR:
- return FILEIO_EINTR;
- case EIO:
- return FILEIO_EIO;
- case EBADF:
- return FILEIO_EBADF;
- case EACCES:
- return FILEIO_EACCES;
- case EFAULT:
- return FILEIO_EFAULT;
- case EBUSY:
- return FILEIO_EBUSY;
- case EEXIST:
- return FILEIO_EEXIST;
- case ENODEV:
- return FILEIO_ENODEV;
- case ENOTDIR:
- return FILEIO_ENOTDIR;
- case EISDIR:
- return FILEIO_EISDIR;
- case EINVAL:
- return FILEIO_EINVAL;
- case ENFILE:
- return FILEIO_ENFILE;
- case EMFILE:
- return FILEIO_EMFILE;
- case EFBIG:
- return FILEIO_EFBIG;
- case ENOSPC:
- return FILEIO_ENOSPC;
- case ESPIPE:
- return FILEIO_ESPIPE;
- case EROFS:
- return FILEIO_EROFS;
- case ENOSYS:
- return FILEIO_ENOSYS;
- case ENAMETOOLONG:
- return FILEIO_ENAMETOOLONG;
+ case EPERM:
+ return FILEIO_EPERM;
+ case ENOENT:
+ return FILEIO_ENOENT;
+ case EINTR:
+ return FILEIO_EINTR;
+ case EIO:
+ return FILEIO_EIO;
+ case EBADF:
+ return FILEIO_EBADF;
+ case EACCES:
+ return FILEIO_EACCES;
+ case EFAULT:
+ return FILEIO_EFAULT;
+ case EBUSY:
+ return FILEIO_EBUSY;
+ case EEXIST:
+ return FILEIO_EEXIST;
+ case ENODEV:
+ return FILEIO_ENODEV;
+ case ENOTDIR:
+ return FILEIO_ENOTDIR;
+ case EISDIR:
+ return FILEIO_EISDIR;
+ case EINVAL:
+ return FILEIO_EINVAL;
+ case ENFILE:
+ return FILEIO_ENFILE;
+ case EMFILE:
+ return FILEIO_EMFILE;
+ case EFBIG:
+ return FILEIO_EFBIG;
+ case ENOSPC:
+ return FILEIO_ENOSPC;
+ case ESPIPE:
+ return FILEIO_ESPIPE;
+ case EROFS:
+ return FILEIO_EROFS;
+ case ENOSYS:
+ return FILEIO_ENOSYS;
+ case ENAMETOOLONG:
+ return FILEIO_ENAMETOOLONG;
}
return FILEIO_EUNKNOWN;
}
@@ -82,48 +82,48 @@ fileio_error_to_host (fileio_error errnum)
{
switch (errnum)
{
- case FILEIO_EPERM:
- return EPERM;
- case FILEIO_ENOENT:
- return ENOENT;
- case FILEIO_EINTR:
- return EINTR;
- case FILEIO_EIO:
- return EIO;
- case FILEIO_EBADF:
- return EBADF;
- case FILEIO_EACCES:
- return EACCES;
- case FILEIO_EFAULT:
- return EFAULT;
- case FILEIO_EBUSY:
- return EBUSY;
- case FILEIO_EEXIST:
- return EEXIST;
- case FILEIO_ENODEV:
- return ENODEV;
- case FILEIO_ENOTDIR:
- return ENOTDIR;
- case FILEIO_EISDIR:
- return EISDIR;
- case FILEIO_EINVAL:
- return EINVAL;
- case FILEIO_ENFILE:
- return ENFILE;
- case FILEIO_EMFILE:
- return EMFILE;
- case FILEIO_EFBIG:
- return EFBIG;
- case FILEIO_ENOSPC:
- return ENOSPC;
- case FILEIO_ESPIPE:
- return ESPIPE;
- case FILEIO_EROFS:
- return EROFS;
- case FILEIO_ENOSYS:
- return ENOSYS;
- case FILEIO_ENAMETOOLONG:
- return ENAMETOOLONG;
+ case FILEIO_EPERM:
+ return EPERM;
+ case FILEIO_ENOENT:
+ return ENOENT;
+ case FILEIO_EINTR:
+ return EINTR;
+ case FILEIO_EIO:
+ return EIO;
+ case FILEIO_EBADF:
+ return EBADF;
+ case FILEIO_EACCES:
+ return EACCES;
+ case FILEIO_EFAULT:
+ return EFAULT;
+ case FILEIO_EBUSY:
+ return EBUSY;
+ case FILEIO_EEXIST:
+ return EEXIST;
+ case FILEIO_ENODEV:
+ return ENODEV;
+ case FILEIO_ENOTDIR:
+ return ENOTDIR;
+ case FILEIO_EISDIR:
+ return EISDIR;
+ case FILEIO_EINVAL:
+ return EINVAL;
+ case FILEIO_ENFILE:
+ return ENFILE;
+ case FILEIO_EMFILE:
+ return EMFILE;
+ case FILEIO_EFBIG:
+ return EFBIG;
+ case FILEIO_ENOSPC:
+ return ENOSPC;
+ case FILEIO_ESPIPE:
+ return ESPIPE;
+ case FILEIO_EROFS:
+ return EROFS;
+ case FILEIO_ENOSYS:
+ return ENOSYS;
+ case FILEIO_ENAMETOOLONG:
+ return ENAMETOOLONG;
}
return -1;
}
@@ -152,7 +152,7 @@ fileio_to_host_openflags (int fileio_open_flags, int *open_flags_p)
open_flags |= O_WRONLY;
if (fileio_open_flags & FILEIO_O_RDWR)
open_flags |= O_RDWR;
- /* On systems supporting binary and text mode, always open files
+ /* On systems supporting binary and text mode, always open files
in binary mode. */
#ifdef O_BINARY
open_flags |= O_BINARY;
@@ -298,9 +298,8 @@ host_to_fileio_stat (struct stat *st, struct fio_stat *fst)
/* FIXME: This is correct for DJGPP, but other systems that don't
have st_blocks, if any, might prefer 512 instead of st_blksize.
(eliz, 30-12-2003) */
- host_to_fileio_ulong (((LONGEST) st->st_size + blksize - 1)
- / blksize,
- fst->fst_blocks);
+ host_to_fileio_ulong (((LONGEST) st->st_size + blksize - 1) / blksize,
+ fst->fst_blocks);
#endif
host_to_fileio_time (st->st_atime, fst->fst_atime);
host_to_fileio_time (st->st_mtime, fst->fst_mtime);
diff --git a/gdbsupport/fileio.h b/gdbsupport/fileio.h
index 690ee21..4a62d9a 100644
--- a/gdbsupport/fileio.h
+++ b/gdbsupport/fileio.h
@@ -29,76 +29,75 @@
corresponding implementation dependent constants in one module. */
/* open(2) flags */
-#define FILEIO_O_RDONLY 0x0
-#define FILEIO_O_WRONLY 0x1
-#define FILEIO_O_RDWR 0x2
-#define FILEIO_O_APPEND 0x8
-#define FILEIO_O_CREAT 0x200
-#define FILEIO_O_TRUNC 0x400
-#define FILEIO_O_EXCL 0x800
-#define FILEIO_O_SUPPORTED (FILEIO_O_RDONLY | FILEIO_O_WRONLY| \
- FILEIO_O_RDWR | FILEIO_O_APPEND| \
- FILEIO_O_CREAT | FILEIO_O_TRUNC| \
- FILEIO_O_EXCL)
+#define FILEIO_O_RDONLY 0x0
+#define FILEIO_O_WRONLY 0x1
+#define FILEIO_O_RDWR 0x2
+#define FILEIO_O_APPEND 0x8
+#define FILEIO_O_CREAT 0x200
+#define FILEIO_O_TRUNC 0x400
+#define FILEIO_O_EXCL 0x800
+#define FILEIO_O_SUPPORTED \
+ (FILEIO_O_RDONLY | FILEIO_O_WRONLY | FILEIO_O_RDWR | FILEIO_O_APPEND \
+ | FILEIO_O_CREAT | FILEIO_O_TRUNC | FILEIO_O_EXCL)
/* mode_t bits */
-#define FILEIO_S_IFREG 0100000
-#define FILEIO_S_IFDIR 040000
-#define FILEIO_S_IFCHR 020000
-#define FILEIO_S_IRUSR 0400
-#define FILEIO_S_IWUSR 0200
-#define FILEIO_S_IXUSR 0100
-#define FILEIO_S_IRWXU 0700
-#define FILEIO_S_IRGRP 040
-#define FILEIO_S_IWGRP 020
-#define FILEIO_S_IXGRP 010
-#define FILEIO_S_IRWXG 070
-#define FILEIO_S_IROTH 04
-#define FILEIO_S_IWOTH 02
-#define FILEIO_S_IXOTH 01
-#define FILEIO_S_IRWXO 07
-#define FILEIO_S_SUPPORTED (FILEIO_S_IFREG|FILEIO_S_IFDIR| \
- FILEIO_S_IRWXU|FILEIO_S_IRWXG| \
- FILEIO_S_IRWXO)
+#define FILEIO_S_IFREG 0100000
+#define FILEIO_S_IFDIR 040000
+#define FILEIO_S_IFCHR 020000
+#define FILEIO_S_IRUSR 0400
+#define FILEIO_S_IWUSR 0200
+#define FILEIO_S_IXUSR 0100
+#define FILEIO_S_IRWXU 0700
+#define FILEIO_S_IRGRP 040
+#define FILEIO_S_IWGRP 020
+#define FILEIO_S_IXGRP 010
+#define FILEIO_S_IRWXG 070
+#define FILEIO_S_IROTH 04
+#define FILEIO_S_IWOTH 02
+#define FILEIO_S_IXOTH 01
+#define FILEIO_S_IRWXO 07
+#define FILEIO_S_SUPPORTED \
+ (FILEIO_S_IFREG | FILEIO_S_IFDIR | FILEIO_S_IRWXU | FILEIO_S_IRWXG \
+ | FILEIO_S_IRWXO)
/* lseek(2) flags */
-#define FILEIO_SEEK_SET 0
-#define FILEIO_SEEK_CUR 1
-#define FILEIO_SEEK_END 2
+#define FILEIO_SEEK_SET 0
+#define FILEIO_SEEK_CUR 1
+#define FILEIO_SEEK_END 2
/* errno values */
enum fileio_error
{
- FILEIO_SUCCESS = 0,
- FILEIO_EPERM = 1,
- FILEIO_ENOENT = 2,
- FILEIO_EINTR = 4,
- FILEIO_EIO = 5,
- FILEIO_EBADF = 9,
- FILEIO_EACCES = 13,
- FILEIO_EFAULT = 14,
- FILEIO_EBUSY = 16,
- FILEIO_EEXIST = 17,
- FILEIO_ENODEV = 19,
- FILEIO_ENOTDIR = 20,
- FILEIO_EISDIR = 21,
- FILEIO_EINVAL = 22,
- FILEIO_ENFILE = 23,
- FILEIO_EMFILE = 24,
- FILEIO_EFBIG = 27,
- FILEIO_ENOSPC = 28,
- FILEIO_ESPIPE = 29,
- FILEIO_EROFS = 30,
- FILEIO_ENOSYS = 88,
- FILEIO_ENAMETOOLONG = 91,
- FILEIO_EUNKNOWN = 9999,
+ FILEIO_SUCCESS = 0,
+ FILEIO_EPERM = 1,
+ FILEIO_ENOENT = 2,
+ FILEIO_EINTR = 4,
+ FILEIO_EIO = 5,
+ FILEIO_EBADF = 9,
+ FILEIO_EACCES = 13,
+ FILEIO_EFAULT = 14,
+ FILEIO_EBUSY = 16,
+ FILEIO_EEXIST = 17,
+ FILEIO_ENODEV = 19,
+ FILEIO_ENOTDIR = 20,
+ FILEIO_EISDIR = 21,
+ FILEIO_EINVAL = 22,
+ FILEIO_ENFILE = 23,
+ FILEIO_EMFILE = 24,
+ FILEIO_EFBIG = 27,
+ FILEIO_ENOSPC = 28,
+ FILEIO_ESPIPE = 29,
+ FILEIO_EROFS = 30,
+ FILEIO_ENOSYS = 88,
+ FILEIO_ENAMETOOLONG = 91,
+ FILEIO_EUNKNOWN = 9999,
};
-#define FIO_INT_LEN 4
-#define FIO_UINT_LEN 4
-#define FIO_MODE_LEN 4
-#define FIO_TIME_LEN 4
-#define FIO_LONG_LEN 8
+#define FIO_INT_LEN 4
+#define FIO_UINT_LEN 4
+#define FIO_MODE_LEN 4
+#define FIO_TIME_LEN 4
+#define FIO_LONG_LEN 8
#define FIO_ULONG_LEN 8
typedef char fio_int_t[FIO_INT_LEN];
@@ -114,25 +113,25 @@ typedef char fio_ulong_t[FIO_ULONG_LEN];
struct fio_stat
{
- fio_uint_t fst_dev;
- fio_uint_t fst_ino;
- fio_mode_t fst_mode;
- fio_uint_t fst_nlink;
- fio_uint_t fst_uid;
- fio_uint_t fst_gid;
- fio_uint_t fst_rdev;
+ fio_uint_t fst_dev;
+ fio_uint_t fst_ino;
+ fio_mode_t fst_mode;
+ fio_uint_t fst_nlink;
+ fio_uint_t fst_uid;
+ fio_uint_t fst_gid;
+ fio_uint_t fst_rdev;
fio_ulong_t fst_size;
fio_ulong_t fst_blksize;
fio_ulong_t fst_blocks;
- fio_time_t fst_atime;
- fio_time_t fst_mtime;
- fio_time_t fst_ctime;
+ fio_time_t fst_atime;
+ fio_time_t fst_mtime;
+ fio_time_t fst_ctime;
};
struct fio_timeval
{
- fio_time_t ftv_sec;
- fio_long_t ftv_usec;
+ fio_time_t ftv_sec;
+ fio_long_t ftv_usec;
};
/* Convert a host-format errno value to a File-I/O error number. */
diff --git a/gdbsupport/filestuff.cc b/gdbsupport/filestuff.cc
index d733210..535a064 100644
--- a/gdbsupport/filestuff.cc
+++ b/gdbsupport/filestuff.cc
@@ -57,8 +57,6 @@
#define SOCK_CLOEXEC 0
#endif
-
-
#ifndef HAVE_FDWALK
#include <dirent.h>
@@ -86,51 +84,51 @@ fdwalk (int (*func) (void *, int), void *arg)
int result = 0;
for (entry = readdir (dir); entry != NULL; entry = readdir (dir))
- {
- long fd;
- char *tail;
-
- errno = 0;
- fd = strtol (entry->d_name, &tail, 10);
- if (*tail != '\0' || errno != 0)
- continue;
- if ((int) fd != fd)
- {
- /* What can we do here really? */
- continue;
- }
-
- if (fd == dirfd (dir))
- continue;
-
- result = func (arg, fd);
- if (result != 0)
- break;
- }
+ {
+ long fd;
+ char *tail;
+
+ errno = 0;
+ fd = strtol (entry->d_name, &tail, 10);
+ if (*tail != '\0' || errno != 0)
+ continue;
+ if ((int) fd != fd)
+ {
+ /* What can we do here really? */
+ continue;
+ }
+
+ if (fd == dirfd (dir))
+ continue;
+
+ result = func (arg, fd);
+ if (result != 0)
+ break;
+ }
closedir (dir);
return result;
}
- /* We may fall through to the next case. */
+ /* We may fall through to the next case. */
#endif
#ifdef HAVE_KINFO_GETFILE
int nfd;
- gdb::unique_xmalloc_ptr<struct kinfo_file[]> fdtbl
- (kinfo_getfile (getpid (), &nfd));
+ gdb::unique_xmalloc_ptr<struct kinfo_file[]> fdtbl (
+ kinfo_getfile (getpid (), &nfd));
if (fdtbl != NULL)
{
for (int i = 0; i < nfd; i++)
- {
- if (fdtbl[i].kf_fd >= 0)
- {
- int result = func (arg, fdtbl[i].kf_fd);
- if (result != 0)
- return result;
- }
- }
+ {
+ if (fdtbl[i].kf_fd >= 0)
+ {
+ int result = func (arg, fdtbl[i].kf_fd);
+ if (result != 0)
+ return result;
+ }
+ }
return 0;
}
- /* We may fall through to the next case. */
+ /* We may fall through to the next case. */
#endif
{
@@ -139,31 +137,32 @@ fdwalk (int (*func) (void *, int), void *arg)
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
struct rlimit rlim;
- if (getrlimit (RLIMIT_NOFILE, &rlim) == 0 && rlim.rlim_max != RLIM_INFINITY)
+ if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
+ && rlim.rlim_max != RLIM_INFINITY)
max = rlim.rlim_max;
else
#endif
{
#ifdef _SC_OPEN_MAX
- max = sysconf (_SC_OPEN_MAX);
+ max = sysconf (_SC_OPEN_MAX);
#else
- /* Whoops. */
- return 0;
+ /* Whoops. */
+ return 0;
#endif /* _SC_OPEN_MAX */
}
for (fd = 0; fd < max; ++fd)
{
- struct stat sb;
- int result;
+ struct stat sb;
+ int result;
- /* Only call FUNC for open fds. */
- if (fstat (fd, &sb) == -1)
- continue;
+ /* Only call FUNC for open fds. */
+ if (fstat (fd, &sb) == -1)
+ continue;
- result = func (arg, fd);
- if (result != 0)
- return result;
+ result = func (arg, fd);
+ if (result != 0)
+ return result;
}
return 0;
@@ -172,8 +171,6 @@ fdwalk (int (*func) (void *, int), void *arg)
#endif /* HAVE_FDWALK */
-
-
/* A vector holding all the fds open when notice_open_fds was called. We
don't use a hashtab because we don't expect there to be many open fds. */
@@ -227,10 +224,10 @@ do_close (void *ignore, int fd)
for (int val : open_fds)
{
if (fd == val)
- {
- /* Keep this one open. */
- return 0;
- }
+ {
+ /* Keep this one open. */
+ return 0;
+ }
}
close (fd);
@@ -245,8 +242,6 @@ close_most_fds (void)
fdwalk (do_close, NULL);
}
-
-
/* This is a tri-state flag. When zero it means we haven't yet tried
O_CLOEXEC. When positive it means that O_CLOEXEC works on this
host. When negative, it means that O_CLOEXEC doesn't work. We
@@ -270,12 +265,12 @@ mark_cloexec (int fd)
fcntl (fd, F_SETFD, old | FD_CLOEXEC);
if (trust_o_cloexec == 0)
- {
- if ((old & FD_CLOEXEC) != 0)
- trust_o_cloexec = 1;
- else
- trust_o_cloexec = -1;
- }
+ {
+ if ((old & FD_CLOEXEC) != 0)
+ trust_o_cloexec = 1;
+ else
+ trust_o_cloexec = -1;
+ }
}
#endif /* HAVE_F_GETFD */
}
@@ -302,8 +297,6 @@ socket_mark_cloexec (int fd)
#endif
-
-
/* See filestuff.h. */
scoped_fd
@@ -330,8 +323,8 @@ gdb_fopen_cloexec (const char *filename, const char *opentype)
unknown modes. Assume that if O_CLOEXEC is zero, then "e" isn't
supported. On MinGW, O_CLOEXEC is an alias of O_NOINHERIT, and
"e" isn't supported. */
- static int fopen_e_ever_failed_einval =
- O_CLOEXEC == 0 || O_CLOEXEC == O_NOINHERIT;
+ static int fopen_e_ever_failed_einval
+ = O_CLOEXEC == 0 || O_CLOEXEC == O_NOINHERIT;
if (!fopen_e_ever_failed_einval)
{
@@ -345,11 +338,11 @@ gdb_fopen_cloexec (const char *filename, const char *opentype)
result = fopen (filename, copy);
if (result == NULL && errno == EINVAL)
- {
- result = fopen (filename, opentype);
- if (result != NULL)
- fopen_e_ever_failed_einval = 1;
- }
+ {
+ result = fopen (filename, opentype);
+ if (result != NULL)
+ fopen_e_ever_failed_einval = 1;
+ }
}
else
result = fopen (filename, opentype);
@@ -364,8 +357,7 @@ gdb_fopen_cloexec (const char *filename, const char *opentype)
/* See filestuff.h. */
int
-gdb_socketpair_cloexec (int domain, int style, int protocol,
- int filedes[2])
+gdb_socketpair_cloexec (int domain, int style, int protocol, int filedes[2])
{
#ifdef HAVE_SOCKETPAIR
int result = socketpair (domain, style | SOCK_CLOEXEC, protocol, filedes);
@@ -418,7 +410,7 @@ gdb_pipe_cloexec (int filedes[2])
mark_cloexec (filedes[0]);
mark_cloexec (filedes[1]);
}
-#else /* HAVE_PIPE */
+#else /* HAVE_PIPE */
gdb_assert_not_reached ("pipe not available on this host");
#endif /* HAVE_PIPE */
#endif /* HAVE_PIPE2 */
@@ -442,7 +434,7 @@ is_regular_file (const char *name, int *errno_ptr)
if (status != 0)
{
if (errno != ENOENT)
- return true;
+ return true;
*errno_ptr = ENOENT;
return false;
}
@@ -463,7 +455,7 @@ bool
mkdir_recursive (const char *dir)
{
auto holder = make_unique_xstrdup (dir);
- char * const start = holder.get ();
+ char *const start = holder.get ();
char *component_start = start;
char *component_end = start;
@@ -471,16 +463,16 @@ mkdir_recursive (const char *dir)
{
/* Find the beginning of the next component. */
while (*component_start == '/')
- component_start++;
+ component_start++;
/* Are we done? */
if (*component_start == '\0')
- return true;
+ return true;
/* Find the slash or null-terminator after this component. */
component_end = component_start;
while (*component_end != '/' && *component_end != '\0')
- component_end++;
+ component_end++;
/* Temporarily replace the slash with a null terminator, so we can create
the directory up to this component. */
@@ -493,8 +485,8 @@ mkdir_recursive (const char *dir)
component, the caller will fail with ENOTDIR when trying to
open/create a file under that path. */
if (mkdir (start, 0700) != 0)
- if (errno != EEXIST)
- return false;
+ if (errno != EEXIST)
+ return false;
/* Restore the overwritten char. */
*component_end = saved_char;
@@ -522,14 +514,14 @@ read_text_file_to_string (const char *path)
int n = fread (&res[start_size], 1, chunk_size, file.get ());
if (n == chunk_size)
- continue;
+ continue;
gdb_assert (n < chunk_size);
/* Less than CHUNK means EOF or error. If it's an error, return
no value. */
if (ferror (file.get ()))
- return {};
+ return {};
/* Resize the string according to the data we read. */
res.resize (start_size + n);
diff --git a/gdbsupport/filestuff.h b/gdbsupport/filestuff.h
index 48bef51..c2f6de4 100644
--- a/gdbsupport/filestuff.h
+++ b/gdbsupport/filestuff.h
@@ -49,7 +49,7 @@ extern void close_most_fds (void);
close-on-exec flag set. */
extern scoped_fd gdb_open_cloexec (const char *filename, int flags,
- /* mode_t */ unsigned long mode);
+ /* mode_t */ unsigned long mode);
/* Like mkstemp, but ensures that the file descriptor is
close-on-exec. */
@@ -66,7 +66,7 @@ gdb_mkostemp_cloexec (char *name_template, int flags = 0)
static inline scoped_fd
gdb_open_cloexec (const std::string &filename, int flags,
- /* mode_t */ unsigned long mode)
+ /* mode_t */ unsigned long mode)
{
return gdb_open_cloexec (filename.c_str (), flags, mode);
}
@@ -75,7 +75,7 @@ gdb_open_cloexec (const std::string &filename, int flags,
close-on-exec flag set. */
extern gdb_file_up gdb_fopen_cloexec (const char *filename,
- const char *opentype);
+ const char *opentype);
/* Convenience wrapper for the above, which takes the filename as an
std::string. */
@@ -90,7 +90,7 @@ gdb_fopen_cloexec (const std::string &filename, const char *opentype)
have the close-on-exec flag set. */
extern int gdb_socketpair_cloexec (int domain, int style, int protocol,
- int filedes[2]);
+ int filedes[2]);
/* Like 'socket', but ensures that the returned file descriptor has
the close-on-exec flag set. */
@@ -104,10 +104,7 @@ extern int gdb_pipe_cloexec (int filedes[2]);
struct gdb_dir_deleter
{
- void operator() (DIR *dir) const
- {
- closedir (dir);
- }
+ void operator() (DIR *dir) const { closedir (dir); }
};
/* A unique pointer to a DIR. */
@@ -119,7 +116,6 @@ typedef std::unique_ptr<DIR, gdb_dir_deleter> gdb_dir_up;
we're expecting a regular file. */
extern bool is_regular_file (const char *name, int *errno_ptr);
-
/* A cheap (as in low-quality) recursive mkdir. Try to create all the
parents directories up to DIR and DIR itself. Stop if we hit an
error along the way. There is no attempt to remove created
diff --git a/gdbsupport/filtered-iterator.h b/gdbsupport/filtered-iterator.h
index d87484c..7336db2 100644
--- a/gdbsupport/filtered-iterator.h
+++ b/gdbsupport/filtered-iterator.h
@@ -40,7 +40,9 @@ public:
template<typename... Args>
explicit filtered_iterator (Args &&...args)
: m_it (std::forward<Args> (args)...)
- { skip_filtered (); }
+ {
+ skip_filtered ();
+ }
/* Create a one-past-end iterator. */
filtered_iterator () = default;
@@ -52,7 +54,8 @@ public:
filtered_iterator (filtered_iterator &&) = default;
filtered_iterator (const filtered_iterator &&other)
: filtered_iterator (static_cast<const filtered_iterator &> (other))
- {}
+ {
+ }
value_type operator* () const { return *m_it; }
@@ -63,19 +66,16 @@ public:
return *this;
}
- bool operator== (const self_type &other) const
- { return m_it == other.m_it; }
+ bool operator== (const self_type &other) const { return m_it == other.m_it; }
- bool operator!= (const self_type &other) const
- { return m_it != other.m_it; }
+ bool operator!= (const self_type &other) const { return m_it != other.m_it; }
private:
-
void skip_filtered ()
{
for (; m_it != m_end; ++m_it)
if (m_filter (*m_it))
- break;
+ break;
}
private:
diff --git a/gdbsupport/format.cc b/gdbsupport/format.cc
index 19f37ec..6c888a5 100644
--- a/gdbsupport/format.cc
+++ b/gdbsupport/format.cc
@@ -45,57 +45,58 @@ format_pieces::format_pieces (const char **arg, bool gdb_extensions)
string = f;
while ((gdb_extensions || *s != '"') && *s != '\0')
- {
- int c = *s++;
- switch (c)
- {
- case '\0':
- continue;
-
- case '\\':
- switch (c = *s++)
- {
- case '\\':
- *f++ = '\\';
- break;
- case 'a':
- *f++ = '\a';
- break;
- case 'b':
- *f++ = '\b';
- break;
- case 'e':
- *f++ = '\e';
- break;
- case 'f':
- *f++ = '\f';
- break;
- case 'n':
- *f++ = '\n';
- break;
- case 'r':
- *f++ = '\r';
- break;
- case 't':
- *f++ = '\t';
- break;
- case 'v':
- *f++ = '\v';
- break;
- case '"':
- *f++ = '"';
- break;
- default:
- /* ??? TODO: handle other escape sequences. */
- error (_("Unrecognized escape character \\%c in format string."),
- c);
- }
- break;
-
- default:
- *f++ = c;
- }
- }
+ {
+ int c = *s++;
+ switch (c)
+ {
+ case '\0':
+ continue;
+
+ case '\\':
+ switch (c = *s++)
+ {
+ case '\\':
+ *f++ = '\\';
+ break;
+ case 'a':
+ *f++ = '\a';
+ break;
+ case 'b':
+ *f++ = '\b';
+ break;
+ case 'e':
+ *f++ = '\e';
+ break;
+ case 'f':
+ *f++ = '\f';
+ break;
+ case 'n':
+ *f++ = '\n';
+ break;
+ case 'r':
+ *f++ = '\r';
+ break;
+ case 't':
+ *f++ = '\t';
+ break;
+ case 'v':
+ *f++ = '\v';
+ break;
+ case '"':
+ *f++ = '"';
+ break;
+ default:
+ /* ??? TODO: handle other escape sequences. */
+ error (
+ _ ("Unrecognized escape character \\%c in format string."),
+ c);
+ }
+ break;
+
+ default:
+ *f++ = c;
+ }
+ }
/* Terminate our escape-processed copy. */
*f++ = '\0';
@@ -119,282 +120,282 @@ format_pieces::format_pieces (const char **arg, bool gdb_extensions)
while (*f)
if (*f++ == '%')
{
- int seen_hash = 0, seen_zero = 0, lcount = 0, seen_prec = 0;
- int seen_space = 0, seen_plus = 0;
- int seen_big_l = 0, seen_h = 0, seen_big_h = 0;
- int seen_big_d = 0, seen_double_big_d = 0;
- int seen_size_t = 0;
- int bad = 0;
- int n_int_args = 0;
- bool seen_i64 = false;
-
- /* Skip over "%%", it will become part of a literal piece. */
- if (*f == '%')
- {
- f++;
- continue;
- }
-
- sub_start = current_substring;
-
- strncpy (current_substring, prev_start, f - 1 - prev_start);
- current_substring += f - 1 - prev_start;
- *current_substring++ = '\0';
-
- if (*sub_start != '\0')
- m_pieces.emplace_back (sub_start, literal_piece, 0);
-
- percent_loc = f - 1;
-
- /* Check the validity of the format specifier, and work
+ int seen_hash = 0, seen_zero = 0, lcount = 0, seen_prec = 0;
+ int seen_space = 0, seen_plus = 0;
+ int seen_big_l = 0, seen_h = 0, seen_big_h = 0;
+ int seen_big_d = 0, seen_double_big_d = 0;
+ int seen_size_t = 0;
+ int bad = 0;
+ int n_int_args = 0;
+ bool seen_i64 = false;
+
+ /* Skip over "%%", it will become part of a literal piece. */
+ if (*f == '%')
+ {
+ f++;
+ continue;
+ }
+
+ sub_start = current_substring;
+
+ strncpy (current_substring, prev_start, f - 1 - prev_start);
+ current_substring += f - 1 - prev_start;
+ *current_substring++ = '\0';
+
+ if (*sub_start != '\0')
+ m_pieces.emplace_back (sub_start, literal_piece, 0);
+
+ percent_loc = f - 1;
+
+ /* Check the validity of the format specifier, and work
out what argument it expects. We only accept C89
format strings, with the exception of long long (which
we autoconf for). */
- /* The first part of a format specifier is a set of flag
+ /* The first part of a format specifier is a set of flag
characters. */
- while (*f != '\0' && strchr ("0-+ #", *f))
- {
- if (*f == '#')
- seen_hash = 1;
- else if (*f == '0')
- seen_zero = 1;
- else if (*f == ' ')
- seen_space = 1;
- else if (*f == '+')
- seen_plus = 1;
- f++;
- }
-
- /* The next part of a format specifier is a width. */
- if (gdb_extensions && *f == '*')
- {
- ++f;
- ++n_int_args;
- }
- else
- {
- while (*f != '\0' && strchr ("0123456789", *f))
- f++;
- }
-
- /* The next part of a format specifier is a precision. */
- if (*f == '.')
- {
- seen_prec = 1;
- f++;
- if (gdb_extensions && *f == '*')
- {
- ++f;
- ++n_int_args;
- }
- else
- {
- while (*f != '\0' && strchr ("0123456789", *f))
- f++;
- }
- }
-
- /* The next part of a format specifier is a length modifier. */
- switch (*f)
- {
- case 'h':
- seen_h = 1;
- f++;
- break;
- case 'l':
- f++;
- lcount++;
- if (*f == 'l')
- {
- f++;
- lcount++;
- }
- break;
- case 'L':
- seen_big_l = 1;
- f++;
- break;
- case 'H':
- /* Decimal32 modifier. */
- seen_big_h = 1;
- f++;
- break;
- case 'D':
- /* Decimal64 and Decimal128 modifiers. */
- f++;
-
- /* Check for a Decimal128. */
- if (*f == 'D')
- {
- f++;
- seen_double_big_d = 1;
- }
- else
- seen_big_d = 1;
- break;
- case 'z':
- /* For size_t or ssize_t. */
- seen_size_t = 1;
- f++;
- break;
- case 'I':
- /* Support the Windows '%I64' extension, because an
+ while (*f != '\0' && strchr ("0-+ #", *f))
+ {
+ if (*f == '#')
+ seen_hash = 1;
+ else if (*f == '0')
+ seen_zero = 1;
+ else if (*f == ' ')
+ seen_space = 1;
+ else if (*f == '+')
+ seen_plus = 1;
+ f++;
+ }
+
+ /* The next part of a format specifier is a width. */
+ if (gdb_extensions && *f == '*')
+ {
+ ++f;
+ ++n_int_args;
+ }
+ else
+ {
+ while (*f != '\0' && strchr ("0123456789", *f))
+ f++;
+ }
+
+ /* The next part of a format specifier is a precision. */
+ if (*f == '.')
+ {
+ seen_prec = 1;
+ f++;
+ if (gdb_extensions && *f == '*')
+ {
+ ++f;
+ ++n_int_args;
+ }
+ else
+ {
+ while (*f != '\0' && strchr ("0123456789", *f))
+ f++;
+ }
+ }
+
+ /* The next part of a format specifier is a length modifier. */
+ switch (*f)
+ {
+ case 'h':
+ seen_h = 1;
+ f++;
+ break;
+ case 'l':
+ f++;
+ lcount++;
+ if (*f == 'l')
+ {
+ f++;
+ lcount++;
+ }
+ break;
+ case 'L':
+ seen_big_l = 1;
+ f++;
+ break;
+ case 'H':
+ /* Decimal32 modifier. */
+ seen_big_h = 1;
+ f++;
+ break;
+ case 'D':
+ /* Decimal64 and Decimal128 modifiers. */
+ f++;
+
+ /* Check for a Decimal128. */
+ if (*f == 'D')
+ {
+ f++;
+ seen_double_big_d = 1;
+ }
+ else
+ seen_big_d = 1;
+ break;
+ case 'z':
+ /* For size_t or ssize_t. */
+ seen_size_t = 1;
+ f++;
+ break;
+ case 'I':
+ /* Support the Windows '%I64' extension, because an
earlier call to format_pieces might have converted %lld
to %I64d. */
- if (f[1] == '6' && f[2] == '4')
- {
- f += 3;
- lcount = 2;
- seen_i64 = true;
- }
- break;
- }
-
- switch (*f)
- {
- case 'u':
- if (seen_hash)
- bad = 1;
- /* FALLTHROUGH */
-
- case 'o':
- case 'x':
- case 'X':
- if (seen_space || seen_plus)
- bad = 1;
- /* FALLTHROUGH */
-
- case 'd':
- case 'i':
- if (seen_size_t)
- this_argclass = size_t_arg;
- else if (lcount == 0)
- this_argclass = int_arg;
- else if (lcount == 1)
- this_argclass = long_arg;
- else
- this_argclass = long_long_arg;
-
- if (seen_big_l)
- bad = 1;
- break;
-
- case 'c':
- this_argclass = lcount == 0 ? int_arg : wide_char_arg;
- if (lcount > 1 || seen_h || seen_big_l)
- bad = 1;
- if (seen_prec || seen_zero || seen_space || seen_plus)
- bad = 1;
- break;
-
- case 'p':
- this_argclass = ptr_arg;
- if (lcount || seen_h || seen_big_l)
- bad = 1;
- if (seen_prec)
- bad = 1;
- if (seen_hash || seen_zero || seen_space || seen_plus)
- bad = 1;
-
- if (gdb_extensions)
- {
- switch (f[1])
- {
- case 's':
- case 'F':
- case '[':
- case ']':
- f++;
- break;
- }
- }
-
- break;
-
- case 's':
- this_argclass = lcount == 0 ? string_arg : wide_string_arg;
- if (lcount > 1 || seen_h || seen_big_l)
- bad = 1;
- if (seen_zero || seen_space || seen_plus)
- bad = 1;
- break;
-
- case 'e':
- case 'f':
- case 'g':
- case 'E':
- case 'G':
- if (seen_double_big_d)
- this_argclass = dec128float_arg;
- else if (seen_big_d)
- this_argclass = dec64float_arg;
- else if (seen_big_h)
- this_argclass = dec32float_arg;
- else if (seen_big_l)
- this_argclass = long_double_arg;
- else
- this_argclass = double_arg;
-
- if (lcount || seen_h)
- bad = 1;
- break;
-
- case '*':
- error (_("`*' not supported for precision or width in printf"));
-
- case 'n':
- error (_("Format specifier `n' not supported in printf"));
-
- case '\0':
- error (_("Incomplete format specifier at end of format string"));
-
- default:
- error (_("Unrecognized format specifier '%c' in printf"), *f);
- }
-
- if (bad)
- error (_("Inappropriate modifiers to "
- "format specifier '%c' in printf"),
- *f);
-
- f++;
-
- sub_start = current_substring;
-
- if (lcount > 1 && !seen_i64 && USE_PRINTF_I64)
- {
- /* Windows' printf does support long long, but not the usual way.
+ if (f[1] == '6' && f[2] == '4')
+ {
+ f += 3;
+ lcount = 2;
+ seen_i64 = true;
+ }
+ break;
+ }
+
+ switch (*f)
+ {
+ case 'u':
+ if (seen_hash)
+ bad = 1;
+ /* FALLTHROUGH */
+
+ case 'o':
+ case 'x':
+ case 'X':
+ if (seen_space || seen_plus)
+ bad = 1;
+ /* FALLTHROUGH */
+
+ case 'd':
+ case 'i':
+ if (seen_size_t)
+ this_argclass = size_t_arg;
+ else if (lcount == 0)
+ this_argclass = int_arg;
+ else if (lcount == 1)
+ this_argclass = long_arg;
+ else
+ this_argclass = long_long_arg;
+
+ if (seen_big_l)
+ bad = 1;
+ break;
+
+ case 'c':
+ this_argclass = lcount == 0 ? int_arg : wide_char_arg;
+ if (lcount > 1 || seen_h || seen_big_l)
+ bad = 1;
+ if (seen_prec || seen_zero || seen_space || seen_plus)
+ bad = 1;
+ break;
+
+ case 'p':
+ this_argclass = ptr_arg;
+ if (lcount || seen_h || seen_big_l)
+ bad = 1;
+ if (seen_prec)
+ bad = 1;
+ if (seen_hash || seen_zero || seen_space || seen_plus)
+ bad = 1;
+
+ if (gdb_extensions)
+ {
+ switch (f[1])
+ {
+ case 's':
+ case 'F':
+ case '[':
+ case ']':
+ f++;
+ break;
+ }
+ }
+
+ break;
+
+ case 's':
+ this_argclass = lcount == 0 ? string_arg : wide_string_arg;
+ if (lcount > 1 || seen_h || seen_big_l)
+ bad = 1;
+ if (seen_zero || seen_space || seen_plus)
+ bad = 1;
+ break;
+
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'E':
+ case 'G':
+ if (seen_double_big_d)
+ this_argclass = dec128float_arg;
+ else if (seen_big_d)
+ this_argclass = dec64float_arg;
+ else if (seen_big_h)
+ this_argclass = dec32float_arg;
+ else if (seen_big_l)
+ this_argclass = long_double_arg;
+ else
+ this_argclass = double_arg;
+
+ if (lcount || seen_h)
+ bad = 1;
+ break;
+
+ case '*':
+ error (_ ("`*' not supported for precision or width in printf"));
+
+ case 'n':
+ error (_ ("Format specifier `n' not supported in printf"));
+
+ case '\0':
+ error (_ ("Incomplete format specifier at end of format string"));
+
+ default:
+ error (_ ("Unrecognized format specifier '%c' in printf"), *f);
+ }
+
+ if (bad)
+ error (_ ("Inappropriate modifiers to "
+ "format specifier '%c' in printf"),
+ *f);
+
+ f++;
+
+ sub_start = current_substring;
+
+ if (lcount > 1 && !seen_i64 && USE_PRINTF_I64)
+ {
+ /* Windows' printf does support long long, but not the usual way.
Convert %lld to %I64d. */
- int length_before_ll = f - percent_loc - 1 - lcount;
-
- strncpy (current_substring, percent_loc, length_before_ll);
- strcpy (current_substring + length_before_ll, "I64");
- current_substring[length_before_ll + 3] =
- percent_loc[length_before_ll + lcount];
- current_substring += length_before_ll + 4;
- }
- else if (this_argclass == wide_string_arg
- || this_argclass == wide_char_arg)
- {
- /* Convert %ls or %lc to %s. */
- int length_before_ls = f - percent_loc - 2;
-
- strncpy (current_substring, percent_loc, length_before_ls);
- strcpy (current_substring + length_before_ls, "s");
- current_substring += length_before_ls + 2;
- }
- else
- {
- strncpy (current_substring, percent_loc, f - percent_loc);
- current_substring += f - percent_loc;
- }
-
- *current_substring++ = '\0';
-
- prev_start = f;
-
- m_pieces.emplace_back (sub_start, this_argclass, n_int_args);
+ int length_before_ll = f - percent_loc - 1 - lcount;
+
+ strncpy (current_substring, percent_loc, length_before_ll);
+ strcpy (current_substring + length_before_ll, "I64");
+ current_substring[length_before_ll + 3]
+ = percent_loc[length_before_ll + lcount];
+ current_substring += length_before_ll + 4;
+ }
+ else if (this_argclass == wide_string_arg
+ || this_argclass == wide_char_arg)
+ {
+ /* Convert %ls or %lc to %s. */
+ int length_before_ls = f - percent_loc - 2;
+
+ strncpy (current_substring, percent_loc, length_before_ls);
+ strcpy (current_substring + length_before_ls, "s");
+ current_substring += length_before_ls + 2;
+ }
+ else
+ {
+ strncpy (current_substring, percent_loc, f - percent_loc);
+ current_substring += f - percent_loc;
+ }
+
+ *current_substring++ = '\0';
+
+ prev_start = f;
+
+ m_pieces.emplace_back (sub_start, this_argclass, n_int_args);
}
/* Record the remainder of the string. */
diff --git a/gdbsupport/format.h b/gdbsupport/format.h
index 342b473..e4f9091 100644
--- a/gdbsupport/format.h
+++ b/gdbsupport/format.h
@@ -23,10 +23,10 @@
#include "gdbsupport/gdb_string_view.h"
#if defined(__MINGW32__) && !defined(PRINTF_HAS_LONG_LONG)
-# define USE_PRINTF_I64 1
-# define PRINTF_HAS_LONG_LONG
+#define USE_PRINTF_I64 1
+#define PRINTF_HAS_LONG_LONG
#else
-# define USE_PRINTF_I64 0
+#define USE_PRINTF_I64 0
#endif
/* The argclass represents the general type of data that goes with a
@@ -36,13 +36,22 @@
classed as int_arg. */
enum argclass
- {
- literal_piece,
- int_arg, long_arg, long_long_arg, size_t_arg, ptr_arg,
- string_arg, wide_string_arg, wide_char_arg,
- double_arg, long_double_arg,
- dec32float_arg, dec64float_arg, dec128float_arg
- };
+{
+ literal_piece,
+ int_arg,
+ long_arg,
+ long_long_arg,
+ size_t_arg,
+ ptr_arg,
+ string_arg,
+ wide_string_arg,
+ wide_char_arg,
+ double_arg,
+ long_double_arg,
+ dec32float_arg,
+ dec64float_arg,
+ dec128float_arg
+};
/* A format piece is a section of the format string that may include a
single print directive somewhere in it, and the associated class
@@ -60,7 +69,7 @@ struct format_piece
bool operator== (const format_piece &other) const
{
return (this->argclass == other.argclass
- && gdb::string_view (this->string) == other.string);
+ && gdb::string_view (this->string) == other.string);
}
const char *string;
@@ -74,7 +83,6 @@ struct format_piece
class format_pieces
{
public:
-
format_pieces (const char **arg, bool gdb_extensions = false);
~format_pieces () = default;
@@ -82,18 +90,11 @@ public:
typedef std::vector<format_piece>::iterator iterator;
- iterator begin ()
- {
- return m_pieces.begin ();
- }
+ iterator begin () { return m_pieces.begin (); }
- iterator end ()
- {
- return m_pieces.end ();
- }
+ iterator end () { return m_pieces.end (); }
private:
-
std::vector<format_piece> m_pieces;
gdb::unique_xmalloc_ptr<char> m_storage;
};
diff --git a/gdbsupport/forward-scope-exit.h b/gdbsupport/forward-scope-exit.h
index bf591dd..0972b32 100644
--- a/gdbsupport/forward-scope-exit.h
+++ b/gdbsupport/forward-scope-exit.h
@@ -81,35 +81,28 @@ namespace detail
template<typename Function, Function *function, typename Signature>
struct forward_scope_exit;
-template<typename Function, Function *function,
- typename Res, typename... Args>
+template<typename Function, Function *function, typename Res, typename... Args>
class forward_scope_exit<Function, function, Res (Args...)>
- : public scope_exit_base<forward_scope_exit<Function,
- function,
- Res (Args...)>>
+ : public scope_exit_base<
+ forward_scope_exit<Function, function, Res (Args...)>>
{
/* For access to on_exit(). */
- friend scope_exit_base<forward_scope_exit<Function,
- function,
- Res (Args...)>>;
+ friend scope_exit_base<
+ forward_scope_exit<Function, function, Res (Args...)>>;
public:
- explicit forward_scope_exit (Args ...args)
+ explicit forward_scope_exit (Args... args)
: m_bind_function (function, args...)
{
/* Nothing. */
}
private:
- void on_exit ()
- {
- m_bind_function ();
- }
+ void on_exit () { m_bind_function (); }
/* The function and the arguments passed to the ctor, all packed in
a std::bind. */
- decltype (std::bind (function, std::declval<Args> ()...))
- m_bind_function;
+ decltype (std::bind (function, std::declval<Args> ()...)) m_bind_function;
};
} /* namespace detail */
diff --git a/gdbsupport/function-view.h b/gdbsupport/function-view.h
index cd62d40..09e5bef 100644
--- a/gdbsupport/function-view.h
+++ b/gdbsupport/function-view.h
@@ -193,9 +193,11 @@
unittests/function-view-selftests.c. */
#include "invoke-result.h"
-namespace gdb {
+namespace gdb
+{
-namespace fv_detail {
+namespace fv_detail
+{
/* Bits shared by all function_view instantiations that do not depend
on the template parameters. */
@@ -207,7 +209,7 @@ union erased_callable
/* For function objects. */
void *data;
- /* For function pointers. */
+ /* For function pointers. */
void (*fn) ();
};
@@ -222,32 +224,29 @@ template<typename Res, typename... Args>
class function_view<Res (Args...)>
{
template<typename From, typename To>
- using CompatibleReturnType
- = Or<std::is_void<To>,
- std::is_same<From, To>,
- std::is_convertible<From, To>>;
+ using CompatibleReturnType = Or<std::is_void<To>, std::is_same<From, To>,
+ std::is_convertible<From, To>>;
/* True if Func can be called with Args, and either the result is
Res, convertible to Res or Res is void. */
template<typename Callable,
- typename Res2 = typename gdb::invoke_result<Callable &, Args...>::type>
+ typename Res2 =
+ typename gdb::invoke_result<Callable &, Args...>::type>
struct IsCompatibleCallable : CompatibleReturnType<Res2, Res>
- {};
+ {
+ };
/* True if Callable is a function_view. Used to avoid hijacking the
copy ctor. */
- template <typename Callable>
+ template<typename Callable>
struct IsFunctionView
: std::is_same<function_view, typename std::decay<Callable>::type>
- {};
-
- public:
+ {
+ };
+public:
/* NULL by default. */
- constexpr function_view () noexcept
- : m_erased_callable {},
- m_invoker {}
- {}
+ constexpr function_view () noexcept : m_erased_callable {}, m_invoker {} {}
/* Default copy/assignment is fine. */
function_view (const function_view &) = default;
@@ -256,10 +255,9 @@ class function_view<Res (Args...)>
/* This is the main entry point. Use SFINAE to avoid hijacking the
copy constructor and to ensure that the target type is
compatible. */
- template
- <typename Callable,
- typename = Requires<Not<IsFunctionView<Callable>>>,
- typename = Requires<IsCompatibleCallable<Callable>>>
+ template<typename Callable,
+ typename = Requires<Not<IsFunctionView<Callable>>>,
+ typename = Requires<IsCompatibleCallable<Callable>>>
function_view (Callable &&callable) noexcept
{
bind (callable);
@@ -269,7 +267,8 @@ class function_view<Res (Args...)>
constexpr function_view (std::nullptr_t) noexcept
: m_erased_callable {},
m_invoker {}
- {}
+ {
+ }
/* Clear a function_view. */
function_view &operator= (std::nullptr_t) noexcept
@@ -282,28 +281,30 @@ class function_view<Res (Args...)>
we check M_INVOKER instead of M_ERASED_CALLABLE because we don't
know which member of the union is active right now. */
constexpr explicit operator bool () const noexcept
- { return m_invoker != nullptr; }
+ {
+ return m_invoker != nullptr;
+ }
/* Call the callable. */
- Res operator () (Args... args) const
- { return m_invoker (m_erased_callable, std::forward<Args> (args)...); }
-
- private:
+ Res operator() (Args... args) const
+ {
+ return m_invoker (m_erased_callable, std::forward<Args> (args)...);
+ }
+private:
/* Bind this function_view to a compatible function object
reference. */
- template <typename Callable>
+ template<typename Callable>
void bind (Callable &callable) noexcept
{
m_erased_callable.data = (void *) std::addressof (callable);
- m_invoker = [] (fv_detail::erased_callable ecall, Args... args)
- noexcept (noexcept (callable (std::forward<Args> (args)...))) -> Res
- {
- auto &restored_callable = *static_cast<Callable *> (ecall.data);
- /* The explicit cast to Res avoids a compile error when Res is
+ m_invoker = [] (fv_detail::erased_callable ecall, Args... args) noexcept (
+ noexcept (callable (std::forward<Args> (args)...))) -> Res {
+ auto &restored_callable = *static_cast<Callable *> (ecall.data);
+ /* The explicit cast to Res avoids a compile error when Res is
void and the callable returns non-void. */
- return (Res) restored_callable (std::forward<Args> (args)...);
- };
+ return (Res) restored_callable (std::forward<Args> (args)...);
+ };
}
/* Bind this function_view to a compatible function pointer.
@@ -317,14 +318,13 @@ class function_view<Res (Args...)>
void bind (Res2 (*fn) (Args2...)) noexcept
{
m_erased_callable.fn = reinterpret_cast<void (*) ()> (fn);
- m_invoker = [] (fv_detail::erased_callable ecall, Args... args)
- noexcept (noexcept (fn (std::forward<Args> (args)...))) -> Res
- {
- auto restored_fn = reinterpret_cast<Res2 (*) (Args2...)> (ecall.fn);
- /* The explicit cast to Res avoids a compile error when Res is
+ m_invoker = [] (fv_detail::erased_callable ecall, Args... args) noexcept (
+ noexcept (fn (std::forward<Args> (args)...))) -> Res {
+ auto restored_fn = reinterpret_cast<Res2 (*) (Args2...)> (ecall.fn);
+ /* The explicit cast to Res avoids a compile error when Res is
void and the callable returns non-void. */
- return (Res) restored_fn (std::forward<Args> (args)...);
- };
+ return (Res) restored_fn (std::forward<Args> (args)...);
+ };
}
/* Storage for the erased callable. */
@@ -343,24 +343,33 @@ class function_view<Res (Args...)>
template<typename Res, typename... Args>
constexpr inline bool
operator== (const function_view<Res (Args...)> &f, std::nullptr_t) noexcept
-{ return !static_cast<bool> (f); }
+{
+ return !static_cast<bool> (f);
+}
template<typename Res, typename... Args>
constexpr inline bool
operator== (std::nullptr_t, const function_view<Res (Args...)> &f) noexcept
-{ return !static_cast<bool> (f); }
+{
+ return !static_cast<bool> (f);
+}
template<typename Res, typename... Args>
constexpr inline bool
operator!= (const function_view<Res (Args...)> &f, std::nullptr_t) noexcept
-{ return static_cast<bool> (f); }
+{
+ return static_cast<bool> (f);
+}
template<typename Res, typename... Args>
constexpr inline bool
operator!= (std::nullptr_t, const function_view<Res (Args...)> &f) noexcept
-{ return static_cast<bool> (f); }
+{
+ return static_cast<bool> (f);
+}
-namespace fv_detail {
+namespace fv_detail
+{
/* Helper traits type to automatically find the right function_view
type for a callable. */
@@ -402,7 +411,7 @@ struct function_view_traits<Res (*&) (Args...)>
/* Reference to const function pointers. */
template<typename Res, typename... Args>
-struct function_view_traits<Res (* const &) (Args...)>
+struct function_view_traits<Res (*const &) (Args...)>
: function_view_traits<Res (Args...)>
{
};
@@ -429,8 +438,8 @@ struct function_view_traits<Res (Class::*) (Args...)>
operator(). */
template<typename FuncObj>
struct function_view_traits
- : function_view_traits <decltype
- (&std::remove_reference<FuncObj>::type::operator())>
+ : function_view_traits<
+ decltype (&std::remove_reference<FuncObj>::type::operator())>
{
};
@@ -439,8 +448,9 @@ struct function_view_traits
/* Make a function_view from a callable. Useful to automatically
deduce the function_view's template argument type. */
template<typename Callable>
-auto make_function_view (Callable &&callable)
- -> typename fv_detail::function_view_traits<Callable>::type
+auto
+make_function_view (Callable &&callable) ->
+ typename fv_detail::function_view_traits<Callable>::type
{
using fv = typename fv_detail::function_view_traits<Callable>::type;
return fv (std::forward<Callable> (callable));
diff --git a/gdbsupport/gdb-checked-static-cast.h b/gdbsupport/gdb-checked-static-cast.h
index bc75244..8000cbb 100644
--- a/gdbsupport/gdb-checked-static-cast.h
+++ b/gdbsupport/gdb-checked-static-cast.h
@@ -50,8 +50,8 @@ checked_static_cast (V *v)
mistakes at compile time, this assert prevents anything other than
downcasts, or casts to same type. */
static_assert (std::is_base_of<V, T_no_P>::value
- || std::is_base_of<T_no_P, V>::value,
- "types must be related");
+ || std::is_base_of<T_no_P, V>::value,
+ "types must be related");
#ifdef DEVELOPMENT
if (v == nullptr)
@@ -66,6 +66,6 @@ checked_static_cast (V *v)
return result;
}
-}
+} // namespace gdb
#endif /* COMMON_GDB_CHECKED_DYNAMIC_CAST_H */
diff --git a/gdbsupport/gdb-dlfcn.cc b/gdbsupport/gdb-dlfcn.cc
index ee17536..8fd6967 100644
--- a/gdbsupport/gdb-dlfcn.cc
+++ b/gdbsupport/gdb-dlfcn.cc
@@ -46,7 +46,8 @@ gdb_dlsym (const gdb_dlhandle_up &handle, const char *symbol)
void
dlclose_deleter::operator() (void *handle) const
{
- gdb_assert_not_reached ("gdb_dlclose should not be called on this platform.");
+ gdb_assert_not_reached (
+ "gdb_dlclose should not be called on this platform.");
}
int
@@ -70,21 +71,20 @@ gdb_dlopen (const char *filename)
return gdb_dlhandle_up (result);
#ifdef HAVE_DLFCN_H
- error (_("Could not load %s: %s"), filename, dlerror());
+ error (_ ("Could not load %s: %s"), filename, dlerror ());
#else
{
LPVOID buffer;
DWORD dw;
- dw = GetLastError();
+ dw = GetLastError ();
- FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &buffer,
- 0, NULL);
+ FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
+ | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, dw, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &buffer, 0, NULL);
- error (_("Could not load %s: %s"), filename, (char *) buffer);
+ error (_ ("Could not load %s: %s"), filename, (char *) buffer);
}
#endif
}
diff --git a/gdbsupport/gdb-dlfcn.h b/gdbsupport/gdb-dlfcn.h
index a51f999..bcc10d9 100644
--- a/gdbsupport/gdb-dlfcn.h
+++ b/gdbsupport/gdb-dlfcn.h
@@ -46,6 +46,6 @@ void *gdb_dlsym (const gdb_dlhandle_up &handle, const char *symbol);
/* Return non-zero if the dynamic library functions are available on
this platform. */
-int is_dl_available(void);
+int is_dl_available (void);
#endif /* GDB_DLFCN_H */
diff --git a/gdbsupport/gdb-hashtab.h b/gdbsupport/gdb-hashtab.h
index 71611a5..6d7fec1 100644
--- a/gdbsupport/gdb-hashtab.h
+++ b/gdbsupport/gdb-hashtab.h
@@ -24,10 +24,7 @@
/* A deleter for a hash table. */
struct htab_deleter
{
- void operator() (htab *ptr) const
- {
- htab_delete (ptr);
- }
+ void operator() (htab *ptr) const { htab_delete (ptr); }
};
/* A unique_ptr wrapper for htab_t. */
diff --git a/gdbsupport/gdb-sigmask.h b/gdbsupport/gdb-sigmask.h
index 492b10e..598ce09 100644
--- a/gdbsupport/gdb-sigmask.h
+++ b/gdbsupport/gdb-sigmask.h
@@ -41,5 +41,4 @@
#endif /* HAVE_SIGPROCMASK */
-
#endif /* GDBSUPPORT_GDB_SIGMASK_H */
diff --git a/gdbsupport/gdb-xfree.h b/gdbsupport/gdb-xfree.h
index 1fb326d..cb5d7d9 100644
--- a/gdbsupport/gdb-xfree.h
+++ b/gdbsupport/gdb-xfree.h
@@ -23,7 +23,7 @@
/* GDB uses this instead of 'free', it detects when it is called on an
invalid type. */
-template <typename T>
+template<typename T>
static void
xfree (T *ptr)
{
@@ -32,9 +32,9 @@ data type. Use operator delete instead.");
if (ptr != NULL)
#ifdef GNULIB_NAMESPACE
- GNULIB_NAMESPACE::free (ptr); /* ARI: free */
+ GNULIB_NAMESPACE::free (ptr); /* ARI: free */
#else
- free (ptr); /* ARI: free */
+ free (ptr); /* ARI: free */
#endif
}
diff --git a/gdbsupport/gdb_assert.h b/gdbsupport/gdb_assert.h
index f399036..e7ef991 100644
--- a/gdbsupport/gdb_assert.h
+++ b/gdbsupport/gdb_assert.h
@@ -31,21 +31,22 @@
existing lower case macro <assert.h>:assert() that it is
replacing. */
-#define gdb_assert(expr) \
- ((void) ((expr) ? 0 : \
- (gdb_assert_fail (#expr, __FILE__, __LINE__, __func__), 0)))
+#define gdb_assert(expr) \
+ ((void) ((expr) \
+ ? 0 \
+ : (gdb_assert_fail (#expr, __FILE__, __LINE__, __func__), 0)))
/* This prints an "Assertion failed" message, asking the user if they
want to continue, dump core, or just exit. */
#define gdb_assert_fail(assertion, file, line, function) \
- internal_error_loc (file, line, _("%s: Assertion `%s' failed."), \
- function, assertion)
+ internal_error_loc (file, line, _ ("%s: Assertion `%s' failed."), function, \
+ assertion)
/* The canonical form of gdb_assert (0).
MESSAGE is a string to include in the error message. */
-#define gdb_assert_not_reached(message, ...) \
- internal_error_loc (__FILE__, __LINE__, _("%s: " message), __func__, \
- ##__VA_ARGS__)
+#define gdb_assert_not_reached(message, ...) \
+ internal_error_loc (__FILE__, __LINE__, _ ("%s: " message), __func__, \
+ ##__VA_ARGS__)
#endif /* COMMON_GDB_ASSERT_H */
diff --git a/gdbsupport/gdb_binary_search.h b/gdbsupport/gdb_binary_search.h
index b6771b9..4010a8c 100644
--- a/gdbsupport/gdb_binary_search.h
+++ b/gdbsupport/gdb_binary_search.h
@@ -17,13 +17,13 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
#ifndef GDBSUPPORT_GDB_BINARY_SEARCH_H
#define GDBSUPPORT_GDB_BINARY_SEARCH_H
#include <algorithm>
-namespace gdb {
+namespace gdb
+{
/* Implements a binary search using C++ iterators.
This differs from std::binary_search in that it returns an iterator for
@@ -39,17 +39,17 @@ namespace gdb {
The return value is an iterator pointing to the found element, or LAST if
no element was found. */
template<typename It, typename T, typename Comp>
-It binary_search (It first, It last, T el, Comp comp)
+It
+binary_search (It first, It last, T el, Comp comp)
{
auto lt = [&] (const typename std::iterator_traits<It>::value_type &a,
- const T &b)
- { return comp (a, b) < 0; };
+ const T &b) { return comp (a, b) < 0; };
auto lb = std::lower_bound (first, last, el, lt);
if (lb != last)
{
if (comp (*lb, el) == 0)
- return lb;
+ return lb;
}
return last;
}
diff --git a/gdbsupport/gdb_file.h b/gdbsupport/gdb_file.h
index 096e67d..a78f9c8 100644
--- a/gdbsupport/gdb_file.h
+++ b/gdbsupport/gdb_file.h
@@ -24,10 +24,7 @@
struct gdb_file_deleter
{
- void operator() (FILE *file) const
- {
- fclose (file);
- }
+ void operator() (FILE *file) const { fclose (file); }
};
/* A unique pointer to a FILE. */
diff --git a/gdbsupport/gdb_locale.h b/gdbsupport/gdb_locale.h
index f7c8cd4..3703c5d 100644
--- a/gdbsupport/gdb_locale.h
+++ b/gdbsupport/gdb_locale.h
@@ -20,20 +20,20 @@
#define COMMON_GDB_LOCALE_H
#ifdef HAVE_LOCALE_H
-# include <locale.h>
+#include <locale.h>
#endif
#ifdef ENABLE_NLS
-# include <libintl.h>
-# define _(String) gettext (String)
-# ifdef gettext_noop
-# define N_(String) gettext_noop (String)
-# else
-# define N_(String) (String)
-# endif
+#include <libintl.h>
+#define _(String) gettext (String)
+#ifdef gettext_noop
+#define N_(String) gettext_noop (String)
#else
-# define _(String) (String)
-# define N_(String) (String)
+#define N_(String) (String)
+#endif
+#else
+#define _(String) (String)
+#define N_(String) (String)
#endif
#ifdef HAVE_LANGINFO_CODESET
diff --git a/gdbsupport/gdb_obstack.cc b/gdbsupport/gdb_obstack.cc
index a37db96..5a93072 100644
--- a/gdbsupport/gdb_obstack.cc
+++ b/gdbsupport/gdb_obstack.cc
@@ -36,7 +36,7 @@ obconcat (struct obstack *obstackp, ...)
const char *s = va_arg (ap, const char *);
if (s == NULL)
- break;
+ break;
obstack_grow_str (obstackp, s);
}
diff --git a/gdbsupport/gdb_obstack.h b/gdbsupport/gdb_obstack.h
index dbd8fab..00d32db 100644
--- a/gdbsupport/gdb_obstack.h
+++ b/gdbsupport/gdb_obstack.h
@@ -17,15 +17,15 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#if !defined (GDB_OBSTACK_H)
+#if !defined(GDB_OBSTACK_H)
#define GDB_OBSTACK_H 1
#include "obstack.h"
/* Utility macros - wrap obstack alloc into something more robust. */
-template <typename T>
-static inline T*
+template<typename T>
+static inline T *
obstack_zalloc (struct obstack *ob)
{
static_assert (IsMallocable<T>::value, "Trying to use OBSTACK_ZALLOC with a \
@@ -33,28 +33,28 @@ non-POD data type. Use obstack_new instead.");
return ((T *) memset (obstack_alloc (ob, sizeof (T)), 0, sizeof (T)));
}
-#define OBSTACK_ZALLOC(OBSTACK,TYPE) obstack_zalloc<TYPE> ((OBSTACK))
+#define OBSTACK_ZALLOC(OBSTACK, TYPE) obstack_zalloc<TYPE> ((OBSTACK))
-template <typename T>
+template<typename T>
static inline T *
obstack_calloc (struct obstack *ob, size_t number)
{
static_assert (IsMallocable<T>::value, "Trying to use OBSTACK_CALLOC with a \
non-POD data type. Use obstack_new instead.");
return ((T *) memset (obstack_alloc (ob, number * sizeof (T)), 0,
- number * sizeof (T)));
+ number * sizeof (T)));
}
-#define OBSTACK_CALLOC(OBSTACK,NUMBER,TYPE) \
+#define OBSTACK_CALLOC(OBSTACK, NUMBER, TYPE) \
obstack_calloc<TYPE> ((OBSTACK), (NUMBER))
/* Allocate an object on OB and call its constructor. */
-template <typename T, typename... Args>
-static inline T*
-obstack_new (struct obstack *ob, Args&&... args)
+template<typename T, typename... Args>
+static inline T *
+obstack_new (struct obstack *ob, Args &&...args)
{
- T* object = (T *) obstack_alloc (ob, sizeof (T));
+ T *object = (T *) obstack_alloc (ob, sizeof (T));
object = new (object) T (std::forward<Args> (args)...);
return object;
}
@@ -71,9 +71,9 @@ obstack_new (struct obstack *ob, Args&&... args)
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free xfree
-#define obstack_grow_str(OBSTACK,STRING) \
+#define obstack_grow_str(OBSTACK, STRING) \
obstack_grow (OBSTACK, STRING, strlen (STRING))
-#define obstack_grow_str0(OBSTACK,STRING) \
+#define obstack_grow_str0(OBSTACK, STRING) \
obstack_grow0 (OBSTACK, STRING, strlen (STRING))
#define obstack_grow_wstr(OBSTACK, WSTRING) \
@@ -101,8 +101,7 @@ obstack_strdup (struct obstack *obstackp, const char *string)
static inline char *
obstack_strdup (struct obstack *obstackp, const std::string &string)
{
- return (char *) obstack_copy0 (obstackp, string.c_str (),
- string.size ());
+ return (char *) obstack_copy0 (obstackp, string.c_str (), string.size ());
}
/* Duplicate the first N characters of STRING, returning a
@@ -119,18 +118,15 @@ obstack_strndup (struct obstack *obstackp, const char *string, size_t n)
/* An obstack that frees itself on scope exit. */
struct auto_obstack : obstack
{
- auto_obstack ()
- { obstack_init (this); }
+ auto_obstack () { obstack_init (this); }
- ~auto_obstack ()
- { obstack_free (this, NULL); }
+ ~auto_obstack () { obstack_free (this, NULL); }
DISABLE_COPY_AND_ASSIGN (auto_obstack);
/* Free all memory in the obstack but leave it valid for further
allocation. */
- void clear ()
- { obstack_free (this, obstack_base (this)); }
+ void clear () { obstack_free (this, obstack_base (this)); }
};
/* Objects are allocated on obstack instead of heap. */
@@ -139,12 +135,12 @@ struct allocate_on_obstack
{
allocate_on_obstack () = default;
- void* operator new (size_t size, struct obstack *obstack)
+ void *operator new (size_t size, struct obstack *obstack)
{
return obstack_alloc (obstack, size);
}
- void* operator new[] (size_t size, struct obstack *obstack)
+ void *operator new[] (size_t size, struct obstack *obstack)
{
return obstack_alloc (obstack, size);
}
diff --git a/gdbsupport/gdb_optional.h b/gdbsupport/gdb_optional.h
index 9b7b7b2..a4a5582 100644
--- a/gdbsupport/gdb_optional.h
+++ b/gdbsupport/gdb_optional.h
@@ -51,19 +51,16 @@ template<typename T>
class optional
{
public:
-
- constexpr optional ()
- : m_dummy ()
- {}
+ constexpr optional () : m_dummy () {}
template<typename... Args>
- constexpr optional (in_place_t, Args &&... args)
+ constexpr optional (in_place_t, Args &&...args)
: m_item (std::forward<Args> (args)...),
m_instantiated (true)
- {}
+ {
+ }
- ~optional ()
- { this->reset (); }
+ ~optional () { this->reset (); }
/* Copy and move constructors. */
@@ -73,61 +70,58 @@ public:
this->emplace (other.get ());
}
- optional (optional &&other)
- noexcept(std::is_nothrow_move_constructible<T> ())
+ optional (optional &&other) noexcept (
+ std::is_nothrow_move_constructible<T> ())
{
if (other.m_instantiated)
this->emplace (std::move (other.get ()));
}
- constexpr optional (const T &other)
- : m_item (other),
- m_instantiated (true)
- {}
+ constexpr optional (const T &other) : m_item (other), m_instantiated (true)
+ {
+ }
- constexpr optional (T &&other)
- noexcept (std::is_nothrow_move_constructible<T> ())
+ constexpr optional (T &&other) noexcept (
+ std::is_nothrow_move_constructible<T> ())
: m_item (std::move (other)),
m_instantiated (true)
- {}
+ {
+ }
/* Assignment operators. */
- optional &
- operator= (const optional &other)
+ optional &operator= (const optional &other)
{
if (m_instantiated && other.m_instantiated)
this->get () = other.get ();
else
{
- if (other.m_instantiated)
- this->emplace (other.get ());
- else
- this->reset ();
+ if (other.m_instantiated)
+ this->emplace (other.get ());
+ else
+ this->reset ();
}
return *this;
}
- optional &
- operator= (optional &&other)
- noexcept (And<std::is_nothrow_move_constructible<T>,
- std::is_nothrow_move_assignable<T>> ())
+ optional &operator= (optional &&other) noexcept (
+ And<std::is_nothrow_move_constructible<T>,
+ std::is_nothrow_move_assignable<T>> ())
{
if (m_instantiated && other.m_instantiated)
this->get () = std::move (other.get ());
else
{
- if (other.m_instantiated)
- this->emplace (std::move (other.get ()));
- else
- this->reset ();
+ if (other.m_instantiated)
+ this->emplace (std::move (other.get ()));
+ else
+ this->reset ();
}
return *this;
}
- optional &
- operator= (const T &other)
+ optional &operator= (const T &other)
{
if (m_instantiated)
this->get () = other;
@@ -137,9 +131,8 @@ public:
}
optional &
- operator= (T &&other)
- noexcept (And<std::is_nothrow_move_constructible<T>,
- std::is_nothrow_move_assignable<T>> ())
+ operator= (T &&other) noexcept (And<std::is_nothrow_move_constructible<T>,
+ std::is_nothrow_move_assignable<T>> ())
{
if (m_instantiated)
this->get () = std::move (other);
@@ -149,38 +142,36 @@ public:
}
template<typename... Args>
- T &emplace (Args &&... args)
+ T &emplace (Args &&...args)
{
this->reset ();
- new (&m_item) T (std::forward<Args>(args)...);
+ new (&m_item) T (std::forward<Args> (args)...);
m_instantiated = true;
return this->get ();
}
/* Observers. */
- constexpr const T *operator-> () const
- { return std::addressof (this->get ()); }
+ constexpr const T *operator->() const
+ {
+ return std::addressof (this->get ());
+ }
- T *operator-> ()
- { return std::addressof (this->get ()); }
+ T *operator->() { return std::addressof (this->get ()); }
- constexpr const T &operator* () const &
- { return this->get (); }
+ constexpr const T &operator* () const & { return this->get (); }
- T &operator* () &
- { return this->get (); }
+ T &operator* () & { return this->get (); }
- T &&operator* () &&
- { return std::move (this->get ()); }
+ T &&operator* () && { return std::move (this->get ()); }
constexpr const T &&operator* () const &&
- { return std::move (this->get ()); }
+ {
+ return std::move (this->get ());
+ }
- constexpr explicit operator bool () const noexcept
- { return m_instantiated; }
+ constexpr explicit operator bool () const noexcept { return m_instantiated; }
- constexpr bool has_value () const noexcept
- { return m_instantiated; }
+ constexpr bool has_value () const noexcept { return m_instantiated; }
/* 'reset' is a 'safe' operation with no precondition. */
void reset () noexcept
@@ -190,7 +181,6 @@ public:
}
private:
-
/* Destroy the object. */
void destroy ()
{
@@ -218,7 +208,9 @@ private:
/* The object. */
union
{
- struct { } m_dummy;
+ struct
+ {
+ } m_dummy;
T m_item;
volatile char dont_use; /* Silences -Wmaybe-uninitialized warning, see
PR gcc/80635. */
@@ -228,6 +220,6 @@ private:
bool m_instantiated = false;
};
-}
+} // namespace gdb
#endif /* COMMON_GDB_OPTIONAL_H */
diff --git a/gdbsupport/gdb_proc_service.h b/gdbsupport/gdb_proc_service.h
index 19d40e0..8094c5a 100644
--- a/gdbsupport/gdb_proc_service.h
+++ b/gdbsupport/gdb_proc_service.h
@@ -64,9 +64,9 @@ EXTERN_C_POP
<sys/procfs.h> wasn't enough to find elf_fpregset_t, try the kernel
headers also (but don't if we don't need to). */
#ifndef HAVE_ELF_FPREGSET_T
-# ifdef HAVE_LINUX_ELF_H
-# include <linux/elf.h>
-# endif
+#ifdef HAVE_LINUX_ELF_H
+#include <linux/elf.h>
+#endif
#endif
EXTERN_C_PUSH
@@ -74,13 +74,13 @@ EXTERN_C_PUSH
/* Functions in this interface return one of these status codes. */
typedef enum
{
- PS_OK, /* Generic "call succeeded". */
- PS_ERR, /* Generic error. */
- PS_BADPID, /* Bad process handle. */
- PS_BADLID, /* Bad LWP identifier. */
- PS_BADADDR, /* Bad address. */
- PS_NOSYM, /* Could not find given symbol. */
- PS_NOFREGS /* FPU register set not available for given LWP. */
+ PS_OK, /* Generic "call succeeded". */
+ PS_ERR, /* Generic error. */
+ PS_BADPID, /* Bad process handle. */
+ PS_BADLID, /* Bad LWP identifier. */
+ PS_BADADDR, /* Bad address. */
+ PS_NOSYM, /* Could not find given symbol. */
+ PS_NOFREGS /* FPU register set not available for given LWP. */
} ps_err_e;
#ifndef HAVE_LWPID_T
@@ -103,27 +103,22 @@ typedef elf_fpregset_t prfpregset_t;
libthread_db. GDB's version is defined below. */
struct ps_prochandle;
-
/* Read or write process memory at the given address. */
-extern ps_err_e ps_pdread (struct ps_prochandle *,
- psaddr_t, void *, size_t);
-extern ps_err_e ps_pdwrite (struct ps_prochandle *,
- psaddr_t, const void *, size_t);
-extern ps_err_e ps_ptread (struct ps_prochandle *,
- psaddr_t, void *, size_t);
-extern ps_err_e ps_ptwrite (struct ps_prochandle *,
- psaddr_t, const void *, size_t);
-
+extern ps_err_e ps_pdread (struct ps_prochandle *, psaddr_t, void *, size_t);
+extern ps_err_e ps_pdwrite (struct ps_prochandle *, psaddr_t, const void *,
+ size_t);
+extern ps_err_e ps_ptread (struct ps_prochandle *, psaddr_t, void *, size_t);
+extern ps_err_e ps_ptwrite (struct ps_prochandle *, psaddr_t, const void *,
+ size_t);
/* Get and set the given LWP's general or FPU register set. */
-extern ps_err_e ps_lgetregs (struct ps_prochandle *,
- lwpid_t, prgregset_t);
-extern ps_err_e ps_lsetregs (struct ps_prochandle *,
- lwpid_t, const prgregset_t);
-extern ps_err_e ps_lgetfpregs (struct ps_prochandle *,
- lwpid_t, prfpregset_t *);
-extern ps_err_e ps_lsetfpregs (struct ps_prochandle *,
- lwpid_t, const prfpregset_t *);
+extern ps_err_e ps_lgetregs (struct ps_prochandle *, lwpid_t, prgregset_t);
+extern ps_err_e ps_lsetregs (struct ps_prochandle *, lwpid_t,
+ const prgregset_t);
+extern ps_err_e ps_lgetfpregs (struct ps_prochandle *, lwpid_t,
+ prfpregset_t *);
+extern ps_err_e ps_lsetfpregs (struct ps_prochandle *, lwpid_t,
+ const prfpregset_t *);
/* Return the PID of the process. */
extern pid_t ps_getpid (struct ps_prochandle *);
@@ -131,18 +126,15 @@ extern pid_t ps_getpid (struct ps_prochandle *);
/* Fetch the special per-thread address associated with the given LWP.
This call is only used on a few platforms (most use a normal register).
The meaning of the `int' parameter is machine-dependent. */
-extern ps_err_e ps_get_thread_area (struct ps_prochandle *,
- lwpid_t, int, psaddr_t *);
-
+extern ps_err_e ps_get_thread_area (struct ps_prochandle *, lwpid_t, int,
+ psaddr_t *);
/* Look up the named symbol in the named DSO in the symbol tables
associated with the process being debugged, filling in *SYM_ADDR
with the corresponding run-time address. */
extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *,
- const char *object_name,
- const char *sym_name,
- psaddr_t *sym_addr);
-
+ const char *object_name,
+ const char *sym_name, psaddr_t *sym_addr);
/* Stop or continue the entire process. */
extern ps_err_e ps_pstop (struct ps_prochandle *);
@@ -155,13 +147,13 @@ extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t);
/* The following are only defined in/called by Solaris. */
/* Get size of extra register set. */
-extern ps_err_e ps_lgetxregsize (struct ps_prochandle *ph,
- lwpid_t lwpid, int *xregsize);
+extern ps_err_e ps_lgetxregsize (struct ps_prochandle *ph, lwpid_t lwpid,
+ int *xregsize);
/* Get extra register set. */
extern ps_err_e ps_lgetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
- caddr_t xregset);
+ caddr_t xregset);
extern ps_err_e ps_lsetxregs (struct ps_prochandle *ph, lwpid_t lwpid,
- caddr_t xregset);
+ caddr_t xregset);
/* Log a message (sends to gdb_stderr). */
extern void ps_plog (const char *fmt, ...);
@@ -173,8 +165,8 @@ EXTERN_C_POP
/* Make sure we export the needed symbols, in case GDB is built with
-fvisibility=hidden. */
-#define PS_EXPORT(SYM) \
- __attribute__((visibility ("default"))) decltype (SYM) SYM
+#define PS_EXPORT(SYM) \
+ __attribute__ ((visibility ("default"))) decltype (SYM) SYM
PS_EXPORT (ps_get_thread_area);
PS_EXPORT (ps_getpid);
diff --git a/gdbsupport/gdb_ref_ptr.h b/gdbsupport/gdb_ref_ptr.h
index 00f02b7..786f80e 100644
--- a/gdbsupport/gdb_ref_ptr.h
+++ b/gdbsupport/gdb_ref_ptr.h
@@ -48,38 +48,26 @@ namespace gdb
template<typename T, typename Policy>
class ref_ptr
{
- public:
-
+public:
/* Create a new NULL instance. */
- ref_ptr ()
- : m_obj (NULL)
- {
- }
+ ref_ptr () : m_obj (NULL) {}
/* Create a new NULL instance. Note that this is not explicit. */
- ref_ptr (const std::nullptr_t)
- : m_obj (NULL)
- {
- }
+ ref_ptr (const std::nullptr_t) : m_obj (NULL) {}
/* Create a new instance. OBJ is a reference, management of which
is now transferred to this class. */
- explicit ref_ptr (T *obj)
- : m_obj (obj)
- {
- }
+ explicit ref_ptr (T *obj) : m_obj (obj) {}
/* Copy another instance. */
- ref_ptr (const ref_ptr &other)
- : m_obj (other.m_obj)
+ ref_ptr (const ref_ptr &other) : m_obj (other.m_obj)
{
if (m_obj != NULL)
Policy::incref (m_obj);
}
/* Transfer ownership from OTHER. */
- ref_ptr (ref_ptr &&other) noexcept
- : m_obj (other.m_obj)
+ ref_ptr (ref_ptr &&other) noexcept : m_obj (other.m_obj)
{
other.m_obj = NULL;
}
@@ -97,9 +85,9 @@ class ref_ptr
/* Do nothing on self-assignment. */
if (this != &other)
{
- reset (other.m_obj);
- if (m_obj != NULL)
- Policy::incref (m_obj);
+ reset (other.m_obj);
+ if (m_obj != NULL)
+ Policy::incref (m_obj);
}
return *this;
}
@@ -110,8 +98,8 @@ class ref_ptr
/* Do nothing on self-assignment. */
if (this != &other)
{
- reset (other.m_obj);
- other.m_obj = NULL;
+ reset (other.m_obj);
+ other.m_obj = NULL;
}
return *this;
}
@@ -127,10 +115,7 @@ class ref_ptr
/* Return this instance's referent without changing the state of
this class. */
- T *get () const
- {
- return m_obj;
- }
+ T *get () const { return m_obj; }
/* Return this instance's referent, and stop managing this
reference. The caller is now responsible for the ownership of
@@ -144,10 +129,7 @@ class ref_ptr
}
/* Let users refer to members of the underlying pointer. */
- T *operator-> () const
- {
- return m_obj;
- }
+ T *operator->() const { return m_obj; }
/* Acquire a new reference and return a ref_ptr that owns it. */
static ref_ptr<T, Policy> new_reference (T *obj)
@@ -156,73 +138,80 @@ class ref_ptr
return ref_ptr<T, Policy> (obj);
}
- private:
-
+private:
T *m_obj;
};
template<typename T, typename Policy>
-inline bool operator== (const ref_ptr<T, Policy> &lhs,
- const ref_ptr<T, Policy> &rhs)
+inline bool
+operator== (const ref_ptr<T, Policy> &lhs, const ref_ptr<T, Policy> &rhs)
{
return lhs.get () == rhs.get ();
}
template<typename T, typename Policy>
-inline bool operator== (const ref_ptr<T, Policy> &lhs, const T *rhs)
+inline bool
+operator== (const ref_ptr<T, Policy> &lhs, const T *rhs)
{
return lhs.get () == rhs;
}
template<typename T, typename Policy>
-inline bool operator== (const ref_ptr<T, Policy> &lhs, const std::nullptr_t)
+inline bool
+operator== (const ref_ptr<T, Policy> &lhs, const std::nullptr_t)
{
return lhs.get () == nullptr;
}
template<typename T, typename Policy>
-inline bool operator== (const T *lhs, const ref_ptr<T, Policy> &rhs)
+inline bool
+operator== (const T *lhs, const ref_ptr<T, Policy> &rhs)
{
return lhs == rhs.get ();
}
template<typename T, typename Policy>
-inline bool operator== (const std::nullptr_t, const ref_ptr<T, Policy> &rhs)
+inline bool
+operator== (const std::nullptr_t, const ref_ptr<T, Policy> &rhs)
{
return nullptr == rhs.get ();
}
template<typename T, typename Policy>
-inline bool operator!= (const ref_ptr<T, Policy> &lhs,
- const ref_ptr<T, Policy> &rhs)
+inline bool
+operator!= (const ref_ptr<T, Policy> &lhs, const ref_ptr<T, Policy> &rhs)
{
return lhs.get () != rhs.get ();
}
template<typename T, typename Policy>
-inline bool operator!= (const ref_ptr<T, Policy> &lhs, const T *rhs)
+inline bool
+operator!= (const ref_ptr<T, Policy> &lhs, const T *rhs)
{
return lhs.get () != rhs;
}
template<typename T, typename Policy>
-inline bool operator!= (const ref_ptr<T, Policy> &lhs, const std::nullptr_t)
+inline bool
+operator!= (const ref_ptr<T, Policy> &lhs, const std::nullptr_t)
{
return lhs.get () != nullptr;
}
template<typename T, typename Policy>
-inline bool operator!= (const T *lhs, const ref_ptr<T, Policy> &rhs)
+inline bool
+operator!= (const T *lhs, const ref_ptr<T, Policy> &rhs)
{
return lhs != rhs.get ();
}
template<typename T, typename Policy>
-inline bool operator!= (const std::nullptr_t, const ref_ptr<T, Policy> &rhs)
+inline bool
+operator!= (const std::nullptr_t, const ref_ptr<T, Policy> &rhs)
{
return nullptr != rhs.get ();
}
-}
+} // namespace gdb
#endif /* COMMON_GDB_REF_PTR_H */
diff --git a/gdbsupport/gdb_regex.cc b/gdbsupport/gdb_regex.cc
index ff9c1a1..8855d2d 100644
--- a/gdbsupport/gdb_regex.cc
+++ b/gdbsupport/gdb_regex.cc
@@ -20,7 +20,7 @@
#include "gdbsupport/def-vector.h"
compiled_regex::compiled_regex (const char *regex, int cflags,
- const char *message)
+ const char *message)
{
gdb_assert (regex != NULL);
gdb_assert (message != NULL);
@@ -42,16 +42,15 @@ compiled_regex::~compiled_regex ()
}
int
-compiled_regex::exec (const char *string, size_t nmatch,
- regmatch_t pmatch[], int eflags) const
+compiled_regex::exec (const char *string, size_t nmatch, regmatch_t pmatch[],
+ int eflags) const
{
return regexec (&m_pattern, string, nmatch, pmatch, eflags);
}
int
-compiled_regex::search (const char *string,
- int length, int start, int range,
- struct re_registers *regs)
+compiled_regex::search (const char *string, int length, int start, int range,
+ struct re_registers *regs)
{
return re_search (&m_pattern, string, length, start, range, regs);
}
diff --git a/gdbsupport/gdb_regex.h b/gdbsupport/gdb_regex.h
index 74c3ece..aa89bee 100644
--- a/gdbsupport/gdb_regex.h
+++ b/gdbsupport/gdb_regex.h
@@ -19,7 +19,7 @@
#ifndef GDB_REGEX_H
#define GDB_REGEX_H 1
-# include "xregex.h"
+#include "xregex.h"
/* A compiled regex. This is mainly a wrapper around regex_t. The
the constructor throws on regcomp error and the destructor is
@@ -31,8 +31,7 @@ class compiled_regex
public:
/* Compile a regexp and throw an exception on error, including
MESSAGE. REGEX and MESSAGE must not be NULL. */
- compiled_regex (const char *regex, int cflags,
- const char *message)
+ compiled_regex (const char *regex, int cflags, const char *message)
ATTRIBUTE_NONNULL (2) ATTRIBUTE_NONNULL (4);
~compiled_regex ();
@@ -40,14 +39,13 @@ public:
DISABLE_COPY_AND_ASSIGN (compiled_regex);
/* Wrapper around ::regexec. */
- int exec (const char *string,
- size_t nmatch, regmatch_t pmatch[],
- int eflags) const;
+ int exec (const char *string, size_t nmatch, regmatch_t pmatch[],
+ int eflags) const;
/* Wrapper around ::re_search. (Not const because re_search's
regex_t parameter isn't either.) */
- int search (const char *string, int size, int startpos,
- int range, struct re_registers *regs);
+ int search (const char *string, int size, int startpos, int range,
+ struct re_registers *regs);
private:
/* The compiled pattern. */
diff --git a/gdbsupport/gdb_select.h b/gdbsupport/gdb_select.h
index 9928aae..6699a58 100644
--- a/gdbsupport/gdb_select.h
+++ b/gdbsupport/gdb_select.h
@@ -31,7 +31,7 @@
#endif
extern int gdb_select (int n, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout);
+ fd_set *exceptfds, struct timeval *timeout);
/* Convenience wrapper around gdb_select that returns -1/EINTR if
set_quit_flag is set, either on entry or from a signal handler or
@@ -42,10 +42,7 @@ extern int gdb_select (int n, fd_set *readfds, fd_set *writefds,
Note this does NOT return -1/EINTR if any signal handler other than
SIGINT runs, nor if the current SIGINT handler does not call
set_quit_flag. */
-extern int interruptible_select (int n,
- fd_set *readfds,
- fd_set *writefds,
- fd_set *exceptfds,
- struct timeval *timeout);
+extern int interruptible_select (int n, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout);
#endif /* !defined(GDB_SELECT_H) */
diff --git a/gdbsupport/gdb_setjmp.h b/gdbsupport/gdb_setjmp.h
index 5fafb9e..38a6b80 100644
--- a/gdbsupport/gdb_setjmp.h
+++ b/gdbsupport/gdb_setjmp.h
@@ -22,15 +22,15 @@
#include <setjmp.h>
#ifdef HAVE_SIGSETJMP
-#define SIGJMP_BUF sigjmp_buf
-#define SIGSETJMP(buf,val) sigsetjmp((buf), val)
-#define SIGLONGJMP(buf,val) siglongjmp((buf), (val))
+#define SIGJMP_BUF sigjmp_buf
+#define SIGSETJMP(buf, val) sigsetjmp ((buf), val)
+#define SIGLONGJMP(buf, val) siglongjmp ((buf), (val))
#else
-#define SIGJMP_BUF jmp_buf
+#define SIGJMP_BUF jmp_buf
/* We ignore val here because that's safer and avoids having to check
whether _setjmp exists. */
-#define SIGSETJMP(buf,val) setjmp(buf)
-#define SIGLONGJMP(buf,val) longjmp((buf), (val))
+#define SIGSETJMP(buf, val) setjmp (buf)
+#define SIGLONGJMP(buf, val) longjmp ((buf), (val))
#endif
#endif /* COMMON_GDB_SETJMP_H */
diff --git a/gdbsupport/gdb_splay_tree.h b/gdbsupport/gdb_splay_tree.h
index 22d9bf6..51de188 100644
--- a/gdbsupport/gdb_splay_tree.h
+++ b/gdbsupport/gdb_splay_tree.h
@@ -22,14 +22,12 @@
#include "splay-tree.h"
-namespace gdb {
+namespace gdb
+{
struct splay_tree_deleter
{
- void operator() (splay_tree tree) const
- {
- splay_tree_delete (tree);
- }
+ void operator() (splay_tree tree) const { splay_tree_delete (tree); }
};
} /* namespace gdb */
@@ -37,6 +35,6 @@ struct splay_tree_deleter
/* A unique pointer to a splay tree. */
typedef std::unique_ptr<splay_tree_s, gdb::splay_tree_deleter>
- gdb_splay_tree_up;
+ gdb_splay_tree_up;
#endif /* COMMON_GDB_SPLAY_TREE_H */
diff --git a/gdbsupport/gdb_string_view.h b/gdbsupport/gdb_string_view.h
index 26a3a9f..968ef11 100644
--- a/gdbsupport/gdb_string_view.h
+++ b/gdbsupport/gdb_string_view.h
@@ -1,6 +1,5 @@
// Components for manipulating non-owning sequences of characters -*- C++ -*-
-
#ifndef COMMON_GDB_STRING_VIEW_H
#define COMMON_GDB_STRING_VIEW_H
@@ -33,13 +32,13 @@
// N3762 basic_string_view library
//
-
#if __cplusplus >= 201703L
#include <string_view>
-namespace gdb {
- using string_view = std::string_view;
+namespace gdb
+{
+using string_view = std::string_view;
} /* namespace gdb */
#else /* __cplusplus < 201703L */
@@ -48,9 +47,10 @@ namespace gdb {
#include <limits>
#include "gdb_assert.h"
-namespace gdb {
+namespace gdb
+{
- /**
+/**
* @class basic_string_view <experimental/string_view>
* @brief A non-owning reference to a string.
*
@@ -69,498 +69,538 @@ namespace gdb {
* size_t _M_len
* @endcode
*/
- template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
- class basic_string_view
- {
- public:
-
- // types
- using traits_type = _Traits;
- using value_type = _CharT;
- using pointer = const _CharT*;
- using const_pointer = const _CharT*;
- using reference = const _CharT&;
- using const_reference = const _CharT&;
- using const_iterator = const _CharT*;
- using iterator = const_iterator;
- using const_reverse_iterator = std::reverse_iterator<const_iterator>;
- using reverse_iterator = const_reverse_iterator;
- using size_type = size_t;
- using difference_type = ptrdiff_t;
- static constexpr size_type npos = size_type(-1);
-
- // [string.view.cons], construct/copy
-
- constexpr
- basic_string_view() noexcept
- : _M_len{0}, _M_str{nullptr}
- { }
-
- constexpr basic_string_view(const basic_string_view&) noexcept = default;
-
- template<typename _Allocator>
- basic_string_view(const std::basic_string<_CharT, _Traits,
- _Allocator>& __str) noexcept
- : _M_len{__str.length()}, _M_str{__str.data()}
- { }
-
- /*constexpr*/ basic_string_view(const _CharT* __str)
- : _M_len{__str == nullptr ? 0 : traits_type::length(__str)},
- _M_str{__str}
- { }
-
- constexpr basic_string_view(const _CharT* __str, size_type __len)
- : _M_len{__len},
- _M_str{__str}
- { }
-
- basic_string_view&
- operator=(const basic_string_view&) noexcept = default;
-
- // [string.view.iterators], iterators
-
- constexpr const_iterator
- begin() const noexcept
- { return this->_M_str; }
-
- constexpr const_iterator
- end() const noexcept
- { return this->_M_str + this->_M_len; }
-
- constexpr const_iterator
- cbegin() const noexcept
- { return this->_M_str; }
-
- constexpr const_iterator
- cend() const noexcept
- { return this->_M_str + this->_M_len; }
-
- const_reverse_iterator
- rbegin() const noexcept
- { return const_reverse_iterator(this->end()); }
-
- const_reverse_iterator
- rend() const noexcept
- { return const_reverse_iterator(this->begin()); }
-
- const_reverse_iterator
- crbegin() const noexcept
- { return const_reverse_iterator(this->end()); }
-
- const_reverse_iterator
- crend() const noexcept
- { return const_reverse_iterator(this->begin()); }
-
- // [string.view.capacity], capacity
-
- constexpr size_type
- size() const noexcept
- { return this->_M_len; }
-
- constexpr size_type
- length() const noexcept
- { return _M_len; }
-
- constexpr size_type
- max_size() const noexcept
- {
- return (npos - sizeof(size_type) - sizeof(void*))
- / sizeof(value_type) / 4;
- }
-
- constexpr bool
- empty() const noexcept
- { return this->_M_len == 0; }
-
- // [string.view.access], element access
-
- constexpr const _CharT&
- operator[](size_type __pos) const
- {
- // TODO: Assert to restore in a way compatible with the constexpr.
- // __glibcxx_assert(__pos < this->_M_len);
- return *(this->_M_str + __pos);
- }
-
- constexpr const _CharT&
- at(size_type __pos) const
- {
- return __pos < this->_M_len
- ? *(this->_M_str + __pos)
- : (error (_("basic_string_view::at: __pos "
- "(which is %zu) >= this->size() "
- "(which is %zu)"),
- __pos, this->size()),
- *this->_M_str);
- }
-
- constexpr const _CharT&
- front() const
- {
- // TODO: Assert to restore in a way compatible with the constexpr.
- // __glibcxx_assert(this->_M_len > 0);
- return *this->_M_str;
- }
-
- constexpr const _CharT&
- back() const
- {
- // TODO: Assert to restore in a way compatible with the constexpr.
- // __glibcxx_assert(this->_M_len > 0);
- return *(this->_M_str + this->_M_len - 1);
- }
-
- constexpr const _CharT*
- data() const noexcept
- { return this->_M_str; }
-
- // [string.view.modifiers], modifiers:
-
- /*constexpr*/ void
- remove_prefix(size_type __n)
- {
- gdb_assert (this->_M_len >= __n);
- this->_M_str += __n;
- this->_M_len -= __n;
- }
-
- /*constexpr*/ void
- remove_suffix(size_type __n)
- { this->_M_len -= __n; }
-
- /*constexpr*/ void
- swap(basic_string_view& __sv) noexcept
- {
- auto __tmp = *this;
- *this = __sv;
- __sv = __tmp;
- }
-
-
- // [string.view.ops], string operations:
-
- template<typename _Allocator>
- explicit operator std::basic_string<_CharT, _Traits, _Allocator>() const
- {
- return { this->_M_str, this->_M_len };
- }
-
- size_type
- copy(_CharT* __str, size_type __n, size_type __pos = 0) const
- {
- gdb_assert (__str != nullptr || __n == 0);
- if (__pos > this->_M_len)
- error (_("basic_string_view::copy: __pos "
- "(which is %zu) > this->size() "
- "(which is %zu)"),
- __pos, this->size());
- size_type __rlen{std::min(__n, size_type{this->_M_len - __pos})};
- for (auto __begin = this->_M_str + __pos,
- __end = __begin + __rlen; __begin != __end;)
- *__str++ = *__begin++;
- return __rlen;
- }
-
-
- // [string.view.ops], string operations:
-
- /*constexpr*/ basic_string_view
- substr(size_type __pos, size_type __n=npos) const
- {
- return __pos <= this->_M_len
- ? basic_string_view{this->_M_str + __pos,
- std::min(__n, size_type{this->_M_len - __pos})}
- : (error (_("basic_string_view::substr: __pos "
- "(which is %zu) > this->size() "
- "(which is %zu)"),
- __pos, this->size()), basic_string_view{});
- }
-
- /*constexpr*/ int
- compare(basic_string_view __str) const noexcept
- {
- int __ret = traits_type::compare(this->_M_str, __str._M_str,
- std::min(this->_M_len, __str._M_len));
- if (__ret == 0)
- __ret = _S_compare(this->_M_len, __str._M_len);
- return __ret;
- }
-
- /*constexpr*/ int
- compare(size_type __pos1, size_type __n1, basic_string_view __str) const
- { return this->substr(__pos1, __n1).compare(__str); }
-
- /*constexpr*/ int
- compare(size_type __pos1, size_type __n1,
- basic_string_view __str, size_type __pos2, size_type __n2) const
- { return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2)); }
-
- /*constexpr*/ int
- compare(const _CharT* __str) const noexcept
- { return this->compare(basic_string_view{__str}); }
-
- /*constexpr*/ int
- compare(size_type __pos1, size_type __n1, const _CharT* __str) const
- { return this->substr(__pos1, __n1).compare(basic_string_view{__str}); }
-
- /*constexpr*/ int
- compare(size_type __pos1, size_type __n1,
- const _CharT* __str, size_type __n2) const
- {
- return this->substr(__pos1, __n1)
- .compare(basic_string_view(__str, __n2));
- }
-
- /*constexpr*/ size_type
- find(basic_string_view __str, size_type __pos = 0) const noexcept
- { return this->find(__str._M_str, __pos, __str._M_len); }
-
- /*constexpr*/ size_type
- find(_CharT __c, size_type __pos=0) const noexcept;
-
- /*constexpr*/ size_type
- find(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
-
- /*constexpr*/ size_type
- find(const _CharT* __str, size_type __pos=0) const noexcept
- { return this->find(__str, __pos, traits_type::length(__str)); }
-
- /*constexpr*/ size_type
- rfind(basic_string_view __str, size_type __pos = npos) const noexcept
- { return this->rfind(__str._M_str, __pos, __str._M_len); }
-
- /*constexpr*/ size_type
- rfind(_CharT __c, size_type __pos = npos) const noexcept;
-
- /*constexpr*/ size_type
- rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
-
- /*constexpr*/ size_type
- rfind(const _CharT* __str, size_type __pos = npos) const noexcept
- { return this->rfind(__str, __pos, traits_type::length(__str)); }
-
- /*constexpr*/ size_type
- find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept
- { return this->find_first_of(__str._M_str, __pos, __str._M_len); }
-
- /*constexpr*/ size_type
- find_first_of(_CharT __c, size_type __pos = 0) const noexcept
- { return this->find(__c, __pos); }
-
- /*constexpr*/ size_type
- find_first_of(const _CharT* __str, size_type __pos, size_type __n) const;
-
- /*constexpr*/ size_type
- find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept
- { return this->find_first_of(__str, __pos, traits_type::length(__str)); }
-
- /*constexpr*/ size_type
- find_last_of(basic_string_view __str,
- size_type __pos = npos) const noexcept
- { return this->find_last_of(__str._M_str, __pos, __str._M_len); }
-
- size_type
- find_last_of(_CharT __c, size_type __pos=npos) const noexcept
- { return this->rfind(__c, __pos); }
-
- /*constexpr*/ size_type
- find_last_of(const _CharT* __str, size_type __pos, size_type __n) const;
-
- /*constexpr*/ size_type
- find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept
- { return this->find_last_of(__str, __pos, traits_type::length(__str)); }
-
- /*constexpr*/ size_type
- find_first_not_of(basic_string_view __str,
- size_type __pos = 0) const noexcept
- { return this->find_first_not_of(__str._M_str, __pos, __str._M_len); }
-
- /*constexpr*/ size_type
- find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept;
-
- /*constexpr*/ size_type
- find_first_not_of(const _CharT* __str,
- size_type __pos, size_type __n) const;
-
- /*constexpr*/ size_type
- find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept
- {
- return this->find_first_not_of(__str, __pos,
- traits_type::length(__str));
- }
-
- /*constexpr*/ size_type
- find_last_not_of(basic_string_view __str,
- size_type __pos = npos) const noexcept
- { return this->find_last_not_of(__str._M_str, __pos, __str._M_len); }
-
- /*constexpr*/ size_type
- find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept;
-
- /*constexpr*/ size_type
- find_last_not_of(const _CharT* __str,
- size_type __pos, size_type __n) const;
-
- /*constexpr*/ size_type
- find_last_not_of(const _CharT* __str,
- size_type __pos = npos) const noexcept
- {
- return this->find_last_not_of(__str, __pos,
- traits_type::length(__str));
- }
-
- private:
-
- static constexpr int
- _S_compare(size_type __n1, size_type __n2) noexcept
- {
- return difference_type(__n1 - __n2) > std::numeric_limits<int>::max()
- ? std::numeric_limits<int>::max()
- : difference_type(__n1 - __n2) < std::numeric_limits<int>::min()
- ? std::numeric_limits<int>::min()
- : static_cast<int>(difference_type(__n1 - __n2));
- }
-
- size_t _M_len;
- const _CharT* _M_str;
- };
-
- // [string.view.comparison], non-member basic_string_view comparison functions
-
- namespace __detail
- {
- // Identity transform to create a non-deduced context, so that only one
- // argument participates in template argument deduction and the other
- // argument gets implicitly converted to the deduced type. See n3766.html.
- template<typename _Tp>
- using __idt = typename std::common_type<_Tp>::type;
- }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator==(basic_string_view<_CharT, _Traits> __x,
- basic_string_view<_CharT, _Traits> __y) noexcept
- { return __x.size() == __y.size() && __x.compare(__y) == 0; }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator==(basic_string_view<_CharT, _Traits> __x,
- __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
- { return __x.size() == __y.size() && __x.compare(__y) == 0; }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
- basic_string_view<_CharT, _Traits> __y) noexcept
- { return __x.size() == __y.size() && __x.compare(__y) == 0; }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator!=(basic_string_view<_CharT, _Traits> __x,
- basic_string_view<_CharT, _Traits> __y) noexcept
- { return !(__x == __y); }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator!=(basic_string_view<_CharT, _Traits> __x,
- __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
- { return !(__x == __y); }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
- basic_string_view<_CharT, _Traits> __y) noexcept
- { return !(__x == __y); }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator< (basic_string_view<_CharT, _Traits> __x,
- basic_string_view<_CharT, _Traits> __y) noexcept
- { return __x.compare(__y) < 0; }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator< (basic_string_view<_CharT, _Traits> __x,
- __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
- { return __x.compare(__y) < 0; }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
- basic_string_view<_CharT, _Traits> __y) noexcept
- { return __x.compare(__y) < 0; }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator> (basic_string_view<_CharT, _Traits> __x,
- basic_string_view<_CharT, _Traits> __y) noexcept
- { return __x.compare(__y) > 0; }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator> (basic_string_view<_CharT, _Traits> __x,
- __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
- { return __x.compare(__y) > 0; }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
- basic_string_view<_CharT, _Traits> __y) noexcept
- { return __x.compare(__y) > 0; }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator<=(basic_string_view<_CharT, _Traits> __x,
- basic_string_view<_CharT, _Traits> __y) noexcept
- { return __x.compare(__y) <= 0; }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator<=(basic_string_view<_CharT, _Traits> __x,
- __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
- { return __x.compare(__y) <= 0; }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator<=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
- basic_string_view<_CharT, _Traits> __y) noexcept
- { return __x.compare(__y) <= 0; }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator>=(basic_string_view<_CharT, _Traits> __x,
- basic_string_view<_CharT, _Traits> __y) noexcept
- { return __x.compare(__y) >= 0; }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator>=(basic_string_view<_CharT, _Traits> __x,
- __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
- { return __x.compare(__y) >= 0; }
-
- template<typename _CharT, typename _Traits>
- /*constexpr*/ bool
- operator>=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
- basic_string_view<_CharT, _Traits> __y) noexcept
- { return __x.compare(__y) >= 0; }
-
- // basic_string_view typedef names
-
- using string_view = basic_string_view<char>;
+template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
+class basic_string_view
+{
+public:
+ // types
+ using traits_type = _Traits;
+ using value_type = _CharT;
+ using pointer = const _CharT *;
+ using const_pointer = const _CharT *;
+ using reference = const _CharT &;
+ using const_reference = const _CharT &;
+ using const_iterator = const _CharT *;
+ using iterator = const_iterator;
+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
+ using reverse_iterator = const_reverse_iterator;
+ using size_type = size_t;
+ using difference_type = ptrdiff_t;
+ static constexpr size_type npos = size_type (-1);
+
+ // [string.view.cons], construct/copy
+
+ constexpr basic_string_view () noexcept : _M_len { 0 }, _M_str { nullptr } {}
+
+ constexpr basic_string_view (const basic_string_view &) noexcept = default;
+
+ template<typename _Allocator>
+ basic_string_view (
+ const std::basic_string<_CharT, _Traits, _Allocator> &__str) noexcept
+ : _M_len { __str.length () },
+ _M_str { __str.data () }
+ {
+ }
+
+ /*constexpr*/ basic_string_view (const _CharT *__str)
+ : _M_len { __str == nullptr ? 0 : traits_type::length (__str) },
+ _M_str { __str }
+ {
+ }
+
+ constexpr basic_string_view (const _CharT *__str, size_type __len)
+ : _M_len { __len },
+ _M_str { __str }
+ {
+ }
+
+ basic_string_view &operator= (const basic_string_view &) noexcept = default;
+
+ // [string.view.iterators], iterators
+
+ constexpr const_iterator begin () const noexcept { return this->_M_str; }
+
+ constexpr const_iterator end () const noexcept
+ {
+ return this->_M_str + this->_M_len;
+ }
+
+ constexpr const_iterator cbegin () const noexcept { return this->_M_str; }
+
+ constexpr const_iterator cend () const noexcept
+ {
+ return this->_M_str + this->_M_len;
+ }
+
+ const_reverse_iterator rbegin () const noexcept
+ {
+ return const_reverse_iterator (this->end ());
+ }
+
+ const_reverse_iterator rend () const noexcept
+ {
+ return const_reverse_iterator (this->begin ());
+ }
+
+ const_reverse_iterator crbegin () const noexcept
+ {
+ return const_reverse_iterator (this->end ());
+ }
+
+ const_reverse_iterator crend () const noexcept
+ {
+ return const_reverse_iterator (this->begin ());
+ }
+
+ // [string.view.capacity], capacity
+
+ constexpr size_type size () const noexcept { return this->_M_len; }
+
+ constexpr size_type length () const noexcept { return _M_len; }
+
+ constexpr size_type max_size () const noexcept
+ {
+ return (npos - sizeof (size_type) - sizeof (void *)) / sizeof (value_type)
+ / 4;
+ }
+
+ constexpr bool empty () const noexcept { return this->_M_len == 0; }
+
+ // [string.view.access], element access
+
+ constexpr const _CharT &operator[] (size_type __pos) const
+ {
+ // TODO: Assert to restore in a way compatible with the constexpr.
+ // __glibcxx_assert(__pos < this->_M_len);
+ return *(this->_M_str + __pos);
+ }
+
+ constexpr const _CharT &at (size_type __pos) const
+ {
+ return __pos < this->_M_len ? *(this->_M_str + __pos)
+ : (error (_ ("basic_string_view::at: __pos "
+ "(which is %zu) >= this->size() "
+ "(which is %zu)"),
+ __pos, this->size ()),
+ *this->_M_str);
+ }
+
+ constexpr const _CharT &front () const
+ {
+ // TODO: Assert to restore in a way compatible with the constexpr.
+ // __glibcxx_assert(this->_M_len > 0);
+ return *this->_M_str;
+ }
+
+ constexpr const _CharT &back () const
+ {
+ // TODO: Assert to restore in a way compatible with the constexpr.
+ // __glibcxx_assert(this->_M_len > 0);
+ return *(this->_M_str + this->_M_len - 1);
+ }
+
+ constexpr const _CharT *data () const noexcept { return this->_M_str; }
+
+ // [string.view.modifiers], modifiers:
+
+ /*constexpr*/ void remove_prefix (size_type __n)
+ {
+ gdb_assert (this->_M_len >= __n);
+ this->_M_str += __n;
+ this->_M_len -= __n;
+ }
+
+ /*constexpr*/ void remove_suffix (size_type __n) { this->_M_len -= __n; }
+
+ /*constexpr*/ void swap (basic_string_view &__sv) noexcept
+ {
+ auto __tmp = *this;
+ *this = __sv;
+ __sv = __tmp;
+ }
+
+ // [string.view.ops], string operations:
+
+ template<typename _Allocator>
+ explicit operator std::basic_string<_CharT, _Traits, _Allocator> () const
+ {
+ return { this->_M_str, this->_M_len };
+ }
+
+ size_type copy (_CharT *__str, size_type __n, size_type __pos = 0) const
+ {
+ gdb_assert (__str != nullptr || __n == 0);
+ if (__pos > this->_M_len)
+ error (_ ("basic_string_view::copy: __pos "
+ "(which is %zu) > this->size() "
+ "(which is %zu)"),
+ __pos, this->size ());
+ size_type __rlen { std::min (__n, size_type { this->_M_len - __pos }) };
+ for (auto __begin = this->_M_str + __pos, __end = __begin + __rlen;
+ __begin != __end;)
+ *__str++ = *__begin++;
+ return __rlen;
+ }
+
+ // [string.view.ops], string operations:
+
+ /*constexpr*/ basic_string_view substr (size_type __pos,
+ size_type __n = npos) const
+ {
+ return __pos <= this->_M_len
+ ? basic_string_view { this->_M_str + __pos,
+ std::min (__n, size_type { this->_M_len
+ - __pos }) }
+ : (error (_ ("basic_string_view::substr: __pos "
+ "(which is %zu) > this->size() "
+ "(which is %zu)"),
+ __pos, this->size ()),
+ basic_string_view {});
+ }
+
+ /*constexpr*/ int compare (basic_string_view __str) const noexcept
+ {
+ int __ret = traits_type::compare (this->_M_str, __str._M_str,
+ std::min (this->_M_len, __str._M_len));
+ if (__ret == 0)
+ __ret = _S_compare (this->_M_len, __str._M_len);
+ return __ret;
+ }
+
+ /*constexpr*/ int compare (size_type __pos1, size_type __n1,
+ basic_string_view __str) const
+ {
+ return this->substr (__pos1, __n1).compare (__str);
+ }
+
+ /*constexpr*/ int compare (size_type __pos1, size_type __n1,
+ basic_string_view __str, size_type __pos2,
+ size_type __n2) const
+ {
+ return this->substr (__pos1, __n1).compare (__str.substr (__pos2, __n2));
+ }
+
+ /*constexpr*/ int compare (const _CharT *__str) const noexcept
+ {
+ return this->compare (basic_string_view { __str });
+ }
+
+ /*constexpr*/ int compare (size_type __pos1, size_type __n1,
+ const _CharT *__str) const
+ {
+ return this->substr (__pos1, __n1).compare (basic_string_view { __str });
+ }
+
+ /*constexpr*/ int compare (size_type __pos1, size_type __n1,
+ const _CharT *__str, size_type __n2) const
+ {
+ return this->substr (__pos1, __n1)
+ .compare (basic_string_view (__str, __n2));
+ }
+
+ /*constexpr*/ size_type find (basic_string_view __str,
+ size_type __pos = 0) const noexcept
+ {
+ return this->find (__str._M_str, __pos, __str._M_len);
+ }
+
+ /*constexpr*/ size_type find (_CharT __c,
+ size_type __pos = 0) const noexcept;
+
+ /*constexpr*/ size_type find (const _CharT *__str, size_type __pos,
+ size_type __n) const noexcept;
+
+ /*constexpr*/ size_type find (const _CharT *__str,
+ size_type __pos = 0) const noexcept
+ {
+ return this->find (__str, __pos, traits_type::length (__str));
+ }
+
+ /*constexpr*/ size_type rfind (basic_string_view __str,
+ size_type __pos = npos) const noexcept
+ {
+ return this->rfind (__str._M_str, __pos, __str._M_len);
+ }
+
+ /*constexpr*/ size_type rfind (_CharT __c,
+ size_type __pos = npos) const noexcept;
+
+ /*constexpr*/ size_type rfind (const _CharT *__str, size_type __pos,
+ size_type __n) const noexcept;
+
+ /*constexpr*/ size_type rfind (const _CharT *__str,
+ size_type __pos = npos) const noexcept
+ {
+ return this->rfind (__str, __pos, traits_type::length (__str));
+ }
+
+ /*constexpr*/ size_type find_first_of (basic_string_view __str,
+ size_type __pos = 0) const noexcept
+ {
+ return this->find_first_of (__str._M_str, __pos, __str._M_len);
+ }
+
+ /*constexpr*/ size_type find_first_of (_CharT __c,
+ size_type __pos = 0) const noexcept
+ {
+ return this->find (__c, __pos);
+ }
+
+ /*constexpr*/ size_type find_first_of (const _CharT *__str, size_type __pos,
+ size_type __n) const;
+
+ /*constexpr*/ size_type find_first_of (const _CharT *__str,
+ size_type __pos = 0) const noexcept
+ {
+ return this->find_first_of (__str, __pos, traits_type::length (__str));
+ }
+
+ /*constexpr*/ size_type find_last_of (basic_string_view __str,
+ size_type __pos = npos) const noexcept
+ {
+ return this->find_last_of (__str._M_str, __pos, __str._M_len);
+ }
+
+ size_type find_last_of (_CharT __c, size_type __pos = npos) const noexcept
+ {
+ return this->rfind (__c, __pos);
+ }
+
+ /*constexpr*/ size_type find_last_of (const _CharT *__str, size_type __pos,
+ size_type __n) const;
+
+ /*constexpr*/ size_type find_last_of (const _CharT *__str,
+ size_type __pos = npos) const noexcept
+ {
+ return this->find_last_of (__str, __pos, traits_type::length (__str));
+ }
+
+ /*constexpr*/ size_type find_first_not_of (basic_string_view __str,
+ size_type __pos
+ = 0) const noexcept
+ {
+ return this->find_first_not_of (__str._M_str, __pos, __str._M_len);
+ }
+
+ /*constexpr*/ size_type find_first_not_of (_CharT __c, size_type __pos
+ = 0) const noexcept;
+
+ /*constexpr*/ size_type find_first_not_of (const _CharT *__str,
+ size_type __pos,
+ size_type __n) const;
+
+ /*constexpr*/ size_type
+ find_first_not_of (const _CharT *__str, size_type __pos = 0) const noexcept
+ {
+ return this->find_first_not_of (__str, __pos, traits_type::length (__str));
+ }
+
+ /*constexpr*/ size_type find_last_not_of (basic_string_view __str,
+ size_type __pos
+ = npos) const noexcept
+ {
+ return this->find_last_not_of (__str._M_str, __pos, __str._M_len);
+ }
+
+ /*constexpr*/ size_type find_last_not_of (_CharT __c, size_type __pos
+ = npos) const noexcept;
+
+ /*constexpr*/ size_type
+ find_last_not_of (const _CharT *__str, size_type __pos, size_type __n) const;
+
+ /*constexpr*/ size_type
+ find_last_not_of (const _CharT *__str, size_type __pos = npos) const noexcept
+ {
+ return this->find_last_not_of (__str, __pos, traits_type::length (__str));
+ }
+
+private:
+ static constexpr int _S_compare (size_type __n1, size_type __n2) noexcept
+ {
+ return difference_type (__n1 - __n2) > std::numeric_limits<int>::max ()
+ ? std::numeric_limits<int>::max ()
+ : difference_type (__n1 - __n2) < std::numeric_limits<int>::min ()
+ ? std::numeric_limits<int>::min ()
+ : static_cast<int> (difference_type (__n1 - __n2));
+ }
+
+ size_t _M_len;
+ const _CharT *_M_str;
+};
+
+// [string.view.comparison], non-member basic_string_view comparison functions
+
+namespace __detail
+{
+// Identity transform to create a non-deduced context, so that only one
+// argument participates in template argument deduction and the other
+// argument gets implicitly converted to the deduced type. See n3766.html.
+template<typename _Tp>
+using __idt = typename std::common_type<_Tp>::type;
+} // namespace __detail
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator== (basic_string_view<_CharT, _Traits> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+{
+ return __x.size () == __y.size () && __x.compare (__y) == 0;
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator== (basic_string_view<_CharT, _Traits> __x,
+ __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
+{
+ return __x.size () == __y.size () && __x.compare (__y) == 0;
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator== (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+{
+ return __x.size () == __y.size () && __x.compare (__y) == 0;
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator!= (basic_string_view<_CharT, _Traits> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+{
+ return !(__x == __y);
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator!= (basic_string_view<_CharT, _Traits> __x,
+ __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
+{
+ return !(__x == __y);
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator!= (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+{
+ return !(__x == __y);
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator<(basic_string_view<_CharT, _Traits> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+{
+ return __x.compare (__y) < 0;
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator<(basic_string_view<_CharT, _Traits> __x,
+ __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
+{
+ return __x.compare (__y) < 0;
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator<(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+{
+ return __x.compare (__y) < 0;
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator> (basic_string_view<_CharT, _Traits> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+{
+ return __x.compare (__y) > 0;
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator> (basic_string_view<_CharT, _Traits> __x,
+ __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
+{
+ return __x.compare (__y) > 0;
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+{
+ return __x.compare (__y) > 0;
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator<= (basic_string_view<_CharT, _Traits> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+{
+ return __x.compare (__y) <= 0;
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator<= (basic_string_view<_CharT, _Traits> __x,
+ __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
+{
+ return __x.compare (__y) <= 0;
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator<= (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+{
+ return __x.compare (__y) <= 0;
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator>= (basic_string_view<_CharT, _Traits> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+{
+ return __x.compare (__y) >= 0;
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator>= (basic_string_view<_CharT, _Traits> __x,
+ __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
+{
+ return __x.compare (__y) >= 0;
+}
+
+template<typename _CharT, typename _Traits>
+/*constexpr*/ bool
+operator>= (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
+ basic_string_view<_CharT, _Traits> __y) noexcept
+{
+ return __x.compare (__y) >= 0;
+}
+
+// basic_string_view typedef names
+
+using string_view = basic_string_view<char>;
} /* namespace gdb */
#include "gdb_string_view.tcc"
#endif // __cplusplus < 201703L
-namespace gdb {
+namespace gdb
+{
static inline std::string
-to_string(const gdb::string_view &view)
+to_string (const gdb::string_view &view)
{
return { view.data (), view.size () };
}
-}
+} // namespace gdb
#endif /* COMMON_GDB_STRING_VIEW_H */
diff --git a/gdbsupport/gdb_sys_time.h b/gdbsupport/gdb_sys_time.h
index 6ea1ae7..4451845 100644
--- a/gdbsupport/gdb_sys_time.h
+++ b/gdbsupport/gdb_sys_time.h
@@ -31,8 +31,8 @@
native 'select' and libiberty, simply undefine away gnulib's
replacements. */
#if GNULIB_defined_struct_timeval
-# undef timeval
-# undef gettimeofday
+#undef timeval
+#undef gettimeofday
#endif
#endif /* COMMON_GDB_SYS_TIME_H */
diff --git a/gdbsupport/gdb_tilde_expand.cc b/gdbsupport/gdb_tilde_expand.cc
index d6bdb87..b8814a9 100644
--- a/gdbsupport/gdb_tilde_expand.cc
+++ b/gdbsupport/gdb_tilde_expand.cc
@@ -31,37 +31,27 @@ public:
/* Construct a "gdb_glob" object by calling "glob" with the provided
parameters. This function can throw if "glob" fails. */
gdb_glob (const char *pattern, int flags,
- int (*errfunc) (const char *epath, int eerrno))
+ int (*errfunc) (const char *epath, int eerrno))
{
int ret = glob (pattern, flags, errfunc, &m_glob);
if (ret != 0)
{
- if (ret == GLOB_NOMATCH)
- error (_("Could not find a match for '%s'."), pattern);
- else
- error (_("glob could not process pattern '%s'."),
- pattern);
+ if (ret == GLOB_NOMATCH)
+ error (_ ("Could not find a match for '%s'."), pattern);
+ else
+ error (_ ("glob could not process pattern '%s'."), pattern);
}
}
/* Destroy the object and free M_GLOB. */
- ~gdb_glob ()
- {
- globfree (&m_glob);
- }
+ ~gdb_glob () { globfree (&m_glob); }
/* Return the GL_PATHC component of M_GLOB. */
- int pathc () const
- {
- return m_glob.gl_pathc;
- }
+ int pathc () const { return m_glob.gl_pathc; }
/* Return the GL_PATHV component of M_GLOB. */
- char **pathv () const
- {
- return m_glob.gl_pathv;
- }
+ char **pathv () const { return m_glob.gl_pathv; }
private:
/* The actual glob object we're dealing with. */
@@ -89,11 +79,9 @@ gdb_tilde_expand (const char *dir)
/* Look for the first dir separator (if any) and split d around it. */
const auto first_sep
- = std::find_if (d.cbegin (), d.cend(),
- [] (const char c) -> bool
- {
- return IS_DIR_SEPARATOR (c);
- });
+ = std::find_if (d.cbegin (), d.cend (), [] (const char c) -> bool {
+ return IS_DIR_SEPARATOR (c);
+ });
const std::string to_expand (d.cbegin (), first_sep);
const std::string remainder (first_sep, d.cend ());
diff --git a/gdbsupport/gdb_unique_ptr.h b/gdbsupport/gdb_unique_ptr.h
index a3ab624..3081915 100644
--- a/gdbsupport/gdb_unique_ptr.h
+++ b/gdbsupport/gdb_unique_ptr.h
@@ -30,14 +30,14 @@ namespace gdb
xmalloc'ed memory. */
/* The deleter for std::unique_xmalloc_ptr. Uses xfree. */
-template <typename T>
+template<typename T>
struct xfree_deleter
{
void operator() (T *ptr) const { xfree (ptr); }
};
/* Same, for arrays. */
-template <typename T>
+template<typename T>
struct xfree_deleter<T[]>
{
void operator() (T *ptr) const { xfree (ptr); }
@@ -46,14 +46,14 @@ struct xfree_deleter<T[]>
/* Import the standard unique_ptr to our namespace with a custom
deleter. */
-template<typename T> using unique_xmalloc_ptr
- = std::unique_ptr<T, xfree_deleter<T>>;
+template<typename T>
+using unique_xmalloc_ptr = std::unique_ptr<T, xfree_deleter<T>>;
/* A no-op deleter. */
template<typename T>
struct noop_deleter
{
- void operator() (T *ptr) const { }
+ void operator() (T *ptr) const {}
};
} /* namespace gdb */
diff --git a/gdbsupport/gdb_unlinker.h b/gdbsupport/gdb_unlinker.h
index 689d9bc..00b3a7d 100644
--- a/gdbsupport/gdb_unlinker.h
+++ b/gdbsupport/gdb_unlinker.h
@@ -30,10 +30,8 @@ namespace gdb
the "keep" method. */
class unlinker
{
- public:
-
- unlinker (const char *filename) ATTRIBUTE_NONNULL (2)
- : m_filename (filename)
+public:
+ unlinker (const char *filename) ATTRIBUTE_NONNULL (2) : m_filename (filename)
{
gdb_assert (filename != NULL);
}
@@ -45,16 +43,12 @@ class unlinker
}
/* Keep the file, rather than unlink it. */
- void keep ()
- {
- m_filename = NULL;
- }
-
- private:
+ void keep () { m_filename = NULL; }
+private:
const char *m_filename;
};
-}
+} // namespace gdb
#endif /* COMMON_GDB_UNLINKER_H */
diff --git a/gdbsupport/gdb_vecs.cc b/gdbsupport/gdb_vecs.cc
index 303d003..bf2d552 100644
--- a/gdbsupport/gdb_vecs.cc
+++ b/gdbsupport/gdb_vecs.cc
@@ -25,9 +25,9 @@
STR into a char pointer vector. */
static void
-delim_string_to_char_ptr_vec_append
- (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *str,
- char delimiter)
+delim_string_to_char_ptr_vec_append (
+ std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *str,
+ char delimiter)
{
do
{
@@ -37,12 +37,12 @@ delim_string_to_char_ptr_vec_append
next_field = strchr (str, delimiter);
if (next_field == NULL)
- this_len = strlen (str);
+ this_len = strlen (str);
else
- {
- this_len = next_field - str;
- next_field++;
- }
+ {
+ this_len = next_field - str;
+ next_field++;
+ }
this_field = (char *) xmalloc (this_len + 1);
memcpy (this_field, str, this_len);
@@ -60,7 +60,7 @@ std::vector<gdb::unique_xmalloc_ptr<char>>
delim_string_to_char_ptr_vec (const char *str, char delimiter)
{
std::vector<gdb::unique_xmalloc_ptr<char>> retval;
-
+
delim_string_to_char_ptr_vec_append (&retval, str, delimiter);
return retval;
@@ -69,8 +69,8 @@ delim_string_to_char_ptr_vec (const char *str, char delimiter)
/* See gdb_vecs.h. */
void
-dirnames_to_char_ptr_vec_append
- (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *dirnames)
+dirnames_to_char_ptr_vec_append (
+ std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *dirnames)
{
delim_string_to_char_ptr_vec_append (vecp, dirnames, DIRNAME_SEPARATOR);
}
@@ -81,7 +81,7 @@ std::vector<gdb::unique_xmalloc_ptr<char>>
dirnames_to_char_ptr_vec (const char *dirnames)
{
std::vector<gdb::unique_xmalloc_ptr<char>> retval;
-
+
dirnames_to_char_ptr_vec_append (&retval, dirnames);
return retval;
diff --git a/gdbsupport/gdb_vecs.h b/gdbsupport/gdb_vecs.h
index 1f1b69b..959faf7 100644
--- a/gdbsupport/gdb_vecs.h
+++ b/gdbsupport/gdb_vecs.h
@@ -25,12 +25,12 @@
You may modify the returned strings. */
extern std::vector<gdb::unique_xmalloc_ptr<char>>
- delim_string_to_char_ptr_vec (const char *str, char delimiter);
+delim_string_to_char_ptr_vec (const char *str, char delimiter);
/* Like dirnames_to_char_ptr_vec, but append the directories to *VECP. */
-extern void dirnames_to_char_ptr_vec_append
- (std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *dirnames);
+extern void dirnames_to_char_ptr_vec_append (
+ std::vector<gdb::unique_xmalloc_ptr<char>> *vecp, const char *dirnames);
/* Split DIRNAMES by DIRNAME_SEPARATOR delimiter and return a list of all the
elements in their original order. For empty string ("") DIRNAMES return
@@ -39,12 +39,12 @@ extern void dirnames_to_char_ptr_vec_append
You may modify the returned strings. */
extern std::vector<gdb::unique_xmalloc_ptr<char>>
- dirnames_to_char_ptr_vec (const char *dirnames);
+dirnames_to_char_ptr_vec (const char *dirnames);
/* Remove the element pointed by iterator IT from VEC, not preserving the order
of the remaining elements. Return the removed element. */
-template <typename T>
+template<typename T>
T
unordered_remove (std::vector<T> &vec, typename std::vector<T>::iterator it)
{
@@ -61,7 +61,7 @@ unordered_remove (std::vector<T> &vec, typename std::vector<T>::iterator it)
/* Remove the element at position IX from VEC, not preserving the order of the
remaining elements. Return the removed element. */
-template <typename T>
+template<typename T>
T
unordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
{
@@ -73,7 +73,7 @@ unordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
/* Remove the element at position IX from VEC, preserving the order the
remaining elements. Return the removed element. */
-template <typename T>
+template<typename T>
T
ordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
{
diff --git a/gdbsupport/gdb_wait.cc b/gdbsupport/gdb_wait.cc
index c7a91de..eda9e4c 100644
--- a/gdbsupport/gdb_wait.cc
+++ b/gdbsupport/gdb_wait.cc
@@ -36,10 +36,10 @@
false positives is justified by the utility of reporting the
terminating signal in the "normal" cases. */
-# include <signal.h>
+#include <signal.h>
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h> /* for EXCEPTION_* constants */
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h> /* for EXCEPTION_* constants */
struct xlate_status
{
@@ -53,27 +53,25 @@ struct xlate_status
int
windows_status_to_termsig (unsigned long status)
{
- static const xlate_status status_xlate_tbl[] =
- {
- {EXCEPTION_ACCESS_VIOLATION, SIGSEGV},
- {EXCEPTION_IN_PAGE_ERROR, SIGSEGV},
- {EXCEPTION_INVALID_HANDLE, SIGSEGV},
- {EXCEPTION_ILLEGAL_INSTRUCTION, SIGILL},
- {EXCEPTION_NONCONTINUABLE_EXCEPTION, SIGILL},
- {EXCEPTION_ARRAY_BOUNDS_EXCEEDED, SIGSEGV},
- {EXCEPTION_FLT_DENORMAL_OPERAND, SIGFPE},
- {EXCEPTION_FLT_DIVIDE_BY_ZERO, SIGFPE},
- {EXCEPTION_FLT_INEXACT_RESULT, SIGFPE},
- {EXCEPTION_FLT_INVALID_OPERATION, SIGFPE},
- {EXCEPTION_FLT_OVERFLOW, SIGFPE},
- {EXCEPTION_FLT_STACK_CHECK, SIGFPE},
- {EXCEPTION_FLT_UNDERFLOW, SIGFPE},
- {EXCEPTION_INT_DIVIDE_BY_ZERO, SIGFPE},
- {EXCEPTION_INT_OVERFLOW, SIGFPE},
- {EXCEPTION_PRIV_INSTRUCTION, SIGILL},
- {EXCEPTION_STACK_OVERFLOW, SIGSEGV},
- {CONTROL_C_EXIT, SIGTERM}
- };
+ static const xlate_status status_xlate_tbl[]
+ = { { EXCEPTION_ACCESS_VIOLATION, SIGSEGV },
+ { EXCEPTION_IN_PAGE_ERROR, SIGSEGV },
+ { EXCEPTION_INVALID_HANDLE, SIGSEGV },
+ { EXCEPTION_ILLEGAL_INSTRUCTION, SIGILL },
+ { EXCEPTION_NONCONTINUABLE_EXCEPTION, SIGILL },
+ { EXCEPTION_ARRAY_BOUNDS_EXCEEDED, SIGSEGV },
+ { EXCEPTION_FLT_DENORMAL_OPERAND, SIGFPE },
+ { EXCEPTION_FLT_DIVIDE_BY_ZERO, SIGFPE },
+ { EXCEPTION_FLT_INEXACT_RESULT, SIGFPE },
+ { EXCEPTION_FLT_INVALID_OPERATION, SIGFPE },
+ { EXCEPTION_FLT_OVERFLOW, SIGFPE },
+ { EXCEPTION_FLT_STACK_CHECK, SIGFPE },
+ { EXCEPTION_FLT_UNDERFLOW, SIGFPE },
+ { EXCEPTION_INT_DIVIDE_BY_ZERO, SIGFPE },
+ { EXCEPTION_INT_OVERFLOW, SIGFPE },
+ { EXCEPTION_PRIV_INSTRUCTION, SIGILL },
+ { EXCEPTION_STACK_OVERFLOW, SIGSEGV },
+ { CONTROL_C_EXIT, SIGTERM } };
for (const xlate_status &x : status_xlate_tbl)
if (x.status == status)
@@ -82,4 +80,4 @@ windows_status_to_termsig (unsigned long status)
return -1;
}
-#endif /* __MINGW32__ */
+#endif /* __MINGW32__ */
diff --git a/gdbsupport/gdb_wait.h b/gdbsupport/gdb_wait.h
index f8d44c9..7dfbd9d 100644
--- a/gdbsupport/gdb_wait.h
+++ b/gdbsupport/gdb_wait.h
@@ -45,23 +45,23 @@
exception, as defined by the various EXCEPTION_* symbols in the
Windows API headers. See also gdb_wait.c. */
-#ifndef WIFEXITED
-# ifdef __MINGW32__
-# define WIFEXITED(w) (((w) & 0xC0000000) == 0)
-# else
-# define WIFEXITED(w) (((w)&0377) == 0)
-# endif
+#ifndef WIFEXITED
+#ifdef __MINGW32__
+#define WIFEXITED(w) (((w) &0xC0000000) == 0)
+#else
+#define WIFEXITED(w) (((w) &0377) == 0)
+#endif
#endif
-#ifndef WIFSIGNALED
-# ifdef __MINGW32__
-# define WIFSIGNALED(w) (((w) & 0xC0000000) == 0xC0000000)
-# else
-# define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0)
-# endif
+#ifndef WIFSIGNALED
+#ifdef __MINGW32__
+#define WIFSIGNALED(w) (((w) &0xC0000000) == 0xC0000000)
+#else
+#define WIFSIGNALED(w) (((w) &0377) != 0177 && ((w) & ~0377) == 0)
+#endif
#endif
-#ifndef WIFSTOPPED
+#ifndef WIFSTOPPED
#ifdef IBM6000
/* Unfortunately, the above comment (about being compatible in all Unix
@@ -69,50 +69,50 @@
status words like 0x57c (sigtrap received after load), and gdb would
choke on it. */
-#define WIFSTOPPED(w) ((w)&0x40)
+#define WIFSTOPPED(w) ((w) &0x40)
#else
-#define WIFSTOPPED(w) (((w)&0377) == 0177)
+#define WIFSTOPPED(w) (((w) &0377) == 0177)
#endif
#endif
-#ifndef WEXITSTATUS
-# ifdef __MINGW32__
-# define WEXITSTATUS(w) ((w) & ~0xC0000000)
-# else
-# define WEXITSTATUS(w) (((w) >> 8) & 0377) /* same as WRETCODE */
-# endif
+#ifndef WEXITSTATUS
+#ifdef __MINGW32__
+#define WEXITSTATUS(w) ((w) & ~0xC0000000)
+#else
+#define WEXITSTATUS(w) (((w) >> 8) & 0377) /* same as WRETCODE */
+#endif
#endif
-#ifndef WTERMSIG
-# ifdef __MINGW32__
+#ifndef WTERMSIG
+#ifdef __MINGW32__
extern int windows_status_to_termsig (unsigned long);
-# define WTERMSIG(w) windows_status_to_termsig (w)
-# else
-# define WTERMSIG(w) ((w) & 0177)
-# endif
+#define WTERMSIG(w) windows_status_to_termsig (w)
+#else
+#define WTERMSIG(w) ((w) &0177)
+#endif
#endif
-#ifndef WSTOPSIG
-#define WSTOPSIG WEXITSTATUS
+#ifndef WSTOPSIG
+#define WSTOPSIG WEXITSTATUS
#endif
/* These are not defined in POSIX, but are used by our programs. */
-#ifndef WSETEXIT
-# ifdef W_EXITCODE
-#define WSETEXIT(w,status) ((w) = W_EXITCODE(status,0))
-# else
-#define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
-# endif
+#ifndef WSETEXIT
+#ifdef W_EXITCODE
+#define WSETEXIT(w, status) ((w) = W_EXITCODE (status, 0))
+#else
+#define WSETEXIT(w, status) ((w) = (0 | ((status) << 8)))
+#endif
#endif
#ifndef W_STOPCODE
#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
#endif
-#ifndef WSETSTOP
-#define WSETSTOP(w,sig) ((w) = W_STOPCODE(sig))
+#ifndef WSETSTOP
+#define WSETSTOP(w, sig) ((w) = W_STOPCODE (sig))
#endif
/* For native GNU/Linux we may use waitpid and the __WCLONE option.
@@ -121,15 +121,15 @@ extern int windows_status_to_termsig (unsigned long);
/* Bits in the third argument to `waitpid'. */
#ifndef WNOHANG
-#define WNOHANG 1 /* Don't block waiting. */
+#define WNOHANG 1 /* Don't block waiting. */
#endif
#ifndef WUNTRACED
-#define WUNTRACED 2 /* Report status of stopped children. */
+#define WUNTRACED 2 /* Report status of stopped children. */
#endif
#ifndef __WCLONE
-#define __WCLONE 0x80000000 /* Wait for cloned process. */
+#define __WCLONE 0x80000000 /* Wait for cloned process. */
#endif
#endif /* COMMON_GDB_WAIT_H */
diff --git a/gdbsupport/hash_enum.h b/gdbsupport/hash_enum.h
index 4867c2d..d03a683 100644
--- a/gdbsupport/hash_enum.h
+++ b/gdbsupport/hash_enum.h
@@ -24,7 +24,8 @@
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2148
*/
-namespace gdb {
+namespace gdb
+{
/* Helper struct for hashing enum types. */
template<typename T>
diff --git a/gdbsupport/host-defs.h b/gdbsupport/host-defs.h
index 8459386..32dbcab 100644
--- a/gdbsupport/host-defs.h
+++ b/gdbsupport/host-defs.h
@@ -25,7 +25,7 @@
/* * Number of bits in a char or unsigned char for the target machine.
Just like CHAR_BIT in <limits.h> but describes the target machine. */
-#if !defined (TARGET_CHAR_BIT)
+#if !defined(TARGET_CHAR_BIT)
#define TARGET_CHAR_BIT 8
#endif
@@ -34,20 +34,20 @@
the number of bits in a host char. If not, use the same size
as the target. */
-#if defined (CHAR_BIT)
+#if defined(CHAR_BIT)
#define HOST_CHAR_BIT CHAR_BIT
#else
#define HOST_CHAR_BIT TARGET_CHAR_BIT
#endif
#ifdef __MSDOS__
-# define CANT_FORK
-# define GLOBAL_CURDIR
-# define DIRNAME_SEPARATOR ';'
+#define CANT_FORK
+#define GLOBAL_CURDIR
+#define DIRNAME_SEPARATOR ';'
#endif
-#if !defined (__CYGWIN__) && defined (_WIN32)
-# define DIRNAME_SEPARATOR ';'
+#if !defined(__CYGWIN__) && defined(_WIN32)
+#define DIRNAME_SEPARATOR ';'
#endif
#ifndef DIRNAME_SEPARATOR
diff --git a/gdbsupport/intrusive_list.h b/gdbsupport/intrusive_list.h
index 5c95f70..5bd8144 100644
--- a/gdbsupport/intrusive_list.h
+++ b/gdbsupport/intrusive_list.h
@@ -27,10 +27,7 @@ template<typename T>
class intrusive_list_node
{
public:
- bool is_linked () const
- {
- return next != INTRUSIVE_LIST_UNLINKED_VALUE;
- }
+ bool is_linked () const { return next != INTRUSIVE_LIST_UNLINKED_VALUE; }
private:
T *next = INTRUSIVE_LIST_UNLINKED_VALUE;
@@ -56,8 +53,7 @@ private:
template<typename T>
struct intrusive_base_node
{
- static intrusive_list_node<T> *as_node (T *elem)
- { return elem; }
+ static intrusive_list_node<T> *as_node (T *elem) { return elem; }
};
/* For element types that keep the node as member field. */
@@ -66,7 +62,9 @@ template<typename T, intrusive_list_node<T> T::*MemberNode>
struct intrusive_member_node
{
static intrusive_list_node<T> *as_node (T *elem)
- { return &(elem->*MemberNode); }
+ {
+ return &(elem->*MemberNode);
+ }
};
/* Common code for forward and reverse iterators. */
@@ -86,30 +84,27 @@ struct intrusive_list_base_iterator
using node_type = intrusive_list_node<T>;
/* Create an iterator pointing to ELEM. */
- explicit intrusive_list_base_iterator (T *elem)
- : m_elem (elem)
- {}
+ explicit intrusive_list_base_iterator (T *elem) : m_elem (elem) {}
/* Create a past-the-end iterator. */
- intrusive_list_base_iterator ()
- : m_elem (nullptr)
- {}
+ intrusive_list_base_iterator () : m_elem (nullptr) {}
- reference operator* () const
- { return *m_elem; }
+ reference operator* () const { return *m_elem; }
- pointer operator-> () const
- { return m_elem; }
+ pointer operator->() const { return m_elem; }
bool operator== (const self_type &other) const
- { return m_elem == other.m_elem; }
+ {
+ return m_elem == other.m_elem;
+ }
bool operator!= (const self_type &other) const
- { return m_elem != other.m_elem; }
+ {
+ return m_elem != other.m_elem;
+ }
protected:
- static node_type *as_node (T *elem)
- { return AsNode::as_node (elem); }
+ static node_type *as_node (T *elem) { return AsNode::as_node (elem); }
/* A past-end-the iterator points to the list's head. */
pointer m_elem;
@@ -119,11 +114,12 @@ protected:
template<typename T, typename AsNode = intrusive_base_node<T>>
struct intrusive_list_iterator
- : public intrusive_list_base_iterator
- <T, AsNode, intrusive_list_iterator<T, AsNode>>
+ : public intrusive_list_base_iterator<T, AsNode,
+ intrusive_list_iterator<T, AsNode>>
{
- using base = intrusive_list_base_iterator
- <T, AsNode, intrusive_list_iterator<T, AsNode>>;
+ using base
+ = intrusive_list_base_iterator<T, AsNode,
+ intrusive_list_iterator<T, AsNode>>;
using self_type = typename base::self_type;
using node_type = typename base::node_type;
@@ -166,11 +162,12 @@ struct intrusive_list_iterator
template<typename T, typename AsNode = intrusive_base_node<T>>
struct intrusive_list_reverse_iterator
- : public intrusive_list_base_iterator
- <T, AsNode, intrusive_list_reverse_iterator<T, AsNode>>
+ : public intrusive_list_base_iterator<
+ T, AsNode, intrusive_list_reverse_iterator<T, AsNode>>
{
- using base = intrusive_list_base_iterator
- <T, AsNode, intrusive_list_reverse_iterator<T, AsNode>>;
+ using base
+ = intrusive_list_base_iterator<T, AsNode,
+ intrusive_list_reverse_iterator<T, AsNode>>;
using self_type = typename base::self_type;
/* Inherit constructor and M_NODE visibility from base. */
@@ -225,7 +222,7 @@ struct intrusive_list_reverse_iterator
where `member` is the name of the member. */
-template <typename T, typename AsNode = intrusive_base_node<T>>
+template<typename T, typename AsNode = intrusive_base_node<T>>
class intrusive_list
{
public:
@@ -245,10 +242,7 @@ public:
intrusive_list () = default;
- ~intrusive_list ()
- {
- clear ();
- }
+ ~intrusive_list () { clear (); }
intrusive_list (intrusive_list &&other)
: m_front (other.m_front),
@@ -274,10 +268,7 @@ public:
std::swap (m_back, other.m_back);
}
- iterator iterator_to (reference value)
- {
- return iterator (&value);
- }
+ iterator iterator_to (reference value) { return iterator (&value); }
const_iterator iterator_to (const_reference value)
{
@@ -369,8 +360,8 @@ public:
if (this->empty ())
{
- *this = std::move (other);
- return;
+ *this = std::move (other);
+ return;
}
/* [A ... B] + [C ... D] */
@@ -460,26 +451,26 @@ private:
if (m_front == &elem)
{
- gdb_assert (elem_node->prev == nullptr);
- m_front = elem_node->next;
+ gdb_assert (elem_node->prev == nullptr);
+ m_front = elem_node->next;
}
else
{
- gdb_assert (elem_node->prev != nullptr);
- intrusive_list_node<T> *prev_node = as_node (elem_node->prev);
- prev_node->next = elem_node->next;
+ gdb_assert (elem_node->prev != nullptr);
+ intrusive_list_node<T> *prev_node = as_node (elem_node->prev);
+ prev_node->next = elem_node->next;
}
if (m_back == &elem)
{
- gdb_assert (elem_node->next == nullptr);
- m_back = elem_node->prev;
+ gdb_assert (elem_node->next == nullptr);
+ m_back = elem_node->prev;
}
else
{
- gdb_assert (elem_node->next != nullptr);
- intrusive_list_node<T> *next_node = as_node (elem_node->next);
- next_node->prev = elem_node->prev;
+ gdb_assert (elem_node->next != nullptr);
+ intrusive_list_node<T> *next_node = as_node (elem_node->next);
+ next_node->prev = elem_node->prev;
}
elem_node->next = INTRUSIVE_LIST_UNLINKED_VALUE;
@@ -513,51 +504,27 @@ public:
{
while (!this->empty ())
{
- pointer p = &front ();
- pop_front ();
- disposer (p);
+ pointer p = &front ();
+ pop_front ();
+ disposer (p);
}
}
- bool empty () const
- {
- return m_front == nullptr;
- }
+ bool empty () const { return m_front == nullptr; }
- iterator begin () noexcept
- {
- return iterator (m_front);
- }
+ iterator begin () noexcept { return iterator (m_front); }
- const_iterator begin () const noexcept
- {
- return const_iterator (m_front);
- }
+ const_iterator begin () const noexcept { return const_iterator (m_front); }
- const_iterator cbegin () const noexcept
- {
- return const_iterator (m_front);
- }
+ const_iterator cbegin () const noexcept { return const_iterator (m_front); }
- iterator end () noexcept
- {
- return {};
- }
+ iterator end () noexcept { return {}; }
- const_iterator end () const noexcept
- {
- return {};
- }
+ const_iterator end () const noexcept { return {}; }
- const_iterator cend () const noexcept
- {
- return {};
- }
+ const_iterator cend () const noexcept { return {}; }
- reverse_iterator rbegin () noexcept
- {
- return reverse_iterator (m_back);
- }
+ reverse_iterator rbegin () noexcept { return reverse_iterator (m_back); }
const_reverse_iterator rbegin () const noexcept
{
@@ -569,26 +536,14 @@ public:
return const_reverse_iterator (m_back);
}
- reverse_iterator rend () noexcept
- {
- return {};
- }
+ reverse_iterator rend () noexcept { return {}; }
- const_reverse_iterator rend () const noexcept
- {
- return {};
- }
+ const_reverse_iterator rend () const noexcept { return {}; }
- const_reverse_iterator crend () const noexcept
- {
- return {};
- }
+ const_reverse_iterator crend () const noexcept { return {}; }
private:
- static node_type *as_node (T *elem)
- {
- return AsNode::as_node (elem);
- }
+ static node_type *as_node (T *elem) { return AsNode::as_node (elem); }
T *m_front = nullptr;
T *m_back = nullptr;
diff --git a/gdbsupport/iterator-range.h b/gdbsupport/iterator-range.h
index e934f5e..4335510 100644
--- a/gdbsupport/iterator-range.h
+++ b/gdbsupport/iterator-range.h
@@ -22,7 +22,7 @@
/* A wrapper that allows using ranged for-loops on a range described by two
iterators. */
-template <typename IteratorType>
+template<typename IteratorType>
struct iterator_range
{
using iterator = IteratorType;
@@ -30,16 +30,18 @@ struct iterator_range
/* Create an iterator_range using BEGIN as the begin iterator.
Assume that the end iterator can be default-constructed. */
- template <typename... Args>
- iterator_range (Args &&...args)
- : m_begin (std::forward<Args> (args)...)
- {}
+ template<typename... Args>
+ iterator_range (Args &&...args) : m_begin (std::forward<Args> (args)...)
+ {
+ }
/* Create an iterator range using explicit BEGIN and END iterators. */
- template <typename... Args>
+ template<typename... Args>
iterator_range (IteratorType begin, IteratorType end)
- : m_begin (std::move (begin)), m_end (std::move (end))
- {}
+ : m_begin (std::move (begin)),
+ m_end (std::move (end))
+ {
+ }
/* Need these as the variadic constructor would be a better match
otherwise. */
@@ -47,15 +49,12 @@ struct iterator_range
iterator_range (const iterator_range &) = default;
iterator_range (iterator_range &&) = default;
- IteratorType begin () const
- { return m_begin; }
+ IteratorType begin () const { return m_begin; }
- IteratorType end () const
- { return m_end; }
+ IteratorType end () const { return m_end; }
/* The number of items in this iterator_range. */
- std::size_t size () const
- { return std::distance (m_begin, m_end); }
+ std::size_t size () const { return std::distance (m_begin, m_end); }
private:
IteratorType m_begin, m_end;
diff --git a/gdbsupport/job-control.cc b/gdbsupport/job-control.cc
index 57dc32c..4820832 100644
--- a/gdbsupport/job-control.cc
+++ b/gdbsupport/job-control.cc
@@ -70,7 +70,7 @@ have_job_control ()
{
/* OK, figure out whether we have job control. If termios is not
available, leave job_control 0. */
-#if defined (HAVE_TERMIOS_H)
+#if defined(HAVE_TERMIOS_H)
/* Do all systems with termios have the POSIX way of identifying job
control? I hope so. */
#ifdef _POSIX_JOB_CONTROL
@@ -79,7 +79,7 @@ have_job_control ()
#ifdef _SC_JOB_CONTROL
job_control = sysconf (_SC_JOB_CONTROL);
#else
- job_control = 0; /* Have to assume the worst. */
+ job_control = 0; /* Have to assume the worst. */
#endif /* _SC_JOB_CONTROL */
#endif /* _POSIX_JOB_CONTROL */
#endif /* HAVE_TERMIOS_H */
diff --git a/gdbsupport/netstuff.cc b/gdbsupport/netstuff.cc
index 55b142d..e2bae0f 100644
--- a/gdbsupport/netstuff.cc
+++ b/gdbsupport/netstuff.cc
@@ -50,41 +50,40 @@ parse_connection_spec_without_prefix (std::string spec, struct addrinfo *hint)
- ai_family is not AF_INET, and
- spec[0] is '[', or
- the number of ':' on spec is greater than 1. */
- bool is_ipv6 = (hint->ai_family == AF_INET6
- || (hint->ai_family != AF_INET
- && (spec[0] == '['
- || std::count (spec.begin (),
- spec.end (), ':') > 1)));
+ bool is_ipv6
+ = (hint->ai_family == AF_INET6
+ || (hint->ai_family != AF_INET
+ && (spec[0] == '['
+ || std::count (spec.begin (), spec.end (), ':') > 1)));
if (is_ipv6)
{
if (spec[0] == '[')
- {
- /* IPv6 addresses can be written as '[ADDR]:PORT', and we
+ {
+ /* IPv6 addresses can be written as '[ADDR]:PORT', and we
support this notation. */
- size_t close_bracket_pos = spec.find_first_of (']');
+ size_t close_bracket_pos = spec.find_first_of (']');
- if (close_bracket_pos == std::string::npos)
- error (_("Missing close bracket in hostname '%s'"),
- spec.c_str ());
+ if (close_bracket_pos == std::string::npos)
+ error (_ ("Missing close bracket in hostname '%s'"),
+ spec.c_str ());
- hint->ai_family = AF_INET6;
+ hint->ai_family = AF_INET6;
- const char c = spec[close_bracket_pos + 1];
+ const char c = spec[close_bracket_pos + 1];
- if (c == '\0')
- last_colon_pos = std::string::npos;
- else if (c != ':')
- error (_("Invalid cruft after close bracket in '%s'"),
- spec.c_str ());
+ if (c == '\0')
+ last_colon_pos = std::string::npos;
+ else if (c != ':')
+ error (_ ("Invalid cruft after close bracket in '%s'"),
+ spec.c_str ());
- /* Erase both '[' and ']'. */
- spec.erase (0, 1);
- spec.erase (close_bracket_pos - 1, 1);
- }
+ /* Erase both '[' and ']'. */
+ spec.erase (0, 1);
+ spec.erase (close_bracket_pos - 1, 1);
+ }
else if (spec.find_first_of (']') != std::string::npos)
- error (_("Missing open bracket in hostname '%s'"),
- spec.c_str ());
+ error (_ ("Missing open bracket in hostname '%s'"), spec.c_str ());
}
if (last_colon_pos == 0)
@@ -119,35 +118,31 @@ parse_connection_spec (const char *spec, struct addrinfo *hint)
/* Struct to hold the association between valid prefixes, their
family and socktype. */
struct host_prefix
- {
- /* The prefix. */
- const char *prefix;
-
- /* The 'ai_family'. */
- int family;
-
- /* The 'ai_socktype'. */
- int socktype;
- };
- static const struct host_prefix prefixes[] =
- {
- { "udp:", AF_UNSPEC, SOCK_DGRAM },
- { "tcp:", AF_UNSPEC, SOCK_STREAM },
- { "udp4:", AF_INET, SOCK_DGRAM },
- { "tcp4:", AF_INET, SOCK_STREAM },
- { "udp6:", AF_INET6, SOCK_DGRAM },
- { "tcp6:", AF_INET6, SOCK_STREAM },
- };
+ {
+ /* The prefix. */
+ const char *prefix;
+
+ /* The 'ai_family'. */
+ int family;
+
+ /* The 'ai_socktype'. */
+ int socktype;
+ };
+ static const struct host_prefix prefixes[] = {
+ { "udp:", AF_UNSPEC, SOCK_DGRAM }, { "tcp:", AF_UNSPEC, SOCK_STREAM },
+ { "udp4:", AF_INET, SOCK_DGRAM }, { "tcp4:", AF_INET, SOCK_STREAM },
+ { "udp6:", AF_INET6, SOCK_DGRAM }, { "tcp6:", AF_INET6, SOCK_STREAM },
+ };
for (const host_prefix prefix : prefixes)
if (startswith (spec, prefix.prefix))
{
- spec += strlen (prefix.prefix);
- hint->ai_family = prefix.family;
- hint->ai_socktype = prefix.socktype;
- hint->ai_protocol
- = hint->ai_socktype == SOCK_DGRAM ? IPPROTO_UDP : IPPROTO_TCP;
- break;
+ spec += strlen (prefix.prefix);
+ hint->ai_family = prefix.family;
+ hint->ai_socktype = prefix.socktype;
+ hint->ai_protocol
+ = hint->ai_socktype == SOCK_DGRAM ? IPPROTO_UDP : IPPROTO_TCP;
+ break;
}
return parse_connection_spec_without_prefix (spec, hint);
diff --git a/gdbsupport/netstuff.h b/gdbsupport/netstuff.h
index f9cf3fc..0ac2c8f 100644
--- a/gdbsupport/netstuff.h
+++ b/gdbsupport/netstuff.h
@@ -31,10 +31,7 @@ class scoped_free_addrinfo
{
public:
/* Default constructor. */
- explicit scoped_free_addrinfo (struct addrinfo *ainfo)
- : m_res (ainfo)
- {
- }
+ explicit scoped_free_addrinfo (struct addrinfo *ainfo) : m_res (ainfo) {}
/* Destructor responsible for free'ing M_RES by calling
'freeaddrinfo'. */
@@ -58,19 +55,17 @@ struct parsed_connection_spec
std::string port_str;
};
-
/* Parse SPEC (which is a string in the form of "ADDR:PORT") and
return a 'parsed_connection_spec' structure with the proper fields
filled in. Also adjust HINT accordingly. */
extern parsed_connection_spec
- parse_connection_spec_without_prefix (std::string spec,
- struct addrinfo *hint);
+parse_connection_spec_without_prefix (std::string spec, struct addrinfo *hint);
/* Parse SPEC (which is a string in the form of
"[tcp[6]:|udp[6]:]ADDR:PORT") and return a 'parsed_connection_spec'
structure with the proper fields filled in. Also adjust HINT
accordingly. */
extern parsed_connection_spec parse_connection_spec (const char *spec,
- struct addrinfo *hint);
+ struct addrinfo *hint);
#endif /* COMMON_NETSTUFF_H */
diff --git a/gdbsupport/new-op.cc b/gdbsupport/new-op.cc
index 6a056ef..6737b52 100644
--- a/gdbsupport/new-op.cc
+++ b/gdbsupport/new-op.cc
@@ -19,7 +19,7 @@
/* GCC does not understand __has_feature. */
#if !defined(__has_feature)
-# define __has_feature(x) 0
+#define __has_feature(x) 0
#endif
#if !__has_feature(address_sanitizer) && !defined(__SANITIZE_ADDRESS__)
@@ -56,7 +56,7 @@ operator new (std::size_t sz)
if (sz == 0)
sz = 1;
- void *p = malloc (sz); /* ARI: malloc */
+ void *p = malloc (sz); /* ARI: malloc */
if (p == NULL)
{
/* If the user decides to continue debugging, throw a
@@ -66,34 +66,34 @@ operator new (std::size_t sz)
can only ever throw std::bad_alloc, or something that extends
it. */
try
- {
- malloc_failure (sz);
- }
+ {
+ malloc_failure (sz);
+ }
catch (gdb_exception &ex)
- {
- throw gdb_quit_bad_alloc (std::move (ex));
- }
+ {
+ throw gdb_quit_bad_alloc (std::move (ex));
+ }
}
return p;
}
void *
-operator new (std::size_t sz, const std::nothrow_t&) noexcept
+operator new (std::size_t sz, const std::nothrow_t &) noexcept
{
/* malloc (0) is unpredictable; avoid it. */
if (sz == 0)
sz = 1;
- return malloc (sz); /* ARI: malloc */
+ return malloc (sz); /* ARI: malloc */
}
void *
operator new[] (std::size_t sz)
{
- return ::operator new (sz);
+ return ::operator new (sz);
}
-void*
-operator new[] (std::size_t sz, const std::nothrow_t&) noexcept
+void *
+operator new[] (std::size_t sz, const std::nothrow_t &) noexcept
{
return ::operator new (sz, std::nothrow);
}
@@ -110,7 +110,7 @@ operator delete (void *p) noexcept
}
void
-operator delete (void *p, const std::nothrow_t&) noexcept
+operator delete (void *p, const std::nothrow_t &) noexcept
{
return ::operator delete (p);
}
@@ -128,7 +128,7 @@ operator delete[] (void *p) noexcept
}
void
-operator delete[] (void *p, const std::nothrow_t&) noexcept
+operator delete[] (void *p, const std::nothrow_t &) noexcept
{
return ::operator delete (p, std::nothrow);
}
diff --git a/gdbsupport/next-iterator.h b/gdbsupport/next-iterator.h
index d4d98a0..d630f3c 100644
--- a/gdbsupport/next-iterator.h
+++ b/gdbsupport/next-iterator.h
@@ -35,21 +35,12 @@ struct next_iterator
typedef std::forward_iterator_tag iterator_category;
typedef int difference_type;
- explicit next_iterator (T *item)
- : m_item (item)
- {
- }
+ explicit next_iterator (T *item) : m_item (item) {}
/* Create a one-past-the-end iterator. */
- next_iterator ()
- : m_item (nullptr)
- {
- }
+ next_iterator () : m_item (nullptr) {}
- value_type operator* () const
- {
- return m_item;
- }
+ value_type operator* () const { return m_item; }
bool operator== (const self_type &other) const
{
@@ -68,13 +59,12 @@ struct next_iterator
}
private:
-
T *m_item;
};
/* A convenience wrapper to make a range type around a next_iterator. */
-template <typename T>
+template<typename T>
using next_range = iterator_range<next_iterator<T>>;
#endif /* COMMON_NEXT_ITERATOR_H */
diff --git a/gdbsupport/observable.h b/gdbsupport/observable.h
index 1a009ef..d8f8f46 100644
--- a/gdbsupport/observable.h
+++ b/gdbsupport/observable.h
@@ -64,19 +64,19 @@ struct token
namespace detail
{
- /* Types that don't depend on any template parameter. This saves a
+/* Types that don't depend on any template parameter. This saves a
bit of code and debug info size, compared to putting them inside
class observable. */
- /* Use for sorting algorithm, to indicate which observer we have
+/* Use for sorting algorithm, to indicate which observer we have
visited. */
- enum class visit_state
- {
- NOT_VISITED,
- VISITING,
- VISITED,
- };
-}
+enum class visit_state
+{
+ NOT_VISITED,
+ VISITING,
+ VISITED,
+};
+} // namespace detail
template<typename... T>
class observable
@@ -88,9 +88,13 @@ private:
struct observer
{
observer (const struct token *token, func_type func, const char *name,
- const std::vector<const struct token *> &dependencies)
- : token (token), func (func), name (name), dependencies (dependencies)
- {}
+ const std::vector<const struct token *> &dependencies)
+ : token (token),
+ func (func),
+ name (name),
+ dependencies (dependencies)
+ {
+ }
const struct token *token;
func_type func;
@@ -99,10 +103,7 @@ private:
};
public:
- explicit observable (const char *name)
- : m_name (name)
- {
- }
+ explicit observable (const char *name) : m_name (name) {}
DISABLE_COPY_AND_ASSIGN (observable);
@@ -115,7 +116,7 @@ public:
NAME is the name of the observer, used for debug output purposes. Its
lifetime must be at least as long as the observer is attached. */
void attach (const func_type &f, const char *name,
- const std::vector<const struct token *> &dependencies = {})
+ const std::vector<const struct token *> &dependencies = {})
{
attach (f, nullptr, name, dependencies);
}
@@ -131,7 +132,7 @@ public:
NAME is the name of the observer, used for debug output purposes. Its
lifetime must be at least as long as the observer is attached. */
void attach (const func_type &f, const token &t, const char *name,
- const std::vector<const struct token *> &dependencies = {})
+ const std::vector<const struct token *> &dependencies = {})
{
attach (f, &t, name, dependencies);
}
@@ -141,15 +142,12 @@ public:
calls. */
void detach (const token &t)
{
- auto iter = std::remove_if (m_observers.begin (),
- m_observers.end (),
- [&] (const observer &o)
- {
- return o.token == &t;
- });
+ auto iter
+ = std::remove_if (m_observers.begin (), m_observers.end (),
+ [&] (const observer &o) { return o.token == &t; });
observer_debug_printf ("Detaching observable %s from observer %s",
- iter->name, m_name);
+ iter->name, m_name);
m_observers.erase (iter, m_observers.end ());
}
@@ -161,14 +159,13 @@ public:
for (auto &&e : m_observers)
{
- OBSERVER_SCOPED_DEBUG_START_END ("calling observer %s of observable %s",
- e.name, m_name);
- e.func (args...);
+ OBSERVER_SCOPED_DEBUG_START_END (
+ "calling observer %s of observable %s", e.name, m_name);
+ e.func (args...);
}
}
private:
-
std::vector<observer> m_observers;
const char *m_name;
@@ -179,8 +176,8 @@ private:
If the observer is already visited, do nothing. */
void visit_for_sorting (std::vector<observer> &sorted_observers,
- std::vector<detail::visit_state> &visit_states,
- int index)
+ std::vector<detail::visit_state> &visit_states,
+ int index)
{
if (visit_states[index] == detail::visit_state::VISITED)
return;
@@ -193,10 +190,10 @@ private:
/* For each dependency of this observer... */
for (const token *dep : m_observers[index].dependencies)
{
- /* ... find the observer that has token DEP. If found, visit it. */
+ /* ... find the observer that has token DEP. If found, visit it. */
auto it_dep
- = std::find_if (m_observers.begin (), m_observers.end (),
- [&] (observer o) { return o.token == dep; });
+ = std::find_if (m_observers.begin (), m_observers.end (),
+ [&] (observer o) { return o.token == dep; });
if (it_dep != m_observers.end ())
{
int i = std::distance (m_observers.begin (), it_dep);
@@ -216,8 +213,8 @@ private:
void sort_observers ()
{
std::vector<observer> sorted_observers;
- std::vector<detail::visit_state> visit_states
- (m_observers.size (), detail::visit_state::NOT_VISITED);
+ std::vector<detail::visit_state>
+ visit_states (m_observers.size (), detail::visit_state::NOT_VISITED);
for (size_t i = 0; i < m_observers.size (); i++)
visit_for_sorting (sorted_observers, visit_states, i);
@@ -228,9 +225,8 @@ private:
void attach (const func_type &f, const token *t, const char *name,
const std::vector<const struct token *> &dependencies)
{
-
- observer_debug_printf ("Attaching observable %s to observer %s",
- name, m_name);
+ observer_debug_printf ("Attaching observable %s to observer %s", name,
+ m_name);
m_observers.emplace_back (t, f, name, dependencies);
diff --git a/gdbsupport/offset-type.h b/gdbsupport/offset-type.h
index d7e079c..310de4c 100644
--- a/gdbsupport/offset-type.h
+++ b/gdbsupport/offset-type.h
@@ -50,8 +50,10 @@
/* Declare TYPE as being an offset type. This declares the type and
enables the operators defined below. */
-#define DEFINE_OFFSET_TYPE(TYPE, UNDERLYING) \
- enum class TYPE : UNDERLYING {}; \
+#define DEFINE_OFFSET_TYPE(TYPE, UNDERLYING) \
+ enum class TYPE : UNDERLYING \
+ { \
+ }; \
void is_offset_type (TYPE)
/* The macro macro is all you need to know use offset types. The rest
@@ -76,53 +78,48 @@
/* Adding or subtracting an integer to an offset type shifts the
offset. This is like "PTR = PTR + INT" and "PTR += INT". */
-#define DEFINE_OFFSET_ARITHM_OP(OP) \
- template<typename E, \
- typename = decltype (is_offset_type (std::declval<E> ()))> \
- constexpr E \
- operator OP (E lhs, typename std::underlying_type<E>::type rhs) \
- { \
- using underlying = typename std::underlying_type<E>::type; \
- return (E) (static_cast<underlying> (lhs) OP rhs); \
- } \
- \
- template<typename E, \
- typename = decltype (is_offset_type (std::declval<E> ()))> \
- constexpr E \
- operator OP (typename std::underlying_type<E>::type lhs, E rhs) \
- { \
- using underlying = typename std::underlying_type<E>::type; \
- return (E) (lhs OP static_cast<underlying> (rhs)); \
- } \
- \
- template<typename E, \
- typename = decltype (is_offset_type (std::declval<E> ()))> \
- E & \
- operator OP ## = (E &lhs, typename std::underlying_type<E>::type rhs) \
- { \
- using underlying = typename std::underlying_type<E>::type; \
- lhs = (E) (static_cast<underlying> (lhs) OP rhs); \
- return lhs; \
+#define DEFINE_OFFSET_ARITHM_OP(OP) \
+ template<typename E, \
+ typename = decltype (is_offset_type (std::declval<E> ()))> \
+ constexpr E operator OP (E lhs, typename std::underlying_type<E>::type rhs) \
+ { \
+ using underlying = typename std::underlying_type<E>::type; \
+ return (E) (static_cast<underlying> (lhs) OP rhs); \
+ } \
+ \
+ template<typename E, \
+ typename = decltype (is_offset_type (std::declval<E> ()))> \
+ constexpr E operator OP (typename std::underlying_type<E>::type lhs, E rhs) \
+ { \
+ using underlying = typename std::underlying_type<E>::type; \
+ return (E) (lhs OP static_cast<underlying> (rhs)); \
+ } \
+ \
+ template<typename E, \
+ typename = decltype (is_offset_type (std::declval<E> ()))> \
+ E &operator OP##= (E &lhs, typename std::underlying_type<E>::type rhs) \
+ { \
+ using underlying = typename std::underlying_type<E>::type; \
+ lhs = (E) (static_cast<underlying> (lhs) OP rhs); \
+ return lhs; \
}
-DEFINE_OFFSET_ARITHM_OP(+)
-DEFINE_OFFSET_ARITHM_OP(-)
+DEFINE_OFFSET_ARITHM_OP (+)
+DEFINE_OFFSET_ARITHM_OP (-)
/* Adding two offset types doesn't make sense, just like "PTR + PTR"
doesn't make sense. This is defined as a deleted function so that
a compile error easily brings you to this comment. */
-template<typename E,
- typename = decltype (is_offset_type (std::declval<E> ()))>
-constexpr typename std::underlying_type<E>::type
-operator+ (E lhs, E rhs) = delete;
+template<typename E, typename = decltype (is_offset_type (std::declval<E> ()))>
+constexpr typename std::underlying_type<E>::type operator+ (E lhs, E rhs)
+ = delete;
/* Subtracting two offset types, however, gives you back the
difference between the offsets, as an underlying type. Similar to
how "PTR2 - PTR1" returns a ptrdiff_t. */
-template<typename E,
- typename = decltype (is_offset_type (std::declval<E> ()))>
+template<typename E, typename = decltype (is_offset_type (std::declval<E> ()))>
constexpr typename std::underlying_type<E>::type
operator- (E lhs, E rhs)
{
diff --git a/gdbsupport/packed.h b/gdbsupport/packed.h
index b18146c..a1ffc93 100644
--- a/gdbsupport/packed.h
+++ b/gdbsupport/packed.h
@@ -39,9 +39,9 @@
/* Clang targeting Windows does not support attribute gcc_struct, so
we use the alternative byte array implemention there. */
#if defined _WIN32 && defined __clang__
-# define PACKED_USE_ARRAY 1
+#define PACKED_USE_ARRAY 1
#else
-# define PACKED_USE_ARRAY 0
+#define PACKED_USE_ARRAY 0
#endif
/* For the preferred implementation, we need gcc_struct on Windows, as
@@ -49,9 +49,9 @@
what we want. Clang targeting Windows does not support attribute
gcc_struct. */
#if !PACKED_USE_ARRAY && defined _WIN32 && !defined __clang__
-# define ATTRIBUTE_GCC_STRUCT __attribute__((__gcc_struct__))
+#define ATTRIBUTE_GCC_STRUCT __attribute__ ((__gcc_struct__))
#else
-# define ATTRIBUTE_GCC_STRUCT
+#define ATTRIBUTE_GCC_STRUCT
#endif
template<typename T, size_t Bytes = sizeof (T)>
@@ -68,8 +68,8 @@ public:
ULONGEST tmp = val;
for (int i = (Bytes - 1); i >= 0; --i)
{
- m_bytes[i] = (gdb_byte) tmp;
- tmp >>= HOST_CHAR_BIT;
+ m_bytes[i] = (gdb_byte) tmp;
+ tmp >>= HOST_CHAR_BIT;
}
#else
m_val = val;
@@ -95,10 +95,10 @@ public:
ULONGEST tmp = 0;
for (int i = 0;;)
{
- tmp |= m_bytes[i];
- if (++i == Bytes)
- break;
- tmp <<= HOST_CHAR_BIT;
+ tmp |= m_bytes[i];
+ if (++i == Bytes)
+ break;
+ tmp <<= HOST_CHAR_BIT;
}
return (T) tmp;
#else
@@ -110,7 +110,7 @@ private:
#if PACKED_USE_ARRAY
gdb_byte m_bytes[Bytes];
#else
- T m_val : (Bytes * HOST_CHAR_BIT) ATTRIBUTE_PACKED;
+ T m_val : (Bytes *HOST_CHAR_BIT) ATTRIBUTE_PACKED;
#endif
};
@@ -122,38 +122,38 @@ private:
conversions to go from T to packed<T> to std::atomic<packed<T>>
(and back), and C++ only does one. */
-#define PACKED_ATOMIC_OP(OP) \
- template<typename T, size_t Bytes> \
- bool operator OP (const std::atomic<packed<T, Bytes>> &lhs, \
- const std::atomic<packed<T, Bytes>> &rhs) \
- { \
- return lhs.load () OP rhs.load (); \
- } \
- \
- template<typename T, size_t Bytes> \
- bool operator OP (T lhs, const std::atomic<packed<T, Bytes>> &rhs) \
- { \
- return lhs OP rhs.load (); \
- } \
- \
- template<typename T, size_t Bytes> \
- bool operator OP (const std::atomic<packed<T, Bytes>> &lhs, T rhs) \
- { \
- return lhs.load () OP rhs; \
- } \
- \
- template<typename T, size_t Bytes> \
- bool operator OP (const std::atomic<packed<T, Bytes>> &lhs, \
- packed<T, Bytes> rhs) \
- { \
- return lhs.load () OP rhs; \
- } \
- \
- template<typename T, size_t Bytes> \
- bool operator OP (packed<T, Bytes> lhs, \
- const std::atomic<packed<T, Bytes>> &rhs) \
- { \
- return lhs OP rhs.load (); \
+#define PACKED_ATOMIC_OP(OP) \
+ template<typename T, size_t Bytes> \
+ bool operator OP (const std::atomic<packed<T, Bytes>> &lhs, \
+ const std::atomic<packed<T, Bytes>> &rhs) \
+ { \
+ return lhs.load () OP rhs.load (); \
+ } \
+ \
+ template<typename T, size_t Bytes> \
+ bool operator OP (T lhs, const std::atomic<packed<T, Bytes>> &rhs) \
+ { \
+ return lhs OP rhs.load (); \
+ } \
+ \
+ template<typename T, size_t Bytes> \
+ bool operator OP (const std::atomic<packed<T, Bytes>> &lhs, T rhs) \
+ { \
+ return lhs.load () OP rhs; \
+ } \
+ \
+ template<typename T, size_t Bytes> \
+ bool operator OP (const std::atomic<packed<T, Bytes>> &lhs, \
+ packed<T, Bytes> rhs) \
+ { \
+ return lhs.load () OP rhs; \
+ } \
+ \
+ template<typename T, size_t Bytes> \
+ bool operator OP (packed<T, Bytes> lhs, \
+ const std::atomic<packed<T, Bytes>> &rhs) \
+ { \
+ return lhs OP rhs.load (); \
}
PACKED_ATOMIC_OP (==)
diff --git a/gdbsupport/parallel-for.h b/gdbsupport/parallel-for.h
index de9ebb1..fc4c30d 100644
--- a/gdbsupport/parallel-for.h
+++ b/gdbsupport/parallel-for.h
@@ -38,11 +38,7 @@ template<typename T>
struct par_for_accumulator
{
public:
-
- explicit par_for_accumulator (size_t n_threads)
- : m_futures (n_threads)
- {
- }
+ explicit par_for_accumulator (size_t n_threads) : m_futures (n_threads) {}
/* The result type that is accumulated. */
typedef std::vector<T> result_type;
@@ -71,13 +67,9 @@ public:
}
/* Resize the results to N. */
- void resize (size_t n)
- {
- m_futures.resize (n);
- }
+ void resize (size_t n) { m_futures.resize (n); }
private:
-
/* A vector of futures coming from the tasks run in the
background. */
std::vector<gdb::future<T>> m_futures;
@@ -88,11 +80,7 @@ template<>
struct par_for_accumulator<void>
{
public:
-
- explicit par_for_accumulator (size_t n_threads)
- : m_futures (n_threads)
- {
- }
+ explicit par_for_accumulator (size_t n_threads) : m_futures (n_threads) {}
/* This specialization does not compute results. */
typedef void result_type;
@@ -109,23 +97,19 @@ public:
for (auto &future : m_futures)
{
- /* Use 'get' and not 'wait', to propagate any exception. */
- future.get ();
+ /* Use 'get' and not 'wait', to propagate any exception. */
+ future.get ();
}
}
/* Resize the results to N. */
- void resize (size_t n)
- {
- m_futures.resize (n);
- }
+ void resize (size_t n) { m_futures.resize (n); }
private:
-
std::vector<gdb::future<void>> m_futures;
};
-}
+} // namespace detail
/* A very simple "parallel for". This splits the range of iterators
into subranges, and then passes each subrange to the callback. The
@@ -144,15 +128,14 @@ private:
the number of threads that were used. */
template<class RandomIt, class RangeFunction>
-typename gdb::detail::par_for_accumulator<
- typename gdb::invoke_result<RangeFunction, RandomIt, RandomIt>::type
- >::result_type
+typename gdb::detail::par_for_accumulator<typename gdb::invoke_result<
+ RangeFunction, RandomIt, RandomIt>::type>::result_type
parallel_for_each (unsigned n, RandomIt first, RandomIt last,
- RangeFunction callback,
- gdb::function_view<size_t(RandomIt)> task_size = nullptr)
+ RangeFunction callback,
+ gdb::function_view<size_t (RandomIt)> task_size = nullptr)
{
- using result_type
- = typename gdb::invoke_result<RangeFunction, RandomIt, RandomIt>::type;
+ using result_type =
+ typename gdb::invoke_result<RangeFunction, RandomIt, RandomIt>::type;
/* If enabled, print debug info about how the work is distributed across
the threads. */
@@ -170,34 +153,34 @@ parallel_for_each (unsigned n, RandomIt first, RandomIt last,
if (n_threads > 1)
{
if (task_size != nullptr)
- {
- gdb_assert (n == 1);
- for (RandomIt i = first; i != last; ++i)
- {
- size_t element_size = task_size (i);
- gdb_assert (element_size > 0);
- if (element_size > max_element_size)
- /* We could start scaling here, but that doesn't seem to be
+ {
+ gdb_assert (n == 1);
+ for (RandomIt i = first; i != last; ++i)
+ {
+ size_t element_size = task_size (i);
+ gdb_assert (element_size > 0);
+ if (element_size > max_element_size)
+ /* We could start scaling here, but that doesn't seem to be
worth the effort. */
- element_size = max_element_size;
- size_t prev_total_size = total_size;
- total_size += element_size;
- /* Check for overflow. */
- gdb_assert (prev_total_size < total_size);
- }
- size_per_thread = total_size / n_threads;
- }
+ element_size = max_element_size;
+ size_t prev_total_size = total_size;
+ total_size += element_size;
+ /* Check for overflow. */
+ gdb_assert (prev_total_size < total_size);
+ }
+ size_per_thread = total_size / n_threads;
+ }
else
- {
- /* Require that there should be at least N elements in a
+ {
+ /* Require that there should be at least N elements in a
thread. */
- gdb_assert (n > 0);
- if (n_elements / n_threads < n)
- n_threads = std::max (n_elements / n, (size_t) 1);
- elts_per_thread = n_elements / n_threads;
- elts_left_over = n_elements % n_threads;
- /* n_elements == n_threads * elts_per_thread + elts_left_over. */
- }
+ gdb_assert (n > 0);
+ if (n_elements / n_threads < n)
+ n_threads = std::max (n_elements / n, (size_t) 1);
+ elts_per_thread = n_elements / n_threads;
+ elts_left_over = n_elements % n_threads;
+ /* n_elements == n_threads * elts_per_thread + elts_left_over. */
+ }
}
size_t count = n_threads == 0 ? 0 : n_threads - 1;
@@ -205,17 +188,20 @@ parallel_for_each (unsigned n, RandomIt first, RandomIt last,
if (parallel_for_each_debug)
{
- debug_printf (_("Parallel for: n_elements: %zu\n"), n_elements);
+ debug_printf (_ ("Parallel for: n_elements: %zu\n"), n_elements);
if (task_size != nullptr)
- {
- debug_printf (_("Parallel for: total_size: %zu\n"), total_size);
- debug_printf (_("Parallel for: size_per_thread: %zu\n"), size_per_thread);
- }
+ {
+ debug_printf (_ ("Parallel for: total_size: %zu\n"), total_size);
+ debug_printf (_ ("Parallel for: size_per_thread: %zu\n"),
+ size_per_thread);
+ }
else
- {
- debug_printf (_("Parallel for: minimum elements per thread: %u\n"), n);
- debug_printf (_("Parallel for: elts_per_thread: %zu\n"), elts_per_thread);
- }
+ {
+ debug_printf (_ ("Parallel for: minimum elements per thread: %u\n"),
+ n);
+ debug_printf (_ ("Parallel for: elts_per_thread: %zu\n"),
+ elts_per_thread);
+ }
}
size_t remaining_size = total_size;
@@ -224,81 +210,77 @@ parallel_for_each (unsigned n, RandomIt first, RandomIt last,
RandomIt end;
size_t chunk_size = 0;
if (task_size == nullptr)
- {
- end = first + elts_per_thread;
- if (i < elts_left_over)
- /* Distribute the leftovers over the worker threads, to avoid having
+ {
+ end = first + elts_per_thread;
+ if (i < elts_left_over)
+ /* Distribute the leftovers over the worker threads, to avoid having
to handle all of them in a single thread. */
- end++;
- }
+ end++;
+ }
else
- {
- RandomIt j;
- for (j = first; j < last && chunk_size < size_per_thread; ++j)
- {
- size_t element_size = task_size (j);
- if (element_size > max_element_size)
- element_size = max_element_size;
- chunk_size += element_size;
- }
- end = j;
- remaining_size -= chunk_size;
- }
+ {
+ RandomIt j;
+ for (j = first; j < last && chunk_size < size_per_thread; ++j)
+ {
+ size_t element_size = task_size (j);
+ if (element_size > max_element_size)
+ element_size = max_element_size;
+ chunk_size += element_size;
+ }
+ end = j;
+ remaining_size -= chunk_size;
+ }
/* This case means we don't have enough elements to really
distribute them. Rather than ever submit a task that does
nothing, we short-circuit here. */
if (first == end)
- end = last;
+ end = last;
if (end == last)
- {
- /* We're about to dispatch the last batch of elements, which
+ {
+ /* We're about to dispatch the last batch of elements, which
we normally process in the main thread. So just truncate
the result list here. This avoids submitting empty tasks
to the thread pool. */
- count = i;
- results.resize (count);
- break;
- }
+ count = i;
+ results.resize (count);
+ break;
+ }
if (parallel_for_each_debug)
- {
- debug_printf (_("Parallel for: elements on worker thread %i\t: %zu"),
- i, (size_t)(end - first));
- if (task_size != nullptr)
- debug_printf (_("\t(size: %zu)"), chunk_size);
- debug_printf (_("\n"));
- }
- results.post (i, [=] ()
{
- return callback (first, end);
- });
+ debug_printf (_ (
+ "Parallel for: elements on worker thread %i\t: %zu"),
+ i, (size_t) (end - first));
+ if (task_size != nullptr)
+ debug_printf (_ ("\t(size: %zu)"), chunk_size);
+ debug_printf (_ ("\n"));
+ }
+ results.post (i, [=] () { return callback (first, end); });
first = end;
}
for (int i = count; i < n_worker_threads; ++i)
if (parallel_for_each_debug)
{
- debug_printf (_("Parallel for: elements on worker thread %i\t: 0"), i);
- if (task_size != nullptr)
- debug_printf (_("\t(size: 0)"));
- debug_printf (_("\n"));
+ debug_printf (_ ("Parallel for: elements on worker thread %i\t: 0"),
+ i);
+ if (task_size != nullptr)
+ debug_printf (_ ("\t(size: 0)"));
+ debug_printf (_ ("\n"));
}
/* Process all the remaining elements in the main thread. */
if (parallel_for_each_debug)
{
- debug_printf (_("Parallel for: elements on main thread\t\t: %zu"),
- (size_t)(last - first));
+ debug_printf (_ ("Parallel for: elements on main thread\t\t: %zu"),
+ (size_t) (last - first));
if (task_size != nullptr)
- debug_printf (_("\t(size: %zu)"), remaining_size);
- debug_printf (_("\n"));
+ debug_printf (_ ("\t(size: %zu)"), remaining_size);
+ debug_printf (_ ("\n"));
}
- return results.finish ([=] ()
- {
- return callback (first, last);
- });
+ return results.finish ([=] () { return callback (first, last); });
}
/* A sequential drop-in replacement of parallel_for_each. This can be useful
@@ -306,24 +288,21 @@ parallel_for_each (unsigned n, RandomIt first, RandomIt last,
multi-threading in a fine-grained way. */
template<class RandomIt, class RangeFunction>
-typename gdb::detail::par_for_accumulator<
- typename gdb::invoke_result<RangeFunction, RandomIt, RandomIt>::type
- >::result_type
+typename gdb::detail::par_for_accumulator<typename gdb::invoke_result<
+ RangeFunction, RandomIt, RandomIt>::type>::result_type
sequential_for_each (unsigned n, RandomIt first, RandomIt last,
- RangeFunction callback,
- gdb::function_view<size_t(RandomIt)> task_size = nullptr)
+ RangeFunction callback,
+ gdb::function_view<size_t (RandomIt)> task_size = nullptr)
{
- using result_type = typename gdb::invoke_result<RangeFunction, RandomIt, RandomIt>::type;
+ using result_type =
+ typename gdb::invoke_result<RangeFunction, RandomIt, RandomIt>::type;
gdb::detail::par_for_accumulator<result_type> results (0);
/* Process all the remaining elements in the main thread. */
- return results.finish ([=] ()
- {
- return callback (first, last);
- });
+ return results.finish ([=] () { return callback (first, last); });
}
-}
+} // namespace gdb
#endif /* GDBSUPPORT_PARALLEL_FOR_H */
diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc
index d1a61f4..a601c17 100644
--- a/gdbsupport/pathstuff.cc
+++ b/gdbsupport/pathstuff.cc
@@ -36,7 +36,7 @@ char *current_directory;
gdb::unique_xmalloc_ptr<char>
gdb_realpath (const char *filename)
{
-/* On most hosts, we rely on canonicalize_file_name to compute
+ /* On most hosts, we rely on canonicalize_file_name to compute
the FILENAME's realpath.
But the situation is slightly more complex on Windows, due to some
@@ -59,7 +59,7 @@ gdb_realpath (const char *filename)
does not exist locally), we rely instead on GetFullPathName to
perform the canonicalization. */
-#if defined (_WIN32)
+#if defined(_WIN32)
{
char buf[MAX_PATH];
DWORD len = GetFullPathName (filename, MAX_PATH, buf, NULL);
@@ -169,7 +169,7 @@ child_path (const char *parent, const char *child)
is nul due to CHILD containing the same path as PARENT, the
IS_DIR_SEPARATOR check will fail here. */
if (!IS_DIR_SEPARATOR (child[parent_len]))
- return NULL;
+ return NULL;
/* The first child component starts after the separator after the
common prefix. */
@@ -181,7 +181,7 @@ child_path (const char *parent, const char *child)
while (*child_component != '\0')
{
if (!IS_DIR_SEPARATOR (*child_component))
- return child_component;
+ return child_component;
child_component++;
}
@@ -200,10 +200,10 @@ path_join (gdb::array_view<const char *> paths)
const char *path = paths[i];
if (i > 0)
- gdb_assert (strlen (path) == 0 || !IS_ABSOLUTE_PATH (path));
+ gdb_assert (strlen (path) == 0 || !IS_ABSOLUTE_PATH (path));
if (!ret.empty () && !IS_DIR_SEPARATOR (ret.back ()))
- ret += '/';
+ ret += '/';
ret.append (path);
}
@@ -219,7 +219,7 @@ contains_dir_separator (const char *path)
for (; *path != '\0'; path++)
{
if (IS_DIR_SEPARATOR (*path))
- return true;
+ return true;
}
return false;
@@ -251,7 +251,7 @@ get_standard_cache_dir ()
{
/* Make sure the path is absolute and tilde-expanded. */
std::string abs = gdb_abspath (home);
- return path_join (abs.c_str (), HOME_CACHE_DIR, "gdb");
+ return path_join (abs.c_str (), HOME_CACHE_DIR, "gdb");
}
#ifdef WIN32
@@ -281,7 +281,7 @@ get_standard_temp_dir ()
if (tmp != nullptr)
return tmp;
- error (_("Couldn't find temp dir path, both TMP and TEMP are unset."));
+ error (_ ("Couldn't find temp dir path, both TMP and TEMP are unset."));
#else
const char *tmp = getenv ("TMPDIR");
@@ -352,7 +352,7 @@ find_gdb_home_config_file (const char *name, struct stat *buf)
if (!config_dir_file.empty ())
{
if (stat (config_dir_file.c_str (), buf) == 0)
- return config_dir_file;
+ return config_dir_file;
}
const char *homedir = getenv ("HOME");
@@ -362,7 +362,7 @@ find_gdb_home_config_file (const char *name, struct stat *buf)
std::string abs = gdb_abspath (homedir);
std::string path = string_printf ("%s/%s", abs.c_str (), name);
if (stat (path.c_str (), buf) == 0)
- return path;
+ return path;
}
return {};
diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h
index b22a521..77aa66e 100644
--- a/gdbsupport/pathstuff.h
+++ b/gdbsupport/pathstuff.h
@@ -71,15 +71,14 @@ extern std::string path_join (gdb::array_view<const char *> paths);
/* Same as the above, but accept paths as distinct parameters. */
-template<typename ...Args>
+template<typename... Args>
std::string
path_join (Args... paths)
{
/* It doesn't make sense to join less than two paths. */
- gdb_static_assert (sizeof... (Args) >= 2);
+ gdb_static_assert (sizeof...(Args) >= 2);
- std::array<const char *, sizeof... (Args)> path_array
- { paths... };
+ std::array<const char *, sizeof...(Args)> path_array { paths... };
return path_join (gdb::array_view<const char *> (path_array));
}
@@ -147,7 +146,7 @@ extern std::string get_standard_config_filename (const char *filename);
'~/.config/gdb/gdbinit' and then '~/.gdbinit'. */
extern std::string find_gdb_home_config_file (const char *name,
- struct stat *buf);
+ struct stat *buf);
/* Return the file name of the user's shell. Normally this comes from
the SHELL environment variable. */
diff --git a/gdbsupport/poison.h b/gdbsupport/poison.h
index 956c3d8..ade8181 100644
--- a/gdbsupport/poison.h
+++ b/gdbsupport/poison.h
@@ -47,13 +47,11 @@ be a compile-time error. */
/* Helper for SFINAE. True if "T *" is memsettable. I.e., if T is
either void, or POD. */
template<typename T>
-struct IsMemsettable
- : gdb::Or<std::is_void<T>,
- std::is_pod<T>>
-{};
+struct IsMemsettable : gdb::Or<std::is_void<T>, std::is_pod<T>>
+{
+};
-template <typename T,
- typename = gdb::Requires<gdb::Not<IsMemsettable<T>>>>
+template<typename T, typename = gdb::Requires<gdb::Not<IsMemsettable<T>>>>
void *memset (T *s, int c, size_t n) = delete;
#if HAVE_IS_TRIVIALLY_COPYABLE
@@ -64,23 +62,21 @@ void *memset (T *s, int c, size_t n) = delete;
/* True if "T *" is relocatable. I.e., copyable with memcpy/memmove.
I.e., T is either trivially copyable, or void. */
template<typename T>
-struct IsRelocatable
- : gdb::Or<std::is_void<T>,
- std::is_trivially_copyable<T>>
-{};
+struct IsRelocatable : gdb::Or<std::is_void<T>, std::is_trivially_copyable<T>>
+{
+};
/* True if both source and destination are relocatable. */
-template <typename D, typename S>
-using BothAreRelocatable
- = gdb::And<IsRelocatable<D>, IsRelocatable<S>>;
+template<typename D, typename S>
+using BothAreRelocatable = gdb::And<IsRelocatable<D>, IsRelocatable<S>>;
-template <typename D, typename S,
- typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
+template<typename D, typename S,
+ typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
void *memcpy (D *dest, const S *src, size_t n) = delete;
-template <typename D, typename S,
- typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
+template<typename D, typename S,
+ typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
void *memmove (D *dest, const S *src, size_t n) = delete;
#endif /* HAVE_IS_TRIVIALLY_COPYABLE */
@@ -98,7 +94,7 @@ using IsMallocable = std::true_type;
template<typename T>
using IsFreeable = gdb::Or<std::is_trivially_destructible<T>, std::is_void<T>>;
-template <typename T, typename = gdb::Requires<gdb::Not<IsFreeable<T>>>>
+template<typename T, typename = gdb::Requires<gdb::Not<IsFreeable<T>>>>
void free (T *ptr) = delete;
template<typename T>
@@ -111,7 +107,7 @@ data type. Use operator new instead.");
}
#undef XNEW
-#define XNEW(T) xnew<T>()
+#define XNEW(T) xnew<T> ()
template<typename T>
static T *
@@ -123,7 +119,7 @@ data type. Use operator new instead.");
}
#undef XCNEW
-#define XCNEW(T) xcnew<T>()
+#define XCNEW(T) xcnew<T> ()
template<typename T>
static void
@@ -191,7 +187,8 @@ xnewvar (size_t s)
{
static_assert (IsMallocable<T>::value, "Trying to use XNEWVAR with a \
non-POD data type.");
- return XNEWVAR (T, s);;
+ return XNEWVAR (T, s);
+ ;
}
#undef XNEWVAR
diff --git a/gdbsupport/preprocessor.h b/gdbsupport/preprocessor.h
index 2671125..cbb24d7 100644
--- a/gdbsupport/preprocessor.h
+++ b/gdbsupport/preprocessor.h
@@ -21,7 +21,7 @@
/* Generally useful preprocessor bits. */
/* Concatenate two tokens. */
-#define CONCAT_1(a, b) a ## b
+#define CONCAT_1(a, b) a##b
#define CONCAT(a, b) CONCAT_1 (a, b)
/* Stringification. */
diff --git a/gdbsupport/print-utils.cc b/gdbsupport/print-utils.cc
index 3cc1ed6..d24e288 100644
--- a/gdbsupport/print-utils.cc
+++ b/gdbsupport/print-utils.cc
@@ -65,15 +65,15 @@ decimal2str (const char *sign, ULONGEST addr, int width)
xsnprintf (str, PRINT_CELL_SIZE, "%s%0*lu", sign, width, temp[0]);
break;
case 2:
- xsnprintf (str, PRINT_CELL_SIZE, "%s%0*lu%09lu", sign, width,
- temp[1], temp[0]);
+ xsnprintf (str, PRINT_CELL_SIZE, "%s%0*lu%09lu", sign, width, temp[1],
+ temp[0]);
break;
case 3:
xsnprintf (str, PRINT_CELL_SIZE, "%s%0*lu%09lu%09lu", sign, width,
- temp[2], temp[1], temp[0]);
+ temp[2], temp[1], temp[0]);
break;
default:
- internal_error (_("failed internal consistency check"));
+ internal_error (_ ("failed internal consistency check"));
}
return str;
@@ -103,19 +103,20 @@ octal2str (ULONGEST addr, int width)
{
case 1:
if (temp[0] == 0)
- xsnprintf (str, PRINT_CELL_SIZE, "%*o", width, 0);
+ xsnprintf (str, PRINT_CELL_SIZE, "%*o", width, 0);
else
- xsnprintf (str, PRINT_CELL_SIZE, "0%0*lo", width, temp[0]);
+ xsnprintf (str, PRINT_CELL_SIZE, "0%0*lo", width, temp[0]);
break;
case 2:
- xsnprintf (str, PRINT_CELL_SIZE, "0%0*lo%010lo", width, temp[1], temp[0]);
+ xsnprintf (str, PRINT_CELL_SIZE, "0%0*lo%010lo", width, temp[1],
+ temp[0]);
break;
case 3:
- xsnprintf (str, PRINT_CELL_SIZE, "0%0*lo%010lo%010lo", width,
- temp[2], temp[1], temp[0]);
+ xsnprintf (str, PRINT_CELL_SIZE, "0%0*lo%010lo%010lo", width, temp[2],
+ temp[1], temp[0]);
break;
default:
- internal_error (_("failed internal consistency check"));
+ internal_error (_ ("failed internal consistency check"));
}
return str;
@@ -155,8 +156,8 @@ phex (ULONGEST l, int sizeof_l)
case 8:
str = get_print_cell ();
xsnprintf (str, PRINT_CELL_SIZE, "%08lx%08lx",
- (unsigned long) (l >> thirty_two),
- (unsigned long) (l & 0xffffffff));
+ (unsigned long) (l >> thirty_two),
+ (unsigned long) (l & 0xffffffff));
break;
case 4:
str = get_print_cell ();
@@ -189,16 +190,16 @@ phex_nz (ULONGEST l, int sizeof_l)
{
case 8:
{
- unsigned long high = (unsigned long) (l >> thirty_two);
-
- str = get_print_cell ();
- if (high == 0)
- xsnprintf (str, PRINT_CELL_SIZE, "%lx",
- (unsigned long) (l & 0xffffffff));
- else
- xsnprintf (str, PRINT_CELL_SIZE, "%lx%08lx", high,
- (unsigned long) (l & 0xffffffff));
- break;
+ unsigned long high = (unsigned long) (l >> thirty_two);
+
+ str = get_print_cell ();
+ if (high == 0)
+ xsnprintf (str, PRINT_CELL_SIZE, "%lx",
+ (unsigned long) (l & 0xffffffff));
+ else
+ xsnprintf (str, PRINT_CELL_SIZE, "%lx%08lx", high,
+ (unsigned long) (l & 0xffffffff));
+ break;
}
case 4:
str = get_print_cell ();
@@ -244,7 +245,7 @@ hex_string_custom (LONGEST num, int width)
if (hex_len > width)
width = hex_len;
if (width + 2 >= PRINT_CELL_SIZE)
- internal_error (_("\
+ internal_error (_ ("\
hex_string_custom: insufficient space to store result"));
strcpy (result_end - width - 2, "0x");
@@ -256,45 +257,44 @@ hex_string_custom: insufficient space to store result"));
/* See print-utils.h. */
char *
-int_string (LONGEST val, int radix, int is_signed, int width,
- int use_c_format)
+int_string (LONGEST val, int radix, int is_signed, int width, int use_c_format)
{
switch (radix)
{
case 16:
{
- char *result;
-
- if (width == 0)
- result = hex_string (val);
- else
- result = hex_string_custom (val, width);
- if (! use_c_format)
- result += 2;
- return result;
+ char *result;
+
+ if (width == 0)
+ result = hex_string (val);
+ else
+ result = hex_string_custom (val, width);
+ if (!use_c_format)
+ result += 2;
+ return result;
}
case 10:
{
- if (is_signed && val < 0)
- /* Cast to unsigned before negating, to prevent runtime error:
+ if (is_signed && val < 0)
+ /* Cast to unsigned before negating, to prevent runtime error:
negation of -9223372036854775808 cannot be represented in type
'long int'; cast to an unsigned type to negate this value to
itself. */
- return decimal2str ("-", -(ULONGEST)val, width);
- else
- return decimal2str ("", val, width);
+ return decimal2str ("-", -(ULONGEST) val, width);
+ else
+ return decimal2str ("", val, width);
}
case 8:
{
- char *result = octal2str (val, width);
+ char *result = octal2str (val, width);
- if (use_c_format || val == 0)
- return result;
- else
- return result + 1;
+ if (use_c_format || val == 0)
+ return result;
+ else
+ return result + 1;
}
default:
- internal_error (_("failed internal consistency check"));
+ internal_error (_ ("failed internal consistency check"));
}
}
@@ -330,6 +330,6 @@ host_address_to_string_1 (const void *addr)
char *str = get_print_cell ();
xsnprintf (str, PRINT_CELL_SIZE, "0x%s",
- phex_nz ((uintptr_t) addr, sizeof (addr)));
+ phex_nz ((uintptr_t) addr, sizeof (addr)));
return str;
}
diff --git a/gdbsupport/print-utils.h b/gdbsupport/print-utils.h
index 7df9b0d..1cc3164 100644
--- a/gdbsupport/print-utils.h
+++ b/gdbsupport/print-utils.h
@@ -63,8 +63,8 @@ extern char *hex_string_custom (LONGEST num, int width);
* to use C format in all cases. If it is false, then 'x'
* and 'o' formats do not include a prefix (0x or leading 0). */
-extern char *int_string (LONGEST val, int radix, int is_signed, int width,
- int use_c_format);
+extern char *int_string (LONGEST val, int radix, int is_signed, int width,
+ int use_c_format);
/* Convert a CORE_ADDR into a string. */
diff --git a/gdbsupport/ptid.h b/gdbsupport/ptid.h
index aa296b8..deb2ea8 100644
--- a/gdbsupport/ptid.h
+++ b/gdbsupport/ptid.h
@@ -53,33 +53,31 @@ public:
represent a whole process, including all its lwps/threads. */
explicit constexpr ptid_t (pid_type pid, lwp_type lwp = 0, tid_type tid = 0)
- : m_pid (pid), m_lwp (lwp), m_tid (tid)
- {}
+ : m_pid (pid),
+ m_lwp (lwp),
+ m_tid (tid)
+ {
+ }
/* Fetch the pid (process id) component from the ptid. */
- constexpr pid_type pid () const
- { return m_pid; }
+ constexpr pid_type pid () const { return m_pid; }
/* Return true if the ptid's lwp member is non-zero. */
- constexpr bool lwp_p () const
- { return m_lwp != 0; }
+ constexpr bool lwp_p () const { return m_lwp != 0; }
/* Fetch the lwp (lightweight process) component from the ptid. */
- constexpr lwp_type lwp () const
- { return m_lwp; }
+ constexpr lwp_type lwp () const { return m_lwp; }
/* Return true if the ptid's tid member is non-zero. */
- constexpr bool tid_p () const
- { return m_tid != 0; }
+ constexpr bool tid_p () const { return m_tid != 0; }
/* Fetch the tid (thread id) component from a ptid. */
- constexpr tid_type tid () const
- { return m_tid; }
+ constexpr tid_type tid () const { return m_tid; }
/* Return true if the ptid represents a whole process, including all its
lwps/threads. Such ptids have the form of (pid, 0, 0), with
@@ -87,19 +85,16 @@ public:
constexpr bool is_pid () const
{
- return (*this != make_null ()
- && *this != make_minus_one ()
- && m_lwp == 0
- && m_tid == 0);
+ return (*this != make_null () && *this != make_minus_one () && m_lwp == 0
+ && m_tid == 0);
}
/* Compare two ptids to see if they are equal. */
constexpr bool operator== (const ptid_t &other) const
{
- return (m_pid == other.m_pid
- && m_lwp == other.m_lwp
- && m_tid == other.m_tid);
+ return (m_pid == other.m_pid && m_lwp == other.m_lwp
+ && m_tid == other.m_tid);
}
/* Compare two ptids to see if they are different. */
@@ -120,14 +115,14 @@ public:
constexpr bool matches (const ptid_t &filter) const
{
return (/* If filter represents any ptid, it's always a match. */
- filter == make_minus_one ()
- /* If filter is only a pid, any ptid with that pid
+ filter == make_minus_one ()
+ /* If filter is only a pid, any ptid with that pid
matches. */
- || (filter.is_pid () && m_pid == filter.pid ())
+ || (filter.is_pid () && m_pid == filter.pid ())
- /* Otherwise, this ptid only matches if it's exactly equal
+ /* Otherwise, this ptid only matches if it's exactly equal
to filter. */
- || *this == filter);
+ || *this == filter);
}
/* Return a string representation of the ptid.
@@ -138,13 +133,11 @@ public:
/* Make a null ptid. */
- static constexpr ptid_t make_null ()
- { return ptid_t (0, 0, 0); }
+ static constexpr ptid_t make_null () { return ptid_t (0, 0, 0); }
/* Make a minus one ptid. */
- static constexpr ptid_t make_minus_one ()
- { return ptid_t (-1, 0, 0); }
+ static constexpr ptid_t make_minus_one () { return ptid_t (-1, 0, 0); }
private:
/* Process id. */
@@ -165,9 +158,8 @@ struct hash_ptid
{
std::hash<long> long_hash;
- return (long_hash (ptid.pid ())
- + long_hash (ptid.lwp ())
- + long_hash (ptid.tid ()));
+ return (long_hash (ptid.pid ()) + long_hash (ptid.lwp ())
+ + long_hash (ptid.tid ()));
}
};
diff --git a/gdbsupport/range-chain.h b/gdbsupport/range-chain.h
index 01d6cf0..12cf7e6 100644
--- a/gdbsupport/range-chain.h
+++ b/gdbsupport/range-chain.h
@@ -29,10 +29,9 @@ struct range_chain
class iterator
{
public:
-
iterator (const std::vector<Range> &ranges, size_t idx)
: m_index (idx),
- m_ranges (ranges)
+ m_ranges (ranges)
{
skip_empty ();
}
@@ -40,27 +39,24 @@ struct range_chain
bool operator== (const iterator &other) const
{
if (m_index != other.m_index || &m_ranges != &other.m_ranges)
- return false;
+ return false;
if (m_current.has_value () != other.m_current.has_value ())
- return false;
+ return false;
if (m_current.has_value ())
- return *m_current == *other.m_current;
+ return *m_current == *other.m_current;
return true;
}
- bool operator!= (const iterator &other) const
- {
- return !(*this == other);
- }
+ bool operator!= (const iterator &other) const { return !(*this == other); }
iterator &operator++ ()
{
++*m_current;
if (*m_current == m_ranges[m_index].end ())
- {
- ++m_index;
- skip_empty ();
- }
+ {
+ ++m_index;
+ skip_empty ();
+ }
return *this;
}
@@ -76,11 +72,11 @@ struct range_chain
void skip_empty ()
{
for (; m_index < m_ranges.size (); ++m_index)
- {
- m_current = m_ranges[m_index].begin ();
- if (*m_current != m_ranges[m_index].end ())
- return;
- }
+ {
+ m_current = m_ranges[m_index].begin ();
+ if (*m_current != m_ranges[m_index].end ())
+ return;
+ }
m_current.reset ();
}
@@ -97,23 +93,15 @@ struct range_chain
/* Create a new range_chain. */
template<typename T>
- range_chain (T &&ranges)
- : m_ranges (std::forward<T> (ranges))
+ range_chain (T &&ranges) : m_ranges (std::forward<T> (ranges))
{
}
- iterator begin () const
- {
- return iterator (m_ranges, 0);
- }
+ iterator begin () const { return iterator (m_ranges, 0); }
- iterator end () const
- {
- return iterator (m_ranges, m_ranges.size ());
- }
+ iterator end () const { return iterator (m_ranges, m_ranges.size ()); }
private:
-
/* The sub-ranges. */
std::vector<Range> m_ranges;
};
diff --git a/gdbsupport/refcounted-object.h b/gdbsupport/refcounted-object.h
index d8fdb95..eca885c 100644
--- a/gdbsupport/refcounted-object.h
+++ b/gdbsupport/refcounted-object.h
@@ -56,15 +56,9 @@ private:
struct refcounted_object_ref_policy
{
- static void incref (refcounted_object *ptr)
- {
- ptr->incref ();
- }
+ static void incref (refcounted_object *ptr) { ptr->incref (); }
- static void decref (refcounted_object *ptr)
- {
- ptr->decref ();
- }
+ static void decref (refcounted_object *ptr) { ptr->decref (); }
};
#endif /* COMMON_REFCOUNTED_OBJECT_H */
diff --git a/gdbsupport/reference-to-pointer-iterator.h b/gdbsupport/reference-to-pointer-iterator.h
index 792659b..07b713a 100644
--- a/gdbsupport/reference-to-pointer-iterator.h
+++ b/gdbsupport/reference-to-pointer-iterator.h
@@ -26,7 +26,7 @@
lists, which yield references, and the rest of GDB, which for legacy reasons
expects to iterate on pointers. */
-template <typename IteratorType>
+template<typename IteratorType>
struct reference_to_pointer_iterator
{
using self_type = reference_to_pointer_iterator;
@@ -38,29 +38,32 @@ struct reference_to_pointer_iterator
/* Construct a reference_to_pointer_iterator, passing args to the underyling
iterator. */
- template <typename... Args>
+ template<typename... Args>
reference_to_pointer_iterator (Args &&...args)
: m_it (std::forward<Args> (args)...)
- {}
+ {
+ }
/* Create a past-the-end iterator.
Assumes that default-constructing an underlying iterator creates a
past-the-end iterator. */
- reference_to_pointer_iterator ()
- {}
+ reference_to_pointer_iterator () {}
/* Need these as the variadic constructor would be a better match
otherwise. */
reference_to_pointer_iterator (reference_to_pointer_iterator &) = default;
- reference_to_pointer_iterator (const reference_to_pointer_iterator &) = default;
+ reference_to_pointer_iterator (const reference_to_pointer_iterator &)
+ = default;
reference_to_pointer_iterator (reference_to_pointer_iterator &&) = default;
- reference_to_pointer_iterator &operator= (const reference_to_pointer_iterator &) = default;
- reference_to_pointer_iterator &operator= (reference_to_pointer_iterator &&) = default;
+ reference_to_pointer_iterator &
+ operator= (const reference_to_pointer_iterator &)
+ = default;
+ reference_to_pointer_iterator &operator= (reference_to_pointer_iterator &&)
+ = default;
- value_type operator* () const
- { return &*m_it; }
+ value_type operator* () const { return &*m_it; }
self_type &operator++ ()
{
@@ -68,11 +71,9 @@ struct reference_to_pointer_iterator
return *this;
}
- bool operator== (const self_type &other) const
- { return m_it == other.m_it; }
+ bool operator== (const self_type &other) const { return m_it == other.m_it; }
- bool operator!= (const self_type &other) const
- { return m_it != other.m_it; }
+ bool operator!= (const self_type &other) const { return m_it != other.m_it; }
private:
/* The underlying iterator. */
diff --git a/gdbsupport/rsp-low.cc b/gdbsupport/rsp-low.cc
index 3d8c200..a06f63d 100644
--- a/gdbsupport/rsp-low.cc
+++ b/gdbsupport/rsp-low.cc
@@ -78,8 +78,8 @@ pack_hex_byte (char *pkt, int byte)
/* See rsp-low.h. */
const char *
-unpack_varlen_hex (const char *buff, /* packet to parse */
- ULONGEST *result)
+unpack_varlen_hex (const char *buff, /* packet to parse */
+ ULONGEST *result)
{
int nibble;
ULONGEST retval = 0;
@@ -113,11 +113,11 @@ hex2str (const char *hex, int count)
for (size_t i = 0; i < count; ++i)
{
if (hex[0] == '\0' || hex[1] == '\0')
- {
- /* Hex string is short, or of uneven length. Return what we
+ {
+ /* Hex string is short, or of uneven length. Return what we
have so far. */
- return ret;
- }
+ return ret;
+ }
ret += fromhex (hex[0]) * 16 + fromhex (hex[1]);
hex += 2;
}
@@ -170,8 +170,8 @@ needs_escaping (gdb_byte b)
int
remote_escape_output (const gdb_byte *buffer, int len_units, int unit_size,
- gdb_byte *out_buf, int *out_len_units,
- int out_maxlen_bytes)
+ gdb_byte *out_buf, int *out_len_units,
+ int out_maxlen_bytes)
{
int input_unit_index, output_byte_index = 0, byte_index_in_unit;
int number_escape_bytes_needed;
@@ -179,42 +179,38 @@ remote_escape_output (const gdb_byte *buffer, int len_units, int unit_size,
/* Try to copy integral addressable memory units until
(1) we run out of space or
(2) we copied all of them. */
- for (input_unit_index = 0;
- input_unit_index < len_units;
- input_unit_index++)
+ for (input_unit_index = 0; input_unit_index < len_units; input_unit_index++)
{
/* Find out how many escape bytes we need for this unit. */
number_escape_bytes_needed = 0;
- for (byte_index_in_unit = 0;
- byte_index_in_unit < unit_size;
- byte_index_in_unit++)
- {
- int idx = input_unit_index * unit_size + byte_index_in_unit;
- gdb_byte b = buffer[idx];
- if (needs_escaping (b))
- number_escape_bytes_needed++;
- }
+ for (byte_index_in_unit = 0; byte_index_in_unit < unit_size;
+ byte_index_in_unit++)
+ {
+ int idx = input_unit_index * unit_size + byte_index_in_unit;
+ gdb_byte b = buffer[idx];
+ if (needs_escaping (b))
+ number_escape_bytes_needed++;
+ }
/* Check if we have room to fit this escaped unit. */
- if (output_byte_index + unit_size + number_escape_bytes_needed >
- out_maxlen_bytes)
- break;
+ if (output_byte_index + unit_size + number_escape_bytes_needed
+ > out_maxlen_bytes)
+ break;
/* Copy the unit byte per byte, adding escapes. */
- for (byte_index_in_unit = 0;
- byte_index_in_unit < unit_size;
- byte_index_in_unit++)
- {
- int idx = input_unit_index * unit_size + byte_index_in_unit;
- gdb_byte b = buffer[idx];
- if (needs_escaping (b))
- {
- out_buf[output_byte_index++] = '}';
- out_buf[output_byte_index++] = b ^ 0x20;
- }
- else
- out_buf[output_byte_index++] = b;
- }
+ for (byte_index_in_unit = 0; byte_index_in_unit < unit_size;
+ byte_index_in_unit++)
+ {
+ int idx = input_unit_index * unit_size + byte_index_in_unit;
+ gdb_byte b = buffer[idx];
+ if (needs_escaping (b))
+ {
+ out_buf[output_byte_index++] = '}';
+ out_buf[output_byte_index++] = b ^ 0x20;
+ }
+ else
+ out_buf[output_byte_index++] = b;
+ }
}
*out_len_units = input_unit_index;
@@ -224,8 +220,8 @@ remote_escape_output (const gdb_byte *buffer, int len_units, int unit_size,
/* See rsp-low.h. */
int
-remote_unescape_input (const gdb_byte *buffer, int len,
- gdb_byte *out_buf, int out_maxlen)
+remote_unescape_input (const gdb_byte *buffer, int len, gdb_byte *out_buf,
+ int out_maxlen)
{
int input_index, output_index;
int escaped;
@@ -237,22 +233,21 @@ remote_unescape_input (const gdb_byte *buffer, int len,
gdb_byte b = buffer[input_index];
if (output_index + 1 > out_maxlen)
- error (_("Received too much data from the target."));
+ error (_ ("Received too much data from the target."));
if (escaped)
- {
- out_buf[output_index++] = b ^ 0x20;
- escaped = 0;
- }
+ {
+ out_buf[output_index++] = b ^ 0x20;
+ escaped = 0;
+ }
else if (b == '}')
- escaped = 1;
+ escaped = 1;
else
- out_buf[output_index++] = b;
+ out_buf[output_index++] = b;
}
if (escaped)
- error (_("Unmatched escape character in target response."));
+ error (_ ("Unmatched escape character in target response."));
return output_index;
}
-
diff --git a/gdbsupport/rsp-low.h b/gdbsupport/rsp-low.h
index 327d5f3..99e320c 100644
--- a/gdbsupport/rsp-low.h
+++ b/gdbsupport/rsp-low.h
@@ -67,8 +67,8 @@ extern std::string bin2hex (const gdb_byte *bin, int count);
for the server side as well as the client. */
extern int remote_escape_output (const gdb_byte *buffer, int len_units,
- int unit_size, gdb_byte *out_buf,
- int *out_len_units, int out_maxlen_bytes);
+ int unit_size, gdb_byte *out_buf,
+ int *out_len_units, int out_maxlen_bytes);
/* Convert BUFFER, escaped data LEN bytes long, into binary data
in OUT_BUF. Return the number of bytes written to OUT_BUF.
@@ -77,6 +77,6 @@ extern int remote_escape_output (const gdb_byte *buffer, int len_units,
This function reverses remote_escape_output. */
extern int remote_unescape_input (const gdb_byte *buffer, int len,
- gdb_byte *out_buf, int out_maxlen);
+ gdb_byte *out_buf, int out_maxlen);
#endif /* COMMON_RSP_LOW_H */
diff --git a/gdbsupport/run-time-clock.cc b/gdbsupport/run-time-clock.cc
index 77230d0..f661314 100644
--- a/gdbsupport/run-time-clock.cc
+++ b/gdbsupport/run-time-clock.cc
@@ -40,7 +40,7 @@ timeval_to_microseconds (struct timeval *tv)
void
run_time_clock::now (user_cpu_time_clock::time_point &user,
- system_cpu_time_clock::time_point &system) noexcept
+ system_cpu_time_clock::time_point &system) noexcept
{
#ifdef HAVE_GETRUSAGE
struct rusage rusage;
diff --git a/gdbsupport/run-time-clock.h b/gdbsupport/run-time-clock.h
index 41944b1..f23f0e8 100644
--- a/gdbsupport/run-time-clock.h
+++ b/gdbsupport/run-time-clock.h
@@ -69,7 +69,7 @@ struct run_time_clock
supported. If not supported, then the combined user+kernel time
is returned in USER and SYSTEM is set to zero. */
static void now (user_cpu_time_clock::time_point &user,
- system_cpu_time_clock::time_point &system) noexcept;
+ system_cpu_time_clock::time_point &system) noexcept;
};
#endif /* COMMON_RUN_TIME_CLOCK_H */
diff --git a/gdbsupport/safe-iterator.h b/gdbsupport/safe-iterator.h
index bc8b435..433fb9e 100644
--- a/gdbsupport/safe-iterator.h
+++ b/gdbsupport/safe-iterator.h
@@ -72,8 +72,7 @@ public:
}
/* Create a one-past-end iterator. */
- basic_safe_iterator ()
- {}
+ basic_safe_iterator () {}
value_type operator* () const { return *m_it; }
@@ -85,11 +84,9 @@ public:
return *this;
}
- bool operator== (const self_type &other) const
- { return m_it == other.m_it; }
+ bool operator== (const self_type &other) const { return m_it == other.m_it; }
- bool operator!= (const self_type &other) const
- { return m_it != other.m_it; }
+ bool operator!= (const self_type &other) const { return m_it != other.m_it; }
private:
/* The current element. */
@@ -109,26 +106,15 @@ template<typename Range>
class basic_safe_range
{
public:
-
typedef basic_safe_iterator<typename Range::iterator> iterator;
- explicit basic_safe_range (Range range)
- : m_range (range)
- {
- }
+ explicit basic_safe_range (Range range) : m_range (range) {}
- iterator begin ()
- {
- return iterator (m_range.begin (), m_range.end ());
- }
+ iterator begin () { return iterator (m_range.begin (), m_range.end ()); }
- iterator end ()
- {
- return iterator (m_range.end (), m_range.end ());
- }
+ iterator end () { return iterator (m_range.end (), m_range.end ()); }
private:
-
Range m_range;
};
diff --git a/gdbsupport/scope-exit.h b/gdbsupport/scope-exit.h
index cb8d925..41a8218 100644
--- a/gdbsupport/scope-exit.h
+++ b/gdbsupport/scope-exit.h
@@ -54,7 +54,7 @@
that inherit this implement the on_exit() method, which is called
from scope_exit_base's dtor. */
-template <typename CRTP>
+template<typename CRTP>
class scope_exit_base
{
public:
@@ -64,8 +64,8 @@ public:
{
if (!m_released)
{
- auto *self = static_cast<CRTP *> (this);
- self->on_exit ();
+ auto *self = static_cast<CRTP *> (this);
+ self->on_exit ();
}
}
@@ -82,13 +82,9 @@ public:
/* If this is called, then the wrapped function will not be called
on destruction. */
- void release () noexcept
- {
- m_released = true;
- }
+ void release () noexcept { m_released = true; }
private:
-
/* True if released. Mutable because of the copy ctor hack
above. */
mutable bool m_released = false;
@@ -103,16 +99,15 @@ class scope_exit : public scope_exit_base<scope_exit<EF>>
friend scope_exit_base<scope_exit<EF>>;
public:
-
template<typename EFP,
- typename = gdb::Requires<std::is_constructible<EF, EFP>>>
+ typename = gdb::Requires<std::is_constructible<EF, EFP>>>
scope_exit (EFP &&f)
- try : m_exit_function ((!std::is_lvalue_reference<EFP>::value
- && std::is_nothrow_constructible<EF, EFP>::value)
- ? std::move (f)
- : f)
- {
- }
+ try : m_exit_function ((!std::is_lvalue_reference<EFP>::value
+ && std::is_nothrow_constructible<EF, EFP>::value)
+ ? std::move (f)
+ : f)
+ {
+ }
catch (...)
{
/* "If the initialization of exit_function throws an exception,
@@ -121,13 +116,12 @@ public:
}
template<typename EFP,
- typename = gdb::Requires<std::is_constructible<EF, EFP>>>
- scope_exit (scope_exit &&rhs)
- noexcept (std::is_nothrow_move_constructible<EF>::value
- || std::is_nothrow_copy_constructible<EF>::value)
- : m_exit_function (std::is_nothrow_constructible<EFP>::value
- ? std::move (rhs)
- : rhs)
+ typename = gdb::Requires<std::is_constructible<EF, EFP>>>
+ scope_exit (scope_exit &&rhs) noexcept (
+ std::is_nothrow_move_constructible<EF>::value
+ || std::is_nothrow_copy_constructible<EF>::value)
+ : m_exit_function (
+ std::is_nothrow_constructible<EFP>::value ? std::move (rhs) : rhs)
{
rhs.release ();
}
@@ -145,16 +139,13 @@ public:
void operator= (scope_exit &&) = delete;
private:
- void on_exit ()
- {
- m_exit_function ();
- }
+ void on_exit () { m_exit_function (); }
/* The function to call on scope exit. */
EF m_exit_function;
};
-template <typename EF>
+template<typename EF>
scope_exit<typename std::decay<EF>::type>
make_scope_exit (EF &&f)
{
@@ -164,7 +155,9 @@ make_scope_exit (EF &&f)
namespace detail
{
-enum class scope_exit_lhs {};
+enum class scope_exit_lhs
+{
+};
template<typename EF>
scope_exit<typename std::decay<EF>::type>
@@ -173,7 +166,7 @@ operator+ (scope_exit_lhs, EF &&rhs)
return scope_exit<typename std::decay<EF>::type> (std::forward<EF> (rhs));
}
-}
+} // namespace detail
/* Register a block of code to run on scope exit. Note that the local
context is captured by reference, which means you should be careful
@@ -181,6 +174,6 @@ operator+ (scope_exit_lhs, EF &&rhs)
scope exit runs. */
#define SCOPE_EXIT \
- auto CONCAT(scope_exit_, __LINE__) = ::detail::scope_exit_lhs () + [&] ()
+ auto CONCAT (scope_exit_, __LINE__) = ::detail::scope_exit_lhs () + [&]()
#endif /* COMMON_SCOPE_EXIT_H */
diff --git a/gdbsupport/scoped_fd.h b/gdbsupport/scoped_fd.h
index 6c0d4af..80d3082 100644
--- a/gdbsupport/scoped_fd.h
+++ b/gdbsupport/scoped_fd.h
@@ -30,8 +30,7 @@ class scoped_fd
public:
explicit scoped_fd (int fd = -1) noexcept : m_fd (fd) {}
- scoped_fd (scoped_fd &&other) noexcept
- : m_fd (other.m_fd)
+ scoped_fd (scoped_fd &&other) noexcept : m_fd (other.m_fd)
{
other.m_fd = -1;
}
@@ -46,10 +45,10 @@ public:
{
if (m_fd != other.m_fd)
{
- if (m_fd >= 0)
- close (m_fd);
- m_fd = other.m_fd;
- other.m_fd = -1;
+ if (m_fd >= 0)
+ close (m_fd);
+ m_fd = other.m_fd;
+ other.m_fd = -1;
}
return *this;
}
@@ -75,10 +74,7 @@ public:
return result;
}
- int get () const noexcept
- {
- return m_fd;
- }
+ int get () const noexcept { return m_fd; }
private:
int m_fd;
diff --git a/gdbsupport/scoped_ignore_signal.h b/gdbsupport/scoped_ignore_signal.h
index 1c015a9..4b6ab5c 100644
--- a/gdbsupport/scoped_ignore_signal.h
+++ b/gdbsupport/scoped_ignore_signal.h
@@ -34,7 +34,7 @@
destructor could consume a signal raised due to actions done by
some other thread. */
-template <int Sig, bool ConsumePending>
+template<int Sig, bool ConsumePending>
class scoped_ignore_signal
{
public:
@@ -57,34 +57,34 @@ public:
#ifdef HAVE_SIGPROCMASK
if (!m_was_blocked)
{
- sigset_t set;
+ sigset_t set;
- sigemptyset (&set);
- sigaddset (&set, Sig);
+ sigemptyset (&set);
+ sigaddset (&set, Sig);
- /* If we got a pending Sig signal, consume it before
+ /* If we got a pending Sig signal, consume it before
unblocking. */
- if (ConsumePending)
- {
+ if (ConsumePending)
+ {
#ifdef HAVE_SIGTIMEDWAIT
- const timespec zero_timeout = {};
+ const timespec zero_timeout = {};
- sigtimedwait (&set, nullptr, &zero_timeout);
+ sigtimedwait (&set, nullptr, &zero_timeout);
#else
- sigset_t pending;
+ sigset_t pending;
- sigpending (&pending);
- if (sigismember (&pending, Sig))
- {
- int sig_found;
+ sigpending (&pending);
+ if (sigismember (&pending, Sig))
+ {
+ int sig_found;
- sigwait (&set, &sig_found);
- gdb_assert (sig_found == Sig);
- }
+ sigwait (&set, &sig_found);
+ gdb_assert (sig_found == Sig);
+ }
#endif
- }
+ }
- sigprocmask (SIG_UNBLOCK, &set, nullptr);
+ sigprocmask (SIG_UNBLOCK, &set, nullptr);
}
#else
signal (Sig, m_osig);
@@ -105,10 +105,8 @@ struct scoped_ignore_signal_nop
{
/* Note, these can't both be "= default", because otherwise the
compiler warns that variables of this type are not used. */
- scoped_ignore_signal_nop ()
- {}
- ~scoped_ignore_signal_nop ()
- {}
+ scoped_ignore_signal_nop () {}
+ ~scoped_ignore_signal_nop () {}
DISABLE_COPY_AND_ASSIGN (scoped_ignore_signal_nop);
};
diff --git a/gdbsupport/scoped_ignore_sigttou.h b/gdbsupport/scoped_ignore_sigttou.h
index aa01df2..35c9e858 100644
--- a/gdbsupport/scoped_ignore_sigttou.h
+++ b/gdbsupport/scoped_ignore_sigttou.h
@@ -32,15 +32,9 @@ template<typename T>
class lazy_init
{
public:
- void emplace ()
- {
- new (&m_u.obj) T ();
- }
+ void emplace () { new (&m_u.obj) T (); }
- void reset ()
- {
- m_u.obj.~T ();
- }
+ void reset () { m_u.obj.~T (); }
private:
union u
diff --git a/gdbsupport/scoped_mmap.cc b/gdbsupport/scoped_mmap.cc
index e4096da..08334d3 100644
--- a/gdbsupport/scoped_mmap.cc
+++ b/gdbsupport/scoped_mmap.cc
@@ -37,9 +37,10 @@ mmap_file (const char *filename)
/* We can't map an empty file. */
if (size == 0)
- error (_("file to mmap is empty"));
+ error (_ ("file to mmap is empty"));
- scoped_mmap mmapped_file (nullptr, size, PROT_READ, MAP_PRIVATE, fd.get (), 0);
+ scoped_mmap mmapped_file (nullptr, size, PROT_READ, MAP_PRIVATE, fd.get (),
+ 0);
if (mmapped_file.get () == MAP_FAILED)
perror_with_name (("mmap"));
diff --git a/gdbsupport/scoped_mmap.h b/gdbsupport/scoped_mmap.h
index 456e5ce..e0c15c0 100644
--- a/gdbsupport/scoped_mmap.h
+++ b/gdbsupport/scoped_mmap.h
@@ -32,15 +32,13 @@ class scoped_mmap
public:
scoped_mmap () noexcept : m_mem (MAP_FAILED), m_length (0) {}
scoped_mmap (void *addr, size_t length, int prot, int flags, int fd,
- off_t offset) noexcept : m_length (length)
+ off_t offset) noexcept
+ : m_length (length)
{
m_mem = mmap (addr, m_length, prot, flags, fd, offset);
}
- ~scoped_mmap ()
- {
- destroy ();
- }
+ ~scoped_mmap () { destroy (); }
scoped_mmap (scoped_mmap &&rhs) noexcept
: m_mem (rhs.m_mem),
@@ -61,7 +59,7 @@ public:
}
void reset (void *addr, size_t length, int prot, int flags, int fd,
- off_t offset) noexcept
+ off_t offset) noexcept
{
destroy ();
diff --git a/gdbsupport/scoped_restore.h b/gdbsupport/scoped_restore.h
index b7f3169..9439b9f 100644
--- a/gdbsupport/scoped_restore.h
+++ b/gdbsupport/scoped_restore.h
@@ -26,13 +26,10 @@ class scoped_restore_base
public:
/* This informs the (scoped_restore_tmpl<T>) dtor that you no longer
want the original value restored. */
- void release () const
- { m_saved_var = NULL; }
+ void release () const { m_saved_var = NULL; }
protected:
- scoped_restore_base (void *saved_var)
- : m_saved_var (saved_var)
- {}
+ scoped_restore_base (void *saved_var) : m_saved_var (saved_var) {}
/* The type-erased saved variable. This is here so that clients can
call release() on a "scoped_restore" local, which is a typedef to
@@ -49,8 +46,7 @@ typedef const scoped_restore_base &scoped_restore;
template<typename T>
class scoped_restore_tmpl : public scoped_restore_base
{
- public:
-
+public:
/* Create a new scoped_restore object that saves the current value
of *VAR. *VAR will be restored when this scoped_restore object
is destroyed. */
@@ -65,7 +61,7 @@ class scoped_restore_tmpl : public scoped_restore_base
scoped_restore object is destroyed. This is templated on T2 to
allow passing VALUEs of types convertible to T.
E.g.: T='base'; T2='derived'. */
- template <typename T2>
+ template<typename T2>
scoped_restore_tmpl (T *var, T2 value)
: scoped_restore_base (var),
m_saved_value (*var)
@@ -74,7 +70,7 @@ class scoped_restore_tmpl : public scoped_restore_base
}
scoped_restore_tmpl (const scoped_restore_tmpl<T> &other)
- : scoped_restore_base {other.m_saved_var},
+ : scoped_restore_base { other.m_saved_var },
m_saved_value (other.m_saved_value)
{
other.m_saved_var = NULL;
@@ -89,8 +85,7 @@ class scoped_restore_tmpl : public scoped_restore_base
private:
/* Return a pointer to the saved variable with its type
restored. */
- T *saved_var ()
- { return static_cast<T *> (m_saved_var); }
+ T *saved_var () { return static_cast<T *> (m_saved_var); }
/* No need for this. It is intentionally not defined anywhere. */
scoped_restore_tmpl &operator= (const scoped_restore_tmpl &);
@@ -102,7 +97,8 @@ private:
/* Make a scoped_restore. This is useful because it lets template
argument deduction work. */
template<typename T>
-scoped_restore_tmpl<T> make_scoped_restore (T *var)
+scoped_restore_tmpl<T>
+make_scoped_restore (T *var)
{
return scoped_restore_tmpl<T> (var);
}
@@ -110,7 +106,8 @@ scoped_restore_tmpl<T> make_scoped_restore (T *var)
/* Make a scoped_restore. This is useful because it lets template
argument deduction work. */
template<typename T, typename T2>
-scoped_restore_tmpl<T> make_scoped_restore (T *var, T2 value)
+scoped_restore_tmpl<T>
+make_scoped_restore (T *var, T2 value)
{
return scoped_restore_tmpl<T> (var, value);
}
diff --git a/gdbsupport/search.cc b/gdbsupport/search.cc
index ace02d7..99c6e01 100644
--- a/gdbsupport/search.cc
+++ b/gdbsupport/search.cc
@@ -27,11 +27,10 @@
target side with, for example, gdbserver). */
int
-simple_search_memory
- (gdb::function_view<target_read_memory_ftype> read_memory,
- CORE_ADDR start_addr, ULONGEST search_space_len,
- const gdb_byte *pattern, ULONGEST pattern_len,
- CORE_ADDR *found_addrp)
+simple_search_memory (gdb::function_view<target_read_memory_ftype> read_memory,
+ CORE_ADDR start_addr, ULONGEST search_space_len,
+ const gdb_byte *pattern, ULONGEST pattern_len,
+ CORE_ADDR *found_addrp)
{
const unsigned chunk_size = SEARCH_CHUNK_SIZE;
/* Buffer to hold memory contents for searching. */
@@ -49,9 +48,9 @@ simple_search_memory
if (!read_memory (start_addr, search_buf.data (), search_buf_size))
{
- warning (_("Unable to access %s bytes of target "
- "memory at %s, halting search."),
- pulongest (search_buf_size), hex_string (start_addr));
+ warning (_ ("Unable to access %s bytes of target "
+ "memory at %s, halting search."),
+ pulongest (search_buf_size), hex_string (start_addr));
return -1;
}
@@ -65,53 +64,52 @@ simple_search_memory
{
gdb_byte *found_ptr;
unsigned nr_search_bytes
- = std::min (search_space_len, (ULONGEST) search_buf_size);
+ = std::min (search_space_len, (ULONGEST) search_buf_size);
found_ptr = (gdb_byte *) memmem (search_buf.data (), nr_search_bytes,
- pattern, pattern_len);
+ pattern, pattern_len);
if (found_ptr != NULL)
- {
- CORE_ADDR found_addr = start_addr + (found_ptr - search_buf.data ());
+ {
+ CORE_ADDR found_addr = start_addr + (found_ptr - search_buf.data ());
- *found_addrp = found_addr;
- return 1;
- }
+ *found_addrp = found_addr;
+ return 1;
+ }
/* Not found in this chunk, skip to next chunk. */
/* Don't let search_space_len wrap here, it's unsigned. */
if (search_space_len >= chunk_size)
- search_space_len -= chunk_size;
+ search_space_len -= chunk_size;
else
- search_space_len = 0;
+ search_space_len = 0;
if (search_space_len >= pattern_len)
- {
- unsigned keep_len = search_buf_size - chunk_size;
- CORE_ADDR read_addr = start_addr + chunk_size + keep_len;
- int nr_to_read;
+ {
+ unsigned keep_len = search_buf_size - chunk_size;
+ CORE_ADDR read_addr = start_addr + chunk_size + keep_len;
+ int nr_to_read;
- /* Copy the trailing part of the previous iteration to the front
+ /* Copy the trailing part of the previous iteration to the front
of the buffer for the next iteration. */
- gdb_assert (keep_len == pattern_len - 1);
- if (keep_len > 0)
- memcpy (&search_buf[0], &search_buf[chunk_size], keep_len);
-
- nr_to_read = std::min (search_space_len - keep_len,
- (ULONGEST) chunk_size);
-
- if (!read_memory (read_addr, &search_buf[keep_len], nr_to_read))
- {
- warning (_("Unable to access %s bytes of target "
- "memory at %s, halting search."),
- plongest (nr_to_read),
- hex_string (read_addr));
- return -1;
- }
-
- start_addr += chunk_size;
- }
+ gdb_assert (keep_len == pattern_len - 1);
+ if (keep_len > 0)
+ memcpy (&search_buf[0], &search_buf[chunk_size], keep_len);
+
+ nr_to_read
+ = std::min (search_space_len - keep_len, (ULONGEST) chunk_size);
+
+ if (!read_memory (read_addr, &search_buf[keep_len], nr_to_read))
+ {
+ warning (_ ("Unable to access %s bytes of target "
+ "memory at %s, halting search."),
+ plongest (nr_to_read), hex_string (read_addr));
+ return -1;
+ }
+
+ start_addr += chunk_size;
+ }
}
/* Not found. */
diff --git a/gdbsupport/search.h b/gdbsupport/search.h
index 8501624..b56127e 100644
--- a/gdbsupport/search.h
+++ b/gdbsupport/search.h
@@ -31,12 +31,10 @@
typedef bool target_read_memory_ftype (CORE_ADDR, gdb_byte *, size_t);
/* Utility implementation of searching memory. */
-extern int simple_search_memory
- (gdb::function_view<target_read_memory_ftype> read_memory,
- CORE_ADDR start_addr,
- ULONGEST search_space_len,
- const gdb_byte *pattern,
- ULONGEST pattern_len,
- CORE_ADDR *found_addrp);
+extern int
+simple_search_memory (gdb::function_view<target_read_memory_ftype> read_memory,
+ CORE_ADDR start_addr, ULONGEST search_space_len,
+ const gdb_byte *pattern, ULONGEST pattern_len,
+ CORE_ADDR *found_addrp);
#endif /* COMMON_SEARCH_H */
diff --git a/gdbsupport/selftest.cc b/gdbsupport/selftest.cc
index c2e3936..bb63ce6 100644
--- a/gdbsupport/selftest.cc
+++ b/gdbsupport/selftest.cc
@@ -38,8 +38,7 @@ static std::vector<selftests_generator> lazy_generators;
/* See selftest.h. */
void
-register_test (const std::string &name,
- std::function<void(void)> function)
+register_test (const std::string &name, std::function<void (void)> function)
{
/* Check that no test with this name already exist. */
auto status = tests.emplace (name, std::move (function));
@@ -80,36 +79,35 @@ run_tests (gdb::array_view<const char *const> filters, bool verbose)
bool run = false;
if (filters.empty ())
- run = true;
+ run = true;
else
- {
- for (const char *filter : filters)
- {
- if (test.name.find (filter) != std::string::npos)
- run = true;
- }
- }
+ {
+ for (const char *filter : filters)
+ {
+ if (test.name.find (filter) != std::string::npos)
+ run = true;
+ }
+ }
if (!run)
- continue;
+ continue;
try
- {
- debug_printf (_("Running selftest %s.\n"), test.name.c_str ());
- ++ran;
- test.test ();
- }
+ {
+ debug_printf (_ ("Running selftest %s.\n"), test.name.c_str ());
+ ++ran;
+ test.test ();
+ }
catch (const gdb_exception_error &ex)
- {
- ++failed;
- debug_printf ("Self test failed: %s\n", ex.what ());
- }
+ {
+ ++failed;
+ debug_printf ("Self test failed: %s\n", ex.what ());
+ }
reset ();
}
- debug_printf (_("Ran %d unit tests, %d failed\n"),
- ran, failed);
+ debug_printf (_ ("Ran %d unit tests, %d failed\n"), ran, failed);
}
/* See selftest.h. */
diff --git a/gdbsupport/selftest.h b/gdbsupport/selftest.h
index fba6baf..e441dc7 100644
--- a/gdbsupport/selftest.h
+++ b/gdbsupport/selftest.h
@@ -36,10 +36,11 @@ namespace selftests
struct selftest
{
selftest (std::string name, std::function<void (void)> test)
- : name { std::move (name) }, test { std::move (test) }
- { }
- bool operator< (const selftest &rhs) const
- { return name < rhs.name; }
+ : name { std::move (name) },
+ test { std::move (test) }
+ {
+ }
+ bool operator<(const selftest &rhs) const { return name < rhs.name; }
std::string name;
std::function<void (void)> test;
@@ -60,7 +61,7 @@ extern bool run_verbose ();
/* Register a new self-test. */
extern void register_test (const std::string &name,
- std::function<void(void)> function);
+ std::function<void (void)> function);
/* A selftest generator is a callback function used to delay the generation
of selftests. */
@@ -79,18 +80,20 @@ extern void add_lazy_generator (selftests_generator generator);
element of FILTERS. */
extern void run_tests (gdb::array_view<const char *const> filters,
- bool verbose = false);
+ bool verbose = false);
/* Reset GDB or GDBserver's internal state. */
extern void reset ();
-}
+} // namespace selftests
/* Check that VALUE is true, and, if not, throw an exception. */
-#define SELF_CHECK(VALUE) \
- do { \
- if (!(VALUE)) \
- error (_("self-test failed at %s:%d"), __FILE__, __LINE__); \
- } while (0)
+#define SELF_CHECK(VALUE) \
+ do \
+ { \
+ if (!(VALUE)) \
+ error (_ ("self-test failed at %s:%d"), __FILE__, __LINE__); \
+ } \
+ while (0)
#endif /* COMMON_SELFTEST_H */
diff --git a/gdbsupport/signals-state-save-restore.cc b/gdbsupport/signals-state-save-restore.cc
index 3ec7a25..7b865bd 100644
--- a/gdbsupport/signals-state-save-restore.cc
+++ b/gdbsupport/signals-state-save-restore.cc
@@ -38,7 +38,7 @@ save_original_signals_state (bool quiet)
int i;
int res;
- res = gdb_sigmask (0, NULL, &original_signal_mask);
+ res = gdb_sigmask (0, NULL, &original_signal_mask);
if (res == -1)
perror_with_name (("sigprocmask"));
@@ -50,36 +50,35 @@ save_original_signals_state (bool quiet)
res = sigaction (i, NULL, oldact);
if (res == -1 && errno == EINVAL)
- {
- /* Some signal numbers in the range are invalid. */
- continue;
- }
+ {
+ /* Some signal numbers in the range are invalid. */
+ continue;
+ }
else if (res == -1)
- perror_with_name (("sigaction"));
+ perror_with_name (("sigaction"));
/* If we find a custom signal handler already installed, then
this function was called too late. This is a warning instead
of an internal error because this can also happen if you
LD_PRELOAD a library that installs a signal handler early via
__attribute__((constructor)), like libSegFault.so. */
- if (!quiet
- && oldact->sa_handler != SIG_DFL
- && oldact->sa_handler != SIG_IGN)
- {
- found_preinstalled = true;
+ if (!quiet && oldact->sa_handler != SIG_DFL
+ && oldact->sa_handler != SIG_IGN)
+ {
+ found_preinstalled = true;
- /* Use raw fprintf here because we're being called in early
+ /* Use raw fprintf here because we're being called in early
startup, before GDB's filtered streams are created. */
- fprintf (stderr,
- _("warning: Found custom handler for signal "
- "%d (%s) preinstalled.\n"), i,
- strsignal (i));
- }
+ fprintf (stderr,
+ _ ("warning: Found custom handler for signal "
+ "%d (%s) preinstalled.\n"),
+ i, strsignal (i));
+ }
}
if (found_preinstalled)
{
- fprintf (stderr, _("\
+ fprintf (stderr, _ ("\
Some signal dispositions inherited from the environment (SIG_DFL/SIG_IGN)\n\
won't be propagated to spawned programs.\n"));
}
@@ -99,15 +98,15 @@ restore_original_signals_state (void)
{
res = sigaction (i, &original_signal_actions[i], NULL);
if (res == -1 && errno == EINVAL)
- {
- /* Some signal numbers in the range are invalid. */
- continue;
- }
+ {
+ /* Some signal numbers in the range are invalid. */
+ continue;
+ }
else if (res == -1)
- perror_with_name (("sigaction"));
+ perror_with_name (("sigaction"));
}
- res = gdb_sigmask (SIG_SETMASK, &original_signal_mask, NULL);
+ res = gdb_sigmask (SIG_SETMASK, &original_signal_mask, NULL);
if (res == -1)
perror_with_name (("sigprocmask"));
#endif
diff --git a/gdbsupport/signals.cc b/gdbsupport/signals.cc
index 0d700c0..2cefa20 100644
--- a/gdbsupport/signals.cc
+++ b/gdbsupport/signals.cc
@@ -32,24 +32,24 @@ struct gdbarch;
several for its own use. */
#ifndef REALTIME_LO
-# if defined(__SIGRTMIN)
-# define REALTIME_LO __SIGRTMIN
-# define REALTIME_HI (__SIGRTMAX + 1)
-# elif defined(SIGRTMIN)
-# define REALTIME_LO SIGRTMIN
-# define REALTIME_HI (SIGRTMAX + 1)
-# endif
+#if defined(__SIGRTMIN)
+#define REALTIME_LO __SIGRTMIN
+#define REALTIME_HI (__SIGRTMAX + 1)
+#elif defined(SIGRTMIN)
+#define REALTIME_LO SIGRTMIN
+#define REALTIME_HI (SIGRTMAX + 1)
+#endif
#endif
/* This table must match in order and size the signals in enum
gdb_signal. */
-static const struct {
+static const struct
+{
const char *symbol;
const char *name;
const char *string;
- } signals [] =
-{
+} signals[] = {
#define SET(symbol, constant, name, string) { #symbol, name, string },
#include "gdb/signals.def"
#undef SET
@@ -98,15 +98,13 @@ gdb_signal_from_name (const char *name)
instead. */
/* This ugly cast brought to you by the native VAX compiler. */
- for (sig = GDB_SIGNAL_HUP;
- sig < GDB_SIGNAL_LAST;
+ for (sig = GDB_SIGNAL_HUP; sig < GDB_SIGNAL_LAST;
sig = (enum gdb_signal) ((int) sig + 1))
- if (signals[sig].name != NULL
- && strcmp (name, signals[sig].name) == 0)
+ if (signals[sig].name != NULL && strcmp (name, signals[sig].name) == 0)
return sig;
return GDB_SIGNAL_UNKNOWN;
}
-
+
/* The following functions are to help certain targets deal
with the signal/waitstatus stuff. They could just as well be in
a file called native-utils.c or unixwaitstatus-utils.c or whatever. */
@@ -139,218 +137,216 @@ gdb_signal_from_host (int hostsig)
if (hostsig == SIGTERM)
return GDB_SIGNAL_TERM;
- /* All other signals need preprocessor conditionals. */
-#if defined (SIGHUP)
+ /* All other signals need preprocessor conditionals. */
+#if defined(SIGHUP)
if (hostsig == SIGHUP)
return GDB_SIGNAL_HUP;
#endif
-#if defined (SIGQUIT)
+#if defined(SIGQUIT)
if (hostsig == SIGQUIT)
return GDB_SIGNAL_QUIT;
#endif
-#if defined (SIGTRAP)
+#if defined(SIGTRAP)
if (hostsig == SIGTRAP)
return GDB_SIGNAL_TRAP;
#endif
-#if defined (SIGEMT)
+#if defined(SIGEMT)
if (hostsig == SIGEMT)
return GDB_SIGNAL_EMT;
#endif
-#if defined (SIGKILL)
+#if defined(SIGKILL)
if (hostsig == SIGKILL)
return GDB_SIGNAL_KILL;
#endif
-#if defined (SIGBUS)
+#if defined(SIGBUS)
if (hostsig == SIGBUS)
return GDB_SIGNAL_BUS;
#endif
-#if defined (SIGSYS)
+#if defined(SIGSYS)
if (hostsig == SIGSYS)
return GDB_SIGNAL_SYS;
#endif
-#if defined (SIGPIPE)
+#if defined(SIGPIPE)
if (hostsig == SIGPIPE)
return GDB_SIGNAL_PIPE;
#endif
-#if defined (SIGALRM)
+#if defined(SIGALRM)
if (hostsig == SIGALRM)
return GDB_SIGNAL_ALRM;
#endif
-#if defined (SIGUSR1)
+#if defined(SIGUSR1)
if (hostsig == SIGUSR1)
return GDB_SIGNAL_USR1;
#endif
-#if defined (SIGUSR2)
+#if defined(SIGUSR2)
if (hostsig == SIGUSR2)
return GDB_SIGNAL_USR2;
#endif
-#if defined (SIGCLD)
+#if defined(SIGCLD)
if (hostsig == SIGCLD)
return GDB_SIGNAL_CHLD;
#endif
-#if defined (SIGCHLD)
+#if defined(SIGCHLD)
if (hostsig == SIGCHLD)
return GDB_SIGNAL_CHLD;
#endif
-#if defined (SIGPWR)
+#if defined(SIGPWR)
if (hostsig == SIGPWR)
return GDB_SIGNAL_PWR;
#endif
-#if defined (SIGWINCH)
+#if defined(SIGWINCH)
if (hostsig == SIGWINCH)
return GDB_SIGNAL_WINCH;
#endif
-#if defined (SIGURG)
+#if defined(SIGURG)
if (hostsig == SIGURG)
return GDB_SIGNAL_URG;
#endif
-#if defined (SIGIO)
+#if defined(SIGIO)
if (hostsig == SIGIO)
return GDB_SIGNAL_IO;
#endif
-#if defined (SIGPOLL)
+#if defined(SIGPOLL)
if (hostsig == SIGPOLL)
return GDB_SIGNAL_POLL;
#endif
-#if defined (SIGSTOP)
+#if defined(SIGSTOP)
if (hostsig == SIGSTOP)
return GDB_SIGNAL_STOP;
#endif
-#if defined (SIGTSTP)
+#if defined(SIGTSTP)
if (hostsig == SIGTSTP)
return GDB_SIGNAL_TSTP;
#endif
-#if defined (SIGCONT)
+#if defined(SIGCONT)
if (hostsig == SIGCONT)
return GDB_SIGNAL_CONT;
#endif
-#if defined (SIGTTIN)
+#if defined(SIGTTIN)
if (hostsig == SIGTTIN)
return GDB_SIGNAL_TTIN;
#endif
-#if defined (SIGTTOU)
+#if defined(SIGTTOU)
if (hostsig == SIGTTOU)
return GDB_SIGNAL_TTOU;
#endif
-#if defined (SIGVTALRM)
+#if defined(SIGVTALRM)
if (hostsig == SIGVTALRM)
return GDB_SIGNAL_VTALRM;
#endif
-#if defined (SIGPROF)
+#if defined(SIGPROF)
if (hostsig == SIGPROF)
return GDB_SIGNAL_PROF;
#endif
-#if defined (SIGXCPU)
+#if defined(SIGXCPU)
if (hostsig == SIGXCPU)
return GDB_SIGNAL_XCPU;
#endif
-#if defined (SIGXFSZ)
+#if defined(SIGXFSZ)
if (hostsig == SIGXFSZ)
return GDB_SIGNAL_XFSZ;
#endif
-#if defined (SIGWIND)
+#if defined(SIGWIND)
if (hostsig == SIGWIND)
return GDB_SIGNAL_WIND;
#endif
-#if defined (SIGPHONE)
+#if defined(SIGPHONE)
if (hostsig == SIGPHONE)
return GDB_SIGNAL_PHONE;
#endif
-#if defined (SIGLOST)
+#if defined(SIGLOST)
if (hostsig == SIGLOST)
return GDB_SIGNAL_LOST;
#endif
-#if defined (SIGWAITING)
+#if defined(SIGWAITING)
if (hostsig == SIGWAITING)
return GDB_SIGNAL_WAITING;
#endif
-#if defined (SIGCANCEL)
+#if defined(SIGCANCEL)
if (hostsig == SIGCANCEL)
return GDB_SIGNAL_CANCEL;
#endif
-#if defined (SIGLWP)
+#if defined(SIGLWP)
if (hostsig == SIGLWP)
return GDB_SIGNAL_LWP;
#endif
-#if defined (SIGDANGER)
+#if defined(SIGDANGER)
if (hostsig == SIGDANGER)
return GDB_SIGNAL_DANGER;
#endif
-#if defined (SIGGRANT)
+#if defined(SIGGRANT)
if (hostsig == SIGGRANT)
return GDB_SIGNAL_GRANT;
#endif
-#if defined (SIGRETRACT)
+#if defined(SIGRETRACT)
if (hostsig == SIGRETRACT)
return GDB_SIGNAL_RETRACT;
#endif
-#if defined (SIGMSG)
+#if defined(SIGMSG)
if (hostsig == SIGMSG)
return GDB_SIGNAL_MSG;
#endif
-#if defined (SIGSOUND)
+#if defined(SIGSOUND)
if (hostsig == SIGSOUND)
return GDB_SIGNAL_SOUND;
#endif
-#if defined (SIGSAK)
+#if defined(SIGSAK)
if (hostsig == SIGSAK)
return GDB_SIGNAL_SAK;
#endif
-#if defined (SIGPRIO)
+#if defined(SIGPRIO)
if (hostsig == SIGPRIO)
return GDB_SIGNAL_PRIO;
#endif
- /* Mach exceptions. Assumes that the values for EXC_ are positive! */
-#if defined (EXC_BAD_ACCESS) && defined (_NSIG)
+ /* Mach exceptions. Assumes that the values for EXC_ are positive! */
+#if defined(EXC_BAD_ACCESS) && defined(_NSIG)
if (hostsig == _NSIG + EXC_BAD_ACCESS)
return GDB_EXC_BAD_ACCESS;
#endif
-#if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
+#if defined(EXC_BAD_INSTRUCTION) && defined(_NSIG)
if (hostsig == _NSIG + EXC_BAD_INSTRUCTION)
return GDB_EXC_BAD_INSTRUCTION;
#endif
-#if defined (EXC_ARITHMETIC) && defined (_NSIG)
+#if defined(EXC_ARITHMETIC) && defined(_NSIG)
if (hostsig == _NSIG + EXC_ARITHMETIC)
return GDB_EXC_ARITHMETIC;
#endif
-#if defined (EXC_EMULATION) && defined (_NSIG)
+#if defined(EXC_EMULATION) && defined(_NSIG)
if (hostsig == _NSIG + EXC_EMULATION)
return GDB_EXC_EMULATION;
#endif
-#if defined (EXC_SOFTWARE) && defined (_NSIG)
+#if defined(EXC_SOFTWARE) && defined(_NSIG)
if (hostsig == _NSIG + EXC_SOFTWARE)
return GDB_EXC_SOFTWARE;
#endif
-#if defined (EXC_BREAKPOINT) && defined (_NSIG)
+#if defined(EXC_BREAKPOINT) && defined(_NSIG)
if (hostsig == _NSIG + EXC_BREAKPOINT)
return GDB_EXC_BREAKPOINT;
#endif
-#if defined (SIGINFO)
+#if defined(SIGINFO)
if (hostsig == SIGINFO)
return GDB_SIGNAL_INFO;
#endif
-#if defined (SIGLIBRT)
+#if defined(SIGLIBRT)
if (hostsig == SIGLIBRT)
return GDB_SIGNAL_LIBRT;
#endif
-#if defined (REALTIME_LO)
+#if defined(REALTIME_LO)
if (hostsig >= REALTIME_LO && hostsig < REALTIME_HI)
{
/* This block of GDB_SIGNAL_REALTIME value is in order. */
if (33 <= hostsig && hostsig <= 63)
- return (enum gdb_signal)
- (hostsig - 33 + (int) GDB_SIGNAL_REALTIME_33);
+ return (enum gdb_signal) (hostsig - 33 + (int) GDB_SIGNAL_REALTIME_33);
else if (hostsig == 32)
- return GDB_SIGNAL_REALTIME_32;
+ return GDB_SIGNAL_REALTIME_32;
else if (64 <= hostsig && hostsig <= 127)
- return (enum gdb_signal)
- (hostsig - 64 + (int) GDB_SIGNAL_REALTIME_64);
+ return (enum gdb_signal) (hostsig - 64 + (int) GDB_SIGNAL_REALTIME_64);
else
- error (_("GDB bug: target.c (gdb_signal_from_host): "
- "unrecognized real-time signal"));
+ error (_ ("GDB bug: target.c (gdb_signal_from_host): "
+ "unrecognized real-time signal"));
}
#endif
@@ -363,8 +359,7 @@ gdb_signal_from_host (int hostsig)
accordingly. */
static int
-do_gdb_signal_to_host (enum gdb_signal oursig,
- int *oursig_ok)
+do_gdb_signal_to_host (enum gdb_signal oursig, int *oursig_ok)
{
int retsig;
/* Silence the 'not used' warning, for targets that
@@ -397,229 +392,228 @@ do_gdb_signal_to_host (enum gdb_signal oursig,
return SIGTERM;
/* All other signals need preprocessor conditionals. */
-#if defined (SIGHUP)
+#if defined(SIGHUP)
case GDB_SIGNAL_HUP:
return SIGHUP;
#endif
-#if defined (SIGQUIT)
+#if defined(SIGQUIT)
case GDB_SIGNAL_QUIT:
return SIGQUIT;
#endif
-#if defined (SIGTRAP)
+#if defined(SIGTRAP)
case GDB_SIGNAL_TRAP:
return SIGTRAP;
#endif
-#if defined (SIGEMT)
+#if defined(SIGEMT)
case GDB_SIGNAL_EMT:
return SIGEMT;
#endif
-#if defined (SIGKILL)
+#if defined(SIGKILL)
case GDB_SIGNAL_KILL:
return SIGKILL;
#endif
-#if defined (SIGBUS)
+#if defined(SIGBUS)
case GDB_SIGNAL_BUS:
return SIGBUS;
#endif
-#if defined (SIGSYS)
+#if defined(SIGSYS)
case GDB_SIGNAL_SYS:
return SIGSYS;
#endif
-#if defined (SIGPIPE)
+#if defined(SIGPIPE)
case GDB_SIGNAL_PIPE:
return SIGPIPE;
#endif
-#if defined (SIGALRM)
+#if defined(SIGALRM)
case GDB_SIGNAL_ALRM:
return SIGALRM;
#endif
-#if defined (SIGUSR1)
+#if defined(SIGUSR1)
case GDB_SIGNAL_USR1:
return SIGUSR1;
#endif
-#if defined (SIGUSR2)
+#if defined(SIGUSR2)
case GDB_SIGNAL_USR2:
return SIGUSR2;
#endif
-#if defined (SIGCHLD) || defined (SIGCLD)
+#if defined(SIGCHLD) || defined(SIGCLD)
case GDB_SIGNAL_CHLD:
-#if defined (SIGCHLD)
+#if defined(SIGCHLD)
return SIGCHLD;
#else
return SIGCLD;
#endif
#endif /* SIGCLD or SIGCHLD */
-#if defined (SIGPWR)
+#if defined(SIGPWR)
case GDB_SIGNAL_PWR:
return SIGPWR;
#endif
-#if defined (SIGWINCH)
+#if defined(SIGWINCH)
case GDB_SIGNAL_WINCH:
return SIGWINCH;
#endif
-#if defined (SIGURG)
+#if defined(SIGURG)
case GDB_SIGNAL_URG:
return SIGURG;
#endif
-#if defined (SIGIO)
+#if defined(SIGIO)
case GDB_SIGNAL_IO:
return SIGIO;
#endif
-#if defined (SIGPOLL)
+#if defined(SIGPOLL)
case GDB_SIGNAL_POLL:
return SIGPOLL;
#endif
-#if defined (SIGSTOP)
+#if defined(SIGSTOP)
case GDB_SIGNAL_STOP:
return SIGSTOP;
#endif
-#if defined (SIGTSTP)
+#if defined(SIGTSTP)
case GDB_SIGNAL_TSTP:
return SIGTSTP;
#endif
-#if defined (SIGCONT)
+#if defined(SIGCONT)
case GDB_SIGNAL_CONT:
return SIGCONT;
#endif
-#if defined (SIGTTIN)
+#if defined(SIGTTIN)
case GDB_SIGNAL_TTIN:
return SIGTTIN;
#endif
-#if defined (SIGTTOU)
+#if defined(SIGTTOU)
case GDB_SIGNAL_TTOU:
return SIGTTOU;
#endif
-#if defined (SIGVTALRM)
+#if defined(SIGVTALRM)
case GDB_SIGNAL_VTALRM:
return SIGVTALRM;
#endif
-#if defined (SIGPROF)
+#if defined(SIGPROF)
case GDB_SIGNAL_PROF:
return SIGPROF;
#endif
-#if defined (SIGXCPU)
+#if defined(SIGXCPU)
case GDB_SIGNAL_XCPU:
return SIGXCPU;
#endif
-#if defined (SIGXFSZ)
+#if defined(SIGXFSZ)
case GDB_SIGNAL_XFSZ:
return SIGXFSZ;
#endif
-#if defined (SIGWIND)
+#if defined(SIGWIND)
case GDB_SIGNAL_WIND:
return SIGWIND;
#endif
-#if defined (SIGPHONE)
+#if defined(SIGPHONE)
case GDB_SIGNAL_PHONE:
return SIGPHONE;
#endif
-#if defined (SIGLOST)
+#if defined(SIGLOST)
case GDB_SIGNAL_LOST:
return SIGLOST;
#endif
-#if defined (SIGWAITING)
+#if defined(SIGWAITING)
case GDB_SIGNAL_WAITING:
return SIGWAITING;
#endif
-#if defined (SIGCANCEL)
+#if defined(SIGCANCEL)
case GDB_SIGNAL_CANCEL:
return SIGCANCEL;
#endif
-#if defined (SIGLWP)
+#if defined(SIGLWP)
case GDB_SIGNAL_LWP:
return SIGLWP;
#endif
-#if defined (SIGDANGER)
+#if defined(SIGDANGER)
case GDB_SIGNAL_DANGER:
return SIGDANGER;
#endif
-#if defined (SIGGRANT)
+#if defined(SIGGRANT)
case GDB_SIGNAL_GRANT:
return SIGGRANT;
#endif
-#if defined (SIGRETRACT)
+#if defined(SIGRETRACT)
case GDB_SIGNAL_RETRACT:
return SIGRETRACT;
#endif
-#if defined (SIGMSG)
+#if defined(SIGMSG)
case GDB_SIGNAL_MSG:
return SIGMSG;
#endif
-#if defined (SIGSOUND)
+#if defined(SIGSOUND)
case GDB_SIGNAL_SOUND:
return SIGSOUND;
#endif
-#if defined (SIGSAK)
+#if defined(SIGSAK)
case GDB_SIGNAL_SAK:
return SIGSAK;
#endif
-#if defined (SIGPRIO)
+#if defined(SIGPRIO)
case GDB_SIGNAL_PRIO:
return SIGPRIO;
#endif
/* Mach exceptions. Assumes that the values for EXC_ are positive! */
-#if defined (EXC_BAD_ACCESS) && defined (_NSIG)
+#if defined(EXC_BAD_ACCESS) && defined(_NSIG)
case GDB_EXC_BAD_ACCESS:
return _NSIG + EXC_BAD_ACCESS;
#endif
-#if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
+#if defined(EXC_BAD_INSTRUCTION) && defined(_NSIG)
case GDB_EXC_BAD_INSTRUCTION:
return _NSIG + EXC_BAD_INSTRUCTION;
#endif
-#if defined (EXC_ARITHMETIC) && defined (_NSIG)
+#if defined(EXC_ARITHMETIC) && defined(_NSIG)
case GDB_EXC_ARITHMETIC:
return _NSIG + EXC_ARITHMETIC;
#endif
-#if defined (EXC_EMULATION) && defined (_NSIG)
+#if defined(EXC_EMULATION) && defined(_NSIG)
case GDB_EXC_EMULATION:
return _NSIG + EXC_EMULATION;
#endif
-#if defined (EXC_SOFTWARE) && defined (_NSIG)
+#if defined(EXC_SOFTWARE) && defined(_NSIG)
case GDB_EXC_SOFTWARE:
return _NSIG + EXC_SOFTWARE;
#endif
-#if defined (EXC_BREAKPOINT) && defined (_NSIG)
+#if defined(EXC_BREAKPOINT) && defined(_NSIG)
case GDB_EXC_BREAKPOINT:
return _NSIG + EXC_BREAKPOINT;
#endif
-#if defined (SIGINFO)
+#if defined(SIGINFO)
case GDB_SIGNAL_INFO:
return SIGINFO;
#endif
-#if defined (SIGLIBRT)
+#if defined(SIGLIBRT)
case GDB_SIGNAL_LIBRT:
return SIGLIBRT;
#endif
default:
-#if defined (REALTIME_LO)
+#if defined(REALTIME_LO)
retsig = 0;
- if (oursig >= GDB_SIGNAL_REALTIME_33
- && oursig <= GDB_SIGNAL_REALTIME_63)
- {
- /* This block of signals is continuous, and
+ if (oursig >= GDB_SIGNAL_REALTIME_33 && oursig <= GDB_SIGNAL_REALTIME_63)
+ {
+ /* This block of signals is continuous, and
GDB_SIGNAL_REALTIME_33 is 33 by definition. */
- retsig = (int) oursig - (int) GDB_SIGNAL_REALTIME_33 + 33;
- }
+ retsig = (int) oursig - (int) GDB_SIGNAL_REALTIME_33 + 33;
+ }
else if (oursig == GDB_SIGNAL_REALTIME_32)
- {
- /* GDB_SIGNAL_REALTIME_32 isn't contiguous with
+ {
+ /* GDB_SIGNAL_REALTIME_32 isn't contiguous with
GDB_SIGNAL_REALTIME_33. It is 32 by definition. */
- retsig = 32;
- }
+ retsig = 32;
+ }
else if (oursig >= GDB_SIGNAL_REALTIME_64
- && oursig <= GDB_SIGNAL_REALTIME_127)
- {
- /* This block of signals is continuous, and
+ && oursig <= GDB_SIGNAL_REALTIME_127)
+ {
+ /* This block of signals is continuous, and
GDB_SIGNAL_REALTIME_64 is 64 by definition. */
- retsig = (int) oursig - (int) GDB_SIGNAL_REALTIME_64 + 64;
- }
+ retsig = (int) oursig - (int) GDB_SIGNAL_REALTIME_64 + 64;
+ }
if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
- return retsig;
+ return retsig;
#endif
*oursig_ok = 0;
@@ -644,8 +638,8 @@ gdb_signal_to_host (enum gdb_signal oursig)
{
/* The user might be trying to do "signal SIGSAK" where this system
doesn't have SIGSAK. */
- warning (_("Signal %s does not exist on this system."),
- gdb_signal_to_name (oursig));
+ warning (_ ("Signal %s does not exist on this system."),
+ gdb_signal_to_name (oursig));
return 0;
}
else
diff --git a/gdbsupport/symbol.h b/gdbsupport/symbol.h
index 826e2dc..8b8f9c8 100644
--- a/gdbsupport/symbol.h
+++ b/gdbsupport/symbol.h
@@ -32,6 +32,6 @@ struct objfile;
object files. This function must be provided by the client. */
extern int find_minimal_symbol_address (const char *name, CORE_ADDR *addr,
- struct objfile *objfile);
+ struct objfile *objfile);
#endif /* COMMON_SYMBOL_H */
diff --git a/gdbsupport/tdesc.cc b/gdbsupport/tdesc.cc
index 6ecb323..5c4f850 100644
--- a/gdbsupport/tdesc.cc
+++ b/gdbsupport/tdesc.cc
@@ -21,9 +21,10 @@
#include "gdbsupport/tdesc.h"
tdesc_reg::tdesc_reg (struct tdesc_feature *feature, const std::string &name_,
- int regnum, int save_restore_, const char *group_,
- int bitsize_, const char *type_)
- : name (name_), target_regnum (regnum),
+ int regnum, int save_restore_, const char *group_,
+ int bitsize_, const char *type_)
+ : name (name_),
+ target_regnum (regnum),
save_restore (save_restore_),
group (group_ != NULL ? group_ : ""),
bitsize (bitsize_),
@@ -35,30 +36,29 @@ tdesc_reg::tdesc_reg (struct tdesc_feature *feature, const std::string &name_,
}
/* Predefined types. */
-static tdesc_type_builtin tdesc_predefined_types[] =
-{
- { "bool", TDESC_TYPE_BOOL },
- { "int8", TDESC_TYPE_INT8 },
- { "int16", TDESC_TYPE_INT16 },
- { "int32", TDESC_TYPE_INT32 },
- { "int64", TDESC_TYPE_INT64 },
- { "int128", TDESC_TYPE_INT128 },
- { "uint8", TDESC_TYPE_UINT8 },
- { "uint16", TDESC_TYPE_UINT16 },
- { "uint32", TDESC_TYPE_UINT32 },
- { "uint64", TDESC_TYPE_UINT64 },
- { "uint128", TDESC_TYPE_UINT128 },
- { "code_ptr", TDESC_TYPE_CODE_PTR },
- { "data_ptr", TDESC_TYPE_DATA_PTR },
- { "ieee_half", TDESC_TYPE_IEEE_HALF },
- { "ieee_single", TDESC_TYPE_IEEE_SINGLE },
- { "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
- { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
- { "i387_ext", TDESC_TYPE_I387_EXT },
- { "bfloat16", TDESC_TYPE_BFLOAT16 }
-};
-
-void tdesc_feature::accept (tdesc_element_visitor &v) const
+static tdesc_type_builtin tdesc_predefined_types[]
+ = { { "bool", TDESC_TYPE_BOOL },
+ { "int8", TDESC_TYPE_INT8 },
+ { "int16", TDESC_TYPE_INT16 },
+ { "int32", TDESC_TYPE_INT32 },
+ { "int64", TDESC_TYPE_INT64 },
+ { "int128", TDESC_TYPE_INT128 },
+ { "uint8", TDESC_TYPE_UINT8 },
+ { "uint16", TDESC_TYPE_UINT16 },
+ { "uint32", TDESC_TYPE_UINT32 },
+ { "uint64", TDESC_TYPE_UINT64 },
+ { "uint128", TDESC_TYPE_UINT128 },
+ { "code_ptr", TDESC_TYPE_CODE_PTR },
+ { "data_ptr", TDESC_TYPE_DATA_PTR },
+ { "ieee_half", TDESC_TYPE_IEEE_HALF },
+ { "ieee_single", TDESC_TYPE_IEEE_SINGLE },
+ { "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
+ { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
+ { "i387_ext", TDESC_TYPE_I387_EXT },
+ { "bfloat16", TDESC_TYPE_BFLOAT16 } };
+
+void
+tdesc_feature::accept (tdesc_element_visitor &v) const
{
v.visit_pre (this);
@@ -71,7 +71,8 @@ void tdesc_feature::accept (tdesc_element_visitor &v) const
v.visit_post (this);
}
-bool tdesc_feature::operator== (const tdesc_feature &other) const
+bool
+tdesc_feature::operator== (const tdesc_feature &other) const
{
if (name != other.name)
return false;
@@ -85,8 +86,8 @@ bool tdesc_feature::operator== (const tdesc_feature &other) const
const tdesc_reg_up &reg2 = other.registers[ix];
if (reg1 != reg2 && *reg1 != *reg2)
- return false;
- }
+ return false;
+ }
if (types.size () != other.types.size ())
return false;
@@ -97,7 +98,7 @@ bool tdesc_feature::operator== (const tdesc_feature &other) const
const tdesc_type_up &type2 = other.types[ix];
if (type1 != type2 && *type1 != *type2)
- return false;
+ return false;
}
return true;
@@ -136,12 +137,12 @@ tdesc_named_type (const struct tdesc_feature *feature, const char *id)
/* See gdbsupport/tdesc.h. */
void
-tdesc_create_reg (struct tdesc_feature *feature, const char *name,
- int regnum, int save_restore, const char *group,
- int bitsize, const char *type)
+tdesc_create_reg (struct tdesc_feature *feature, const char *name, int regnum,
+ int save_restore, const char *group, int bitsize,
+ const char *type)
{
- tdesc_reg *reg = new tdesc_reg (feature, name, regnum, save_restore,
- group, bitsize, type);
+ tdesc_reg *reg = new tdesc_reg (feature, name, regnum, save_restore, group,
+ bitsize, type);
feature->registers.emplace_back (reg);
}
@@ -150,7 +151,7 @@ tdesc_create_reg (struct tdesc_feature *feature, const char *name,
struct tdesc_type *
tdesc_create_vector (struct tdesc_feature *feature, const char *name,
- struct tdesc_type *field_type, int count)
+ struct tdesc_type *field_type, int count)
{
tdesc_type_vector *type = new tdesc_type_vector (name, field_type, count);
feature->types.emplace_back (type);
@@ -195,8 +196,7 @@ tdesc_create_union (struct tdesc_feature *feature, const char *name)
/* See gdbsupport/tdesc.h. */
tdesc_type_with_fields *
-tdesc_create_flags (struct tdesc_feature *feature, const char *name,
- int size)
+tdesc_create_flags (struct tdesc_feature *feature, const char *name, int size)
{
gdb_assert (size > 0);
@@ -210,8 +210,7 @@ tdesc_create_flags (struct tdesc_feature *feature, const char *name,
/* See gdbsupport/tdesc.h. */
tdesc_type_with_fields *
-tdesc_create_enum (struct tdesc_feature *feature, const char *name,
- int size)
+tdesc_create_enum (struct tdesc_feature *feature, const char *name, int size)
{
gdb_assert (size > 0);
@@ -226,10 +225,10 @@ tdesc_create_enum (struct tdesc_feature *feature, const char *name,
void
tdesc_add_field (tdesc_type_with_fields *type, const char *field_name,
- struct tdesc_type *field_type)
+ struct tdesc_type *field_type)
{
gdb_assert (type->kind == TDESC_TYPE_UNION
- || type->kind == TDESC_TYPE_STRUCT);
+ || type->kind == TDESC_TYPE_STRUCT);
/* Initialize start and end so we know this is not a bit-field
when we print-c-tdesc. */
@@ -240,10 +239,10 @@ tdesc_add_field (tdesc_type_with_fields *type, const char *field_name,
void
tdesc_add_typed_bitfield (tdesc_type_with_fields *type, const char *field_name,
- int start, int end, struct tdesc_type *field_type)
+ int start, int end, struct tdesc_type *field_type)
{
gdb_assert (type->kind == TDESC_TYPE_STRUCT
- || type->kind == TDESC_TYPE_FLAGS);
+ || type->kind == TDESC_TYPE_FLAGS);
gdb_assert (start >= 0 && end >= start);
type->fields.emplace_back (field_name, field_type, start, end);
@@ -253,7 +252,7 @@ tdesc_add_typed_bitfield (tdesc_type_with_fields *type, const char *field_name,
void
tdesc_add_bitfield (tdesc_type_with_fields *type, const char *field_name,
- int start, int end)
+ int start, int end)
{
struct tdesc_type *field_type;
@@ -270,53 +269,56 @@ tdesc_add_bitfield (tdesc_type_with_fields *type, const char *field_name,
/* See gdbsupport/tdesc.h. */
void
-tdesc_add_flag (tdesc_type_with_fields *type, int start,
- const char *flag_name)
+tdesc_add_flag (tdesc_type_with_fields *type, int start, const char *flag_name)
{
gdb_assert (type->kind == TDESC_TYPE_FLAGS
- || type->kind == TDESC_TYPE_STRUCT);
+ || type->kind == TDESC_TYPE_STRUCT);
type->fields.emplace_back (flag_name,
- tdesc_predefined_type (TDESC_TYPE_BOOL),
- start, start);
+ tdesc_predefined_type (TDESC_TYPE_BOOL), start,
+ start);
}
/* See gdbsupport/tdesc.h. */
void
tdesc_add_enum_value (tdesc_type_with_fields *type, int value,
- const char *name)
+ const char *name)
{
gdb_assert (type->kind == TDESC_TYPE_ENUM);
- type->fields.emplace_back (name,
- tdesc_predefined_type (TDESC_TYPE_INT32),
- value, -1);
+ type->fields.emplace_back (name, tdesc_predefined_type (TDESC_TYPE_INT32),
+ value, -1);
}
-void print_xml_feature::visit_pre (const tdesc_feature *e)
+void
+print_xml_feature::visit_pre (const tdesc_feature *e)
{
add_line ("<feature name=\"%s\">", e->name.c_str ());
indent (1);
}
-void print_xml_feature::visit_post (const tdesc_feature *e)
+void
+print_xml_feature::visit_post (const tdesc_feature *e)
{
indent (-1);
add_line ("</feature>");
}
-void print_xml_feature::visit (const tdesc_type_builtin *t)
+void
+print_xml_feature::visit (const tdesc_type_builtin *t)
{
- error (_("xml output is not supported for type \"%s\"."), t->name.c_str ());
+ error (_ ("xml output is not supported for type \"%s\"."), t->name.c_str ());
}
-void print_xml_feature::visit (const tdesc_type_vector *t)
+void
+print_xml_feature::visit (const tdesc_type_vector *t)
{
- add_line ("<vector id=\"%s\" type=\"%s\" count=\"%d\"/>",
- t->name.c_str (), t->element_type->name.c_str (), t->count);
+ add_line ("<vector id=\"%s\" type=\"%s\" count=\"%d\"/>", t->name.c_str (),
+ t->element_type->name.c_str (), t->count);
}
-void print_xml_feature::visit (const tdesc_type_with_fields *t)
+void
+print_xml_feature::visit (const tdesc_type_with_fields *t)
{
const static char *types[] = { "struct", "union", "flags", "enum" };
@@ -324,68 +326,66 @@ void print_xml_feature::visit (const tdesc_type_with_fields *t)
std::string tmp;
- string_appendf (tmp,
- "<%s id=\"%s\"", types[t->kind - TDESC_TYPE_STRUCT],
- t->name.c_str ());
+ string_appendf (tmp, "<%s id=\"%s\"", types[t->kind - TDESC_TYPE_STRUCT],
+ t->name.c_str ());
switch (t->kind)
{
case TDESC_TYPE_STRUCT:
case TDESC_TYPE_FLAGS:
if (t->size > 0)
- string_appendf (tmp, " size=\"%d\"", t->size);
+ string_appendf (tmp, " size=\"%d\"", t->size);
string_appendf (tmp, ">");
add_line (tmp);
for (const tdesc_type_field &f : t->fields)
- {
- tmp.clear ();
- string_appendf (tmp, " <field name=\"%s\"", f.name.c_str ());
- if (f.start != -1)
- string_appendf (tmp, " start=\"%d\" end=\"%d\"", f.start,
- f.end);
- string_appendf (tmp, " type=\"%s\"/>",
- f.type->name.c_str ());
- add_line (tmp);
- }
+ {
+ tmp.clear ();
+ string_appendf (tmp, " <field name=\"%s\"", f.name.c_str ());
+ if (f.start != -1)
+ string_appendf (tmp, " start=\"%d\" end=\"%d\"", f.start, f.end);
+ string_appendf (tmp, " type=\"%s\"/>", f.type->name.c_str ());
+ add_line (tmp);
+ }
break;
case TDESC_TYPE_ENUM:
if (t->size > 0)
- string_appendf (tmp, " size=\"%d\"", t->size);
+ string_appendf (tmp, " size=\"%d\"", t->size);
string_appendf (tmp, ">");
add_line (tmp);
/* The 'start' of the field is reused as the enum value. The 'end'
of the field is always set to -1 for enum values. */
for (const tdesc_type_field &f : t->fields)
- add_line (" <evalue name=\"%s\" value=\"%d\"/>",
- f.name.c_str (), f.start);
+ add_line (" <evalue name=\"%s\" value=\"%d\"/>", f.name.c_str (),
+ f.start);
break;
case TDESC_TYPE_UNION:
string_appendf (tmp, ">");
add_line (tmp);
for (const tdesc_type_field &f : t->fields)
- add_line (" <field name=\"%s\" type=\"%s\"/>",
- f.name.c_str (), f.type->name.c_str ());
+ add_line (" <field name=\"%s\" type=\"%s\"/>", f.name.c_str (),
+ f.type->name.c_str ());
break;
default:
- error (_("xml output is not supported for type \"%s\"."),
- t->name.c_str ());
+ error (_ ("xml output is not supported for type \"%s\"."),
+ t->name.c_str ());
}
add_line ("</%s>", types[t->kind - TDESC_TYPE_STRUCT]);
}
-void print_xml_feature::visit (const tdesc_reg *r)
+void
+print_xml_feature::visit (const tdesc_reg *r)
{
std::string tmp;
string_appendf (tmp,
- "<reg name=\"%s\" bitsize=\"%d\" type=\"%s\" regnum=\"%ld\"",
- r->name.c_str (), r->bitsize, r->type.c_str (),
- r->target_regnum);
+ "<reg name=\"%s\" bitsize=\"%d\" type=\"%s\" regnum=\"%ld\"",
+ r->name.c_str (), r->bitsize, r->type.c_str (),
+ r->target_regnum);
if (r->group.length () > 0)
string_appendf (tmp, " group=\"%s\"", r->group.c_str ());
@@ -398,7 +398,8 @@ void print_xml_feature::visit (const tdesc_reg *r)
add_line (tmp);
}
-void print_xml_feature::visit_pre (const target_desc *e)
+void
+print_xml_feature::visit_pre (const target_desc *e)
{
#ifndef IN_PROCESS_AGENT
add_line ("<?xml version=\"1.0\"?>");
@@ -406,8 +407,7 @@ void print_xml_feature::visit_pre (const target_desc *e)
add_line ("<target>");
indent (1);
if (tdesc_architecture_name (e))
- add_line ("<architecture>%s</architecture>",
- tdesc_architecture_name (e));
+ add_line ("<architecture>%s</architecture>", tdesc_architecture_name (e));
const char *osabi = tdesc_osabi_name (e);
if (osabi != nullptr)
@@ -417,11 +417,12 @@ void print_xml_feature::visit_pre (const target_desc *e)
= tdesc_compatible_info_list (e);
for (const auto &c : compatible_list)
add_line ("<compatible>%s</compatible>",
- tdesc_compatible_info_arch_name (c));
+ tdesc_compatible_info_arch_name (c));
#endif
}
-void print_xml_feature::visit_post (const target_desc *e)
+void
+print_xml_feature::visit_post (const target_desc *e)
{
indent (-1);
add_line ("</target>");
diff --git a/gdbsupport/tdesc.h b/gdbsupport/tdesc.h
index 40f0dac..8ee99a5 100644
--- a/gdbsupport/tdesc.h
+++ b/gdbsupport/tdesc.h
@@ -31,29 +31,21 @@ struct target_desc;
class tdesc_element_visitor
{
public:
- virtual void visit_pre (const target_desc *e)
- {}
+ virtual void visit_pre (const target_desc *e) {}
- virtual void visit_post (const target_desc *e)
- {}
+ virtual void visit_post (const target_desc *e) {}
- virtual void visit_pre (const tdesc_feature *e)
- {}
+ virtual void visit_pre (const tdesc_feature *e) {}
- virtual void visit_post (const tdesc_feature *e)
- {}
+ virtual void visit_post (const tdesc_feature *e) {}
- virtual void visit (const tdesc_type_builtin *e)
- {}
+ virtual void visit (const tdesc_type_builtin *e) {}
- virtual void visit (const tdesc_type_vector *e)
- {}
+ virtual void visit (const tdesc_type_vector *e) {}
- virtual void visit (const tdesc_type_with_fields *e)
- {}
+ virtual void visit (const tdesc_type_with_fields *e) {}
- virtual void visit (const tdesc_reg *e)
- {}
+ virtual void visit (const tdesc_reg *e) {}
};
class tdesc_element
@@ -67,8 +59,8 @@ public:
struct tdesc_reg : tdesc_element
{
tdesc_reg (struct tdesc_feature *feature, const std::string &name_,
- int regnum, int save_restore_, const char *group_,
- int bitsize_, const char *type_);
+ int regnum, int save_restore_, const char *group_, int bitsize_,
+ const char *type_);
virtual ~tdesc_reg () = default;
@@ -108,25 +100,16 @@ struct tdesc_reg : tdesc_element
/* The target-described type corresponding to TYPE, if found. */
struct tdesc_type *tdesc_type;
- void accept (tdesc_element_visitor &v) const override
- {
- v.visit (this);
- }
+ void accept (tdesc_element_visitor &v) const override { v.visit (this); }
bool operator== (const tdesc_reg &other) const
{
- return (name == other.name
- && target_regnum == other.target_regnum
- && save_restore == other.save_restore
- && bitsize == other.bitsize
- && group == other.group
- && type == other.type);
+ return (name == other.name && target_regnum == other.target_regnum
+ && save_restore == other.save_restore && bitsize == other.bitsize
+ && group == other.group && type == other.type);
}
- bool operator!= (const tdesc_reg &other) const
- {
- return !(*this == other);
- }
+ bool operator!= (const tdesc_reg &other) const { return !(*this == other); }
};
typedef std::unique_ptr<tdesc_reg> tdesc_reg_up;
@@ -143,14 +126,14 @@ typedef std::unique_ptr<tdesc_compatible_info> tdesc_compatible_info_up;
/* Return a vector of compatibility information pointers from the target
description TARGET_DESC. */
-const std::vector<tdesc_compatible_info_up> &tdesc_compatible_info_list
- (const target_desc *target_desc);
+const std::vector<tdesc_compatible_info_up> &
+tdesc_compatible_info_list (const target_desc *target_desc);
/* Return the architecture name from a compatibility information
COMPATIBLE. */
-const char *tdesc_compatible_info_arch_name
- (const tdesc_compatible_info_up &compatible);
+const char *
+tdesc_compatible_info_arch_name (const tdesc_compatible_info_up &compatible);
enum tdesc_type_kind
{
@@ -186,8 +169,10 @@ enum tdesc_type_kind
struct tdesc_type : tdesc_element
{
tdesc_type (const std::string &name_, enum tdesc_type_kind kind_)
- : name (name_), kind (kind_)
- {}
+ : name (name_),
+ kind (kind_)
+ {
+ }
virtual ~tdesc_type () = default;
@@ -204,10 +189,7 @@ struct tdesc_type : tdesc_element
return name == other.name && kind == other.kind;
}
- bool operator!= (const tdesc_type &other) const
- {
- return !(*this == other);
- }
+ bool operator!= (const tdesc_type &other) const { return !(*this == other); }
};
typedef std::unique_ptr<tdesc_type> tdesc_type_up;
@@ -215,13 +197,11 @@ typedef std::unique_ptr<tdesc_type> tdesc_type_up;
struct tdesc_type_builtin : tdesc_type
{
tdesc_type_builtin (const std::string &name, enum tdesc_type_kind kind)
- : tdesc_type (name, kind)
- {}
-
- void accept (tdesc_element_visitor &v) const override
+ : tdesc_type (name, kind)
{
- v.visit (this);
}
+
+ void accept (tdesc_element_visitor &v) const override { v.visit (this); }
};
/* tdesc_type for vector types. */
@@ -229,16 +209,15 @@ struct tdesc_type_builtin : tdesc_type
struct tdesc_type_vector : tdesc_type
{
tdesc_type_vector (const std::string &name, tdesc_type *element_type_,
- int count_)
- : tdesc_type (name, TDESC_TYPE_VECTOR),
- element_type (element_type_), count (count_)
- {}
-
- void accept (tdesc_element_visitor &v) const override
+ int count_)
+ : tdesc_type (name, TDESC_TYPE_VECTOR),
+ element_type (element_type_),
+ count (count_)
{
- v.visit (this);
}
+ void accept (tdesc_element_visitor &v) const override { v.visit (this); }
+
struct tdesc_type *element_type;
int count;
};
@@ -247,10 +226,14 @@ struct tdesc_type_vector : tdesc_type
struct tdesc_type_field
{
- tdesc_type_field (const std::string &name_, tdesc_type *type_,
- int start_, int end_)
- : name (name_), type (type_), start (start_), end (end_)
- {}
+ tdesc_type_field (const std::string &name_, tdesc_type *type_, int start_,
+ int end_)
+ : name (name_),
+ type (type_),
+ start (start_),
+ end (end_)
+ {
+ }
std::string name;
struct tdesc_type *type;
@@ -265,15 +248,14 @@ struct tdesc_type_field
struct tdesc_type_with_fields : tdesc_type
{
tdesc_type_with_fields (const std::string &name, tdesc_type_kind kind,
- int size_ = 0)
- : tdesc_type (name, kind), size (size_)
- {}
-
- void accept (tdesc_element_visitor &v) const override
+ int size_ = 0)
+ : tdesc_type (name, kind),
+ size (size_)
{
- v.visit (this);
}
+ void accept (tdesc_element_visitor &v) const override { v.visit (this); }
+
std::vector<tdesc_type_field> fields;
int size;
};
@@ -283,9 +265,7 @@ struct tdesc_type_with_fields : tdesc_type
struct tdesc_feature : tdesc_element
{
- tdesc_feature (const std::string &name_)
- : name (name_)
- {}
+ tdesc_feature (const std::string &name_) : name (name_) {}
virtual ~tdesc_feature () = default;
@@ -331,8 +311,7 @@ typedef std::unique_ptr<target_desc, target_desc_deleter> target_desc_up;
target_desc_up allocate_target_description (void);
/* Set TARGET_DESC's architecture by NAME. */
-void set_tdesc_architecture (target_desc *target_desc,
- const char *name);
+void set_tdesc_architecture (target_desc *target_desc, const char *name);
/* Return the architecture associated with this target description as a string,
or NULL if no architecture was specified. */
@@ -348,47 +327,44 @@ const char *tdesc_osabi_name (const struct target_desc *target_desc);
/* Return the type associated with ID in the context of FEATURE, or
NULL if none. */
struct tdesc_type *tdesc_named_type (const struct tdesc_feature *feature,
- const char *id);
+ const char *id);
/* Return the created feature named NAME in target description TDESC. */
struct tdesc_feature *tdesc_create_feature (struct target_desc *tdesc,
- const char *name);
+ const char *name);
/* Return the created vector tdesc_type named NAME in FEATURE. */
struct tdesc_type *tdesc_create_vector (struct tdesc_feature *feature,
- const char *name,
- struct tdesc_type *field_type,
- int count);
+ const char *name,
+ struct tdesc_type *field_type,
+ int count);
/* Return the created struct tdesc_type named NAME in FEATURE. */
tdesc_type_with_fields *tdesc_create_struct (struct tdesc_feature *feature,
- const char *name);
+ const char *name);
/* Return the created union tdesc_type named NAME in FEATURE. */
tdesc_type_with_fields *tdesc_create_union (struct tdesc_feature *feature,
- const char *name);
+ const char *name);
/* Return the created flags tdesc_type named NAME in FEATURE. */
tdesc_type_with_fields *tdesc_create_flags (struct tdesc_feature *feature,
- const char *name,
- int size);
+ const char *name, int size);
/* Return the created enum tdesc_type named NAME in FEATURE. */
tdesc_type_with_fields *tdesc_create_enum (struct tdesc_feature *feature,
- const char *name,
- int size);
+ const char *name, int size);
/* Add a new field to TYPE. FIELD_NAME is its name, and FIELD_TYPE is
its type. */
void tdesc_add_field (tdesc_type_with_fields *type, const char *field_name,
- struct tdesc_type *field_type);
+ struct tdesc_type *field_type);
/* Add a new bitfield to TYPE, with range START to END. FIELD_NAME is its name,
and FIELD_TYPE is its type. */
void tdesc_add_typed_bitfield (tdesc_type_with_fields *type,
- const char *field_name,
- int start, int end,
- struct tdesc_type *field_type);
+ const char *field_name, int start, int end,
+ struct tdesc_type *field_type);
/* Set the total length of TYPE. Structs which contain bitfields may
omit the reserved bits, so the end of the last field may not
@@ -399,21 +375,21 @@ void tdesc_set_struct_size (tdesc_type_with_fields *type, int size);
Untyped bitfields become either uint32 or uint64 depending on the size
of the underlying type. */
void tdesc_add_bitfield (tdesc_type_with_fields *type, const char *field_name,
- int start, int end);
+ int start, int end);
/* A flag is just a typed(bool) single-bit bitfield.
This function is kept to minimize changes in generated files. */
void tdesc_add_flag (tdesc_type_with_fields *type, int start,
- const char *flag_name);
+ const char *flag_name);
/* Add field with VALUE and NAME to the enum TYPE. */
void tdesc_add_enum_value (tdesc_type_with_fields *type, int value,
- const char *name);
+ const char *name);
/* Create a register in feature FEATURE. */
void tdesc_create_reg (struct tdesc_feature *feature, const char *name,
- int regnum, int save_restore, const char *group,
- int bitsize, const char *type);
+ int regnum, int save_restore, const char *group,
+ int bitsize, const char *type);
/* Return the tdesc in string XML format. */
@@ -424,10 +400,7 @@ const char *tdesc_get_features_xml (const target_desc *tdesc);
class print_xml_feature : public tdesc_element_visitor
{
public:
- print_xml_feature (std::string *buffer_)
- : m_buffer (buffer_),
- m_depth (0)
- {}
+ print_xml_feature (std::string *buffer_) : m_buffer (buffer_), m_depth (0) {}
void visit_pre (const target_desc *e) override;
void visit_post (const target_desc *e) override;
@@ -439,15 +412,11 @@ public:
void visit (const tdesc_reg *reg) override;
private:
-
/* Called with a positive value of ADJUST when we move inside an element,
for example inside <target>, and with a negative value when we leave
the element. In this class this function does nothing, but a
sub-class can override this to track the current level of nesting. */
- void indent (int adjust)
- {
- m_depth += (adjust * 2);
- }
+ void indent (int adjust) { m_depth += (adjust * 2); }
/* Functions to add lines to the output buffer M_BUFFER. Each of these
functions appends a newline, so don't include one in the strings being
diff --git a/gdbsupport/thread-pool.cc b/gdbsupport/thread-pool.cc
index 1c871ed..43b0976 100644
--- a/gdbsupport/thread-pool.cc
+++ b/gdbsupport/thread-pool.cc
@@ -47,14 +47,14 @@
ATTRIBUTE_UNUSED static void
do_set_thread_name (int (*set_name) (pthread_t, const char *, void *),
- const char *name)
+ const char *name)
{
set_name (pthread_self (), "%s", const_cast<char *> (name));
}
ATTRIBUTE_UNUSED static void
do_set_thread_name (int (*set_name) (pthread_t, const char *),
- const char *name)
+ const char *name)
{
set_name (pthread_self (), name);
}
@@ -73,7 +73,7 @@ set_thread_name (const char *name)
do_set_thread_name (pthread_setname_np, name);
}
-#elif defined (USE_WIN32API)
+#elif defined(USE_WIN32API)
#include <windows.h>
@@ -90,7 +90,7 @@ init_windows ()
if (hm)
dyn_SetThreadDescription
= (SetThreadDescription_ftype *) GetProcAddress (hm,
- "SetThreadDescription");
+ "SetThreadDescription");
/* On some versions of Windows, this function is only available in
KernelBase.dll, not kernel32.dll. */
@@ -98,9 +98,8 @@ init_windows ()
{
hm = LoadLibrary (TEXT ("KernelBase.dll"));
if (hm)
- dyn_SetThreadDescription
- = (SetThreadDescription_ftype *) GetProcAddress (hm,
- "SetThreadDescription");
+ dyn_SetThreadDescription = (SetThreadDescription_ftype *)
+ GetProcAddress (hm, "SetThreadDescription");
}
}
@@ -114,7 +113,7 @@ do_set_thread_name (const wchar_t *name)
dyn_SetThreadDescription (GetCurrentThread (), name);
}
-#define set_thread_name(NAME) do_set_thread_name (L ## NAME)
+#define set_thread_name(NAME) do_set_thread_name (L##NAME)
#else /* USE_WIN32API */
@@ -162,27 +161,27 @@ thread_pool::set_thread_count (size_t num_threads)
threads. */
block_signals blocker;
for (size_t i = m_thread_count; i < num_threads; ++i)
- {
- try
- {
- std::thread thread (&thread_pool::thread_function, this);
- thread.detach ();
- }
- catch (const std::system_error &)
- {
- /* libstdc++ may not implement std::thread, and will
+ {
+ try
+ {
+ std::thread thread (&thread_pool::thread_function, this);
+ thread.detach ();
+ }
+ catch (const std::system_error &)
+ {
+ /* libstdc++ may not implement std::thread, and will
throw an exception on use. It seems fine to ignore
this, and any other sort of startup failure here. */
- num_threads = i;
- break;
- }
- }
+ num_threads = i;
+ break;
+ }
+ }
}
/* If the new size is smaller, terminate some existing threads. */
if (num_threads < m_thread_count)
{
for (size_t i = num_threads; i < m_thread_count; ++i)
- m_tasks.emplace ();
+ m_tasks.emplace ();
m_tasks_cv.notify_all ();
}
@@ -228,17 +227,17 @@ thread_pool::thread_function ()
optional<task_t> t;
{
- /* We want to hold the lock while examining the task list, but
+ /* We want to hold the lock while examining the task list, but
not while invoking the task function. */
- std::unique_lock<std::mutex> guard (m_tasks_mutex);
- while (m_tasks.empty ())
- m_tasks_cv.wait (guard);
- t = std::move (m_tasks.front());
- m_tasks.pop ();
+ std::unique_lock<std::mutex> guard (m_tasks_mutex);
+ while (m_tasks.empty ())
+ m_tasks_cv.wait (guard);
+ t = std::move (m_tasks.front ());
+ m_tasks.pop ();
}
if (!t.has_value ())
- break;
+ break;
(*t) ();
}
}
diff --git a/gdbsupport/thread-pool.h b/gdbsupport/thread-pool.h
index 013c6ab..847df64 100644
--- a/gdbsupport/thread-pool.h
+++ b/gdbsupport/thread-pool.h
@@ -57,11 +57,7 @@ template<typename T>
class future
{
public:
-
- explicit future (T value)
- : m_value (std::move (value))
- {
- }
+ explicit future (T value) : m_value (std::move (value)) {}
future () = default;
future (future &&other) = default;
@@ -69,12 +65,11 @@ public:
future &operator= (future &&other) = default;
future &operator= (const future &other) = delete;
- void wait () const { }
+ void wait () const {}
T get () { return std::move (m_value); }
private:
-
T m_value;
};
@@ -84,13 +79,12 @@ template<>
class future<void>
{
public:
- void wait () const { }
- void get () { }
+ void wait () const {}
+ void get () {}
};
#endif /* CXX_STD_THREAD */
-
/* A thread pool.
There is a single global thread pool, see g_thread_pool. Tasks can
@@ -150,7 +144,6 @@ public:
}
private:
-
thread_pool () = default;
#if CXX_STD_THREAD
@@ -180,6 +173,6 @@ private:
#endif /* CXX_STD_THREAD */
};
-}
+} // namespace gdb
#endif /* GDBSUPPORT_THREAD_POOL_H */
diff --git a/gdbsupport/traits.h b/gdbsupport/traits.h
index f6bb649..f3088f8 100644
--- a/gdbsupport/traits.h
+++ b/gdbsupport/traits.h
@@ -22,7 +22,7 @@
/* GCC does not understand __has_feature. */
#if !defined(__has_feature)
-# define __has_feature(x) 0
+#define __has_feature(x) 0
#endif
/* HAVE_IS_TRIVIALLY_COPYABLE is defined as 1 iff
@@ -30,7 +30,7 @@
in GCC 5. */
#if (__has_feature(is_trivially_copyable) \
|| (defined __GNUC__ && __GNUC__ >= 5))
-# define HAVE_IS_TRIVIALLY_COPYABLE 1
+#define HAVE_IS_TRIVIALLY_COPYABLE 1
#endif
/* HAVE_IS_TRIVIALLY_CONSTRUCTIBLE is defined as 1 iff
@@ -38,16 +38,20 @@
in GCC 5. */
#if (__has_feature(is_trivially_constructible) \
|| (defined __GNUC__ && __GNUC__ >= 5))
-# define HAVE_IS_TRIVIALLY_CONSTRUCTIBLE 1
+#define HAVE_IS_TRIVIALLY_CONSTRUCTIBLE 1
#endif
-namespace gdb {
+namespace gdb
+{
/* Pre C++14-safe (CWG 1558) version of C++17's std::void_t. See
<http://en.cppreference.com/w/cpp/types/void_t>. */
template<typename... Ts>
-struct make_void { typedef void type; };
+struct make_void
+{
+ typedef void type;
+};
template<typename... Ts>
using void_t = typename make_void<Ts...>::type;
@@ -67,10 +71,11 @@ struct nonesuch
void operator= (const nonesuch &) = delete;
};
-namespace detection_detail {
+namespace detection_detail
+{
/* Implementation of the detection idiom (negative case). */
-template<typename Default, typename AlwaysVoid,
- template<typename...> class Op, typename... Args>
+template<typename Default, typename AlwaysVoid, template<typename...> class Op,
+ typename... Args>
struct detector
{
using value_t = std::false_type;
@@ -86,25 +91,22 @@ struct detector<Default, void_t<Op<Args...>>, Op, Args...>
};
/* Detect whether Op<Args...> is a valid type, use Default if not. */
-template<typename Default, template<typename...> class Op,
- typename... Args>
+template<typename Default, template<typename...> class Op, typename... Args>
using detected_or = detector<Default, void, Op, Args...>;
/* Op<Args...> if that is a valid type, otherwise Default. */
-template<typename Default, template<typename...> class Op,
- typename... Args>
-using detected_or_t
- = typename detected_or<Default, Op, Args...>::type;
+template<typename Default, template<typename...> class Op, typename... Args>
+using detected_or_t = typename detected_or<Default, Op, Args...>::type;
-} /* detection_detail */
+} // namespace detection_detail
template<template<typename...> class Op, typename... Args>
-using is_detected
- = typename detection_detail::detector<nonesuch, void, Op, Args...>::value_t;
+using is_detected =
+ typename detection_detail::detector<nonesuch, void, Op, Args...>::value_t;
template<template<typename...> class Op, typename... Args>
-using detected_t
- = typename detection_detail::detector<nonesuch, void, Op, Args...>::type;
+using detected_t =
+ typename detection_detail::detector<nonesuch, void, Op, Args...>::type;
template<typename Default, template<typename...> class Op, typename... Args>
using detected_or = detection_detail::detected_or<Default, Op, Args...>;
@@ -124,53 +126,60 @@ using is_detected_convertible
template<typename Predicate>
struct Not : public std::integral_constant<bool, !Predicate::value>
-{};
+{
+};
template<typename...>
struct Or;
template<>
struct Or<> : public std::false_type
-{};
+{
+};
template<typename B1>
struct Or<B1> : public B1
-{};
+{
+};
template<typename B1, typename B2>
-struct Or<B1, B2>
- : public std::conditional<B1::value, B1, B2>::type
-{};
+struct Or<B1, B2> : public std::conditional<B1::value, B1, B2>::type
+{
+};
-template<typename B1,typename B2,typename B3, typename... Bn>
+template<typename B1, typename B2, typename B3, typename... Bn>
struct Or<B1, B2, B3, Bn...>
: public std::conditional<B1::value, B1, Or<B2, B3, Bn...>>::type
-{};
+{
+};
template<typename...>
struct And;
template<>
struct And<> : public std::true_type
-{};
+{
+};
template<typename B1>
struct And<B1> : public B1
-{};
+{
+};
template<typename B1, typename B2>
-struct And<B1, B2>
- : public std::conditional<B1::value, B2, B1>::type
-{};
+struct And<B1, B2> : public std::conditional<B1::value, B2, B1>::type
+{
+};
template<typename B1, typename B2, typename B3, typename... Bn>
struct And<B1, B2, B3, Bn...>
: public std::conditional<B1::value, And<B2, B3, Bn...>, B1>::type
-{};
+{
+};
/* Concepts-light-like helper to make SFINAE logic easier to read. */
template<typename Condition>
using Requires = typename std::enable_if<Condition::value, void>::type;
-}
+} // namespace gdb
#endif /* COMMON_TRAITS_H */
diff --git a/gdbsupport/valid-expr.h b/gdbsupport/valid-expr.h
index 75734c8..6591b14 100644
--- a/gdbsupport/valid-expr.h
+++ b/gdbsupport/valid-expr.h
@@ -55,57 +55,52 @@
line number, so client code should wrap sets of calls in a
test-specific namespace too, to fully guarantee uniqueness between
the multiple clients in the codebase. */
-#define CHECK_VALID_EXPR_INT(TYPENAMES, TYPES, VALID, EXPR_TYPE, EXPR) \
- namespace CONCAT (check_valid_expr, __LINE__) { \
- \
- template <TYPENAMES, typename = decltype (EXPR)> \
- struct archetype \
- { \
- }; \
- \
- static_assert (gdb::is_detected_exact<archetype<TYPES, EXPR_TYPE>, \
- archetype, TYPES>::value == VALID, \
- ""); \
+#define CHECK_VALID_EXPR_INT(TYPENAMES, TYPES, VALID, EXPR_TYPE, EXPR) \
+ namespace CONCAT (check_valid_expr, __LINE__) \
+ { \
+ \
+ template<TYPENAMES, typename = decltype (EXPR)> \
+ struct archetype \
+ { \
+ }; \
+ \
+ static_assert (gdb::is_detected_exact<archetype<TYPES, EXPR_TYPE>, \
+ archetype, TYPES>::value \
+ == VALID, \
+ ""); \
} /* namespace */
/* A few convenience macros that support expressions involving a
varying numbers of types. If you need more types, feel free to add
another variant. */
-#define CHECK_VALID_EXPR_1(T1, VALID, EXPR_TYPE, EXPR) \
- CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1), \
- ESC_PARENS (T1), \
- VALID, EXPR_TYPE, EXPR)
+#define CHECK_VALID_EXPR_1(T1, VALID, EXPR_TYPE, EXPR) \
+ CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1), ESC_PARENS (T1), VALID, \
+ EXPR_TYPE, EXPR)
-#define CHECK_VALID_EXPR_2(T1, T2, VALID, EXPR_TYPE, EXPR) \
- CHECK_VALID_EXPR_INT (ESC_PARENS(typename T1, typename T2), \
- ESC_PARENS (T1, T2), \
- VALID, EXPR_TYPE, EXPR)
+#define CHECK_VALID_EXPR_2(T1, T2, VALID, EXPR_TYPE, EXPR) \
+ CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2), \
+ ESC_PARENS (T1, T2), VALID, EXPR_TYPE, EXPR)
-#define CHECK_VALID_EXPR_3(T1, T2, T3, VALID, EXPR_TYPE, EXPR) \
+#define CHECK_VALID_EXPR_3(T1, T2, T3, VALID, EXPR_TYPE, EXPR) \
CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2, typename T3), \
- ESC_PARENS (T1, T2, T3), \
- VALID, EXPR_TYPE, EXPR)
-
-#define CHECK_VALID_EXPR_4(T1, T2, T3, T4, VALID, EXPR_TYPE, EXPR) \
- CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2, \
- typename T3, typename T4), \
- ESC_PARENS (T1, T2, T3, T4), \
- VALID, EXPR_TYPE, EXPR)
-
-#define CHECK_VALID_EXPR_5(T1, T2, T3, T4, T5, VALID, EXPR_TYPE, EXPR) \
- CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2, \
- typename T3, typename T4, \
- typename T5), \
- ESC_PARENS (T1, T2, T3, T4, T5), \
- VALID, EXPR_TYPE, EXPR)
-
-#define CHECK_VALID_EXPR_6(T1, T2, T3, T4, T5, T6, \
- VALID, EXPR_TYPE, EXPR) \
- CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2, \
- typename T3, typename T4, \
- typename T5, typename T6), \
- ESC_PARENS (T1, T2, T3, T4, T5, T6), \
- VALID, EXPR_TYPE, EXPR)
+ ESC_PARENS (T1, T2, T3), VALID, EXPR_TYPE, EXPR)
+
+#define CHECK_VALID_EXPR_4(T1, T2, T3, T4, VALID, EXPR_TYPE, EXPR) \
+ CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2, typename T3, \
+ typename T4), \
+ ESC_PARENS (T1, T2, T3, T4), VALID, EXPR_TYPE, EXPR)
+
+#define CHECK_VALID_EXPR_5(T1, T2, T3, T4, T5, VALID, EXPR_TYPE, EXPR) \
+ CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2, typename T3, \
+ typename T4, typename T5), \
+ ESC_PARENS (T1, T2, T3, T4, T5), VALID, EXPR_TYPE, \
+ EXPR)
+
+#define CHECK_VALID_EXPR_6(T1, T2, T3, T4, T5, T6, VALID, EXPR_TYPE, EXPR) \
+ CHECK_VALID_EXPR_INT (ESC_PARENS (typename T1, typename T2, typename T3, \
+ typename T4, typename T5, typename T6), \
+ ESC_PARENS (T1, T2, T3, T4, T5, T6), VALID, \
+ EXPR_TYPE, EXPR)
#endif /* COMMON_VALID_EXPR_H */
diff --git a/gdbsupport/x86-xstate.h b/gdbsupport/x86-xstate.h
index b8740fd..34a10e8 100644
--- a/gdbsupport/x86-xstate.h
+++ b/gdbsupport/x86-xstate.h
@@ -21,56 +21,56 @@
#define COMMON_X86_XSTATE_H
/* The extended state feature bits. */
-#define X86_XSTATE_X87 (1ULL << 0)
-#define X86_XSTATE_SSE (1ULL << 1)
-#define X86_XSTATE_AVX (1ULL << 2)
-#define X86_XSTATE_BNDREGS (1ULL << 3)
-#define X86_XSTATE_BNDCFG (1ULL << 4)
-#define X86_XSTATE_MPX (X86_XSTATE_BNDREGS | X86_XSTATE_BNDCFG)
+#define X86_XSTATE_X87 (1ULL << 0)
+#define X86_XSTATE_SSE (1ULL << 1)
+#define X86_XSTATE_AVX (1ULL << 2)
+#define X86_XSTATE_BNDREGS (1ULL << 3)
+#define X86_XSTATE_BNDCFG (1ULL << 4)
+#define X86_XSTATE_MPX (X86_XSTATE_BNDREGS | X86_XSTATE_BNDCFG)
/* AVX 512 adds three feature bits. All three must be enabled. */
-#define X86_XSTATE_K (1ULL << 5)
-#define X86_XSTATE_ZMM_H (1ULL << 6)
-#define X86_XSTATE_ZMM (1ULL << 7)
-#define X86_XSTATE_AVX512 (X86_XSTATE_K | X86_XSTATE_ZMM_H \
- | X86_XSTATE_ZMM)
+#define X86_XSTATE_K (1ULL << 5)
+#define X86_XSTATE_ZMM_H (1ULL << 6)
+#define X86_XSTATE_ZMM (1ULL << 7)
+#define X86_XSTATE_AVX512 (X86_XSTATE_K | X86_XSTATE_ZMM_H | X86_XSTATE_ZMM)
-#define X86_XSTATE_PKRU (1ULL << 9)
+#define X86_XSTATE_PKRU (1ULL << 9)
/* Supported mask and size of the extended state. */
-#define X86_XSTATE_X87_MASK X86_XSTATE_X87
-#define X86_XSTATE_SSE_MASK (X86_XSTATE_X87 | X86_XSTATE_SSE)
-#define X86_XSTATE_AVX_MASK (X86_XSTATE_SSE_MASK | X86_XSTATE_AVX)
-#define X86_XSTATE_MPX_MASK (X86_XSTATE_SSE_MASK | X86_XSTATE_MPX)
-#define X86_XSTATE_AVX_MPX_MASK (X86_XSTATE_AVX_MASK | X86_XSTATE_MPX)
-#define X86_XSTATE_AVX_AVX512_MASK (X86_XSTATE_AVX_MASK | X86_XSTATE_AVX512)
-#define X86_XSTATE_AVX_MPX_AVX512_PKU_MASK (X86_XSTATE_AVX_MPX_MASK\
- | X86_XSTATE_AVX512 | X86_XSTATE_PKRU)
-
-#define X86_XSTATE_ALL_MASK (X86_XSTATE_AVX_MPX_AVX512_PKU_MASK)
-
-
-#define X86_XSTATE_SSE_SIZE 576
-#define X86_XSTATE_AVX_SIZE 832
-#define X86_XSTATE_BNDREGS_SIZE 1024
-#define X86_XSTATE_BNDCFG_SIZE 1088
-#define X86_XSTATE_AVX512_SIZE 2688
-#define X86_XSTATE_PKRU_SIZE 2696
-#define X86_XSTATE_MAX_SIZE 2696
-
+#define X86_XSTATE_X87_MASK X86_XSTATE_X87
+#define X86_XSTATE_SSE_MASK (X86_XSTATE_X87 | X86_XSTATE_SSE)
+#define X86_XSTATE_AVX_MASK (X86_XSTATE_SSE_MASK | X86_XSTATE_AVX)
+#define X86_XSTATE_MPX_MASK (X86_XSTATE_SSE_MASK | X86_XSTATE_MPX)
+#define X86_XSTATE_AVX_MPX_MASK (X86_XSTATE_AVX_MASK | X86_XSTATE_MPX)
+#define X86_XSTATE_AVX_AVX512_MASK (X86_XSTATE_AVX_MASK | X86_XSTATE_AVX512)
+#define X86_XSTATE_AVX_MPX_AVX512_PKU_MASK \
+ (X86_XSTATE_AVX_MPX_MASK | X86_XSTATE_AVX512 | X86_XSTATE_PKRU)
+
+#define X86_XSTATE_ALL_MASK (X86_XSTATE_AVX_MPX_AVX512_PKU_MASK)
+
+#define X86_XSTATE_SSE_SIZE 576
+#define X86_XSTATE_AVX_SIZE 832
+#define X86_XSTATE_BNDREGS_SIZE 1024
+#define X86_XSTATE_BNDCFG_SIZE 1088
+#define X86_XSTATE_AVX512_SIZE 2688
+#define X86_XSTATE_PKRU_SIZE 2696
+#define X86_XSTATE_MAX_SIZE 2696
/* In case one of the MPX XCR0 bits is set we consider we have MPX. */
-#define HAS_MPX(XCR0) (((XCR0) & X86_XSTATE_MPX) != 0)
-#define HAS_AVX(XCR0) (((XCR0) & X86_XSTATE_AVX) != 0)
-#define HAS_AVX512(XCR0) (((XCR0) & X86_XSTATE_AVX512) != 0)
-#define HAS_PKRU(XCR0) (((XCR0) & X86_XSTATE_PKRU) != 0)
+#define HAS_MPX(XCR0) (((XCR0) &X86_XSTATE_MPX) != 0)
+#define HAS_AVX(XCR0) (((XCR0) &X86_XSTATE_AVX) != 0)
+#define HAS_AVX512(XCR0) (((XCR0) &X86_XSTATE_AVX512) != 0)
+#define HAS_PKRU(XCR0) (((XCR0) &X86_XSTATE_PKRU) != 0)
/* Get I386 XSAVE extended state size. */
-#define X86_XSTATE_SIZE(XCR0) \
- (HAS_PKRU (XCR0) ? X86_XSTATE_PKRU_SIZE : \
- (HAS_AVX512 (XCR0) ? X86_XSTATE_AVX512_SIZE : \
- (HAS_MPX (XCR0) ? X86_XSTATE_BNDCFG_SIZE : \
- (HAS_AVX (XCR0) ? X86_XSTATE_AVX_SIZE : X86_XSTATE_SSE_SIZE))))
+#define X86_XSTATE_SIZE(XCR0) \
+ (HAS_PKRU (XCR0) \
+ ? X86_XSTATE_PKRU_SIZE \
+ : (HAS_AVX512 (XCR0) \
+ ? X86_XSTATE_AVX512_SIZE \
+ : (HAS_MPX (XCR0) ? X86_XSTATE_BNDCFG_SIZE \
+ : (HAS_AVX (XCR0) ? X86_XSTATE_AVX_SIZE \
+ : X86_XSTATE_SSE_SIZE))))
/* Initial value for fctrl register, as defined in the X86 manual, and
confirmed in the (Linux) kernel source. When the x87 floating point
diff --git a/gdbsupport/xml-utils.cc b/gdbsupport/xml-utils.cc
index 2486031..23186e6 100644
--- a/gdbsupport/xml-utils.cc
+++ b/gdbsupport/xml-utils.cc
@@ -42,23 +42,23 @@ xml_escape_text_append (std::string &result, const char *text)
switch (text[i])
{
case '\'':
- result += "&apos;";
- break;
+ result += "&apos;";
+ break;
case '\"':
- result += "&quot;";
- break;
+ result += "&quot;";
+ break;
case '&':
- result += "&amp;";
- break;
+ result += "&amp;";
+ break;
case '<':
- result += "&lt;";
- break;
+ result += "&lt;";
+ break;
case '>':
- result += "&gt;";
- break;
+ result += "&gt;";
+ break;
default:
- result += text[i];
- break;
+ result += text[i];
+ break;
}
}
@@ -78,89 +78,89 @@ string_xml_appendf (std::string &buffer, const char *format, ...)
for (f = format; *f; f++)
{
if (percent)
- {
- char buf[32];
- char *str = buf;
- const char *f_old = f;
-
- switch (*f)
- {
- case 's':
- str = va_arg (ap, char *);
- break;
- case 'd':
- sprintf (str, "%d", va_arg (ap, int));
- break;
- case 'u':
- sprintf (str, "%u", va_arg (ap, unsigned int));
- break;
- case 'x':
- sprintf (str, "%x", va_arg (ap, unsigned int));
- break;
- case 'o':
- sprintf (str, "%o", va_arg (ap, unsigned int));
- break;
- case 'l':
- f++;
- switch (*f)
- {
- case 'd':
- sprintf (str, "%ld", va_arg (ap, long));
- break;
- case 'u':
- sprintf (str, "%lu", va_arg (ap, unsigned long));
- break;
- case 'x':
- sprintf (str, "%lx", va_arg (ap, unsigned long));
- break;
- case 'o':
- sprintf (str, "%lo", va_arg (ap, unsigned long));
- break;
- case 'l':
- f++;
- switch (*f)
- {
- case 'd':
- sprintf (str, "%" PRId64,
- (int64_t) va_arg (ap, long long));
- break;
- case 'u':
- sprintf (str, "%" PRIu64,
- (uint64_t) va_arg (ap, unsigned long long));
- break;
- case 'x':
- sprintf (str, "%" PRIx64,
- (uint64_t) va_arg (ap, unsigned long long));
- break;
- case 'o':
- sprintf (str, "%" PRIo64,
- (uint64_t) va_arg (ap, unsigned long long));
- break;
- default:
- str = 0;
- break;
- }
- break;
- default:
- str = 0;
- break;
- }
- break;
- default:
- str = 0;
- break;
- }
-
- if (str)
- {
- buffer.append (prev, f_old - prev - 1);
- xml_escape_text_append (buffer, str);
- prev = f + 1;
- }
- percent = 0;
- }
+ {
+ char buf[32];
+ char *str = buf;
+ const char *f_old = f;
+
+ switch (*f)
+ {
+ case 's':
+ str = va_arg (ap, char *);
+ break;
+ case 'd':
+ sprintf (str, "%d", va_arg (ap, int));
+ break;
+ case 'u':
+ sprintf (str, "%u", va_arg (ap, unsigned int));
+ break;
+ case 'x':
+ sprintf (str, "%x", va_arg (ap, unsigned int));
+ break;
+ case 'o':
+ sprintf (str, "%o", va_arg (ap, unsigned int));
+ break;
+ case 'l':
+ f++;
+ switch (*f)
+ {
+ case 'd':
+ sprintf (str, "%ld", va_arg (ap, long));
+ break;
+ case 'u':
+ sprintf (str, "%lu", va_arg (ap, unsigned long));
+ break;
+ case 'x':
+ sprintf (str, "%lx", va_arg (ap, unsigned long));
+ break;
+ case 'o':
+ sprintf (str, "%lo", va_arg (ap, unsigned long));
+ break;
+ case 'l':
+ f++;
+ switch (*f)
+ {
+ case 'd':
+ sprintf (str, "%" PRId64,
+ (int64_t) va_arg (ap, long long));
+ break;
+ case 'u':
+ sprintf (str, "%" PRIu64,
+ (uint64_t) va_arg (ap, unsigned long long));
+ break;
+ case 'x':
+ sprintf (str, "%" PRIx64,
+ (uint64_t) va_arg (ap, unsigned long long));
+ break;
+ case 'o':
+ sprintf (str, "%" PRIo64,
+ (uint64_t) va_arg (ap, unsigned long long));
+ break;
+ default:
+ str = 0;
+ break;
+ }
+ break;
+ default:
+ str = 0;
+ break;
+ }
+ break;
+ default:
+ str = 0;
+ break;
+ }
+
+ if (str)
+ {
+ buffer.append (prev, f_old - prev - 1);
+ xml_escape_text_append (buffer, str);
+ prev = f + 1;
+ }
+ percent = 0;
+ }
else if (*f == '%')
- percent = 1;
+ percent = 1;
}
buffer.append (prev);