diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:36:23 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:46:02 -0500 |
commit | c583a2520616c2736cffc389c89a48b159366e6c (patch) | |
tree | b4925f26506fcee96c16119431c01760f05db95d /gdb/inf-ptrace.c | |
parent | ca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff) | |
download | binutils-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/inf-ptrace.c')
-rw-r--r-- | gdb/inf-ptrace.c | 71 |
1 files changed, 32 insertions, 39 deletions
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index a335165..8864bdf 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -34,8 +34,6 @@ #include "utils.h" #include "gdbarch.h" - - static PTRACE_TYPE_RET gdb_ptrace (PTRACE_TYPE_ARG1 request, ptid_t ptid, PTRACE_TYPE_ARG3 addr, PTRACE_TYPE_ARG4 data) @@ -51,10 +49,7 @@ gdb_ptrace (PTRACE_TYPE_ARG1 request, ptid_t ptid, PTRACE_TYPE_ARG3 addr, /* The event pipe registered as a waitable file in the event loop. */ event_pipe inf_ptrace_target::m_event_pipe; -inf_ptrace_target::~inf_ptrace_target () -{} - - +inf_ptrace_target::~inf_ptrace_target () {} /* Prepare to be traced. */ @@ -73,8 +68,8 @@ inf_ptrace_me (void) void inf_ptrace_target::create_inferior (const char *exec_file, - const std::string &allargs, - char **env, int from_tty) + const std::string &allargs, char **env, + int from_tty) { inferior *inf = current_inferior (); @@ -83,7 +78,7 @@ inf_ptrace_target::create_inferior (const char *exec_file, int ops_already_pushed = inf->target_is_pushed (this); target_unpush_up unpusher; - if (! ops_already_pushed) + if (!ops_already_pushed) { /* Clear possible core file with its process_stratum. */ inf->push_target (this); @@ -139,11 +134,11 @@ inf_ptrace_target::attach (const char *args, int from_tty) pid_t pid = parse_pid_to_attach (args); - if (pid == getpid ()) /* Trying to masturbate? */ - error (_("I refuse to debug myself!")); + if (pid == getpid ()) /* Trying to masturbate? */ + error (_ ("I refuse to debug myself!")); target_unpush_up unpusher; - if (! ops_already_pushed) + if (!ops_already_pushed) { /* target_pid_to_str already uses the target. Also clear possible core file with its process_stratum. */ @@ -155,11 +150,11 @@ inf_ptrace_target::attach (const char *args, int from_tty) #ifdef PT_ATTACH errno = 0; - ptrace (PT_ATTACH, pid, (PTRACE_TYPE_ARG3)0, 0); + ptrace (PT_ATTACH, pid, (PTRACE_TYPE_ARG3) 0, 0); if (errno != 0) perror_with_name (("ptrace")); #else - error (_("This system does not support attaching to a process")); + error (_ ("This system does not support attaching to a process")); #endif inferior_appeared (inf, pid); @@ -192,11 +187,11 @@ inf_ptrace_target::detach (inferior *inf, int from_tty) previously attached to the inferior. It *might* work if we started the process ourselves. */ errno = 0; - ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3)1, 0); + ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3) 1, 0); if (errno != 0) perror_with_name (("ptrace")); #else - error (_("This system does not support detaching from a process")); + error (_ ("This system does not support detaching from a process")); #endif detach_success (inf); @@ -224,7 +219,7 @@ inf_ptrace_target::kill () if (pid == 0) return; - ptrace (PT_KILL, pid, (PTRACE_TYPE_ARG3)0, 0); + ptrace (PT_KILL, pid, (PTRACE_TYPE_ARG3) 0, 0); waitpid (pid, &status, 0); target_mourn_inferior (inferior_ptid); @@ -281,7 +276,8 @@ inf_ptrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal) where it was. If GDB wanted it to start some other way, we have already written a new program counter value to the child. */ errno = 0; - gdb_ptrace (request, ptid, (PTRACE_TYPE_ARG3)1, gdb_signal_to_host (signal)); + gdb_ptrace (request, ptid, (PTRACE_TYPE_ARG3) 1, + gdb_signal_to_host (signal)); if (errno != 0) perror_with_name (("ptrace")); } @@ -334,7 +330,7 @@ inf_ptrace_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, } gdb_printf (gdb_stderr, - _("Child process unexpectedly missing: %s.\n"), + _ ("Child process unexpectedly missing: %s.\n"), safe_strerror (save_errno)); ourstatus->set_ignore (); @@ -358,8 +354,7 @@ inf_ptrace_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, be non-null. Return the number of transferred bytes. */ static ULONGEST -inf_ptrace_peek_poke (ptid_t ptid, gdb_byte *readbuf, - const gdb_byte *writebuf, +inf_ptrace_peek_poke (ptid_t ptid, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST addr, ULONGEST len) { ULONGEST n; @@ -371,9 +366,7 @@ inf_ptrace_peek_poke (ptid_t ptid, gdb_byte *readbuf, ULONGEST skip = addr & (sizeof (PTRACE_TYPE_RET) - 1); addr -= skip; - for (n = 0; - n < len; - n += chunk, addr += sizeof (PTRACE_TYPE_RET), skip = 0) + for (n = 0; n < len; n += chunk, addr += sizeof (PTRACE_TYPE_RET), skip = 0) { /* Restrict to a chunk that fits in the current word. */ chunk = std::min (sizeof (PTRACE_TYPE_RET) - skip, len - n); @@ -390,7 +383,7 @@ inf_ptrace_peek_poke (ptid_t ptid, gdb_byte *readbuf, { errno = 0; buf.word = gdb_ptrace (PT_READ_I, ptid, - (PTRACE_TYPE_ARG3)(uintptr_t) addr, 0); + (PTRACE_TYPE_ARG3) (uintptr_t) addr, 0); if (errno != 0) break; if (readbuf != NULL) @@ -400,15 +393,15 @@ inf_ptrace_peek_poke (ptid_t ptid, gdb_byte *readbuf, { memcpy (buf.byte + skip, writebuf + n, chunk); errno = 0; - gdb_ptrace (PT_WRITE_D, ptid, (PTRACE_TYPE_ARG3)(uintptr_t) addr, - buf.word); + gdb_ptrace (PT_WRITE_D, ptid, (PTRACE_TYPE_ARG3) (uintptr_t) addr, + buf.word); if (errno != 0) { /* Using the appropriate one (I or D) is necessary for Gould NP1, at least. */ errno = 0; - gdb_ptrace (PT_WRITE_I, ptid, (PTRACE_TYPE_ARG3)(uintptr_t) addr, - buf.word); + gdb_ptrace (PT_WRITE_I, ptid, + (PTRACE_TYPE_ARG3) (uintptr_t) addr, buf.word); if (errno != 0) break; } @@ -421,10 +414,10 @@ inf_ptrace_peek_poke (ptid_t ptid, gdb_byte *readbuf, /* Implement the to_xfer_partial target_ops method. */ enum target_xfer_status -inf_ptrace_target::xfer_partial (enum target_object object, - const char *annex, gdb_byte *readbuf, - const gdb_byte *writebuf, - ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) +inf_ptrace_target::xfer_partial (enum target_object object, const char *annex, + gdb_byte *readbuf, const gdb_byte *writebuf, + ULONGEST offset, ULONGEST len, + ULONGEST *xfered_len) { ptid_t ptid = inferior_ptid; @@ -450,7 +443,7 @@ inf_ptrace_target::xfer_partial (enum target_object object, piod.piod_len = len; errno = 0; - if (gdb_ptrace (PT_IO, ptid, (caddr_t)&piod, 0) == 0) + if (gdb_ptrace (PT_IO, ptid, (caddr_t) &piod, 0) == 0) { /* Return the actual number of bytes read or written. */ *xfered_len = piod.piod_len; @@ -463,15 +456,15 @@ inf_ptrace_target::xfer_partial (enum target_object object, return TARGET_XFER_EOF; } #endif - *xfered_len = inf_ptrace_peek_poke (ptid, readbuf, writebuf, - offset, len); + *xfered_len + = inf_ptrace_peek_poke (ptid, readbuf, writebuf, offset, len); return *xfered_len != 0 ? TARGET_XFER_OK : TARGET_XFER_EOF; case TARGET_OBJECT_UNWIND_TABLE: return TARGET_XFER_E_IO; case TARGET_OBJECT_AUXV: -#if defined (PT_IO) && defined (PIOD_READ_AUXV) +#if defined(PT_IO) && defined(PIOD_READ_AUXV) /* OpenBSD 4.5 has a new PIOD_READ_AUXV operation for the PT_IO request that allows us to read the auxilliary vector. Other BSD's may follow if they feel the need to support PIE. */ @@ -486,7 +479,7 @@ inf_ptrace_target::xfer_partial (enum target_object object, piod.piod_len = len; errno = 0; - if (gdb_ptrace (PT_IO, ptid, (caddr_t)&piod, 0) == 0) + if (gdb_ptrace (PT_IO, ptid, (caddr_t) &piod, 0) == 0) { /* Return the actual number of bytes read or written. */ *xfered_len = piod.piod_len; @@ -520,7 +513,7 @@ inf_ptrace_target::files_info () { struct inferior *inf = current_inferior (); - gdb_printf (_("\tUsing the running image of %s %s.\n"), + gdb_printf (_ ("\tUsing the running image of %s %s.\n"), inf->attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid).c_str ()); } |