[Lldb-commits] [lldb] r341320 - [PseudoTerminal][NFC] Use llvm errno helpers
Author: xbolva00 Date: Mon Sep 3 07:59:57 2018 New Revision: 341320 URL: http://llvm.org/viewvc/llvm-project?rev=341320&view=rev Log: [PseudoTerminal][NFC] Use llvm errno helpers Summary: LLVM provide (str)errno helpers, so convert code to use it. Also fixes warning: /home/xbolva00/LLVM/llvm/tools/lldb/source/Host/common/PseudoTerminal.cpp:248:25: warning: ignoring return value of ‘char* strerror_r(int, char*, size_t)’, declared with attribute warn_unused_result [-Wunused-result] ::strerror_r(errno, error_str, error_len); Reviewers: JDevlieghere Reviewed By: JDevlieghere Subscribers: abidh, lldb-commits Differential Revision: https://reviews.llvm.org/D51591 Modified: lldb/trunk/source/Host/common/PseudoTerminal.cpp Modified: lldb/trunk/source/Host/common/PseudoTerminal.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/PseudoTerminal.cpp?rev=341320&r1=341319&r2=341320&view=diff == --- lldb/trunk/source/Host/common/PseudoTerminal.cpp (original) +++ lldb/trunk/source/Host/common/PseudoTerminal.cpp Mon Sep 3 07:59:57 2018 @@ -10,7 +10,8 @@ #include "lldb/Host/PseudoTerminal.h" #include "lldb/Host/Config.h" -#include +#include "llvm/Support/Errno.h" + #include #include #include @@ -27,6 +28,14 @@ int posix_openpt(int flags); using namespace lldb_private; //-- +// Write string describing error number +//-- +static void ErrnoToStr(char *error_str, size_t error_len) { + std::string strerror = llvm::sys::StrError(); + ::snprintf(error_str, error_len, "%s", strerror.c_str()); +} + +//-- // PseudoTerminal constructor //-- PseudoTerminal::PseudoTerminal() @@ -88,14 +97,14 @@ bool PseudoTerminal::OpenFirstAvailableM m_master_fd = ::posix_openpt(oflag); if (m_master_fd < 0) { if (error_str) - ::strerror_r(errno, error_str, error_len); + ErrnoToStr(error_str, error_len); return false; } // Grant access to the slave pseudo terminal if (::grantpt(m_master_fd) < 0) { if (error_str) - ::strerror_r(errno, error_str, error_len); + ErrnoToStr(error_str, error_len); CloseMasterFileDescriptor(); return false; } @@ -103,7 +112,7 @@ bool PseudoTerminal::OpenFirstAvailableM // Clear the lock flag on the slave pseudo terminal if (::unlockpt(m_master_fd) < 0) { if (error_str) - ::strerror_r(errno, error_str, error_len); + ErrnoToStr(error_str, error_len); CloseMasterFileDescriptor(); return false; } @@ -143,7 +152,7 @@ bool PseudoTerminal::OpenSlave(int oflag if (m_slave_fd < 0) { if (error_str) - ::strerror_r(errno, error_str, error_len); + ErrnoToStr(error_str, error_len); return false; } @@ -175,7 +184,7 @@ const char *PseudoTerminal::GetSlaveName const char *slave_name = ::ptsname(m_master_fd); if (error_str && slave_name == nullptr) -::strerror_r(errno, error_str, error_len); +ErrnoToStr(error_str, error_len); return slave_name; } @@ -213,7 +222,7 @@ lldb::pid_t PseudoTerminal::Fork(char *e if (pid < 0) { // Fork failed if (error_str) -::strerror_r(errno, error_str, error_len); +ErrnoToStr(error_str, error_len); } else if (pid == 0) { // Child Process ::setsid(); @@ -229,23 +238,23 @@ lldb::pid_t PseudoTerminal::Fork(char *e // Acquire the controlling terminal if (::ioctl(m_slave_fd, TIOCSCTTY, (char *)0) < 0) { if (error_str) -::strerror_r(errno, error_str, error_len); +ErrnoToStr(error_str, error_len); } #endif // Duplicate all stdio file descriptors to the slave pseudo terminal if (::dup2(m_slave_fd, STDIN_FILENO) != STDIN_FILENO) { if (error_str && !error_str[0]) -::strerror_r(errno, error_str, error_len); +ErrnoToStr(error_str, error_len); } if (::dup2(m_slave_fd, STDOUT_FILENO) != STDOUT_FILENO) { if (error_str && !error_str[0]) -::strerror_r(errno, error_str, error_len); +ErrnoToStr(error_str, error_len); } if (::dup2(m_slave_fd, STDERR_FILENO) != STDERR_FILENO) { if (error_str && !error_str[0]) -::strerror_r(errno, error_str, error_len); +ErrnoToStr(error_str, error_len); } } } else { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341340 - [NFC] Fixed enum constant in boolean context error
Author: xbolva00 Date: Mon Sep 3 15:09:08 2018 New Revision: 341340 URL: http://llvm.org/viewvc/llvm-project?rev=341340&view=rev Log: [NFC] Fixed enum constant in boolean context error Summary: /home/xbolva00/LLVM/llvm/tools/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:656:59: warning: enum constant in boolean context [-Wint-in-bool-context] if (mh.magic == llvm::MachO::MH_CIGAM || llvm::MachO::MH_MAGIC) ^~~~ /home/xbolva00/LLVM/llvm/tools/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:658:62: warning: enum constant in boolean context [-Wint-in-bool-context] if (mh.magic == llvm::MachO::MH_CIGAM_64 || llvm::MachO::MH_MAGIC_64) Reviewers: JDevlieghere, teemperor Reviewed By: teemperor Subscribers: abidh, lldb-commits Differential Revision: https://reviews.llvm.org/D51600 Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=341340&r1=341339&r2=341340&view=diff == --- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Mon Sep 3 15:09:08 2018 @@ -652,11 +652,12 @@ bool DynamicLoaderDarwinKernel::KextImag llvm::MachO::mach_header mh; size_t size_to_read = 512; - if (ReadMachHeader (m_load_address, process, mh)) { -if (mh.magic == llvm::MachO::MH_CIGAM || llvm::MachO::MH_MAGIC) - size_to_read = sizeof (llvm::MachO::mach_header) + mh.sizeofcmds; -if (mh.magic == llvm::MachO::MH_CIGAM_64 || llvm::MachO::MH_MAGIC_64) - size_to_read = sizeof (llvm::MachO::mach_header_64) + mh.sizeofcmds; + if (ReadMachHeader(m_load_address, process, mh)) { +if (mh.magic == llvm::MachO::MH_CIGAM || mh.magic == llvm::MachO::MH_MAGIC) + size_to_read = sizeof(llvm::MachO::mach_header) + mh.sizeofcmds; +if (mh.magic == llvm::MachO::MH_CIGAM_64 || +mh.magic == llvm::MachO::MH_MAGIC_64) + size_to_read = sizeof(llvm::MachO::mach_header_64) + mh.sizeofcmds; } ModuleSP memory_module_sp = ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341339 - [NFC] Use llvm_unreachable instead of lldb::assert
Author: xbolva00 Date: Mon Sep 3 15:08:30 2018 New Revision: 341339 URL: http://llvm.org/viewvc/llvm-project?rev=341339&view=rev Log: [NFC] Use llvm_unreachable instead of lldb::assert Summary: Fixes implicit fall through warnings Reviewers: JDevlieghere, teemperor Reviewed By: teemperor Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D51601 Modified: lldb/trunk/source/Host/common/Editline.cpp Modified: lldb/trunk/source/Host/common/Editline.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Editline.cpp?rev=341339&r1=341338&r2=341339&view=diff == --- lldb/trunk/source/Host/common/Editline.cpp (original) +++ lldb/trunk/source/Host/common/Editline.cpp Mon Sep 3 15:08:30 2018 @@ -526,7 +526,7 @@ int Editline::GetCharacter(EditLineGetCh break; case lldb::eConnectionStatusInterrupted: -lldbassert(0 && "Interrupts should have been handled above."); +llvm_unreachable("Interrupts should have been handled above."); case lldb::eConnectionStatusError:// Check GetError() for details case lldb::eConnectionStatusTimedOut: // Request timed out ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341334 - [ClangUserExpression][NFC] Removed unused code
Author: xbolva00 Date: Mon Sep 3 11:21:21 2018 New Revision: 341334 URL: http://llvm.org/viewvc/llvm-project?rev=341334&view=rev Log: [ClangUserExpression][NFC] Removed unused code Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=341334&r1=341333&r2=341334&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Mon Sep 3 11:21:21 2018 @@ -655,10 +655,6 @@ bool ClangUserExpression::Complete(Execu if (!PrepareForParsing(diagnostic_manager, exe_ctx)) return false; - lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown; - if (auto new_lang = GetLanguageForExpr(diagnostic_manager, exe_ctx)) -lang_type = new_lang.getValue(); - if (log) log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341387 - Terminate debugger if an assert was hit
Author: xbolva00 Date: Tue Sep 4 10:19:15 2018 New Revision: 341387 URL: http://llvm.org/viewvc/llvm-project?rev=341387&view=rev Log: Terminate debugger if an assert was hit Reviewers: JDevlieghere, teemperor, #lldb Reviewed By: JDevlieghere Subscribers: clayborg, lemo, lldb-commits Differential Revision: https://reviews.llvm.org/D51604 Modified: lldb/trunk/source/Utility/LLDBAssert.cpp Modified: lldb/trunk/source/Utility/LLDBAssert.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/LLDBAssert.cpp?rev=341387&r1=341386&r2=341387&view=diff == --- lldb/trunk/source/Utility/LLDBAssert.cpp (original) +++ lldb/trunk/source/Utility/LLDBAssert.cpp Tue Sep 4 10:19:15 2018 @@ -19,14 +19,14 @@ using namespace lldb_private; void lldb_private::lldb_assert(bool expression, const char *expr_text, const char *func, const char *file, unsigned int line) { - if (expression) -; - else { -errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n", - expr_text, func, file, line); -errs() << "backtrace leading to the failure:\n"; -llvm::sys::PrintStackTrace(errs()); -errs() << "please file a bug report against lldb reporting this failure " - "log, and as many details as possible\n"; - } + if (LLVM_LIKELY(expression)) +return; + + errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n", + expr_text, func, file, line); + errs() << "backtrace leading to the failure:\n"; + llvm::sys::PrintStackTrace(errs()); + errs() << "please file a bug report against lldb reporting this failure " +"log, and as many details as possible\n"; + abort(); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341746 - Check if a terminal supports colors on Windows properly
Author: xbolva00 Date: Sat Sep 8 00:15:56 2018 New Revision: 341746 URL: http://llvm.org/viewvc/llvm-project?rev=341746&view=rev Log: Check if a terminal supports colors on Windows properly Summary: Previously we SetUseColor(true) wrongly when output was not a terminal so it broken some (not public) bots. Thanks for issue report, @stella.stamenova Reviewers: stella.stamenova, zturner Reviewed By: stella.stamenova Subscribers: abidh, lldb-commits, stella.stamenova Differential Revision: https://reviews.llvm.org/D51772 Modified: lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Host/common/File.cpp Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=341746&r1=341745&r2=341746&view=diff == --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Sat Sep 8 00:15:56 2018 @@ -812,7 +812,6 @@ Debugger::Debugger(lldb::LogOutputCallba // Enabling use of ANSI color codes because LLDB is using them to highlight // text. llvm::sys::Process::UseANSIEscapeCodes(true); - SetUseColor(true); #endif } Modified: lldb/trunk/source/Host/common/File.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=341746&r1=341745&r2=341746&view=diff == --- lldb/trunk/source/Host/common/File.cpp (original) +++ lldb/trunk/source/Host/common/File.cpp Sat Sep 8 00:15:56 2018 @@ -806,6 +806,9 @@ void File::CalculateInteractiveAndTermin if (_isatty(fd)) { m_is_interactive = eLazyBoolYes; m_is_real_terminal = eLazyBoolYes; +#if defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) + m_supports_colors = eLazyBoolYes; +#endif } #else if (isatty(fd)) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341315 - [Symtab][NFC] Added llvm_unreachable to supress compiler warning
Author: xbolva00 Date: Mon Sep 3 05:57:54 2018 New Revision: 341315 URL: http://llvm.org/viewvc/llvm-project?rev=341315&view=rev Log: [Symtab][NFC] Added llvm_unreachable to supress compiler warning Reviewers: JDevlieghere Reviewed By: JDevlieghere Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D51587 Modified: lldb/trunk/source/Symbol/Symtab.cpp Modified: lldb/trunk/source/Symbol/Symtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=341315&r1=341314&r2=341315&view=diff == --- lldb/trunk/source/Symbol/Symtab.cpp (original) +++ lldb/trunk/source/Symbol/Symtab.cpp Mon Sep 3 05:57:54 2018 @@ -249,6 +249,7 @@ static bool lldb_skip_name(llvm::StringR case Mangled::eManglingSchemeNone: return true; } + llvm_unreachable("unknown scheme!"); } void Symtab::InitNameIndexes() { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r342075 - Do not create new terminals when launching process on Windows with --no-stdio
Author: xbolva00 Date: Wed Sep 12 12:50:45 2018 New Revision: 342075 URL: http://llvm.org/viewvc/llvm-project?rev=342075&view=rev Log: Do not create new terminals when launching process on Windows with --no-stdio Summary: Partially fixes PR38222 Reviewers: teemperor, zturner, stella.stamenova Reviewed By: zturner, stella.stamenova Subscribers: JDevlieghere, clayborg, labath, abidh, lldb-commits Differential Revision: https://reviews.llvm.org/D51966 Modified: lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp Modified: lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp?rev=342075&r1=342074&r2=342075&view=diff == --- lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp (original) +++ lldb/trunk/source/Host/windows/ProcessLauncherWindows.cpp Wed Sep 12 12:50:45 2018 @@ -76,6 +76,9 @@ ProcessLauncherWindows::LaunchProcess(co if (launch_info.GetFlags().Test(eLaunchFlagDebug)) flags |= DEBUG_ONLY_THIS_PROCESS; + if (launch_info.GetFlags().Test(eLaunchFlagDisableSTDIO)) +flags &= ~CREATE_NEW_CONSOLE; + LPVOID env_block = nullptr; ::CreateEnvironmentBuffer(launch_info.GetEnvironment(), environment); if (!environment.empty()) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341497 - Set Windows console mode to enable support for ansi escape codes
Author: xbolva00 Date: Wed Sep 5 15:06:58 2018 New Revision: 341497 URL: http://llvm.org/viewvc/llvm-project?rev=341497&view=rev Log: Set Windows console mode to enable support for ansi escape codes Summary: Windows console now supports supports ANSI escape codes, but we need to enable it using SetConsoleMode with ENABLE_VIRTUAL_TERMINAL_PROCESSING flag. https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences. Syntax hightlighting now works fine on Windows: https://i.imgur.com/P0i04A7.png Reviewers: JDevlieghere, teemperor, zturner Reviewed By: zturner Subscribers: abidh, lldb-commits Differential Revision: https://reviews.llvm.org/D51615 Modified: lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=341497&r1=341496&r2=341497&view=diff == --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Wed Sep 5 15:06:58 2018 @@ -50,6 +50,7 @@ #if defined(_WIN32) #include "lldb/Host/windows/PosixApi.h" // for PATH_MAX +#include "lldb/Host/windows/windows.h" #endif #include "llvm/ADT/None.h" // for None @@ -58,6 +59,7 @@ #include "llvm/ADT/iterator.h" // for iterator_facade_... #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/Process.h" #include "llvm/Support/Threading.h" #include "llvm/Support/raw_ostream.h" // for raw_fd_ostream @@ -804,6 +806,13 @@ Debugger::Debugger(lldb::LogOutputCallba // Turn off use-color if we don't write to a terminal with color support. if (!m_output_file_sp->GetFile().GetIsTerminalWithColors()) SetUseColor(false); + +#if defined(_WIN32) && defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) + // Enabling use of ANSI color codes because LLDB is using them to highlight + // text. + llvm::sys::Process::UseANSIEscapeCodes(true); + SetUseColor(true); +#endif } Debugger::~Debugger() { Clear(); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r345755 - [NFC] Fixed -Wsign-compare warning
Author: xbolva00 Date: Wed Oct 31 11:03:36 2018 New Revision: 345755 URL: http://llvm.org/viewvc/llvm-project?rev=345755&view=rev Log: [NFC] Fixed -Wsign-compare warning Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=345755&r1=345754&r2=345755&view=diff == --- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Wed Oct 31 11:03:36 2018 @@ -1547,7 +1547,7 @@ lldb::ValueObjectListSP ScriptInterprete if (py_return.get()) { PythonList result_list(PyRefType::Borrowed, py_return.get()); ValueObjectListSP result = ValueObjectListSP(new ValueObjectList()); -for (int i = 0; i < result_list.GetSize(); i++) { +for (size_t i = 0; i < result_list.GetSize(); i++) { PyObject *item = result_list.GetItemAtIndex(i).get(); lldb::SBValue *sb_value_ptr = (lldb::SBValue *)g_swig_cast_to_sbvalue(item); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits