From 05097246f352eca76207c9ebb08656c88bdf751a Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Mon, 30 Apr 2018 16:49:04 +0000 Subject: Reflow paragraphs in comments. This is intended as a clean up after the big clang-format commit (r280751), which unfortunately resulted in many of the comment paragraphs in LLDB being very hard to read. FYI, the script I used was: import textwrap import commands import os import sys import re tmp = "%s.tmp"%sys.argv[1] out = open(tmp, "w+") with open(sys.argv[1], "r") as f: header = "" text = "" comment = re.compile(r'^( *//) ([^ ].*)$') special = re.compile(r'^((([A-Z]+[: ])|([0-9]+ )).*)|(.*;)$') for line in f: match = comment.match(line) if match and not special.match(match.group(2)): # skip intentionally short comments. if not text and len(match.group(2)) < 40: out.write(line) continue if text: text += " " + match.group(2) else: header = match.group(1) text = match.group(2) continue if text: filled = textwrap.wrap(text, width=(78-len(header)), break_long_words=False) for l in filled: out.write(header+" "+l+'\n') text = "" out.write(line) os.rename(tmp, sys.argv[1]) Differential Revision: https://reviews.llvm.org/D46144 llvm-svn: 331197 --- .../Host/windows/ConnectionGenericFileWindows.cpp | 44 +++++++++------------- lldb/source/Host/windows/EditLineWin.cpp | 8 ++-- lldb/source/Host/windows/Host.cpp | 14 +++---- lldb/source/Host/windows/HostInfoWindows.cpp | 9 ++--- lldb/source/Host/windows/HostProcessWindows.cpp | 4 +- lldb/source/Host/windows/PipeWindows.cpp | 27 ++++++------- 6 files changed, 45 insertions(+), 61 deletions(-) (limited to 'lldb/source/Host/windows') diff --git a/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp b/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp index 41bdb5f41fb..e59e190dcb2 100644 --- a/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp +++ b/lldb/source/Host/windows/ConnectionGenericFileWindows.cpp @@ -21,12 +21,10 @@ using namespace lldb_private; namespace { // This is a simple helper class to package up the information needed to return -// from a Read/Write -// operation function. Since there is a lot of code to be run before exit -// regardless of whether the -// operation succeeded or failed, combined with many possible return paths, this -// is the cleanest -// way to represent it. +// from a Read/Write operation function. Since there is a lot of code to be +// run before exit regardless of whether the operation succeeded or failed, +// combined with many possible return paths, this is the cleanest way to +// represent it. class ReturnInfo { public: void Set(size_t bytes, ConnectionStatus status, DWORD error_code) { @@ -78,11 +76,9 @@ void ConnectionGenericFile::InitializeEventHandles() { m_event_handles[kInterruptEvent] = CreateEvent(NULL, FALSE, FALSE, NULL); // Note, we should use a manual reset event for the hEvent argument of the - // OVERLAPPED. This - // is because both WaitForMultipleObjects and GetOverlappedResult (if you set - // the bWait - // argument to TRUE) will wait for the event to be signalled. If we use an - // auto-reset event, + // OVERLAPPED. This is because both WaitForMultipleObjects and + // GetOverlappedResult (if you set the bWait argument to TRUE) will wait for + // the event to be signalled. If we use an auto-reset event, // WaitForMultipleObjects will reset the event, return successfully, and then // GetOverlappedResult will block since the event is no longer signalled. m_event_handles[kBytesAvailableEvent] = @@ -147,8 +143,7 @@ lldb::ConnectionStatus ConnectionGenericFile::Disconnect(Status *error_ptr) { return eConnectionStatusSuccess; // Reset the handle so that after we unblock any pending reads, subsequent - // calls to Read() will - // see a disconnected state. + // calls to Read() will see a disconnected state. HANDLE old_file = m_file; m_file = INVALID_HANDLE_VALUE; @@ -157,8 +152,7 @@ lldb::ConnectionStatus ConnectionGenericFile::Disconnect(Status *error_ptr) { ::CancelIoEx(old_file, &m_overlapped); // Close the file handle if we owned it, but don't close the event handles. - // We could always - // reconnect with the same Connection instance. + // We could always reconnect with the same Connection instance. if (m_owns_file) ::CloseHandle(old_file); @@ -190,8 +184,7 @@ size_t ConnectionGenericFile::Read(void *dst, size_t dst_len, if (result || ::GetLastError() == ERROR_IO_PENDING) { if (!result) { // The expected return path. The operation is pending. Wait for the - // operation to complete - // or be interrupted. + // operation to complete or be interrupted. DWORD milliseconds = timeout ? std::chrono::duration_cast(*timeout) @@ -219,11 +212,9 @@ size_t ConnectionGenericFile::Read(void *dst, size_t dst_len, // The data is ready. Figure out how much was read and return; if (!::GetOverlappedResult(m_file, &m_overlapped, &bytes_read, FALSE)) { DWORD result_error = ::GetLastError(); - // ERROR_OPERATION_ABORTED occurs when someone calls Disconnect() during a - // blocking read. - // This triggers a call to CancelIoEx, which causes the operation to - // complete and the - // result to be ERROR_OPERATION_ABORTED. + // ERROR_OPERATION_ABORTED occurs when someone calls Disconnect() during + // a blocking read. This triggers a call to CancelIoEx, which causes the + // operation to complete and the result to be ERROR_OPERATION_ABORTED. if (result_error == ERROR_HANDLE_EOF || result_error == ERROR_OPERATION_ABORTED || result_error == ERROR_BROKEN_PIPE) @@ -250,9 +241,9 @@ finish: if (error_ptr) *error_ptr = return_info.GetError(); - // kBytesAvailableEvent is a manual reset event. Make sure it gets reset here - // so that any - // subsequent operations don't immediately see bytes available. + // kBytesAvailableEvent is a manual reset event. Make sure it gets reset + // here so that any subsequent operations don't immediately see bytes + // available. ResetEvent(m_event_handles[kBytesAvailableEvent]); IncrementFilePointer(return_info.GetBytes()); @@ -284,7 +275,8 @@ size_t ConnectionGenericFile::Write(const void *src, size_t src_len, m_overlapped.hEvent = NULL; - // Writes are not interruptible like reads are, so just block until it's done. + // Writes are not interruptible like reads are, so just block until it's + // done. result = ::WriteFile(m_file, src, src_len, NULL, &m_overlapped); if (!result && ::GetLastError() != ERROR_IO_PENDING) { return_info.Set(0, eConnectionStatusError, ::GetLastError()); diff --git a/lldb/source/Host/windows/EditLineWin.cpp b/lldb/source/Host/windows/EditLineWin.cpp index 133cd622546..3bccc4e1a2c 100644 --- a/lldb/source/Host/windows/EditLineWin.cpp +++ b/lldb/source/Host/windows/EditLineWin.cpp @@ -316,8 +316,8 @@ int el_get(EditLine *el, int code, ...) { } int el_source(EditLine *el, const char *file) { - // init edit line by reading the contents of 'file' - // nothing to do here on windows... + // init edit line by reading the contents of 'file' nothing to do here on + // windows... return 0; } @@ -342,8 +342,8 @@ void history_end(History *) { } int history(History *, HistEvent *, int op, ...) { - // perform operation 'op' on the history list with - // optional arguments as needed by the operation. + // perform operation 'op' on the history list with optional arguments as + // needed by the operation. return 0; } diff --git a/lldb/source/Host/windows/Host.cpp b/lldb/source/Host/windows/Host.cpp index 53834822404..2ecc6141385 100644 --- a/lldb/source/Host/windows/Host.cpp +++ b/lldb/source/Host/windows/Host.cpp @@ -35,8 +35,7 @@ using namespace lldb_private; namespace { bool GetTripleForProcess(const FileSpec &executable, llvm::Triple &triple) { // Open the PE File as a binary file, and parse just enough information to - // determine the - // machine type. + // determine the machine type. File imageBinary(executable.GetPath().c_str(), File::eOpenOptionRead, lldb::eFilePermissionsUserRead); imageBinary.SeekFromStart(0x3c); @@ -63,8 +62,8 @@ bool GetTripleForProcess(const FileSpec &executable, llvm::Triple &triple) { } bool GetExecutableForProcess(const AutoHandle &handle, std::string &path) { - // Get the process image path. MAX_PATH isn't long enough, paths can actually - // be up to 32KB. + // Get the process image path. MAX_PATH isn't long enough, paths can + // actually be up to 32KB. std::vector buffer(PATH_MAX); DWORD dwSize = buffer.size(); if (!::QueryFullProcessImageNameW(handle.get(), 0, &buffer[0], &dwSize)) @@ -75,10 +74,9 @@ bool GetExecutableForProcess(const AutoHandle &handle, std::string &path) { void GetProcessExecutableAndTriple(const AutoHandle &handle, ProcessInstanceInfo &process) { // We may not have permissions to read the path from the process. So start - // off by - // setting the executable file to whatever Toolhelp32 gives us, and then try - // to - // enhance this with more detailed information, but fail gracefully. + // off by setting the executable file to whatever Toolhelp32 gives us, and + // then try to enhance this with more detailed information, but fail + // gracefully. std::string executable; llvm::Triple triple; triple.setVendor(llvm::Triple::PC); diff --git a/lldb/source/Host/windows/HostInfoWindows.cpp b/lldb/source/Host/windows/HostInfoWindows.cpp index 53a24ad1893..cc38e0bb579 100644 --- a/lldb/source/Host/windows/HostInfoWindows.cpp +++ b/lldb/source/Host/windows/HostInfoWindows.cpp @@ -50,11 +50,10 @@ bool HostInfoWindows::GetOSVersion(uint32_t &major, uint32_t &minor, info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); #pragma warning(push) #pragma warning(disable : 4996) - // Starting with Microsoft SDK for Windows 8.1, this function is deprecated in - // favor of the - // new Windows Version Helper APIs. Since we don't specify a minimum SDK - // version, it's easier - // to simply disable the warning rather than try to support both APIs. + // Starting with Microsoft SDK for Windows 8.1, this function is deprecated + // in favor of the new Windows Version Helper APIs. Since we don't specify a + // minimum SDK version, it's easier to simply disable the warning rather than + // try to support both APIs. if (GetVersionEx((LPOSVERSIONINFO)&info) == 0) { return false; } diff --git a/lldb/source/Host/windows/HostProcessWindows.cpp b/lldb/source/Host/windows/HostProcessWindows.cpp index 49d42ce0542..61e19ed5146 100644 --- a/lldb/source/Host/windows/HostProcessWindows.cpp +++ b/lldb/source/Host/windows/HostProcessWindows.cpp @@ -88,8 +88,8 @@ HostThread HostProcessWindows::StartMonitoring( info->callback = callback; // Since the life of this HostProcessWindows instance and the life of the - // process may be different, duplicate the handle so that - // the monitor thread can have ownership over its own copy of the handle. + // process may be different, duplicate the handle so that the monitor thread + // can have ownership over its own copy of the handle. HostThread result; if (::DuplicateHandle(GetCurrentProcess(), m_process, GetCurrentProcess(), &info->process_handle, 0, FALSE, DUPLICATE_SAME_ACCESS)) diff --git a/lldb/source/Host/windows/PipeWindows.cpp b/lldb/source/Host/windows/PipeWindows.cpp index e8f4753d11e..1951c9ca193 100644 --- a/lldb/source/Host/windows/PipeWindows.cpp +++ b/lldb/source/Host/windows/PipeWindows.cpp @@ -40,11 +40,9 @@ PipeWindows::PipeWindows() { PipeWindows::~PipeWindows() { Close(); } Status PipeWindows::CreateNew(bool child_process_inherit) { - // Even for anonymous pipes, we open a named pipe. This is because you cannot - // get - // overlapped i/o on Windows without using a named pipe. So we synthesize a - // unique - // name. + // Even for anonymous pipes, we open a named pipe. This is because you + // cannot get overlapped i/o on Windows without using a named pipe. So we + // synthesize a unique name. uint32_t serial = g_pipe_serial.fetch_add(1); std::string pipe_name; llvm::raw_string_ostream pipe_name_stream(pipe_name); @@ -65,8 +63,8 @@ Status PipeWindows::CreateNew(llvm::StringRef name, std::string pipe_path = "\\\\.\\Pipe\\"; pipe_path.append(name); - // Always open for overlapped i/o. We implement blocking manually in Read and - // Write. + // Always open for overlapped i/o. We implement blocking manually in Read + // and Write. DWORD read_mode = FILE_FLAG_OVERLAPPED; m_read = ::CreateNamedPipeA( pipe_path.c_str(), PIPE_ACCESS_INBOUND | read_mode, @@ -250,12 +248,10 @@ Status PipeWindows::ReadWithTimeout(void *buf, size_t size, DWORD wait_result = ::WaitForSingleObject(m_read_overlapped.hEvent, timeout); if (wait_result != WAIT_OBJECT_0) { // The operation probably failed. However, if it timed out, we need to - // cancel the I/O. - // Between the time we returned from WaitForSingleObject and the time we - // call CancelIoEx, - // the operation may complete. If that hapens, CancelIoEx will fail and - // return ERROR_NOT_FOUND. - // If that happens, the original operation should be considered to have been + // cancel the I/O. Between the time we returned from WaitForSingleObject + // and the time we call CancelIoEx, the operation may complete. If that + // hapens, CancelIoEx will fail and return ERROR_NOT_FOUND. If that + // happens, the original operation should be considered to have been // successful. bool failed = true; DWORD failure_error = ::GetLastError(); @@ -268,9 +264,8 @@ Status PipeWindows::ReadWithTimeout(void *buf, size_t size, return Status(failure_error, eErrorTypeWin32); } - // Now we call GetOverlappedResult setting bWait to false, since we've already - // waited - // as long as we're willing to. + // Now we call GetOverlappedResult setting bWait to false, since we've + // already waited as long as we're willing to. if (!GetOverlappedResult(m_read, &m_read_overlapped, &sys_bytes_read, FALSE)) return Status(::GetLastError(), eErrorTypeWin32); -- cgit v1.2.3