diff options
Diffstat (limited to 'lldb/source/Host/common')
| -rw-r--r-- | lldb/source/Host/common/Editline.cpp | 118 | ||||
| -rw-r--r-- | lldb/source/Host/common/File.cpp | 8 | ||||
| -rw-r--r-- | lldb/source/Host/common/Host.cpp | 20 | ||||
| -rw-r--r-- | lldb/source/Host/common/HostInfoBase.cpp | 18 | ||||
| -rw-r--r-- | lldb/source/Host/common/MainLoop.cpp | 13 | ||||
| -rw-r--r-- | lldb/source/Host/common/NativeBreakpointList.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Host/common/NativeProcessProtocol.cpp | 72 | ||||
| -rw-r--r-- | lldb/source/Host/common/NativeRegisterContext.cpp | 14 | ||||
| -rw-r--r-- | lldb/source/Host/common/PseudoTerminal.cpp | 101 | ||||
| -rw-r--r-- | lldb/source/Host/common/Socket.cpp | 24 | ||||
| -rw-r--r-- | lldb/source/Host/common/SoftwareBreakpoint.cpp | 17 | ||||
| -rw-r--r-- | lldb/source/Host/common/Symbols.cpp | 24 | ||||
| -rw-r--r-- | lldb/source/Host/common/TaskPool.cpp | 9 | ||||
| -rw-r--r-- | lldb/source/Host/common/Terminal.cpp | 25 | ||||
| -rw-r--r-- | lldb/source/Host/common/UDPSocket.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Host/common/XML.cpp | 4 |
16 files changed, 223 insertions, 252 deletions
diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index 7b580dde656..329c0c1f3b7 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/source/Host/common/Editline.cpp @@ -33,8 +33,8 @@ using namespace lldb_private::line_editor; // doesn't explicitly initialize the curses termcap library, which it gets away // with until TERM is set to VT100 where it stumbles over an implementation // assumption that may not exist on other platforms. The setupterm() function -// would normally require headers that don't work gracefully in this context, so -// the function declaraction has been hoisted here. +// would normally require headers that don't work gracefully in this context, +// so the function declaraction has been hoisted here. #if defined(__APPLE__) extern "C" { int setupterm(char *term, int fildes, int *errret); @@ -43,12 +43,10 @@ int setupterm(char *term, int fildes, int *errret); #endif // Editline uses careful cursor management to achieve the illusion of editing a -// multi-line block of text -// with a single line editor. Preserving this illusion requires fairly careful -// management of cursor -// state. Read and understand the relationship between DisplayInput(), -// MoveCursor(), SetCurrentLine(), -// and SaveEditedLine() before making changes. +// multi-line block of text with a single line editor. Preserving this +// illusion requires fairly careful management of cursor state. Read and +// understand the relationship between DisplayInput(), MoveCursor(), +// SetCurrentLine(), and SaveEditedLine() before making changes. #define ESCAPE "\x1b" #define ANSI_FAINT ESCAPE "[2m" @@ -70,8 +68,7 @@ int setupterm(char *term, int fildes, int *errret); #define EditLineStringFormatSpec "%s" // use #defines so wide version functions and structs will resolve to old -// versions -// for case of libedit not built with wide char support +// versions for case of libedit not built with wide char support #define history_w history #define history_winit history_init #define history_wend history_end @@ -145,10 +142,8 @@ bool IsInputPending(FILE *file) { // FIXME: This will be broken on Windows if we ever re-enable Editline. You // can't use select // on something that isn't a socket. This will have to be re-written to not - // use a FILE*, but - // instead use some kind of yet-to-be-created abstraction that select-like - // functionality on - // non-socket objects. + // use a FILE*, but instead use some kind of yet-to-be-created abstraction + // that select-like functionality on non-socket objects. const int fd = fileno(file); SelectHelper select_helper; select_helper.SetTimeout(std::chrono::microseconds(0)); @@ -160,13 +155,13 @@ namespace lldb_private { namespace line_editor { typedef std::weak_ptr<EditlineHistory> EditlineHistoryWP; -// EditlineHistory objects are sometimes shared between multiple -// Editline instances with the same program name. +// EditlineHistory objects are sometimes shared between multiple Editline +// instances with the same program name. class EditlineHistory { private: - // Use static GetHistory() function to get a EditlineHistorySP to one of these - // objects + // Use static GetHistory() function to get a EditlineHistorySP to one of + // these objects EditlineHistory(const std::string &prefix, uint32_t size, bool unique_entries) : m_history(NULL), m_event(), m_prefix(prefix), m_path() { m_history = history_winit(); @@ -436,11 +431,10 @@ unsigned char Editline::RecallHistory(bool earlier) { if (history_w(pHistory, &history_event, H_FIRST) == -1) return CC_ERROR; - // Save any edits to the "live" entry in case we return by moving forward in - // history - // (it would be more bash-like to save over any current entry, but libedit - // doesn't - // offer the ability to add entries anywhere except the end.) + // Save any edits to the "live" entry in case we return by moving forward + // in history (it would be more bash-like to save over any current entry, + // but libedit doesn't offer the ability to add entries anywhere except the + // end.) SaveEditedLine(); m_live_history_lines = m_input_lines; m_in_history = true; @@ -466,8 +460,7 @@ unsigned char Editline::RecallHistory(bool earlier) { DisplayInput(); // Prepare to edit the last line when moving to previous entry, or the first - // line - // when moving to next entry + // line when moving to next entry SetCurrentLine(m_current_line_index = earlier ? (int)m_input_lines.size() - 1 : 0); MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt); @@ -490,8 +483,8 @@ int Editline::GetCharacter(EditLineGetCharType *c) { } if (m_multiline_enabled) { - // Detect when the number of rows used for this input line changes due to an - // edit + // Detect when the number of rows used for this input line changes due to + // an edit int lineLength = (int)((info->lastchar - info->buffer) + GetPromptWidth()); int new_line_rows = (lineLength / m_terminal_width) + 1; if (m_current_line_rows != -1 && new_line_rows != m_current_line_rows) { @@ -510,12 +503,10 @@ int Editline::GetCharacter(EditLineGetCharType *c) { char ch = 0; // This mutex is locked by our caller (GetLine). Unlock it while we read a - // character - // (blocking operation), so we do not hold the mutex indefinitely. This - // gives a chance - // for someone to interrupt us. After Read returns, immediately lock the - // mutex again and - // check if we were interrupted. + // character (blocking operation), so we do not hold the mutex + // indefinitely. This gives a chance for someone to interrupt us. After + // Read returns, immediately lock the mutex again and check if we were + // interrupted. m_output_mutex.unlock(); int read_count = m_input_connection.Read(&ch, 1, llvm::None, status, NULL); m_output_mutex.lock(); @@ -614,7 +605,8 @@ unsigned char Editline::EndOrAddLineCommand(int ch) { // Save any edits to this line SaveEditedLine(); - // If this is the end of the last line, consider whether to add a line instead + // If this is the end of the last line, consider whether to add a line + // instead const LineInfoW *info = el_wline(m_editline); if (m_current_line_index == m_input_lines.size() - 1 && info->cursor == info->lastchar) { @@ -653,8 +645,8 @@ unsigned char Editline::DeleteNextCharCommand(int ch) { return CC_REFRESH; } - // Fail when at the end of the last line, except when ^D is pressed on - // the line is empty, in which case it is treated as EOF + // Fail when at the end of the last line, except when ^D is pressed on the + // line is empty, in which case it is treated as EOF if (m_current_line_index == m_input_lines.size() - 1) { if (ch == 4 && info->buffer == info->lastchar) { fprintf(m_output_file, "^D\n"); @@ -685,7 +677,8 @@ unsigned char Editline::DeleteNextCharCommand(int ch) { unsigned char Editline::DeletePreviousCharCommand(int ch) { LineInfoW *info = const_cast<LineInfoW *>(el_wline(m_editline)); - // Just delete the previous character normally when not at the start of a line + // Just delete the previous character normally when not at the start of a + // line if (info->cursor > info->buffer) { el_deletestr(m_editline, 1); return CC_REFRESH; @@ -709,8 +702,7 @@ unsigned char Editline::DeletePreviousCharCommand(int ch) { DisplayInput(m_current_line_index); // Put the cursor back where libedit expects it to be before returning to - // editing - // by telling libedit about the newly inserted text + // editing by telling libedit about the newly inserted text MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt); el_winsertstr(m_editline, priorLine.c_str()); return CC_REDISPLAY; @@ -762,7 +754,8 @@ unsigned char Editline::NextLineCommand(int ch) { EditLineStringType(indentation, EditLineCharType(' '))); } - // Move down past the current line using newlines to force scrolling if needed + // Move down past the current line using newlines to force scrolling if + // needed SetCurrentLine(m_current_line_index + 1); const LineInfoW *info = el_wline(m_editline); int cursor_position = (int)((info->cursor - info->buffer) + GetPromptWidth()); @@ -824,8 +817,7 @@ unsigned char Editline::FixIndentationCommand(int ch) { DisplayInput(m_current_line_index); // Reposition the cursor back on the original line and prepare to restart - // editing - // with a new cursor position + // editing with a new cursor position SetCurrentLine(m_current_line_index); MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt); m_revert_cursor_index = cursor_position + indent_correction; @@ -945,9 +937,9 @@ void Editline::ConfigureEditor(bool multiline) { m_multiline_enabled = multiline; if (m_editline) { - // Disable edit mode to stop the terminal from flushing all input - // during the call to el_end() since we expect to have multiple editline - // instances in this program. + // Disable edit mode to stop the terminal from flushing all input during + // the call to el_end() since we expect to have multiple editline instances + // in this program. el_set(m_editline, EL_EDITMODE, 0); el_end(m_editline); } @@ -973,7 +965,8 @@ void Editline::ConfigureEditor(bool multiline) { return Editline::InstanceFor(editline)->GetCharacter(c); })); - // Commands used for multiline support, registered whether or not they're used + // Commands used for multiline support, registered whether or not they're + // used el_wset(m_editline, EL_ADDFN, EditLineConstString("lldb-break-line"), EditLineConstString("Insert a line break"), (EditlineCommandCallbackType)([](EditLine *editline, int ch) { @@ -1031,13 +1024,11 @@ void Editline::ConfigureEditor(bool multiline) { return Editline::InstanceFor(editline)->FixIndentationCommand(ch); })); - // Register the complete callback under two names for compatibility with older - // clients using - // custom .editrc files (largely because libedit has a bad bug where if you - // have a bind command - // that tries to bind to a function name that doesn't exist, it can corrupt - // the heap and - // crash your process later.) + // Register the complete callback under two names for compatibility with + // older clients using custom .editrc files (largely because libedit has a + // bad bug where if you have a bind command that tries to bind to a function + // name that doesn't exist, it can corrupt the heap and crash your process + // later.) EditlineCommandCallbackType complete_callback = [](EditLine *editline, int ch) { return Editline::InstanceFor(editline)->TabCommand(ch); @@ -1118,8 +1109,7 @@ void Editline::ConfigureEditor(bool multiline) { NULL); // Escape is absorbed exiting edit mode, so re-register important - // sequences - // without the prefix + // sequences without the prefix el_set(m_editline, EL_BIND, "-a", "[A", "lldb-previous-line", NULL); el_set(m_editline, EL_BIND, "-a", "[B", "lldb-next-line", NULL); el_set(m_editline, EL_BIND, "-a", "[\\^", "lldb-revert-line", NULL); @@ -1176,18 +1166,18 @@ Editline::Editline(const char *editline_name, FILE *input_file, Editline::~Editline() { if (m_editline) { - // Disable edit mode to stop the terminal from flushing all input - // during the call to el_end() since we expect to have multiple editline - // instances in this program. + // Disable edit mode to stop the terminal from flushing all input during + // the call to el_end() since we expect to have multiple editline instances + // in this program. el_set(m_editline, EL_EDITMODE, 0); el_end(m_editline); m_editline = nullptr; } - // EditlineHistory objects are sometimes shared between multiple - // Editline instances with the same program name. So just release - // our shared pointer and if we are the last owner, it will save the - // history to the history save file automatically. + // EditlineHistory objects are sometimes shared between multiple Editline + // instances with the same program name. So just release our shared pointer + // and if we are the last owner, it will save the history to the history save + // file automatically. m_history_sp.reset(); } @@ -1313,8 +1303,8 @@ bool Editline::GetLines(int first_line_number, StringList &lines, bool &interrupted) { ConfigureEditor(true); - // Print the initial input lines, then move the cursor back up to the start of - // input + // Print the initial input lines, then move the cursor back up to the start + // of input SetBaseLineNumber(first_line_number); m_input_lines = std::vector<EditLineStringType>(); m_input_lines.insert(m_input_lines.begin(), EditLineConstString("")); diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index 22b42c6f1c7..52fe6764699 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -126,8 +126,8 @@ FILE *File::GetStream() { const char *mode = GetStreamOpenModeFromOptions(m_options); if (mode) { if (!m_should_close_fd) { -// We must duplicate the file descriptor if we don't own it because -// when you call fdopen, the stream will own the fd +// We must duplicate the file descriptor if we don't own it because when you +// call fdopen, the stream will own the fd #ifdef _WIN32 m_descriptor = ::_dup(GetDescriptor()); #else @@ -139,8 +139,8 @@ FILE *File::GetStream() { m_stream = llvm::sys::RetryAfterSignal(nullptr, ::fdopen, m_descriptor, mode); - // If we got a stream, then we own the stream and should no - // longer own the descriptor because fclose() will close it for us + // If we got a stream, then we own the stream and should no longer own + // the descriptor because fclose() will close it for us if (m_stream) { m_own_stream = true; diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index 16dc80a5768..ac4593484f3 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -119,9 +119,8 @@ HostThread Host::StartMonitoringChildProcess( #ifndef __linux__ //------------------------------------------------------------------ -// Scoped class that will disable thread canceling when it is -// constructed, and exception safely restore the previous value it -// when it goes out of scope. +// Scoped class that will disable thread canceling when it is constructed, and +// exception safely restore the previous value it when it goes out of scope. //------------------------------------------------------------------ class ScopedPThreadCancelDisabler { public: @@ -270,8 +269,7 @@ static thread_result_t MonitorChildProcessThreadFunction(void *arg) { __FUNCTION__, arg); break; } - // If the callback returns true, it means this process should - // exit + // If the callback returns true, it means this process should exit if (callback_return) { if (log) log->Printf("%s (arg = %p) thread exiting because callback " @@ -497,9 +495,9 @@ Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir, llvm::SmallString<PATH_MAX> output_file_path; if (command_output_ptr) { - // Create a temporary file to get the stdout/stderr and redirect the - // output of the command into this file. We will later read this file - // if all goes well and fill the data into "command_output_ptr" + // Create a temporary file to get the stdout/stderr and redirect the output + // of the command into this file. We will later read this file if all goes + // well and fill the data into "command_output_ptr" FileSpec tmpdir_file_spec; if (HostInfo::GetLLDBPath(ePathTypeLLDBTempSystemDir, tmpdir_file_spec)) { tmpdir_file_spec.AppendPathComponent("lldb-shell-output.%%%%%%"); @@ -580,7 +578,8 @@ Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir, return error; } -// The functions below implement process launching for non-Apple-based platforms +// The functions below implement process launching for non-Apple-based +// platforms #if !defined(__APPLE__) Status Host::LaunchProcess(ProcessLaunchInfo &launch_info) { std::unique_ptr<ProcessLauncher> delegate_launcher; @@ -595,8 +594,7 @@ Status Host::LaunchProcess(ProcessLaunchInfo &launch_info) { HostProcess process = launcher.LaunchProcess(launch_info, error); // TODO(zturner): It would be better if the entire HostProcess were returned - // instead of writing - // it into this structure. + // instead of writing it into this structure. launch_info.SetProcessID(process.GetProcessId()); return error; diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp index cb00db70ee3..d905491b7a7 100644 --- a/lldb/source/Host/common/HostInfoBase.cpp +++ b/lldb/source/Host/common/HostInfoBase.cpp @@ -33,19 +33,19 @@ using namespace lldb_private; namespace { //---------------------------------------------------------------------- -// The HostInfoBaseFields is a work around for windows not supporting -// static variables correctly in a thread safe way. Really each of the -// variables in HostInfoBaseFields should live in the functions in which -// they are used and each one should be static, but the work around is -// in place to avoid this restriction. Ick. +// The HostInfoBaseFields is a work around for windows not supporting static +// variables correctly in a thread safe way. Really each of the variables in +// HostInfoBaseFields should live in the functions in which they are used and +// each one should be static, but the work around is in place to avoid this +// restriction. Ick. //---------------------------------------------------------------------- struct HostInfoBaseFields { ~HostInfoBaseFields() { if (m_lldb_process_tmp_dir.Exists()) { // Remove the LLDB temporary directory if we have one. Set "recurse" to - // true to all files that were created for the LLDB process can be cleaned - // up. + // true to all files that were created for the LLDB process can be + // cleaned up. llvm::sys::fs::remove_directories(m_lldb_process_tmp_dir.GetPath()); } } @@ -354,8 +354,8 @@ bool HostInfoBase::ComputeSystemPluginsDirectory(FileSpec &file_spec) { bool HostInfoBase::ComputeClangDirectory(FileSpec &file_spec) { return false; } bool HostInfoBase::ComputeUserPluginsDirectory(FileSpec &file_spec) { - // TODO(zturner): Figure out how to compute the user plugins directory for all - // platforms. + // TODO(zturner): Figure out how to compute the user plugins directory for + // all platforms. return false; } diff --git a/lldb/source/Host/common/MainLoop.cpp b/lldb/source/Host/common/MainLoop.cpp index 2e101c061e8..65158c94293 100644 --- a/lldb/source/Host/common/MainLoop.cpp +++ b/lldb/source/Host/common/MainLoop.cpp @@ -209,8 +209,8 @@ Status MainLoop::RunImpl::Poll() { void MainLoop::RunImpl::ProcessEvents() { #ifdef __ANDROID__ - // Collect first all readable file descriptors into a separate vector and then - // iterate over it to invoke callbacks. Iterating directly over + // Collect first all readable file descriptors into a separate vector and + // then iterate over it to invoke callbacks. Iterating directly over // loop.m_read_fds is not possible because the callbacks can modify the // container which could invalidate the iterator. std::vector<IOObject::WaitableHandle> fds; @@ -285,8 +285,7 @@ MainLoop::ReadHandleUP MainLoop::RegisterReadObject(const IOObjectSP &object_sp, } // We shall block the signal, then install the signal handler. The signal will -// be unblocked in -// the Run() function to check for signal delivery. +// be unblocked in the Run() function to check for signal delivery. MainLoop::SignalHandleUP MainLoop::RegisterSignal(int signo, const Callback &callback, Status &error) { #ifdef SIGNAL_POLLING_UNSUPPORTED @@ -321,9 +320,9 @@ MainLoop::RegisterSignal(int signo, const Callback &callback, Status &error) { assert(ret == 0); #endif - // If we're using kqueue, the signal needs to be unblocked in order to recieve - // it. If using pselect/ppoll, we need to block it, and later unblock it as a - // part of the system call. + // If we're using kqueue, the signal needs to be unblocked in order to + // recieve it. If using pselect/ppoll, we need to block it, and later unblock + // it as a part of the system call. ret = pthread_sigmask(HAVE_SYS_EVENT_H ? SIG_UNBLOCK : SIG_BLOCK, &new_action.sa_mask, &old_set); assert(ret == 0 && "pthread_sigmask failed"); diff --git a/lldb/source/Host/common/NativeBreakpointList.cpp b/lldb/source/Host/common/NativeBreakpointList.cpp index ce5eb94a8d1..cfcbe083106 100644 --- a/lldb/source/Host/common/NativeBreakpointList.cpp +++ b/lldb/source/Host/common/NativeBreakpointList.cpp @@ -104,8 +104,8 @@ Status NativeBreakpointList::DecRef(lldb::addr_t addr) { return error; } - // Breakpoint has no more references. Disable it if it's not - // already disabled. + // Breakpoint has no more references. Disable it if it's not already + // disabled. if (log) log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- removing due to no remaining references", diff --git a/lldb/source/Host/common/NativeProcessProtocol.cpp b/lldb/source/Host/common/NativeProcessProtocol.cpp index 7367ea7c436..cc998e6da9f 100644 --- a/lldb/source/Host/common/NativeProcessProtocol.cpp +++ b/lldb/source/Host/common/NativeProcessProtocol.cpp @@ -137,29 +137,28 @@ NativeProcessProtocol::GetHardwareDebugSupportInfo() const { Status NativeProcessProtocol::SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) { - // This default implementation assumes setting the watchpoint for - // the process will require setting the watchpoint for each of the - // threads. Furthermore, it will track watchpoints set for the - // process and will add them to each thread that is attached to - // via the (FIXME implement) OnThreadAttached () method. + // This default implementation assumes setting the watchpoint for the process + // will require setting the watchpoint for each of the threads. Furthermore, + // it will track watchpoints set for the process and will add them to each + // thread that is attached to via the (FIXME implement) OnThreadAttached () + // method. Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); // Update the thread list UpdateThreads(); - // Keep track of the threads we successfully set the watchpoint - // for. If one of the thread watchpoint setting operations fails, - // back off and remove the watchpoint for all the threads that - // were successfully set so we get back to a consistent state. + // Keep track of the threads we successfully set the watchpoint for. If one + // of the thread watchpoint setting operations fails, back off and remove the + // watchpoint for all the threads that were successfully set so we get back + // to a consistent state. std::vector<NativeThreadProtocol *> watchpoint_established_threads; - // Tell each thread to set a watchpoint. In the event that - // hardware watchpoints are requested but the SetWatchpoint fails, - // try to set a software watchpoint as a fallback. It's - // conceivable that if there are more threads than hardware - // watchpoints available, some of the threads will fail to set - // hardware watchpoints while software ones may be available. + // Tell each thread to set a watchpoint. In the event that hardware + // watchpoints are requested but the SetWatchpoint fails, try to set a + // software watchpoint as a fallback. It's conceivable that if there are + // more threads than hardware watchpoints available, some of the threads will + // fail to set hardware watchpoints while software ones may be available. std::lock_guard<std::recursive_mutex> guard(m_threads_mutex); for (const auto &thread : m_threads) { assert(thread && "thread list should not have a NULL thread!"); @@ -167,8 +166,8 @@ Status NativeProcessProtocol::SetWatchpoint(lldb::addr_t addr, size_t size, Status thread_error = thread->SetWatchpoint(addr, size, watch_flags, hardware); if (thread_error.Fail() && hardware) { - // Try software watchpoints since we failed on hardware watchpoint setting - // and we may have just run out of hardware watchpoints. + // Try software watchpoints since we failed on hardware watchpoint + // setting and we may have just run out of hardware watchpoints. thread_error = thread->SetWatchpoint(addr, size, watch_flags, false); if (thread_error.Success()) LLDB_LOG(log, @@ -176,13 +175,12 @@ Status NativeProcessProtocol::SetWatchpoint(lldb::addr_t addr, size_t size, } if (thread_error.Success()) { - // Remember that we set this watchpoint successfully in - // case we need to clear it later. + // Remember that we set this watchpoint successfully in case we need to + // clear it later. watchpoint_established_threads.push_back(thread.get()); } else { - // Unset the watchpoint for each thread we successfully - // set so that we get back to a consistent state of "not - // set" for the watchpoint. + // Unset the watchpoint for each thread we successfully set so that we + // get back to a consistent state of "not set" for the watchpoint. for (auto unwatch_thread_sp : watchpoint_established_threads) { Status remove_error = unwatch_thread_sp->RemoveWatchpoint(addr); if (remove_error.Fail()) @@ -208,9 +206,9 @@ Status NativeProcessProtocol::RemoveWatchpoint(lldb::addr_t addr) { const Status thread_error = thread->RemoveWatchpoint(addr); if (thread_error.Fail()) { - // Keep track of the first thread error if any threads - // fail. We want to try to remove the watchpoint from - // every thread, though, even if one or more have errors. + // Keep track of the first thread error if any threads fail. We want to + // try to remove the watchpoint from every thread, though, even if one or + // more have errors. if (!overall_error.Fail()) overall_error = thread_error; } @@ -226,9 +224,9 @@ NativeProcessProtocol::GetHardwareBreakpointMap() const { Status NativeProcessProtocol::SetHardwareBreakpoint(lldb::addr_t addr, size_t size) { - // This default implementation assumes setting a hardware breakpoint for - // this process will require setting same hardware breakpoint for each - // of its existing threads. New thread will do the same once created. + // This default implementation assumes setting a hardware breakpoint for this + // process will require setting same hardware breakpoint for each of its + // existing threads. New thread will do the same once created. Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); // Update the thread list @@ -254,13 +252,13 @@ Status NativeProcessProtocol::SetHardwareBreakpoint(lldb::addr_t addr, Status thread_error = thread->SetHardwareBreakpoint(addr, size); if (thread_error.Success()) { - // Remember that we set this breakpoint successfully in - // case we need to clear it later. + // Remember that we set this breakpoint successfully in case we need to + // clear it later. breakpoint_established_threads.push_back(thread.get()); } else { - // Unset the breakpoint for each thread we successfully - // set so that we get back to a consistent state of "not - // set" for this hardware breakpoint. + // Unset the breakpoint for each thread we successfully set so that we + // get back to a consistent state of "not set" for this hardware + // breakpoint. for (auto rollback_thread_sp : breakpoint_established_threads) { Status remove_error = rollback_thread_sp->RemoveHardwareBreakpoint(addr); @@ -320,8 +318,8 @@ bool NativeProcessProtocol::UnregisterNativeDelegate( remove(m_delegates.begin(), m_delegates.end(), &native_delegate), m_delegates.end()); - // We removed the delegate if the count of delegates shrank after - // removing all copies of the given native_delegate from the vector. + // We removed the delegate if the count of delegates shrank after removing + // all copies of the given native_delegate from the vector. return m_delegates.size() < initial_size; } @@ -410,8 +408,8 @@ void NativeProcessProtocol::SetState(lldb::StateType state, // Give process a chance to do any stop id bump processing, such as // clearing cached data that is invalidated each time the process runs. - // Note if/when we support some threads running, we'll end up needing - // to manage this per thread and per process. + // Note if/when we support some threads running, we'll end up needing to + // manage this per thread and per process. DoStopIDBumped(m_stop_id); } diff --git a/lldb/source/Host/common/NativeRegisterContext.cpp b/lldb/source/Host/common/NativeRegisterContext.cpp index 60eaebdc94c..49b8284da97 100644 --- a/lldb/source/Host/common/NativeRegisterContext.cpp +++ b/lldb/source/Host/common/NativeRegisterContext.cpp @@ -28,13 +28,12 @@ NativeRegisterContext::NativeRegisterContext(NativeThreadProtocol &thread) NativeRegisterContext::~NativeRegisterContext() {} // FIXME revisit invalidation, process stop ids, etc. Right now we don't -// support caching in NativeRegisterContext. We can do this later by -// utilizing NativeProcessProtocol::GetStopID () and adding a stop id to +// support caching in NativeRegisterContext. We can do this later by utilizing +// NativeProcessProtocol::GetStopID () and adding a stop id to // NativeRegisterContext. // void -// NativeRegisterContext::InvalidateIfNeeded (bool force) -// { +// NativeRegisterContext::InvalidateIfNeeded (bool force) { // ProcessSP process_sp (m_thread.GetProcess()); // bool invalidate = force; // uint32_t process_stop_id = UINT32_MAX; @@ -365,8 +364,8 @@ Status NativeRegisterContext::ReadRegisterValueFromMemory( // We now have a memory buffer that contains the part or all of the register // value. Set the register value using this memory data. // TODO: we might need to add a parameter to this function in case the byte - // order of the memory data doesn't match the process. For now we are assuming - // they are the same. + // order of the memory data doesn't match the process. For now we are + // assuming they are the same. reg_value.SetFromMemoryData(reg_info, src, src_len, process.GetByteOrder(), error); @@ -385,8 +384,7 @@ Status NativeRegisterContext::WriteRegisterValueToMemory( // TODO: we might need to add a parameter to this function in case the byte // order of the memory data doesn't match the process. For now we are - // assuming - // they are the same. + // assuming they are the same. const size_t bytes_copied = reg_value.GetAsMemoryData( reg_info, dst, dst_len, process.GetByteOrder(), error); diff --git a/lldb/source/Host/common/PseudoTerminal.cpp b/lldb/source/Host/common/PseudoTerminal.cpp index 9657cb6523d..c9b290078e1 100644 --- a/lldb/source/Host/common/PseudoTerminal.cpp +++ b/lldb/source/Host/common/PseudoTerminal.cpp @@ -35,10 +35,10 @@ PseudoTerminal::PseudoTerminal() //---------------------------------------------------------------------- // Destructor // -// The destructor will close the master and slave file descriptors -// if they are valid and ownership has not been released using the -// ReleaseMasterFileDescriptor() or the ReleaseSaveFileDescriptor() -// member functions. +// The destructor will close the master and slave file descriptors if they are +// valid and ownership has not been released using the +// ReleaseMasterFileDescriptor() or the ReleaseSaveFileDescriptor() member +// functions. //---------------------------------------------------------------------- PseudoTerminal::~PseudoTerminal() { CloseMasterFileDescriptor(); @@ -66,15 +66,14 @@ void PseudoTerminal::CloseSlaveFileDescriptor() { } //---------------------------------------------------------------------- -// Open the first available pseudo terminal with OFLAG as the -// permissions. The file descriptor is stored in this object and can -// be accessed with the MasterFileDescriptor() accessor. The -// ownership of the master file descriptor can be released using -// the ReleaseMasterFileDescriptor() accessor. If this object has -// a valid master files descriptor when its destructor is called, it -// will close the master file descriptor, therefore clients must -// call ReleaseMasterFileDescriptor() if they wish to use the master -// file descriptor after this object is out of scope or destroyed. +// Open the first available pseudo terminal with OFLAG as the permissions. The +// file descriptor is stored in this object and can be accessed with the +// MasterFileDescriptor() accessor. The ownership of the master file descriptor +// can be released using the ReleaseMasterFileDescriptor() accessor. If this +// object has a valid master files descriptor when its destructor is called, it +// will close the master file descriptor, therefore clients must call +// ReleaseMasterFileDescriptor() if they wish to use the master file descriptor +// after this object is out of scope or destroyed. // // RETURNS: // True when successful, false indicating an error occurred. @@ -118,12 +117,12 @@ bool PseudoTerminal::OpenFirstAvailableMaster(int oflag, char *error_str, } //---------------------------------------------------------------------- -// Open the slave pseudo terminal for the current master pseudo -// terminal. A master pseudo terminal should already be valid prior to -// calling this function (see OpenFirstAvailableMaster()). -// The file descriptor is stored this object's member variables and can -// be accessed via the GetSlaveFileDescriptor(), or released using the -// ReleaseSlaveFileDescriptor() member function. +// Open the slave pseudo terminal for the current master pseudo terminal. A +// master pseudo terminal should already be valid prior to calling this +// function (see OpenFirstAvailableMaster()). The file descriptor is stored +// this object's member variables and can be accessed via the +// GetSlaveFileDescriptor(), or released using the ReleaseSlaveFileDescriptor() +// member function. // // RETURNS: // True when successful, false indicating an error occurred. @@ -152,8 +151,8 @@ bool PseudoTerminal::OpenSlave(int oflag, char *error_str, size_t error_len) { } //---------------------------------------------------------------------- -// Get the name of the slave pseudo terminal. A master pseudo terminal -// should already be valid prior to calling this function (see +// Get the name of the slave pseudo terminal. A master pseudo terminal should +// already be valid prior to calling this function (see // OpenFirstAvailableMaster()). // // RETURNS: @@ -185,18 +184,16 @@ const char *PseudoTerminal::GetSlaveName(char *error_str, // Fork a child process and have its stdio routed to a pseudo terminal. // // In the parent process when a valid pid is returned, the master file -// descriptor can be used as a read/write access to stdio of the -// child process. +// descriptor can be used as a read/write access to stdio of the child process. // -// In the child process the stdin/stdout/stderr will already be routed -// to the slave pseudo terminal and the master file descriptor will be -// closed as it is no longer needed by the child process. +// In the child process the stdin/stdout/stderr will already be routed to the +// slave pseudo terminal and the master file descriptor will be closed as it is +// no longer needed by the child process. // -// This class will close the file descriptors for the master/slave -// when the destructor is called, so be sure to call -// ReleaseMasterFileDescriptor() or ReleaseSlaveFileDescriptor() if any -// file descriptors are going to be used past the lifespan of this -// object. +// This class will close the file descriptors for the master/slave when the +// destructor is called, so be sure to call ReleaseMasterFileDescriptor() or +// ReleaseSlaveFileDescriptor() if any file descriptors are going to be used +// past the lifespan of this object. // // RETURNS: // in the parent process: the pid of the child, or -1 if fork fails @@ -261,49 +258,47 @@ lldb::pid_t PseudoTerminal::Fork(char *error_str, size_t error_len) { } //---------------------------------------------------------------------- -// The master file descriptor accessor. This object retains ownership -// of the master file descriptor when this accessor is used. Use -// ReleaseMasterFileDescriptor() if you wish this object to release -// ownership of the master file descriptor. +// The master file descriptor accessor. This object retains ownership of the +// master file descriptor when this accessor is used. Use +// ReleaseMasterFileDescriptor() if you wish this object to release ownership +// of the master file descriptor. // -// Returns the master file descriptor, or -1 if the master file -// descriptor is not currently valid. +// Returns the master file descriptor, or -1 if the master file descriptor is +// not currently valid. //---------------------------------------------------------------------- int PseudoTerminal::GetMasterFileDescriptor() const { return m_master_fd; } //---------------------------------------------------------------------- // The slave file descriptor accessor. // -// Returns the slave file descriptor, or -1 if the slave file -// descriptor is not currently valid. +// Returns the slave file descriptor, or -1 if the slave file descriptor is not +// currently valid. //---------------------------------------------------------------------- int PseudoTerminal::GetSlaveFileDescriptor() const { return m_slave_fd; } //---------------------------------------------------------------------- -// Release ownership of the master pseudo terminal file descriptor -// without closing it. The destructor for this class will close the -// master file descriptor if the ownership isn't released using this -// call and the master file descriptor has been opened. +// Release ownership of the master pseudo terminal file descriptor without +// closing it. The destructor for this class will close the master file +// descriptor if the ownership isn't released using this call and the master +// file descriptor has been opened. //---------------------------------------------------------------------- int PseudoTerminal::ReleaseMasterFileDescriptor() { - // Release ownership of the master pseudo terminal file - // descriptor without closing it. (the destructor for this - // class will close it otherwise!) + // Release ownership of the master pseudo terminal file descriptor without + // closing it. (the destructor for this class will close it otherwise!) int fd = m_master_fd; m_master_fd = invalid_fd; return fd; } //---------------------------------------------------------------------- -// Release ownership of the slave pseudo terminal file descriptor -// without closing it. The destructor for this class will close the -// slave file descriptor if the ownership isn't released using this -// call and the slave file descriptor has been opened. +// Release ownership of the slave pseudo terminal file descriptor without +// closing it. The destructor for this class will close the slave file +// descriptor if the ownership isn't released using this call and the slave +// file descriptor has been opened. //---------------------------------------------------------------------- int PseudoTerminal::ReleaseSlaveFileDescriptor() { - // Release ownership of the slave pseudo terminal file - // descriptor without closing it (the destructor for this - // class will close it otherwise!) + // Release ownership of the slave pseudo terminal file descriptor without + // closing it (the destructor for this class will close it otherwise!) int fd = m_slave_fd; m_slave_fd = invalid_fd; return fd; diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index 4c23e4eb560..875291bc115 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -160,18 +160,17 @@ Status Socket::TcpListen(llvm::StringRef host_and_port, error = listen_socket->Listen(host_and_port, backlog); if (error.Success()) { - // We were asked to listen on port zero which means we - // must now read the actual port that was given to us - // as port zero is a special code for "find an open port - // for me". + // We were asked to listen on port zero which means we must now read the + // actual port that was given to us as port zero is a special code for + // "find an open port for me". if (port == 0) port = listen_socket->GetLocalPortNumber(); - // Set the port predicate since when doing a listen://<host>:<port> - // it often needs to accept the incoming connection which is a blocking - // system call. Allowing access to the bound port using a predicate allows - // us to wait for the port predicate to be set to a non-zero value from - // another thread in an efficient manor. + // Set the port predicate since when doing a listen://<host>:<port> it + // often needs to accept the incoming connection which is a blocking system + // call. Allowing access to the bound port using a predicate allows us to + // wait for the port predicate to be set to a non-zero value from another + // thread in an efficient manor. if (predicate) predicate->SetValue(port, eBroadcastAlways); socket = listen_socket.release(); @@ -282,8 +281,7 @@ bool Socket::DecodeHostAndPort(llvm::StringRef host_and_port, } // If this was unsuccessful, then check if it's simply a signed 32-bit - // integer, representing - // a port with an empty host. + // integer, representing a port with an empty host. host_str.clear(); port_str.clear(); bool ok = false; @@ -436,8 +434,8 @@ NativeSocket Socket::AcceptSocket(NativeSocket sockfd, struct sockaddr *addr, error.Clear(); #if defined(ANDROID_USE_ACCEPT_WORKAROUND) // Hack: - // This enables static linking lldb-server to an API 21 libc, but still having - // it run on older devices. It is necessary because API 21 libc's + // This enables static linking lldb-server to an API 21 libc, but still + // having it run on older devices. It is necessary because API 21 libc's // implementation of accept() uses the accept4 syscall(), which is not // available in older kernels. Using an older libc would fix this issue, but // introduce other ones, as the old libraries were quite buggy. diff --git a/lldb/source/Host/common/SoftwareBreakpoint.cpp b/lldb/source/Host/common/SoftwareBreakpoint.cpp index 14dbafd94c0..353dadf6ce6 100644 --- a/lldb/source/Host/common/SoftwareBreakpoint.cpp +++ b/lldb/source/Host/common/SoftwareBreakpoint.cpp @@ -17,9 +17,8 @@ using namespace lldb_private; -// ------------------------------------------------------------------- -// static members -// ------------------------------------------------------------------- +// ------------------------------------------------------------------- static +// members ------------------------------------------------------------------- Status SoftwareBreakpoint::CreateSoftwareBreakpoint( NativeProcessProtocol &process, lldb::addr_t addr, size_t size_hint, @@ -34,8 +33,7 @@ Status SoftwareBreakpoint::CreateSoftwareBreakpoint( __FUNCTION__); // Ask the NativeProcessProtocol subclass to fill in the correct software - // breakpoint - // trap for the breakpoint site. + // breakpoint trap for the breakpoint site. size_t bp_opcode_size = 0; const uint8_t *bp_opcode_bytes = NULL; Status error = process.GetSoftwareBreakpointTrapOpcode( @@ -98,9 +96,8 @@ Status SoftwareBreakpoint::CreateSoftwareBreakpoint( log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- SUCCESS", __FUNCTION__, addr); - // Set the breakpoint and verified it was written properly. Now - // create a breakpoint remover that understands how to undo this - // breakpoint. + // Set the breakpoint and verified it was written properly. Now create a + // breakpoint remover that understands how to undo this breakpoint. breakpoint_sp.reset(new SoftwareBreakpoint(process, addr, saved_opcode_bytes, bp_opcode_bytes, bp_opcode_size)); return Status(); @@ -280,8 +277,8 @@ Status SoftwareBreakpoint::DoDisable() { // Make sure the breakpoint opcode exists at this address if (::memcmp(curr_break_op, m_trap_opcodes, m_opcode_size) == 0) { break_op_found = true; - // We found a valid breakpoint opcode at this address, now restore - // the saved opcode. + // We found a valid breakpoint opcode at this address, now restore the + // saved opcode. size_t bytes_written = 0; error = m_process.WriteMemory(m_addr, m_saved_opcodes, m_opcode_size, bytes_written); diff --git a/lldb/source/Host/common/Symbols.cpp b/lldb/source/Host/common/Symbols.cpp index 4fce965f75e..89bc1bd6ad7 100644 --- a/lldb/source/Host/common/Symbols.cpp +++ b/lldb/source/Host/common/Symbols.cpp @@ -111,15 +111,15 @@ static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec, // Add a ".dSYM" name to each directory component of the path, // stripping off components. e.g. we may have a binary like - // /S/L/F/Foundation.framework/Versions/A/Foundation - // and + // /S/L/F/Foundation.framework/Versions/A/Foundation and // /S/L/F/Foundation.framework.dSYM // - // so we'll need to start with /S/L/F/Foundation.framework/Versions/A, - // add the .dSYM part to the "A", and if that doesn't exist, strip off - // the "A" and try it again with "Versions", etc., until we find a - // dSYM bundle or we've stripped off enough path components that - // there's no need to continue. + // so we'll need to start with + // /S/L/F/Foundation.framework/Versions/A, add the .dSYM part to the + // "A", and if that doesn't exist, strip off the "A" and try it again + // with "Versions", etc., until we find a dSYM bundle or we've + // stripped off enough path components that there's no need to + // continue. for (int i = 0; i < 4; i++) { // Does this part of the path have a "." character - could it be a @@ -131,7 +131,8 @@ static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec, dsym_fspec = parent_dirs; dsym_fspec.RemoveLastPathComponent(); - // If the current directory name is "Foundation.framework", see if + // If the current directory name is "Foundation.framework", see + // if // "Foundation.framework.dSYM/Contents/Resources/DWARF/Foundation" // exists & has the right uuid. std::string dsym_fn = fn; @@ -293,10 +294,9 @@ FileSpec Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec) { if (num_specs == 1) { ModuleSpec mspec; if (specs.GetModuleSpecAtIndex(0, mspec)) { - // Skip the uuids check if module_uuid is invalid. - // For example, this happens for *.dwp files since - // at the moment llvm-dwp doesn't output build ids, - // nor does binutils dwp. + // Skip the uuids check if module_uuid is invalid. For example, + // this happens for *.dwp files since at the moment llvm-dwp + // doesn't output build ids, nor does binutils dwp. if (!module_uuid.IsValid() || module_uuid == mspec.GetUUID()) return file_spec; } diff --git a/lldb/source/Host/common/TaskPool.cpp b/lldb/source/Host/common/TaskPool.cpp index 156a0794299..c54b9a8ae56 100644 --- a/lldb/source/Host/common/TaskPool.cpp +++ b/lldb/source/Host/common/TaskPool.cpp @@ -49,8 +49,8 @@ void TaskPool::AddTaskImpl(std::function<void()> &&task_fn) { TaskPoolImpl::TaskPoolImpl() : m_thread_count(0) {} unsigned GetHardwareConcurrencyHint() { - // std::thread::hardware_concurrency may return 0 - // if the value is not well defined or not computable. + // std::thread::hardware_concurrency may return 0 if the value is not well + // defined or not computable. static const unsigned g_hardware_concurrency = std::max(1u, std::thread::hardware_concurrency()); return g_hardware_concurrency; @@ -64,9 +64,8 @@ void TaskPoolImpl::AddTask(std::function<void()> &&task_fn) { if (m_thread_count < GetHardwareConcurrencyHint()) { m_thread_count++; // Note that this detach call needs to happen with the m_tasks_mutex held. - // This prevents the thread - // from exiting prematurely and triggering a linux libc bug - // (https://sourceware.org/bugzilla/show_bug.cgi?id=19951). + // This prevents the thread from exiting prematurely and triggering a linux + // libc bug (https://sourceware.org/bugzilla/show_bug.cgi?id=19951). lldb_private::ThreadLauncher::LaunchThread("task-pool.worker", WorkerPtr, this, nullptr, min_stack_size) .Release(); diff --git a/lldb/source/Host/common/Terminal.cpp b/lldb/source/Host/common/Terminal.cpp index 022b3fa50a8..35902dd5ae3 100644 --- a/lldb/source/Host/common/Terminal.cpp +++ b/lldb/source/Host/common/Terminal.cpp @@ -107,9 +107,9 @@ void TerminalState::Clear() { } //---------------------------------------------------------------------- -// Save the current state of the TTY for the file descriptor "fd" -// and if "save_process_group" is true, attempt to save the process -// group info for the TTY. +// Save the current state of the TTY for the file descriptor "fd" and if +// "save_process_group" is true, attempt to save the process group info for the +// TTY. //---------------------------------------------------------------------- bool TerminalState::Save(int fd, bool save_process_group) { m_tty.SetFileDescriptor(fd); @@ -142,8 +142,8 @@ bool TerminalState::Save(int fd, bool save_process_group) { } //---------------------------------------------------------------------- -// Restore the state of the TTY using the cached values from a -// previous call to Save(). +// Restore the state of the TTY using the cached values from a previous call to +// Save(). //---------------------------------------------------------------------- bool TerminalState::Restore() const { #ifndef LLDB_DISABLE_POSIX @@ -173,8 +173,8 @@ bool TerminalState::Restore() const { } //---------------------------------------------------------------------- -// Returns true if this object has valid saved TTY state settings -// that can be used to restore a previous state. +// Returns true if this object has valid saved TTY state settings that can be +// used to restore a previous state. //---------------------------------------------------------------------- bool TerminalState::IsValid() const { return m_tty.FileDescriptorIsValid() && @@ -236,21 +236,20 @@ bool TerminalStateSwitcher::Restore(uint32_t idx) const { m_ttystates[idx].IsValid()) return true; - // Set the state to match the index passed in and only update the - // current state if there are no errors. + // Set the state to match the index passed in and only update the current + // state if there are no errors. if (m_ttystates[idx].Restore()) { m_currentState = idx; return true; } - // We failed to set the state. The tty state was invalid or not - // initialized. + // We failed to set the state. The tty state was invalid or not initialized. return false; } //------------------------------------------------------------------ -// Save the state at index "idx" for file descriptor "fd" and -// save the process group if requested. +// Save the state at index "idx" for file descriptor "fd" and save the process +// group if requested. // // Returns true if the restore was successful, false otherwise. //------------------------------------------------------------------ diff --git a/lldb/source/Host/common/UDPSocket.cpp b/lldb/source/Host/common/UDPSocket.cpp index 21dacbc626e..96bcc6a150a 100644 --- a/lldb/source/Host/common/UDPSocket.cpp +++ b/lldb/source/Host/common/UDPSocket.cpp @@ -69,8 +69,8 @@ Status UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit, if (!DecodeHostAndPort(name, host_str, port_str, port, &error)) return error; - // At this point we have setup the receive port, now we need to - // setup the UDP send socket + // At this point we have setup the receive port, now we need to setup the UDP + // send socket struct addrinfo hints; struct addrinfo *service_info_list = nullptr; diff --git a/lldb/source/Host/common/XML.cpp b/lldb/source/Host/common/XML.cpp index 42e3d4b6e92..7468a3d7ac6 100644 --- a/lldb/source/Host/common/XML.cpp +++ b/lldb/source/Host/common/XML.cpp @@ -252,8 +252,8 @@ void XMLNode::ForEachSiblingElementWithName( if (node->type != XML_ELEMENT_NODE) continue; - // If name is nullptr, we take all nodes of type "t", else - // just the ones whose name matches + // If name is nullptr, we take all nodes of type "t", else just the ones + // whose name matches if (name) { if (strcmp((const char *)node->name, name) != 0) continue; // Name mismatch, ignore this one |

