[Lldb-commits] [lldb] r305779 - Remove home-grown thread-local storage wrappers
Author: labath Date: Tue Jun 20 03:11:43 2017 New Revision: 305779 URL: http://llvm.org/viewvc/llvm-project?rev=305779&view=rev Log: Remove home-grown thread-local storage wrappers Summary: Use c++11 thread_local variables instead. As far as I am aware, they are supported by all compilers/targets we care about. Reviewers: zturner, jingham Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D34274 Modified: lldb/trunk/include/lldb/Host/Host.h lldb/trunk/source/Core/Timer.cpp lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Host/windows/Host.cpp Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=305779&r1=305778&r2=305779&view=diff == --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Tue Jun 20 03:11:43 2017 @@ -132,15 +132,6 @@ public: static const char *GetSignalAsCString(int signo); - typedef void (*ThreadLocalStorageCleanupCallback)(void *p); - - static lldb::thread_key_t - ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback); - - static void *ThreadLocalStorageGet(lldb::thread_key_t key); - - static void ThreadLocalStorageSet(lldb::thread_key_t key, void *value); - //-- /// Given an address in the current process (the process that /// is running the LLDB code), return the name of the module that Modified: lldb/trunk/source/Core/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Timer.cpp?rev=305779&r1=305778&r2=305779&view=diff == --- lldb/trunk/source/Core/Timer.cpp (original) +++ lldb/trunk/source/Core/Timer.cpp Tue Jun 20 03:11:43 2017 @@ -38,20 +38,9 @@ static std::mutex &GetFileMutex() { return *g_file_mutex_ptr; } -static void ThreadSpecificCleanup(void *p) { - delete static_cast(p); -} - -static TimerStack *GetTimerStackForCurrentThread() { - static lldb::thread_key_t g_key = - Host::ThreadLocalStorageCreate(ThreadSpecificCleanup); - - void *timer_stack = Host::ThreadLocalStorageGet(g_key); - if (timer_stack == NULL) { -Host::ThreadLocalStorageSet(g_key, new TimerStack); -timer_stack = Host::ThreadLocalStorageGet(g_key); - } - return (TimerStack *)timer_stack; +static TimerStack &GetTimerStackForCurrentThread() { + static thread_local TimerStack g_stack; + return g_stack; } Timer::Category::Category(const char *cat) : m_name(cat) { @@ -66,16 +55,14 @@ void Timer::SetQuiet(bool value) { g_qui Timer::Timer(Timer::Category &category, const char *format, ...) : m_category(category), m_total_start(std::chrono::steady_clock::now()) { - TimerStack *stack = GetTimerStackForCurrentThread(); - if (!stack) -return; + TimerStack &stack = GetTimerStackForCurrentThread(); - stack->push_back(this); - if (g_quiet && stack->size() <= g_display_depth) { + stack.push_back(this); + if (g_quiet && stack.size() <= g_display_depth) { std::lock_guard lock(GetFileMutex()); // Indent -::fprintf(stdout, "%*s", int(stack->size() - 1) * TIMER_INDENT_AMOUNT, ""); +::fprintf(stdout, "%*s", int(stack.size() - 1) * TIMER_INDENT_AMOUNT, ""); // Print formatted string va_list args; va_start(args, format); @@ -90,26 +77,23 @@ Timer::Timer(Timer::Category &category, Timer::~Timer() { using namespace std::chrono; - TimerStack *stack = GetTimerStackForCurrentThread(); - if (!stack) -return; - auto stop_time = steady_clock::now(); auto total_dur = stop_time - m_total_start; auto timer_dur = total_dur - m_child_duration; - if (g_quiet && stack->size() <= g_display_depth) { + TimerStack &stack = GetTimerStackForCurrentThread(); + if (g_quiet && stack.size() <= g_display_depth) { std::lock_guard lock(GetFileMutex()); ::fprintf(stdout, "%*s%.9f sec (%.9f sec)\n", - int(stack->size() - 1) * TIMER_INDENT_AMOUNT, "", + int(stack.size() - 1) * TIMER_INDENT_AMOUNT, "", duration(total_dur).count(), duration(timer_dur).count()); } - assert(stack->back() == this); - stack->pop_back(); - if (!stack->empty()) -stack->back()->ChildDuration(total_dur); + assert(stack.back() == this); + stack.pop_back(); + if (!stack.empty()) +stack.back()->ChildDuration(total_dur); // Keep total results for each category so we can dump results. m_category.m_nanos += std::chrono::nanoseconds(timer_dur).count(); Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=305779&r1=305778&r2=305779&view=diff == --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/s
[Lldb-commits] [lldb] r305778 - ProcessLauncherPosixFork: Fetch errno early
Author: labath Date: Tue Jun 20 03:11:37 2017 New Revision: 305778 URL: http://llvm.org/viewvc/llvm-project?rev=305778&view=rev Log: ProcessLauncherPosixFork: Fetch errno early I was seeing some unlikely errno values here. I am not sure if this will help, but it nontheless seems like a good idea to stash errno value before issuing other syscalls. Modified: lldb/trunk/source/Host/posix/ProcessLauncherPosixFork.cpp Modified: lldb/trunk/source/Host/posix/ProcessLauncherPosixFork.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/ProcessLauncherPosixFork.cpp?rev=305778&r1=305777&r2=305778&view=diff == --- lldb/trunk/source/Host/posix/ProcessLauncherPosixFork.cpp (original) +++ lldb/trunk/source/Host/posix/ProcessLauncherPosixFork.cpp Tue Jun 20 03:11:37 2017 @@ -52,10 +52,10 @@ static void FixupEnvironment(Args &env) static void LLVM_ATTRIBUTE_NORETURN ExitWithError(int error_fd, const char *operation) { - std::ostringstream os; - os << operation << " failed: " << strerror(errno); - write(error_fd, os.str().data(), os.str().size()); - close(error_fd); + int err = errno; + llvm::raw_fd_ostream os(error_fd, true); + os << operation << " failed: " << llvm::sys::StrError(err); + os.flush(); _exit(1); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r305780 - [linux] Change the way we load vdso pseudo-module
Author: labath Date: Tue Jun 20 03:11:47 2017 New Revision: 305780 URL: http://llvm.org/viewvc/llvm-project?rev=305780&view=rev Log: [linux] Change the way we load vdso pseudo-module Summary: This is basically a revert of D16107 and parts of D10800, which were trying to get vdso loading working. They did this by implementing a generic load-an-elf-file from memory approach, which is not correct, since we cannot assume that an elf file is loaded in memory in full (it usually isn't, as there's no need to load section headers for example). This meant that we would read garbage instead of section sizes, and if that garbage happened to be a large number, we would crash while trying to allocate a buffer to accomodate the hypothetical section. Instead of this, I add a bit of custom code to load the vdso to DynamicLoaderPOSIXDYLD (which already needed to handle the vdso specially). I determine the size of the memory to read using Process::GetMemoryRegionInfo, which is information coming from the OS, and cannot be forged by a malicious/misbehaving application. Reviewers: eugene, clayborg Subscribers: lldb-commits, ravitheja, tberghammer, emaste Differential Revision: https://reviews.llvm.org/D34352 Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp?rev=305780&r1=305779&r2=305780&view=diff == --- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp Tue Jun 20 03:11:47 2017 @@ -21,6 +21,7 @@ #include "lldb/Core/Section.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" @@ -484,6 +485,27 @@ DynamicLoaderPOSIXDYLD::GetStepThroughTr return thread_plan_sp; } +void DynamicLoaderPOSIXDYLD::LoadVDSO(ModuleList &modules) { + if (m_vdso_base == LLDB_INVALID_ADDRESS) +return; + + FileSpec file("[vdso]", false); + + MemoryRegionInfo info; + Status status = m_process->GetMemoryRegionInfo(m_vdso_base, info); + if (status.Fail()) { +Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); +LLDB_LOG(log, "Failed to get vdso region info: {0}", status); +return; + } + + if (ModuleSP module_sp = m_process->ReadModuleFromMemory( + file, m_vdso_base, info.GetRange().GetByteSize())) { +UpdateLoadedSections(module_sp, LLDB_INVALID_ADDRESS, m_vdso_base, false); +m_process->GetTarget().GetImages().AppendIfNeeded(module_sp); + } +} + void DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() { DYLDRendezvous::iterator I; DYLDRendezvous::iterator E; @@ -502,14 +524,7 @@ void DynamicLoaderPOSIXDYLD::LoadAllCurr // that ourselves here. ModuleSP executable = GetTargetExecutable(); m_loaded_modules[executable] = m_rendezvous.GetLinkMapAddress(); - if (m_vdso_base != LLDB_INVALID_ADDRESS) { -FileSpec file_spec("[vdso]", false); -ModuleSP module_sp = LoadModuleAtAddress(file_spec, LLDB_INVALID_ADDRESS, - m_vdso_base, false); -if (module_sp.get()) { - module_list.Append(module_sp); -} - } + LoadVDSO(module_list); std::vector module_names; for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h?rev=305780&r1=305779&r2=305780&view=diff == --- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h Tue Jun 20 03:11:47 2017 @@ -17,11 +17,11 @@ // Other libraries and framework includes // Project includes +#include "DYLDRendezvous.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" +#include "lldb/Core/ModuleList.h" #include "lldb/Target/DynamicLoader.h" -#include "DYLDRendezvous.h" - class AuxVector; class DynamicLoaderPOSIXDYLD : public lldb_private::DynamicLoader { @@ -138,6 +138,8 @@ protected: /// of all dependent modules. virtual void LoadAllCurrentModules(); + void LoadVDSO(lldb_private::ModuleList &modules); + /// Computes a value for m_load_offset returning the compu
[Lldb-commits] [PATCH] D34274: Remove home-grown thread-local storage wrappers
This revision was automatically updated to reflect the committed changes. Closed by commit rL305779: Remove home-grown thread-local storage wrappers (authored by labath). Changed prior to commit: https://reviews.llvm.org/D34274?vs=102810&id=103169#toc Repository: rL LLVM https://reviews.llvm.org/D34274 Files: lldb/trunk/include/lldb/Host/Host.h lldb/trunk/source/Core/Timer.cpp lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Host/windows/Host.cpp Index: lldb/trunk/source/Host/windows/Host.cpp === --- lldb/trunk/source/Host/windows/Host.cpp +++ lldb/trunk/source/Host/windows/Host.cpp @@ -101,19 +101,6 @@ return lldb::thread_t(::GetCurrentThread()); } -lldb::thread_key_t -Host::ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback) { - return TlsAlloc(); -} - -void *Host::ThreadLocalStorageGet(lldb::thread_key_t key) { - return ::TlsGetValue(key); -} - -void Host::ThreadLocalStorageSet(lldb::thread_key_t key, void *value) { - ::TlsSetValue(key, value); -} - void Host::Kill(lldb::pid_t pid, int signo) { TerminateProcess((HANDLE)pid, 1); } Index: lldb/trunk/source/Host/common/Host.cpp === --- lldb/trunk/source/Host/common/Host.cpp +++ lldb/trunk/source/Host/common/Host.cpp @@ -406,25 +406,6 @@ #endif -#ifndef _WIN32 - -lldb::thread_key_t -Host::ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback) { - pthread_key_t key; - ::pthread_key_create(&key, callback); - return key; -} - -void *Host::ThreadLocalStorageGet(lldb::thread_key_t key) { - return ::pthread_getspecific(key); -} - -void Host::ThreadLocalStorageSet(lldb::thread_key_t key, void *value) { - ::pthread_setspecific(key, value); -} - -#endif - #if !defined(__APPLE__) // see Host.mm bool Host::GetBundleDirectory(const FileSpec &file, FileSpec &bundle) { Index: lldb/trunk/source/Core/Timer.cpp === --- lldb/trunk/source/Core/Timer.cpp +++ lldb/trunk/source/Core/Timer.cpp @@ -38,20 +38,9 @@ return *g_file_mutex_ptr; } -static void ThreadSpecificCleanup(void *p) { - delete static_cast(p); -} - -static TimerStack *GetTimerStackForCurrentThread() { - static lldb::thread_key_t g_key = - Host::ThreadLocalStorageCreate(ThreadSpecificCleanup); - - void *timer_stack = Host::ThreadLocalStorageGet(g_key); - if (timer_stack == NULL) { -Host::ThreadLocalStorageSet(g_key, new TimerStack); -timer_stack = Host::ThreadLocalStorageGet(g_key); - } - return (TimerStack *)timer_stack; +static TimerStack &GetTimerStackForCurrentThread() { + static thread_local TimerStack g_stack; + return g_stack; } Timer::Category::Category(const char *cat) : m_name(cat) { @@ -66,16 +55,14 @@ Timer::Timer(Timer::Category &category, const char *format, ...) : m_category(category), m_total_start(std::chrono::steady_clock::now()) { - TimerStack *stack = GetTimerStackForCurrentThread(); - if (!stack) -return; + TimerStack &stack = GetTimerStackForCurrentThread(); - stack->push_back(this); - if (g_quiet && stack->size() <= g_display_depth) { + stack.push_back(this); + if (g_quiet && stack.size() <= g_display_depth) { std::lock_guard lock(GetFileMutex()); // Indent -::fprintf(stdout, "%*s", int(stack->size() - 1) * TIMER_INDENT_AMOUNT, ""); +::fprintf(stdout, "%*s", int(stack.size() - 1) * TIMER_INDENT_AMOUNT, ""); // Print formatted string va_list args; va_start(args, format); @@ -90,26 +77,23 @@ Timer::~Timer() { using namespace std::chrono; - TimerStack *stack = GetTimerStackForCurrentThread(); - if (!stack) -return; - auto stop_time = steady_clock::now(); auto total_dur = stop_time - m_total_start; auto timer_dur = total_dur - m_child_duration; - if (g_quiet && stack->size() <= g_display_depth) { + TimerStack &stack = GetTimerStackForCurrentThread(); + if (g_quiet && stack.size() <= g_display_depth) { std::lock_guard lock(GetFileMutex()); ::fprintf(stdout, "%*s%.9f sec (%.9f sec)\n", - int(stack->size() - 1) * TIMER_INDENT_AMOUNT, "", + int(stack.size() - 1) * TIMER_INDENT_AMOUNT, "", duration(total_dur).count(), duration(timer_dur).count()); } - assert(stack->back() == this); - stack->pop_back(); - if (!stack->empty()) -stack->back()->ChildDuration(total_dur); + assert(stack.back() == this); + stack.pop_back(); + if (!stack.empty()) +stack.back()->ChildDuration(total_dur); // Keep total results for each category so we can dump results. m_category.m_nanos += std::chrono::nanoseconds(timer_dur).count(); Index: lldb/trunk/include/lldb/Host/Host.h === --- lldb/trunk/include/lldb/Host/Host.h +++ lldb/trunk/include/lldb/Host/Host.h @@ -132,15 +132,6 @@ static
[Lldb-commits] [PATCH] D34352: [linux] Change the way we load vdso pseudo-module
This revision was automatically updated to reflect the committed changes. Closed by commit rL305780: [linux] Change the way we load vdso pseudo-module (authored by labath). Changed prior to commit: https://reviews.llvm.org/D34352?vs=103045&id=103170#toc Repository: rL LLVM https://reviews.llvm.org/D34352 Files: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h Index: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h === --- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h +++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h @@ -17,11 +17,11 @@ // Other libraries and framework includes // Project includes +#include "DYLDRendezvous.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" +#include "lldb/Core/ModuleList.h" #include "lldb/Target/DynamicLoader.h" -#include "DYLDRendezvous.h" - class AuxVector; class DynamicLoaderPOSIXDYLD : public lldb_private::DynamicLoader { @@ -138,6 +138,8 @@ /// of all dependent modules. virtual void LoadAllCurrentModules(); + void LoadVDSO(lldb_private::ModuleList &modules); + /// Computes a value for m_load_offset returning the computed address on /// success and LLDB_INVALID_ADDRESS on failure. lldb::addr_t ComputeLoadOffset(); Index: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp === --- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -21,6 +21,7 @@ #include "lldb/Core/Section.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" @@ -484,6 +485,27 @@ return thread_plan_sp; } +void DynamicLoaderPOSIXDYLD::LoadVDSO(ModuleList &modules) { + if (m_vdso_base == LLDB_INVALID_ADDRESS) +return; + + FileSpec file("[vdso]", false); + + MemoryRegionInfo info; + Status status = m_process->GetMemoryRegionInfo(m_vdso_base, info); + if (status.Fail()) { +Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); +LLDB_LOG(log, "Failed to get vdso region info: {0}", status); +return; + } + + if (ModuleSP module_sp = m_process->ReadModuleFromMemory( + file, m_vdso_base, info.GetRange().GetByteSize())) { +UpdateLoadedSections(module_sp, LLDB_INVALID_ADDRESS, m_vdso_base, false); +m_process->GetTarget().GetImages().AppendIfNeeded(module_sp); + } +} + void DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() { DYLDRendezvous::iterator I; DYLDRendezvous::iterator E; @@ -502,14 +524,7 @@ // that ourselves here. ModuleSP executable = GetTargetExecutable(); m_loaded_modules[executable] = m_rendezvous.GetLinkMapAddress(); - if (m_vdso_base != LLDB_INVALID_ADDRESS) { -FileSpec file_spec("[vdso]", false); -ModuleSP module_sp = LoadModuleAtAddress(file_spec, LLDB_INVALID_ADDRESS, - m_vdso_base, false); -if (module_sp.get()) { - module_list.Append(module_sp); -} - } + LoadVDSO(module_list); std::vector module_names; for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) Index: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h === --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h @@ -14,7 +14,6 @@ #include // C++ Includes -#include #include // Other libraries and framework includes @@ -182,9 +181,6 @@ typedef std::map FileAddressToAddressClassMap; - typedef std::function - SetDataFunction; /// Version of this reader common to all plugins based on this class. static const uint32_t m_plugin_version = 1; @@ -230,7 +226,7 @@ // Parses the ELF program headers. static size_t GetProgramHeaderInfo(ProgramHeaderColl &program_headers, - const SetDataFunction &set_data, + lldb_private::DataExtractor &object_data, const elf::ELFHeader &header); // Finds PT_NOTE segments and calculates their crc sum. @@ -255,7 +251,7 @@ /// Parses the elf section headers and returns the uuid, debug link name, crc, /// archspec. static size_t GetSectionHeaderInfo(SectionHeaderColl §ion_headers, - const SetDataFunction &set_data, +
[Lldb-commits] [lldb] r305789 - Delete a lot of empty directories in test/
Author: labath Date: Tue Jun 20 06:23:36 2017 New Revision: 305789 URL: http://llvm.org/viewvc/llvm-project?rev=305789&view=rev Log: Delete a lot of empty directories in test/ The files in those directories have been moved to packages/Python/lldbsuite/test quite a while ago. However, the directories themselves remained, probably because the move was done using git, and git does not track directories. Checking out the repository with svn shows that the directories were still there. Removed: lldb/trunk/test/android/ lldb/trunk/test/api/ lldb/trunk/test/arm_emulation/ lldb/trunk/test/attic/ lldb/trunk/test/benchmarks/ lldb/trunk/test/c++/ lldb/trunk/test/driver/ lldb/trunk/test/example/ lldb/trunk/test/expression_command/ lldb/trunk/test/functionalities/ lldb/trunk/test/help/ lldb/trunk/test/lang/ lldb/trunk/test/linux/ lldb/trunk/test/logging/ lldb/trunk/test/macosx/ lldb/trunk/test/make/ lldb/trunk/test/pexpect-2.4/ lldb/trunk/test/plugins/ lldb/trunk/test/python_api/ lldb/trunk/test/settings/ lldb/trunk/test/source-manager/ lldb/trunk/test/terminal/ lldb/trunk/test/tools/ lldb/trunk/test/types/ lldb/trunk/test/unittest2/ lldb/trunk/test/warnings/ ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D34400: Move Connection from Core to Host
labath created this revision. Herald added a subscriber: mgorny. All implementations of the connection interface live in the Host module already, so it makes sense for the interface itself to be defined there. https://reviews.llvm.org/D34400 Files: include/lldb/Core/Connection.h include/lldb/Host/Connection.h include/lldb/Host/posix/ConnectionFileDescriptorPosix.h include/lldb/Host/windows/ConnectionGenericFileWindows.h source/Core/CMakeLists.txt source/Core/Communication.cpp source/Core/Connection.cpp source/Host/CMakeLists.txt source/Host/common/Connection.cpp source/Host/posix/ConnectionFileDescriptorPosix.cpp tools/lldb-server/Acceptor.h Index: tools/lldb-server/Acceptor.h === --- tools/lldb-server/Acceptor.h +++ tools/lldb-server/Acceptor.h @@ -9,7 +9,7 @@ #ifndef lldb_server_Acceptor_h_ #define lldb_server_Acceptor_h_ -#include "lldb/Core/Connection.h" +#include "lldb/Host/Connection.h" #include "lldb/Host/Socket.h" #include "lldb/Utility/Status.h" Index: source/Host/posix/ConnectionFileDescriptorPosix.cpp === --- source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -20,6 +20,7 @@ #include "lldb/Host/Socket.h" #include "lldb/Host/SocketAddress.h" #include "lldb/Utility/SelectHelper.h" +#include "lldb/Utility/Timeout.h" // C Includes #include @@ -42,7 +43,6 @@ #include "llvm/ADT/SmallVector.h" #endif // Project includes -#include "lldb/Core/Communication.h" #include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Host/Socket.h" Index: source/Host/common/Connection.cpp === --- source/Host/common/Connection.cpp +++ source/Host/common/Connection.cpp @@ -7,7 +7,7 @@ // //===--===// -#include "lldb/Core/Connection.h" +#include "lldb/Host/Connection.h" #if defined(_WIN32) #include "lldb/Host/windows/ConnectionGenericFileWindows.h" Index: source/Host/CMakeLists.txt === --- source/Host/CMakeLists.txt +++ source/Host/CMakeLists.txt @@ -4,6 +4,7 @@ endmacro() add_host_subdirectory(common + common/Connection.cpp common/File.cpp common/FileCache.cpp common/FileSystem.cpp Index: source/Core/Communication.cpp === --- source/Core/Communication.cpp +++ source/Core/Communication.cpp @@ -9,9 +9,9 @@ #include "lldb/Core/Communication.h" -#include "lldb/Core/Connection.h" #include "lldb/Core/Event.h" #include "lldb/Core/Listener.h" +#include "lldb/Host/Connection.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Utility/ConstString.h" // for ConstString Index: source/Core/CMakeLists.txt === --- source/Core/CMakeLists.txt +++ source/Core/CMakeLists.txt @@ -7,7 +7,6 @@ ArchSpec.cpp Broadcaster.cpp Communication.cpp - Connection.cpp Debugger.cpp Disassembler.cpp DumpDataExtractor.cpp Index: include/lldb/Host/windows/ConnectionGenericFileWindows.h === --- include/lldb/Host/windows/ConnectionGenericFileWindows.h +++ include/lldb/Host/windows/ConnectionGenericFileWindows.h @@ -10,7 +10,7 @@ #ifndef liblldb_Host_windows_ConnectionGenericFileWindows_h_ #define liblldb_Host_windows_ConnectionGenericFileWindows_h_ -#include "lldb/Core/Connection.h" +#include "lldb/Host/Connection.h" #include "lldb/Host/windows/windows.h" #include "lldb/lldb-types.h" Index: include/lldb/Host/posix/ConnectionFileDescriptorPosix.h === --- include/lldb/Host/posix/ConnectionFileDescriptorPosix.h +++ include/lldb/Host/posix/ConnectionFileDescriptorPosix.h @@ -19,7 +19,7 @@ // Other libraries and framework includes // Project includes -#include "lldb/Core/Connection.h" +#include "lldb/Host/Connection.h" #include "lldb/Host/IOObject.h" #include "lldb/Host/Pipe.h" #include "lldb/Host/Predicate.h" Index: include/lldb/Host/Connection.h === --- include/lldb/Host/Connection.h +++ include/lldb/Host/Connection.h @@ -31,7 +31,7 @@ namespace lldb_private { //-- -/// @class Connection Connection.h "lldb/Core/Connection.h" +/// @class Connection Connection.h "lldb/Host/Connection.h" /// @brief A communication connection class. /// /// A class that implements that actual communication functions for ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/li
Re: [Lldb-commits] [PATCH] D34400: Move Connection from Core to Host
I had actually been considering going the other way. Moving connection and all implementations to Utility. Host is a big contributor to the dependency problems, so putting more stuff in seems like the wrong direction. The end state i had in mind was similar to llvm support (which is more less the equivalent of lldb host), where it has all the host specific functionality but contains no deps. With that in mind, thoughts on moving everything to Utility? On Tue, Jun 20, 2017 at 5:56 AM Pavel Labath via Phabricator < revi...@reviews.llvm.org> wrote: > labath created this revision. > Herald added a subscriber: mgorny. > > All implementations of the connection interface live in the Host module > already, so it makes sense for the interface itself to be defined there. > > > https://reviews.llvm.org/D34400 > > Files: > include/lldb/Core/Connection.h > include/lldb/Host/Connection.h > include/lldb/Host/posix/ConnectionFileDescriptorPosix.h > include/lldb/Host/windows/ConnectionGenericFileWindows.h > source/Core/CMakeLists.txt > source/Core/Communication.cpp > source/Core/Connection.cpp > source/Host/CMakeLists.txt > source/Host/common/Connection.cpp > source/Host/posix/ConnectionFileDescriptorPosix.cpp > tools/lldb-server/Acceptor.h > > ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r305794 - Correct syntax mistake hidden in assert(3)
Author: kamil Date: Tue Jun 20 08:51:06 2017 New Revision: 305794 URL: http://llvm.org/viewvc/llvm-project?rev=305794&view=rev Log: Correct syntax mistake hidden in assert(3) wait_status cannot be compared with WaitStatus::Stop, go for wait_status.type. Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp?rev=305794&r1=305793&r2=305794&view=diff == --- lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp (original) +++ lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp Tue Jun 20 08:51:06 2017 @@ -845,7 +845,7 @@ void NativeProcessNetBSD::SigchldHandler if (exited) MonitorExited(wait_pid, wait_status); else { -assert(wait_status == WaitStatus::Stop); +assert(wait_status.type == WaitStatus::Stop); MonitorCallback(wait_pid, wait_status.status); } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D34400: Move Connection from Core to Host
On 20 June 2017 at 14:28, Zachary Turner wrote: > I had actually been considering going the other way. Moving connection and > all implementations to Utility. Host is a big contributor to the dependency > problems, so putting more stuff in seems like the wrong direction. Well, I'd say that Core is an even bigger contributor to the cycles than Host (e.g. it has Timer.cpp, which depends on nothing, and Debugger.cpp, which depends on everything). With this, I was looking at breaking the Host->Core dependency. After this patch the only Core files which are included from Host are: Core/ArchSpec.h Core/Communication.h Core/Module.h Core/ModuleSpec.h Core/RegisterValue.h Core/State.h Core/StreamFile.h Core/StructuredData.h Core/Timer.h Core/TraceOptions.h Of these, only the Module dependency worries me (but I haven't yet looked at why exactly it's needed) -- I believe all the others can be solved fairly easily by moving the relevant files to Host or Utility. > > The end state i had in mind was similar to llvm support (which is more less > the equivalent of lldb host), where it has all the host specific > functionality but contains no deps. > > With that in mind, thoughts on moving everything to Utility? I am not categorically against it, but it's not my preferred solution either. For example, if we were to move Connection there now, it would require at least moving all of the socket library and pipes which is a large chunk of host-specific code. I like how currently we have this separation where Utility contains some fairly generic classes and algorithms, and Host contains things for interfacing with the host system (which tends to be ugly and full of ifdefs -- I'd like to avoid ifdefs in Utlity if at all possible). I realize it's possible I may run into a wall with this philosophy, but I'd like to try and give it a go. I think the fact that we have the llvm support library under us, where we can hide a lot of the non-debugger-specific host code, means that there is a fair chance this could succeed. > > On Tue, Jun 20, 2017 at 5:56 AM Pavel Labath via Phabricator > wrote: >> >> labath created this revision. >> Herald added a subscriber: mgorny. >> >> All implementations of the connection interface live in the Host module >> already, so it makes sense for the interface itself to be defined there. >> >> >> https://reviews.llvm.org/D34400 >> >> Files: >> include/lldb/Core/Connection.h >> include/lldb/Host/Connection.h >> include/lldb/Host/posix/ConnectionFileDescriptorPosix.h >> include/lldb/Host/windows/ConnectionGenericFileWindows.h >> source/Core/CMakeLists.txt >> source/Core/Communication.cpp >> source/Core/Connection.cpp >> source/Host/CMakeLists.txt >> source/Host/common/Connection.cpp >> source/Host/posix/ConnectionFileDescriptorPosix.cpp >> tools/lldb-server/Acceptor.h >> > ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D34400: Move Connection from Core to Host
I do think at some point we will need to break up Host, but whether the best way is to move stuff into Utility or to somewhere else is an open question. Host also depends on Target, Symbol, process plugins, and various other things. So we will need a way to group together all the stuff in Host that has no other dependencies. This could then remove the dependency from X -> Host for many values of X. I agree that Core is bigger, but unfortunately with deps it's kind of all or nothing. You don't see any benefit from removing 99 if there's still 1 more. If you don't want to do it now that's fine as it does indeed require moving many other things, but moving it to Host seems like a lateral move at best - nothing gained nothing lost. What about moving the base class to Utility? At least then you wouldn't need to link Host to use Connection, which could encourage a factory-like pattern On Tue, Jun 20, 2017 at 7:00 AM Pavel Labath wrote: > On 20 June 2017 at 14:28, Zachary Turner wrote: > > I had actually been considering going the other way. Moving connection > and > > all implementations to Utility. Host is a big contributor to the > dependency > > problems, so putting more stuff in seems like the wrong direction. > > Well, I'd say that Core is an even bigger contributor to the cycles > than Host (e.g. it has Timer.cpp, which depends on nothing, and > Debugger.cpp, which depends on everything). With this, I was looking > at breaking the Host->Core dependency. After this patch the only Core > files which are included from Host are: > Core/ArchSpec.h > Core/Communication.h > Core/Module.h > Core/ModuleSpec.h > Core/RegisterValue.h > Core/State.h > Core/StreamFile.h > Core/StructuredData.h > Core/Timer.h > Core/TraceOptions.h > > Of these, only the Module dependency worries me (but I haven't yet > looked at why exactly it's needed) -- I believe all the others can be > solved fairly easily by moving the relevant files to Host or Utility. > > > > > > The end state i had in mind was similar to llvm support (which is more > less > > the equivalent of lldb host), where it has all the host specific > > functionality but contains no deps. > > > > With that in mind, thoughts on moving everything to Utility? > > I am not categorically against it, but it's not my preferred solution > either. For example, if we were to move Connection there now, it would > require at least moving all of the socket library and pipes which is a > large chunk of host-specific code. I like how currently we have this > separation where Utility contains some fairly generic classes and > algorithms, and Host contains things for interfacing with the host > system (which tends to be ugly and full of ifdefs -- I'd like to avoid > ifdefs in Utlity if at all possible). > > I realize it's possible I may run into a wall with this philosophy, > but I'd like to try and give it a go. I think the fact that we have > the llvm support library under us, where we can hide a lot of the > non-debugger-specific host code, means that there is a fair chance > this could succeed. > > > > > > On Tue, Jun 20, 2017 at 5:56 AM Pavel Labath via Phabricator > > wrote: > >> > >> labath created this revision. > >> Herald added a subscriber: mgorny. > >> > >> All implementations of the connection interface live in the Host module > >> already, so it makes sense for the interface itself to be defined there. > >> > >> > >> https://reviews.llvm.org/D34400 > >> > >> Files: > >> include/lldb/Core/Connection.h > >> include/lldb/Host/Connection.h > >> include/lldb/Host/posix/ConnectionFileDescriptorPosix.h > >> include/lldb/Host/windows/ConnectionGenericFileWindows.h > >> source/Core/CMakeLists.txt > >> source/Core/Communication.cpp > >> source/Core/Connection.cpp > >> source/Host/CMakeLists.txt > >> source/Host/common/Connection.cpp > >> source/Host/posix/ConnectionFileDescriptorPosix.cpp > >> tools/lldb-server/Acceptor.h > >> > > > ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D34400: Move Connection from Core to Host
On 20 June 2017 at 16:47, Zachary Turner wrote: > I do think at some point we will need to break up Host, but whether the best > way is to move stuff into Utility or to somewhere else is an open question. > Host also depends on Target, Symbol, process plugins, and various other > things. So we will need a way to group together all the stuff in Host that > has no other dependencies. This could then remove the dependency from X -> > Host for many values of X. The process plugin dependency has already been removed. The current list I see is: Core, Interpreter, Symbol, Target, ScriptInterpreterPython. It's a fair number of things but it's not too many. > > I agree that Core is bigger, but unfortunately with deps it's kind of all or > nothing. You don't see any benefit from removing 99 if there's still 1 more. Yes, that's true. My intention is to slowly go through them and remove all 100 of them. I'm not saying it will be done quickly, and I don't even have much time to dedicate to that, but I can eventually get there. > > If you don't want to do it now that's fine as it does indeed require moving > many other things, but moving it to Host seems like a lateral move at best - > nothing gained nothing lost. What about moving the base class to Utility? At > least then you wouldn't need to link Host to use Connection, which could > encourage a factory-like pattern Yes, it does not bring us anything right now. But after I remove all of the Host->Core dependencies, I can remove the direct edge from the dependency graph, which I think *is* something. We will still have an indirect edge through one of the other modules, but it decreases the scope of the problem (density of the graph). As for the "moving the base class to Utility" idea, I had considered that already. Eventually, I decided I prefer keeping it in Host, close to the other classes, but it's a weak preference. I'd like to hear what others think about this. ? ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r305873 - Fix a python object leak in SWIG glue.
Author: zturner Date: Tue Jun 20 20:52:37 2017 New Revision: 305873 URL: http://llvm.org/viewvc/llvm-project?rev=305873&view=rev Log: Fix a python object leak in SWIG glue. PyObject_CallFunction returns a PyObject which needs to be decref'ed when it is no longer needed. Patch by David Luyer Differential Revision: https://reviews.llvm.org/D33740 Modified: lldb/trunk/scripts/Python/python-wrapper.swig Modified: lldb/trunk/scripts/Python/python-wrapper.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=305873&r1=305872&r2=305873&view=diff == --- lldb/trunk/scripts/Python/python-wrapper.swig (original) +++ lldb/trunk/scripts/Python/python-wrapper.swig Tue Jun 20 20:52:37 2017 @@ -929,7 +929,8 @@ void LLDBSwigPythonCallPythonLogOutputCa void LLDBSwigPythonCallPythonLogOutputCallback(const char *str, void *baton) { if (baton != Py_None) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyObject_CallFunction(reinterpret_cast(baton), const_cast("s"), str); + PyObject *result = PyObject_CallFunction(reinterpret_cast(baton), const_cast("s"), str); + Py_XDECREF(result); SWIG_PYTHON_THREAD_END_BLOCK; } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits