aboutsummaryrefslogtreecommitdiff
path: root/gdb/target
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2023-02-08 15:36:23 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2023-02-08 15:46:02 -0500
commitc583a2520616c2736cffc389c89a48b159366e6c (patch)
treeb4925f26506fcee96c16119431c01760f05db95d /gdb/target
parentca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff)
downloadbinutils-users/simark/clang-format.zip
binutils-users/simark/clang-format.tar.gz
binutils-users/simark/clang-format.tar.bz2
Run clang-format.shusers/simark/clang-format
Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968
Diffstat (limited to 'gdb/target')
-rw-r--r--gdb/target/target.c34
-rw-r--r--gdb/target/target.h20
-rw-r--r--gdb/target/waitstatus.c12
-rw-r--r--gdb/target/waitstatus.h57
4 files changed, 58 insertions, 65 deletions
diff --git a/gdb/target/target.c b/gdb/target/target.c
index 8089918..931a966 100644
--- a/gdb/target/target.c
+++ b/gdb/target/target.c
@@ -26,11 +26,10 @@
location pointed to by ERRPTR if ERRPTR is non-null. */
static int
-partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr,
- int len, int *errptr)
+partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int *errptr)
{
- int nread; /* Number of bytes actually read. */
- int errcode; /* Error from last read. */
+ int nread; /* Number of bytes actually read. */
+ int errcode; /* Error from last read. */
/* First try a complete read. */
errcode = target_read_memory (memaddr, myaddr, len);
@@ -64,12 +63,11 @@ partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr,
int
target_read_string (CORE_ADDR addr, int len, int width,
unsigned int fetchlimit,
- gdb::unique_xmalloc_ptr<gdb_byte> *buffer,
- int *bytes_read)
+ gdb::unique_xmalloc_ptr<gdb_byte> *buffer, int *bytes_read)
{
- int errcode; /* Errno returned from bad reads. */
- unsigned int nfetch; /* Chars to fetch / chars fetched. */
- gdb_byte *bufptr; /* Pointer to next available byte in
+ int errcode; /* Errno returned from bad reads. */
+ unsigned int nfetch; /* Chars to fetch / chars fetched. */
+ gdb_byte *bufptr; /* Pointer to next available byte in
buffer. */
/* Loop until we either have all the characters, or we encounter
@@ -87,16 +85,16 @@ target_read_string (CORE_ADDR addr, int len, int width,
bufptr = buffer->get ();
nfetch = partial_memory_read (addr, bufptr, fetchlen * width, &errcode)
- / width;
+ / width;
addr += nfetch * width;
bufptr += nfetch * width;
}
else if (len == -1)
{
unsigned long bufsize = 0;
- unsigned int chunksize; /* Size of each fetch, in chars. */
- int found_nul; /* Non-zero if we found the nul char. */
- gdb_byte *limit; /* First location past end of fetch buffer. */
+ unsigned int chunksize; /* Size of each fetch, in chars. */
+ int found_nul; /* Non-zero if we found the nul char. */
+ gdb_byte *limit; /* First location past end of fetch buffer. */
found_nul = 0;
/* We are looking for a NUL terminator to end the fetching, so we
@@ -122,7 +120,7 @@ target_read_string (CORE_ADDR addr, int len, int width,
/* Read as much as we can. */
nfetch = partial_memory_read (addr, bufptr, nfetch * width, &errcode)
- / width;
+ / width;
/* Scan this chunk for the null character that terminates the string
to print. If found, we don't need to fetch any more. Note
@@ -151,12 +149,12 @@ target_read_string (CORE_ADDR addr, int len, int width,
}
}
}
- while (errcode == 0 /* no error */
- && bufptr - buffer->get () < fetchlimit * width /* no overrun */
- && !found_nul); /* haven't found NUL yet */
+ while (errcode == 0 /* no error */
+ && bufptr - buffer->get () < fetchlimit * width /* no overrun */
+ && !found_nul); /* haven't found NUL yet */
}
else
- { /* Length of string is really 0! */
+ { /* Length of string is really 0! */
/* We always allocate *buffer. */
buffer->reset ((gdb_byte *) xmalloc (1));
bufptr = buffer->get ();
diff --git a/gdb/target/target.h b/gdb/target/target.h
index d1a18ee..b9c1cf2 100644
--- a/gdb/target/target.h
+++ b/gdb/target/target.h
@@ -53,8 +53,8 @@ extern int target_read_uint32 (CORE_ADDR memaddr, uint32_t *result);
in some cases -- but these will not be returned). Returns nullptr
on error. */
-extern gdb::unique_xmalloc_ptr<char> target_read_string
- (CORE_ADDR memaddr, int len, int *bytes_read = nullptr);
+extern gdb::unique_xmalloc_ptr<char>
+target_read_string (CORE_ADDR memaddr, int len, int *bytes_read = nullptr);
/* Read a string from the inferior, at ADDR, with LEN characters of
WIDTH bytes each. Fetch at most FETCHLIMIT characters. BUFFER
@@ -131,17 +131,17 @@ extern int target_supports_multi_process (void);
/* Possible terminal states. */
enum class target_terminal_state
- {
- /* The inferior's terminal settings are in effect. */
- is_inferior = 0,
+{
+ /* The inferior's terminal settings are in effect. */
+ is_inferior = 0,
- /* Some of our terminal settings are in effect, enough to get
+ /* Some of our terminal settings are in effect, enough to get
proper output. */
- is_ours_for_output = 1,
+ is_ours_for_output = 1,
- /* Our terminal settings are in effect, for output and input. */
- is_ours = 2
- };
+ /* Our terminal settings are in effect, for output and input. */
+ is_ours = 2
+};
/* Represents the state of the target terminal. */
class target_terminal
diff --git a/gdb/target/waitstatus.c b/gdb/target/waitstatus.c
index 2b8404f..83ae653 100644
--- a/gdb/target/waitstatus.c
+++ b/gdb/target/waitstatus.c
@@ -25,13 +25,13 @@
std::string
target_waitstatus::to_string () const
{
- std::string str = string_printf
- ("status->kind = %s", target_waitkind_str (this->kind ()));
+ std::string str
+ = string_printf ("status->kind = %s", target_waitkind_str (this->kind ()));
-/* Make sure the compiler warns if a new TARGET_WAITKIND enumerator is added
+ /* Make sure the compiler warns if a new TARGET_WAITKIND enumerator is added
but not handled here. */
-DIAGNOSTIC_PUSH
-DIAGNOSTIC_ERROR_SWITCH
+ DIAGNOSTIC_PUSH
+ DIAGNOSTIC_ERROR_SWITCH
switch (this->kind ())
{
case TARGET_WAITKIND_EXITED:
@@ -63,7 +63,7 @@ DIAGNOSTIC_ERROR_SWITCH
case TARGET_WAITKIND_THREAD_CREATED:
return str;
}
-DIAGNOSTIC_POP
+ DIAGNOSTIC_POP
gdb_assert_not_reached ("invalid target_waitkind value: %d",
(int) this->kind ());
diff --git a/gdb/target/waitstatus.h b/gdb/target/waitstatus.h
index 0a88b86..0fa9e16 100644
--- a/gdb/target/waitstatus.h
+++ b/gdb/target/waitstatus.h
@@ -47,15 +47,15 @@ enum target_waitkind
value.related_pid. I.e., if the child forks, value.related_pid
is the parent's ID. */
TARGET_WAITKIND_FORKED,
-
+
/* The program has vforked. A "related" process's PTID is in
value.related_pid. */
TARGET_WAITKIND_VFORKED,
-
+
/* The program has exec'ed a new executable file. The new file's
pathname is pointed to by value.execd_pathname. */
TARGET_WAITKIND_EXECD,
-
+
/* The program had previously vforked, and now the child is done
with the shared memory region, because it exec'ed or exited.
Note that the event is reported to the vfork parent. This is
@@ -87,11 +87,11 @@ enum target_waitkind
function. This way the event loop is responsive to other events,
like for instance the user typing. */
TARGET_WAITKIND_IGNORE,
-
+
/* The target has run out of history information,
and cannot run backward any further. */
TARGET_WAITKIND_NO_HISTORY,
-
+
/* There are no resumed children left in the program. */
TARGET_WAITKIND_NO_RESUMED,
@@ -107,12 +107,12 @@ enum target_waitkind
static inline const char *
target_waitkind_str (target_waitkind kind)
{
-/* Make sure the compiler warns if a new TARGET_WAITKIND enumerator is added
+ /* Make sure the compiler warns if a new TARGET_WAITKIND enumerator is added
but not handled here. */
-DIAGNOSTIC_PUSH
-DIAGNOSTIC_ERROR_SWITCH
+ DIAGNOSTIC_PUSH
+ DIAGNOSTIC_ERROR_SWITCH
switch (kind)
- {
+ {
case TARGET_WAITKIND_EXITED:
return "EXITED";
case TARGET_WAITKIND_STOPPED:
@@ -145,8 +145,8 @@ DIAGNOSTIC_ERROR_SWITCH
return "THREAD_CREATED";
case TARGET_WAITKIND_THREAD_EXITED:
return "THREAD_EXITED";
- };
-DIAGNOSTIC_POP
+ };
+ DIAGNOSTIC_POP
gdb_assert_not_reached ("invalid target_waitkind value: %d\n", (int) kind);
}
@@ -212,10 +212,7 @@ struct target_waitstatus
/* Destructor. */
- ~target_waitstatus ()
- {
- this->reset ();
- }
+ ~target_waitstatus () { this->reset (); }
/* Setters: set the wait status kind plus any associated data. */
@@ -342,10 +339,7 @@ struct target_waitstatus
/* Get the kind of this wait status. */
- target_waitkind kind () const
- {
- return m_kind;
- }
+ target_waitkind kind () const { return m_kind; }
/* Getters for the associated data.
@@ -394,6 +388,7 @@ struct target_waitstatus
std::string to_string () const;
private:
+
/* Reset the wait status to its original state. */
void reset ()
{
@@ -407,18 +402,18 @@ private:
/* Additional information about the event. */
union
- {
- /* Exit status */
- int exit_status;
- /* Signal number */
- enum gdb_signal sig;
- /* Forked child pid */
- ptid_t child_ptid;
- /* execd pathname */
- char *execd_pathname;
- /* Syscall number */
- int syscall_number;
- } m_value {};
+ {
+ /* Exit status */
+ int exit_status;
+ /* Signal number */
+ enum gdb_signal sig;
+ /* Forked child pid */
+ ptid_t child_ptid;
+ /* execd pathname */
+ char *execd_pathname;
+ /* Syscall number */
+ int syscall_number;
+ } m_value {};
};
/* Extended reasons that can explain why a target/thread stopped for a