[Lldb-commits] [PATCH] D32522: Test case for the issue raised in D32271
vbalu created this revision. Adding test case to test the scenario in https://reviews.llvm.org/D3 Repository: rL LLVM https://reviews.llvm.org/D32522 Files: packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py packages/Python/lldbsuite/test/lldbtest.py Index: packages/Python/lldbsuite/test/lldbtest.py === --- packages/Python/lldbsuite/test/lldbtest.py +++ packages/Python/lldbsuite/test/lldbtest.py @@ -1484,6 +1484,9 @@ """ Platform specific way to build an executable from C/C++ sources. """ d = {'CXX_SOURCES': sources, 'EXE': exe_name} +if not os.path.exists(os.path.dirname(exe_name)): +if os.path.dirname(exe_name): +os.mkdir(os.path.dirname(exe_name)) self.buildDefault(dictionary=d) def buildDefault( Index: packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py === --- packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py +++ packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py @@ -8,6 +8,7 @@ import os import time import lldb +import shutil from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil @@ -38,6 +39,23 @@ process = target.GetProcess() self.assertTrue(process, PROCESS_IS_VALID) + def test_attach_to_process_frm_different_dir_by_id(self): + """Test attach by process id""" +self.buildProgram('main.cpp','newdir/proc_attach') +exe = os.path.join(os.getcwd(), 'newdir/proc_attach') +self.addTearDownHook(lambda: shutil.rmtree(os.path.dirname(exe))) + +# Spawn a new process +popen = self.spawnSubprocess(exe) +self.addTearDownHook(self.cleanupSubprocesses) + +self.runCmd("process attach -p " + str(popen.pid)) + +target = self.dbg.GetSelectedTarget() + +process = target.GetProcess() +self.assertTrue(process, PROCESS_IS_VALID) + def test_attach_to_process_by_name(self): """Test attach by process name""" self.build() Index: packages/Python/lldbsuite/test/lldbtest.py === --- packages/Python/lldbsuite/test/lldbtest.py +++ packages/Python/lldbsuite/test/lldbtest.py @@ -1484,6 +1484,9 @@ """ Platform specific way to build an executable from C/C++ sources. """ d = {'CXX_SOURCES': sources, 'EXE': exe_name} +if not os.path.exists(os.path.dirname(exe_name)): +if os.path.dirname(exe_name): +os.mkdir(os.path.dirname(exe_name)) self.buildDefault(dictionary=d) def buildDefault( Index: packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py === --- packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py +++ packages/Python/lldbsuite/test/functionalities/process_attach/TestProcessAttach.py @@ -8,6 +8,7 @@ import os import time import lldb +import shutil from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil @@ -38,6 +39,23 @@ process = target.GetProcess() self.assertTrue(process, PROCESS_IS_VALID) + def test_attach_to_process_frm_different_dir_by_id(self): + """Test attach by process id""" +self.buildProgram('main.cpp','newdir/proc_attach') +exe = os.path.join(os.getcwd(), 'newdir/proc_attach') +self.addTearDownHook(lambda: shutil.rmtree(os.path.dirname(exe))) + +# Spawn a new process +popen = self.spawnSubprocess(exe) +self.addTearDownHook(self.cleanupSubprocesses) + +self.runCmd("process attach -p " + str(popen.pid)) + +target = self.dbg.GetSelectedTarget() + +process = target.GetProcess() +self.assertTrue(process, PROCESS_IS_VALID) + def test_attach_to_process_by_name(self): """Test attach by process name""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D29581: Initial implementation of SB APIs for Tracing support.
ravitheja updated this revision to Diff 96682. ravitheja added a comment. Fixing few header file inclusions. https://reviews.llvm.org/D29581 Files: include/lldb/API/LLDB.h include/lldb/API/SBDefines.h include/lldb/API/SBError.h include/lldb/API/SBProcess.h include/lldb/API/SBStructuredData.h include/lldb/API/SBTrace.h include/lldb/API/SBTraceOptions.h include/lldb/Core/StructuredDataImpl.h include/lldb/Core/TraceOptions.h include/lldb/Target/Process.h include/lldb/lldb-enumerations.h include/lldb/lldb-forward.h scripts/interface/SBProcess.i scripts/interface/SBStructuredData.i scripts/interface/SBTrace.i scripts/interface/SBTraceOptions.i scripts/lldb.swig source/API/CMakeLists.txt source/API/SBProcess.cpp source/API/SBStructuredData.cpp source/API/SBTrace.cpp source/API/SBTraceOptions.cpp Index: source/API/SBTraceOptions.cpp === --- /dev/null +++ source/API/SBTraceOptions.cpp @@ -0,0 +1,94 @@ +//===-- SBTraceOptions.cpp --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "lldb/API/SBTraceOptions.h" +#include "lldb/API/SBError.h" +#include "lldb/API/SBStructuredData.h" +#include "lldb/Utility/Log.h" +#include "lldb/Core/StructuredDataImpl.h" +#include "lldb/Core/TraceOptions.h" + +using namespace lldb; +using namespace lldb_private; + +SBTraceOptions::SBTraceOptions() { + m_traceoptions_sp.reset(new TraceOptions()); +} + +lldb::TraceType SBTraceOptions::getType() const { + if (m_traceoptions_sp) +return m_traceoptions_sp->getType(); + return lldb::TraceType::eTraceTypeNone; +} + +uint64_t SBTraceOptions::getTraceBufferSize() const { + if (m_traceoptions_sp) +return m_traceoptions_sp->getTraceBufferSize(); + return 0; +} + +lldb::SBStructuredData SBTraceOptions::getTraceParams(lldb::SBError &error) { + error.Clear(); + const lldb_private::StructuredData::DictionarySP dict_obj = + m_traceoptions_sp->getTraceParams(); + lldb::SBStructuredData structData; + if (dict_obj && structData.m_impl_up) +structData.m_impl_up->SetObjectSP(dict_obj->shared_from_this()); + else +error.SetErrorString("Empty trace params"); + return structData; +} + +uint64_t SBTraceOptions::getMetaDataBufferSize() const { + if (m_traceoptions_sp) +return m_traceoptions_sp->getTraceBufferSize(); + return 0; +} + +void SBTraceOptions::setTraceParams(lldb::SBStructuredData ¶ms) { + if (m_traceoptions_sp && params.m_impl_up) { +StructuredData::ObjectSP obj_sp = params.m_impl_up->GetObjectSP(); +if (obj_sp && obj_sp->GetAsDictionary() != nullptr) + m_traceoptions_sp->setTraceParams( + std::static_pointer_cast(obj_sp)); + } + return; +} + +void SBTraceOptions::setType(lldb::TraceType type) { + if (m_traceoptions_sp) +m_traceoptions_sp->setType(type); +} + +void SBTraceOptions::setTraceBufferSize(uint64_t size) { + if (m_traceoptions_sp) +m_traceoptions_sp->setTraceBufferSize(size); +} + +void SBTraceOptions::setMetaDataBufferSize(uint64_t size) { + if (m_traceoptions_sp) +m_traceoptions_sp->setMetaDataBufferSize(size); +} + +bool SBTraceOptions::IsValid() { + if (m_traceoptions_sp) +return true; + return false; +} + +void SBTraceOptions::setThreadID(lldb::tid_t thread_id) { + if (m_traceoptions_sp) +m_traceoptions_sp->setThreadID(thread_id); +} + +lldb::tid_t SBTraceOptions::getThreadID() { + if (m_traceoptions_sp) +return m_traceoptions_sp->getThreadID(); + return LLDB_INVALID_THREAD_ID; +} Index: source/API/SBTrace.cpp === --- /dev/null +++ source/API/SBTrace.cpp @@ -0,0 +1,109 @@ +//===-- SBTrace.cpp -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "lldb/Utility/Log.h" +#include "lldb/Target/Process.h" + +#include "lldb/API/SBTrace.h" +#include "lldb/API/SBTraceOptions.h" + +using namespace lldb; +using namespace lldb_private; + +class TraceImpl { +public: + lldb::user_id_t uid; +}; + +lldb::ProcessSP SBTrace::GetSP() const { return m_opaque_wp.lock(); } + +size_t SBTrace::GetTraceData(SBError &error, void *buf, size_t size, + size_t offset, lldb::tid_t thread_id) { + size_t bytes_read = 0; + ProcessSP process_sp(GetSP()); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + error.Clear(); + + if (!process_sp) { +error.SetErrorString("invalid process"); + } e
[Lldb-commits] [lldb] r301389 - Initial implementation of SB APIs for Tracing support.
Author: ravitheja Date: Wed Apr 26 03:48:50 2017 New Revision: 301389 URL: http://llvm.org/viewvc/llvm-project?rev=301389&view=rev Log: Initial implementation of SB APIs for Tracing support. Summary: This patch introduces new SB APIs for tracing support inside LLDB. The idea is to gather trace data from LLDB and provide it through this APIs to external tools integrating with LLDB. These tools will be responsible for interpreting and presenting the trace data to their users. The patch implements the following new SB APIs -> -> StartTrace - starts tracing with given parameters -> StopTrace - stops tracing. -> GetTraceData - read the trace data . -> GetMetaData - read the meta data assosciated with the trace. -> GetTraceConfig - read the trace configuration Tracing is associated with a user_id that is returned by the StartTrace API and this id needs to be used for accessing the trace data and also Stopping the trace. The user_id itself may map to tracing the complete process or just an individual thread. The APIs require an additional thread parameter when the user of these APIs wishes to perform thread specific manipulations on the tracing instances. The patch also includes the corresponding python wrappers for the C++ based APIs. Reviewers: k8stone, lldb-commits, clayborg Reviewed By: clayborg Subscribers: jingham, mgorny Differential Revision: https://reviews.llvm.org/D29581 Added: lldb/trunk/include/lldb/API/SBTrace.h lldb/trunk/include/lldb/API/SBTraceOptions.h lldb/trunk/include/lldb/Core/StructuredDataImpl.h lldb/trunk/include/lldb/Core/TraceOptions.h lldb/trunk/scripts/interface/SBTrace.i lldb/trunk/scripts/interface/SBTraceOptions.i lldb/trunk/source/API/SBTrace.cpp lldb/trunk/source/API/SBTraceOptions.cpp Modified: lldb/trunk/include/lldb/API/LLDB.h lldb/trunk/include/lldb/API/SBDefines.h lldb/trunk/include/lldb/API/SBError.h lldb/trunk/include/lldb/API/SBProcess.h lldb/trunk/include/lldb/API/SBStructuredData.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/scripts/interface/SBProcess.i lldb/trunk/scripts/interface/SBStructuredData.i lldb/trunk/scripts/lldb.swig lldb/trunk/source/API/CMakeLists.txt lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/API/SBStructuredData.cpp Modified: lldb/trunk/include/lldb/API/LLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/LLDB.h?rev=301389&r1=301388&r2=301389&view=diff == --- lldb/trunk/include/lldb/API/LLDB.h (original) +++ lldb/trunk/include/lldb/API/LLDB.h Wed Apr 26 03:48:50 2017 @@ -63,6 +63,8 @@ #include "lldb/API/SBThread.h" #include "lldb/API/SBThreadCollection.h" #include "lldb/API/SBThreadPlan.h" +#include "lldb/API/SBTrace.h" +#include "lldb/API/SBTraceOptions.h" #include "lldb/API/SBType.h" #include "lldb/API/SBTypeCategory.h" #include "lldb/API/SBTypeEnumMember.h" Modified: lldb/trunk/include/lldb/API/SBDefines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=301389&r1=301388&r2=301389&view=diff == --- lldb/trunk/include/lldb/API/SBDefines.h (original) +++ lldb/trunk/include/lldb/API/SBDefines.h Wed Apr 26 03:48:50 2017 @@ -79,6 +79,8 @@ class LLDB_API SBTarget; class LLDB_API SBThread; class LLDB_API SBThreadCollection; class LLDB_API SBThreadPlan; +class LLDB_API SBTrace; +class LLDB_API SBTraceOptions; class LLDB_API SBType; class LLDB_API SBTypeCategory; class LLDB_API SBTypeEnumMember; Modified: lldb/trunk/include/lldb/API/SBError.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBError.h?rev=301389&r1=301388&r2=301389&view=diff == --- lldb/trunk/include/lldb/API/SBError.h (original) +++ lldb/trunk/include/lldb/API/SBError.h Wed Apr 26 03:48:50 2017 @@ -61,6 +61,7 @@ protected: friend class SBProcess; friend class SBStructuredData; friend class SBThread; + friend class SBTrace; friend class SBTarget; friend class SBValue; friend class SBWatchpoint; Modified: lldb/trunk/include/lldb/API/SBProcess.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=301389&r1=301388&r2=301389&view=diff == --- lldb/trunk/include/lldb/API/SBProcess.h (original) +++ lldb/trunk/include/lldb/API/SBProcess.h Wed Apr 26 03:48:50 2017 @@ -234,6 +234,33 @@ public: bool GetDescription(lldb::SBStream &description); + //-- + /// Start Tracing with the given SBTraceOptions. + /// + /// @param[in] options + /// Class containing trace options like trace buffer
[Lldb-commits] [PATCH] D32522: Test case for the issue raised in D32271
labath added a comment. Thank you for taking the time to add the test. I'd like to avoid modifying the test framework for the sake of this test, if that is possible. Comment at: packages/Python/lldbsuite/test/lldbtest.py:1487 'EXE': exe_name} +if not os.path.exists(os.path.dirname(exe_name)): +if os.path.dirname(exe_name): How about you just modify the test to create the directory and copy the file there? That way you will not have to modify the general test framework for a one-off test... Repository: rL LLVM https://reviews.llvm.org/D32522 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32434: ObjectFileELF: Fix symbol lookup in bss section
labath requested review of this revision. labath added a comment. This revision is now accepted and ready to land. In https://reviews.llvm.org/D32434#737205, @labath wrote: > In https://reviews.llvm.org/D32434#737179, @zturner wrote: > > > If you look at the source code of yaml2obj, all this boils down to a single > > call to `ELFState::writeELF`. If you just link against that, we could > > avoid even shelling out to an external tool, and the YAML could be a string > > literal defined inside the unit test cpp file. This would also greatly > > simplify the xcode build. > > > > Thoughts? > > > I like that. Let me see how that goes.. Unfortunately, it's not going to be that easy. All of the yaml->elf conversion code lives in tools/yaml2obj, and is not a part of any library any library that we could pull in. Maybe there's a case to be made for making yaml2obj a library, but I am not sure if this is the time to do that. https://reviews.llvm.org/D32434 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32503: Remove unused code related to CPlusPlusLanguage::FindEquivalentNames
tberghammer added a comment. I looked into the history of this code once and my understanding is that Enrico added this code in https://github.com/llvm-mirror/lldb/commit/bad9753828b6e0e415e38094bb9627e41d57874c but it have never been used (at least in upstream). The original commit message also indicates this. Repository: rL LLVM https://reviews.llvm.org/D32503 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32168: [LLDB][MIPS] Fix TestStepOverBreakpoint.py failure
nitesh.jain updated this revision to Diff 96722. nitesh.jain added a comment. Update diff as per suggestion https://reviews.llvm.org/D32168 Files: include/lldb/API/SBAddress.h include/lldb/API/SBInstructionList.h packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py scripts/interface/SBInstructionList.i source/API/SBAddress.cpp source/API/SBInstructionList.cpp Index: source/API/SBInstructionList.cpp === --- source/API/SBInstructionList.cpp +++ source/API/SBInstructionList.cpp @@ -9,6 +9,7 @@ #include "lldb/API/SBInstructionList.h" #include "lldb/API/SBInstruction.h" +#include "lldb/API/SBAddress.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/Module.h" @@ -49,6 +50,34 @@ return inst; } +size_t SBInstructionList::GetInstructionsCount(const SBAddress &start, + const SBAddress &end, + bool canSetBreakpoint) { + size_t num_instructions = GetSize(); + size_t i = 0; + SBAddress addr; + size_t lower_index = 0; + size_t upper_index = 0; + size_t instructions_to_skip = 0; + for (i = 0; i < num_instructions; ++i) { +addr = GetInstructionAtIndex(i).GetAddress(); +if (start == addr) + lower_index = i; +if (end == addr) + upper_index = i; + } + if (canSetBreakpoint) +for (i = lower_index; i <= upper_index; ++i) { + if (!CanSetBreakpoint(i)) +++instructions_to_skip; +} + return upper_index - lower_index - instructions_to_skip; +} + +bool SBInstructionList::CanSetBreakpoint(size_t index) { + return !GetInstructionAtIndex(index).HasDelaySlot(); +} + void SBInstructionList::Clear() { m_opaque_sp.reset(); } void SBInstructionList::AppendInstruction(SBInstruction insn) {} Index: source/API/SBAddress.cpp === --- source/API/SBAddress.cpp +++ source/API/SBAddress.cpp @@ -55,6 +55,12 @@ return *this; } +bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) { + if (lhs.IsValid() && rhs.IsValid()) +return lhs.ref() == rhs.ref(); + return false; +} + bool SBAddress::IsValid() const { return m_opaque_ap.get() != NULL && m_opaque_ap->IsValid(); } Index: scripts/interface/SBInstructionList.i === --- scripts/interface/SBInstructionList.i +++ scripts/interface/SBInstructionList.i @@ -44,6 +44,11 @@ lldb::SBInstruction GetInstructionAtIndex (uint32_t idx); +size_t GetInstructionsCount(const SBAddress &start, const SBAddress &end, +bool canSetBreakpoint); + +bool CanSetBreakpoint(size_t index); + void Clear (); Index: packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py === --- packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py +++ packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py @@ -62,19 +62,11 @@ instructions = function.GetInstructions(self.target) addr_1 = self.breakpoint1.GetLocationAtIndex(0).GetAddress() addr_4 = self.breakpoint4.GetLocationAtIndex(0).GetAddress() -delay_slot = 0 -addr_1_load_address = addr_1.GetLoadAddress(self.target) -addr_4_load_address = addr_4.GetLoadAddress(self.target) -for i in range(instructions.GetSize()) : -addr = instructions.GetInstructionAtIndex(i).GetAddress() -addr_load_address = addr.GetLoadAddress(self.target) -if (addr == addr_1) : index_1 = i -if (addr == addr_4) : index_4 = i -if (addr_1_load_address <= addr_load_address <= addr_4_load_address): -if (instructions.GetInstructionAtIndex(i).HasDelaySlot()) : -delay_slot = delay_slot + 1 - -steps_expected = index_4 - index_1 - delay_slot + +# if third argument is true then the count correspond to the +# number of instructions on which breakpoint can be set. +# start = addr_1, end = addr_4, canSetBreakpoint = True +steps_expected = instructions.GetInstructionsCount(addr_1, addr_4, True) step_count = 0 # Step from breakpoint_1 to breakpoint_4 while True: Index: include/lldb/API/SBInstructionList.h === --- include/lldb/API/SBInstructionList.h +++ include/lldb/API/SBInstructionList.h @@ -32,6 +32,12 @@ lldb::SBInstruction GetInstructionAtIndex(uint32_t idx); + size_t GetInstructionsCount(const SBAddress &start, + const SBAddress &end, + b
[Lldb-commits] [PATCH] D32503: Remove unused code related to CPlusPlusLanguage::FindEquivalentNames
scott.smith added a comment. In https://reviews.llvm.org/D32503#737953, @tberghammer wrote: > I looked into the history of this code once and my understanding is that > Enrico added this code in > https://github.com/llvm-mirror/lldb/commit/bad9753828b6e0e415e38094bb9627e41d57874c > but it have never been used (at least in upstream). The original commit > message also indicates this. That was four years ago! So we have code that is unused, has no tests, and is not visible via a library (since this header is not in include/lldb/*). The code is also short enough that it can be rewritten if anyone wants it. Ok to delete? Repository: rL LLVM https://reviews.llvm.org/D32503 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32503: Remove unused code related to CPlusPlusLanguage::FindEquivalentNames
tberghammer added a comment. I am fully support deleting it (and pretty much any unused code). If we need it in the future then we will still have it in the svn history. Repository: rL LLVM https://reviews.llvm.org/D32503 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32503: Remove unused code related to CPlusPlusLanguage::FindEquivalentNames
zturner accepted this revision. zturner added a comment. This revision is now accepted and ready to land. Code is still present in history, if someone needs this again in the future they can do some git archaeology to dig it up. Repository: rL LLVM https://reviews.llvm.org/D32503 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads
krytarowski added a comment. ping? Repository: rL LLVM https://reviews.llvm.org/D32149 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32503: Remove unused code related to CPlusPlusLanguage::FindEquivalentNames
scott.smith added a comment. In https://reviews.llvm.org/D32503#738243, @zturner wrote: > Code is still present in history, if someone needs this again in the future > they can do some git archaeology to dig it up. Can someone please commit this for me? I don't have access. Thank you! Repository: rL LLVM https://reviews.llvm.org/D32503 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32434: ObjectFileELF: Fix symbol lookup in bss section
zturner accepted this revision. zturner added a comment. Alright, thanks for trying anyway! https://reviews.llvm.org/D32434 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32306: Remove lock from ConstString::GetLength
scott.smith added inline comments. Comment at: source/Utility/ConstString.cpp:49 + // pointer, we don't need the lock. const StringPoolEntryType &entry = GetStringMapEntryFromKeyData(ccstr); return entry.getKey().size(); zturner wrote: > Why do we even have this function which digs into the `StringMap` internals > rather than just calling existing `StringMap` member functions? Can Can we > just delete `GetStringMapEntryFromKeyData` entirely and use `StringMap::find`? Probably performance. If we have to call Find, then we have to call hash, fault in the appropriate bucket, and then finally return the entry that we already have in hand. Plus we'd need the lock. Repository: rL LLVM https://reviews.llvm.org/D32306 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32168: [LLDB][MIPS] Fix TestStepOverBreakpoint.py failure
jingham requested changes to this revision. jingham added a comment. This revision now requires changes to proceed. The substance seems fine. I'm not sure I would guess what GetInstructionsCount with canSetBreakpoint == true would do without reading the code. You could fix this with a more explicit parameter name, but I can't think of a good name that's short enough not to be awful, something like: `excludeInstructionsWhereYouCantSetBreakpoints` would get it but yuck... Better to just add a header comment explaining what that parameter actually does. It's also odd to have the SBInstructionList hold the logic determining whether you can set a breakpoint on an instruction. That should really be in SBInstruction, or even better should be in the lldb_private::Instruction class, since this seems like a generally useful bit of knowledge, and then routed through SBInstruction. https://reviews.llvm.org/D32168 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D32306: Remove lock from ConstString::GetLength
Other alternatives though include adding a function to StringMap which gives us what we need, and having this function do the pointer hacking, or simply calling strlen. On Wed, Apr 26, 2017 at 11:03 AM Scott Smith via Phabricator < revi...@reviews.llvm.org> wrote: > scott.smith added inline comments. > > > > Comment at: source/Utility/ConstString.cpp:49 > + // pointer, we don't need the lock. >const StringPoolEntryType &entry = > GetStringMapEntryFromKeyData(ccstr); >return entry.getKey().size(); > > zturner wrote: > > Why do we even have this function which digs into the `StringMap` > internals rather than just calling existing `StringMap` member functions? > Can Can we just delete `GetStringMapEntryFromKeyData` entirely and use > `StringMap::find`? > Probably performance. If we have to call Find, then we have to call hash, > fault in the appropriate bucket, and then finally return the entry that we > already have in hand. Plus we'd need the lock. > > > > Repository: > rL LLVM > > https://reviews.llvm.org/D32306 > > > > ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r301441 - Use llvm::ArrayRef rather than std::vector/std::initializer lists for some
Author: lhames Date: Wed Apr 26 13:15:40 2017 New Revision: 301441 URL: http://llvm.org/viewvc/llvm-project?rev=301441&view=rev Log: Use llvm::ArrayRef rather than std::vector/std::initializer lists for some ValueObject methods. Using ArrayRef allows us to remove some overloads, work with more array-like types, and avoid some std::vector temporaries. https://reviews.llvm.org/D32518 Modified: lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=301441&r1=301440&r2=301441&view=diff == --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Wed Apr 26 13:15:40 2017 @@ -27,6 +27,7 @@ #include "lldb/lldb-private-enumerations.h" // for AddressType #include "lldb/lldb-types.h"// for addr_t, offs... +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" // for StringRef @@ -37,7 +38,6 @@ #include// for recursive_mutex #include // for string #include // for pair -#include #include // for size_t #include // for uint32_t @@ -489,35 +489,19 @@ public: virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create); // this will always create the children if necessary - lldb::ValueObjectSP - GetChildAtIndexPath(const std::initializer_list &idxs, - size_t *index_of_error = nullptr); - - lldb::ValueObjectSP GetChildAtIndexPath(const std::vector &idxs, + lldb::ValueObjectSP GetChildAtIndexPath(llvm::ArrayRef idxs, size_t *index_of_error = nullptr); - lldb::ValueObjectSP GetChildAtIndexPath( - const std::initializer_list> &idxs, - size_t *index_of_error = nullptr); - lldb::ValueObjectSP - GetChildAtIndexPath(const std::vector> &idxs, + GetChildAtIndexPath(llvm::ArrayRef> idxs, size_t *index_of_error = nullptr); // this will always create the children if necessary - lldb::ValueObjectSP - GetChildAtNamePath(const std::initializer_list &names, - ConstString *name_of_error = nullptr); - - lldb::ValueObjectSP GetChildAtNamePath(const std::vector &names, + lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef names, ConstString *name_of_error = nullptr); - lldb::ValueObjectSP GetChildAtNamePath( - const std::initializer_list> &names, - ConstString *name_of_error = nullptr); - lldb::ValueObjectSP - GetChildAtNamePath(const std::vector> &names, + GetChildAtNamePath(llvm::ArrayRef> names, ConstString *name_of_error = nullptr); virtual lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name, Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=301441&r1=301440&r2=301441&view=diff == --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Wed Apr 26 13:15:40 2017 @@ -481,21 +481,8 @@ ValueObjectSP ValueObject::GetChildAtInd return child_sp; } -ValueObjectSP -ValueObject::GetChildAtIndexPath(const std::initializer_list &idxs, - size_t *index_of_error) { - return GetChildAtIndexPath(std::vector(idxs), index_of_error); -} - -ValueObjectSP ValueObject::GetChildAtIndexPath( -const std::initializer_list> &idxs, -size_t *index_of_error) { - return GetChildAtIndexPath(std::vector>(idxs), - index_of_error); -} - lldb::ValueObjectSP -ValueObject::GetChildAtIndexPath(const std::vector &idxs, +ValueObject::GetChildAtIndexPath(llvm::ArrayRef idxs, size_t *index_of_error) { if (idxs.size() == 0) return GetSP(); @@ -512,7 +499,7 @@ ValueObject::GetChildAtIndexPath(const s } lldb::ValueObjectSP ValueObject::GetChildAtIndexPath( -const std::vector> &idxs, size_t *index_of_error) { + llvm::ArrayRef> idxs, size_t *index_of_error) { if (idxs.size() == 0) return GetSP(); ValueObjectSP root(GetSP()); @@ -528,20 +515,7 @@ lldb::ValueObjectSP ValueObject::GetChil } lldb::ValueObjectSP -ValueObject::GetChildAtNamePath(const std::initializer_list &names, -ConstString *name_of_error) { - return GetChildAtNamePath(std::vector(names), name_of_error); -} - -lldb::ValueObjectSP ValueObject::GetChildAtNamePath( -const std::initializer_list> &names, -ConstString *name_of_error) { - return GetChildAtNamePath(std::vector>(names), -name_of_er
[Lldb-commits] [lldb] r301461 - Fixed a crash when dealing with an empty method name in the ObjC runtime.
Author: spyffe Date: Wed Apr 26 15:36:47 2017 New Revision: 301461 URL: http://llvm.org/viewvc/llvm-project?rev=301461&view=rev Log: Fixed a crash when dealing with an empty method name in the ObjC runtime. I've filed a bug covering better unit testing of our runtime metadata reader, which will allow this to be testable.. Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp?rev=301461&r1=301460&r2=301461&view=diff == --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp Wed Apr 26 15:36:47 2017 @@ -355,9 +355,14 @@ public: } } +clang::IdentifierInfo **identifier_infos = selector_components.data(); +if (!identifier_infos) { + return NULL; +} + clang::Selector sel = ast_ctx.Selectors.getSelector( is_zero_argument ? 0 : selector_components.size(), -selector_components.data()); +identifier_infos); clang::QualType ret_type = ClangUtil::GetQualType(type_realizer_sp->RealizeType( ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r301483 - Update lldb to match clang r301442.
Author: rsmith Date: Wed Apr 26 17:10:53 2017 New Revision: 301483 URL: http://llvm.org/viewvc/llvm-project?rev=301483&view=rev Log: Update lldb to match clang r301442. This code really doesn't make any sense: there is only ever one InputKind here. Plus, this is an incomplete and out-of-date copy-paste of some Clang code. This really ought to be revisited, but this change should get the bots green again. Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=301483&r1=301482&r2=301483&view=diff == --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Apr 26 17:10:53 2017 @@ -378,10 +378,9 @@ static void ParseLangArgs(LangOptions &O // Set some properties which depend solely on the input kind; it would be nice // to move these to the language standard, and have the driver resolve the // input kind + language standard. - if (IK == IK_Asm) { + if (IK.getLanguage() == InputKind::Asm) { Opts.AsmPreprocessor = 1; - } else if (IK == IK_ObjC || IK == IK_ObjCXX || IK == IK_PreprocessedObjC || - IK == IK_PreprocessedObjCXX) { + } else if (IK.isObjectiveC()) { Opts.ObjC1 = Opts.ObjC2 = 1; } @@ -389,30 +388,24 @@ static void ParseLangArgs(LangOptions &O if (LangStd == LangStandard::lang_unspecified) { // Based on the base language, pick one. -switch (IK) { -case IK_None: -case IK_AST: -case IK_LLVM_IR: -case IK_RenderScript: +switch (IK.getLanguage()) { +case InputKind::Unknown: +case InputKind::LLVM_IR: +case InputKind::RenderScript: llvm_unreachable("Invalid input kind!"); -case IK_OpenCL: +case InputKind::OpenCL: LangStd = LangStandard::lang_opencl; break; -case IK_CUDA: -case IK_PreprocessedCuda: +case InputKind::CUDA: LangStd = LangStandard::lang_cuda; break; -case IK_Asm: -case IK_C: -case IK_PreprocessedC: -case IK_ObjC: -case IK_PreprocessedObjC: +case InputKind::Asm: +case InputKind::C: +case InputKind::ObjC: LangStd = LangStandard::lang_gnu99; break; -case IK_CXX: -case IK_PreprocessedCXX: -case IK_ObjCXX: -case IK_PreprocessedObjCXX: +case InputKind::CXX: +case InputKind::ObjCXX: LangStd = LangStandard::lang_gnucxx98; break; } @@ -784,8 +777,8 @@ IdentifierTable *ClangASTContext::getIde LangOptions *ClangASTContext::getLanguageOptions() { if (m_language_options_ap.get() == nullptr) { m_language_options_ap.reset(new LangOptions()); -ParseLangArgs(*m_language_options_ap, IK_ObjCXX, GetTargetTriple()); -//InitializeLangOptions(*m_language_options_ap, IK_ObjCXX); +ParseLangArgs(*m_language_options_ap, InputKind::ObjCXX, GetTargetTriple()); +//InitializeLangOptions(*m_language_options_ap, InputKind::ObjCXX); } return m_language_options_ap.get(); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32568: Protect Proces::GetMemoryRegionInfo and ::GetFileLoadAddress with a lock
scott.smith created this revision. Both routines (on Linux, at least) utilize a cache; protect the cache with a mutex to allow concurrent callers. Repository: rL LLVM https://reviews.llvm.org/D32568 Files: source/Plugins/Process/Linux/NativeProcessLinux.cpp source/Plugins/Process/Linux/NativeProcessLinux.h source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp source/Plugins/Process/NetBSD/NativeProcessNetBSD.h source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp === --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -1440,7 +1440,6 @@ region_info.Clear(); if (m_supports_memory_region_info != eLazyBoolNo) { -m_supports_memory_region_info = eLazyBoolYes; char packet[64]; const int packet_len = ::snprintf( packet, sizeof(packet), "qMemoryRegionInfo:%" PRIx64, (uint64_t)addr); @@ -1516,6 +1515,7 @@ // We got an invalid address range back error.SetErrorString("Server returned invalid range"); } + m_supports_memory_region_info = eLazyBoolYes; } else { m_supports_memory_region_info = eLazyBoolNo; } Index: source/Plugins/Process/NetBSD/NativeProcessNetBSD.h === --- source/Plugins/Process/NetBSD/NativeProcessNetBSD.h +++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.h @@ -106,6 +106,9 @@ private: MainLoop::SignalHandleUP m_sigchld_handle; ArchSpec m_arch; + + // Mutex to protect the memory region cache. + std::recursive_mutex m_memory_region_mutex; LazyBool m_supports_mem_region; std::vector> m_mem_region_cache; Index: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp === --- source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp +++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp @@ -565,6 +565,7 @@ Error NativeProcessNetBSD::GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) { + std::lock_guard guard(m_memory_region_mutex); if (m_supports_mem_region == LazyBool::eLazyBoolNo) { // We're done. return Error("unsupported"); Index: source/Plugins/Process/Linux/NativeProcessLinux.h === --- source/Plugins/Process/Linux/NativeProcessLinux.h +++ source/Plugins/Process/Linux/NativeProcessLinux.h @@ -126,6 +126,8 @@ MainLoop::SignalHandleUP m_sigchld_handle; ArchSpec m_arch; + // Mutex to protect the memory region cache. + std::recursive_mutex m_memory_region_mutex; LazyBool m_supports_mem_region; std::vector> m_mem_region_cache; Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp === --- source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -1516,6 +1516,7 @@ Error NativeProcessLinux::GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) { + std::lock_guard guard(m_memory_region_mutex); // FIXME review that the final memory region returned extends to the end of // the virtual address space, // with no perms if it is not mapped. @@ -2221,6 +,7 @@ Error NativeProcessLinux::GetLoadedModuleFileSpec(const char *module_path, FileSpec &file_spec) { + std::lock_guard guard(m_memory_region_mutex); Error error = PopulateMemoryRegionCache(); if (error.Fail()) return error; @@ -2240,6 +2242,7 @@ Error NativeProcessLinux::GetFileLoadAddress(const llvm::StringRef &file_name, lldb::addr_t &load_addr) { + std::lock_guard guard(m_memory_region_mutex); load_addr = LLDB_INVALID_ADDRESS; Error error = PopulateMemoryRegionCache(); if (error.Fail()) Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp === --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -1440,7 +1440,6 @@ region_info.Clear(); if (m_supports_memory_region_info != eLazyBoolNo) { -m_supports_memory_region_info = eLazyBoolYes; char packet[64]; const int packet_len = ::snprintf( packet, sizeof(packet), "qMemoryRegionInfo:%" PRIx64, (uint64_t)addr); @@ -1516,6 +1515,7 @@ // We got an invalid address range back error.SetErrorString("Server returned invalid range"); } + m_supports_memory_region_info = eLazyBoolYes; } else { m_supports_memory_reg
[Lldb-commits] [PATCH] D32306: Remove lock from ConstString::GetLength
scott.smith updated this revision to Diff 96841. scott.smith added a comment. Use StringMapEntry::GetStringMapEntryFromKeyData instead of ConstString's version. Repository: rL LLVM https://reviews.llvm.org/D32306 Files: source/Utility/ConstString.cpp Index: source/Utility/ConstString.cpp === --- source/Utility/ConstString.cpp +++ source/Utility/ConstString.cpp @@ -38,14 +38,13 @@ static StringPoolEntryType & GetStringMapEntryFromKeyData(const char *keyData) { -char *ptr = const_cast(keyData) - sizeof(StringPoolEntryType); -return *reinterpret_cast(ptr); +return StringPoolEntryType::GetStringMapEntryFromKeyData(keyData); } - size_t GetConstCStringLength(const char *ccstr) const { + static size_t GetConstCStringLength(const char *ccstr) { if (ccstr != nullptr) { - const uint8_t h = hash(llvm::StringRef(ccstr)); - llvm::sys::SmartScopedReader rlock(m_string_pools[h].m_mutex); + // Since the entry is read only, and we derive the entry entirely from the + // pointer, we don't need the lock. const StringPoolEntryType &entry = GetStringMapEntryFromKeyData(ccstr); return entry.getKey().size(); } @@ -218,10 +217,8 @@ if (m_string == rhs.m_string) return false; - llvm::StringRef lhs_string_ref(m_string, - StringPool().GetConstCStringLength(m_string)); - llvm::StringRef rhs_string_ref( - rhs.m_string, StringPool().GetConstCStringLength(rhs.m_string)); + llvm::StringRef lhs_string_ref(GetStringRef()); + llvm::StringRef rhs_string_ref(rhs.GetStringRef()); // If both have valid C strings, then return the comparison if (lhs_string_ref.data() && rhs_string_ref.data()) @@ -240,7 +237,7 @@ } size_t ConstString::GetLength() const { - return StringPool().GetConstCStringLength(m_string); + return Pool::GetConstCStringLength(m_string); } bool ConstString::Equals(const ConstString &lhs, const ConstString &rhs, @@ -255,10 +252,8 @@ return false; // perform case insensitive equality test - llvm::StringRef lhs_string_ref( - lhs.m_string, StringPool().GetConstCStringLength(lhs.m_string)); - llvm::StringRef rhs_string_ref( - rhs.m_string, StringPool().GetConstCStringLength(rhs.m_string)); + llvm::StringRef lhs_string_ref(lhs.GetStringRef()); + llvm::StringRef rhs_string_ref(rhs.GetStringRef()); return lhs_string_ref.equals_lower(rhs_string_ref); } @@ -270,10 +265,8 @@ if (lhs_cstr == rhs_cstr) return 0; if (lhs_cstr && rhs_cstr) { -llvm::StringRef lhs_string_ref( -lhs_cstr, StringPool().GetConstCStringLength(lhs_cstr)); -llvm::StringRef rhs_string_ref( -rhs_cstr, StringPool().GetConstCStringLength(rhs_cstr)); +llvm::StringRef lhs_string_ref(lhs.GetStringRef()); +llvm::StringRef rhs_string_ref(rhs.GetStringRef()); if (case_sensitive) { return lhs_string_ref.compare(rhs_string_ref); Index: source/Utility/ConstString.cpp === --- source/Utility/ConstString.cpp +++ source/Utility/ConstString.cpp @@ -38,14 +38,13 @@ static StringPoolEntryType & GetStringMapEntryFromKeyData(const char *keyData) { -char *ptr = const_cast(keyData) - sizeof(StringPoolEntryType); -return *reinterpret_cast(ptr); +return StringPoolEntryType::GetStringMapEntryFromKeyData(keyData); } - size_t GetConstCStringLength(const char *ccstr) const { + static size_t GetConstCStringLength(const char *ccstr) { if (ccstr != nullptr) { - const uint8_t h = hash(llvm::StringRef(ccstr)); - llvm::sys::SmartScopedReader rlock(m_string_pools[h].m_mutex); + // Since the entry is read only, and we derive the entry entirely from the + // pointer, we don't need the lock. const StringPoolEntryType &entry = GetStringMapEntryFromKeyData(ccstr); return entry.getKey().size(); } @@ -218,10 +217,8 @@ if (m_string == rhs.m_string) return false; - llvm::StringRef lhs_string_ref(m_string, - StringPool().GetConstCStringLength(m_string)); - llvm::StringRef rhs_string_ref( - rhs.m_string, StringPool().GetConstCStringLength(rhs.m_string)); + llvm::StringRef lhs_string_ref(GetStringRef()); + llvm::StringRef rhs_string_ref(rhs.GetStringRef()); // If both have valid C strings, then return the comparison if (lhs_string_ref.data() && rhs_string_ref.data()) @@ -240,7 +237,7 @@ } size_t ConstString::GetLength() const { - return StringPool().GetConstCStringLength(m_string); + return Pool::GetConstCStringLength(m_string); } bool ConstString::Equals(const ConstString &lhs, const ConstString &rhs, @@ -255,10 +252,8 @@ return false; // perform case insensitive equality test - llvm::StringRef lhs_string_ref( - lhs.m_string, StringPool().GetConstCStringLength(lhs.m_string)); - llvm::StringRef rhs_st
[Lldb-commits] [lldb] r301492 - Re-landing IPv6 support for LLDB Host
Author: cbieneman Date: Wed Apr 26 18:17:20 2017 New Revision: 301492 URL: http://llvm.org/viewvc/llvm-project?rev=301492&view=rev Log: Re-landing IPv6 support for LLDB Host This support was landed in r300579, and reverted in r300669 due to failures on the bots. The failures were caused by sockets not being properly closed, and this updated version of the patches should resolve that. Summary from the original change: This patch adds IPv6 support to LLDB/Host's TCP socket implementation. Supporting IPv6 involved a few significant changes to the implementation of the socket layers, and I have performed some significant code cleanup along the way. This patch changes the Socket constructors for all types of sockets to not create sockets until first use. This is required for IPv6 support because the socket type will vary based on the address you are connecting to. This also has the benefit of removing code that could have errors from the Socket subclass constructors (which seems like a win to me). The patch also slightly changes the API and behaviors of the Listen/Accept pattern. Previously both Listen and Accept calls took an address specified as a string. Now only listen does. This change was made because the Listen call can result in opening more than one socket. In order to support listening for both IPv4 and IPv6 connections we need to open one AF_INET socket and one AF_INET6 socket. During the listen call we construct a map of file descriptors to addrin structures which represent the allowable incoming connection address. This map removes the need for taking an address into the Accept call. This does have a change in functionality. Previously you could Listen for connections based on one address, and Accept connections from a different address. This is no longer supported. I could not find anywhere in LLDB where we actually used the APIs in that way. The new API does still support AnyAddr for allowing incoming connections from any address. The Listen implementation is implemented using kqueue on FreeBSD and Darwin, WSAPoll on Windows and poll(2) everywhere else. https://reviews.llvm.org/D31823 Added: lldb/trunk/source/Host/common/MainLoop.cpp - copied, changed from r301483, lldb/trunk/source/Host/posix/MainLoopPosix.cpp Removed: lldb/trunk/include/lldb/Host/posix/MainLoopPosix.h lldb/trunk/source/Host/posix/MainLoopPosix.cpp Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake lldb/trunk/include/lldb/Host/Config.h lldb/trunk/include/lldb/Host/Config.h.cmake lldb/trunk/include/lldb/Host/MainLoop.h lldb/trunk/include/lldb/Host/Socket.h lldb/trunk/include/lldb/Host/common/TCPSocket.h lldb/trunk/include/lldb/Host/common/UDPSocket.h lldb/trunk/include/lldb/Host/linux/AbstractSocket.h lldb/trunk/include/lldb/Host/posix/DomainSocket.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Host/CMakeLists.txt lldb/trunk/source/Host/common/Socket.cpp lldb/trunk/source/Host/common/SocketAddress.cpp lldb/trunk/source/Host/common/TCPSocket.cpp lldb/trunk/source/Host/common/UDPSocket.cpp lldb/trunk/source/Host/linux/AbstractSocket.cpp lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp lldb/trunk/source/Host/posix/DomainSocket.cpp lldb/trunk/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj lldb/trunk/tools/debugserver/source/CMakeLists.txt lldb/trunk/tools/debugserver/source/RNBSocket.cpp lldb/trunk/tools/debugserver/source/debugserver.cpp lldb/trunk/tools/lldb-server/Acceptor.cpp lldb/trunk/unittests/Host/SocketTest.cpp lldb/trunk/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp lldb/trunk/unittests/debugserver/RNBSocketTest.cpp Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=301492&r1=301491&r2=301492&view=diff == --- lldb/trunk/cmake/modules/LLDBConfig.cmake (original) +++ lldb/trunk/cmake/modules/LLDBConfig.cmake Wed Apr 26 18:17:20 2017 @@ -1,4 +1,7 @@ include(CheckCXXSymbolExists) +include(CheckSymbolExists) +include(CheckIncludeFile) +include(CheckIncludeFiles) set(LLDB_PROJECT_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) set(LLDB_SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/source") @@ -426,10 +429,14 @@ if ((CMAKE_SYSTEM_NAME MATCHES "Android" endif() find_package(Backtrace) +set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) +check_symbol_exists(ppoll poll.h HAVE_PPOLL) +set(CMAKE_REQUIRED_DEFINITIONS) +check_symbol_exists(sigaction signal.h HAVE_SIGACTION) include(CheckIncludeFile) check_include_file(termios.h HAVE_TERMIOS_H) -check_include_file(sys/event.h HAVE_SYS_EVENT_H) +check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H) # These checks exist in LLVM's configuration, so I
[Lldb-commits] [lldb] r301493 - Fix libcxx formatters for changes in r300140.
Author: lhames Date: Wed Apr 26 18:29:59 2017 New Revision: 301493 URL: http://llvm.org/viewvc/llvm-project?rev=301493&view=rev Log: Fix libcxx formatters for changes in r300140. Summary: LLVM r300140 changed the layout and field names of __compressed_pair, which broke LLDB's std::vector, std::map and std::unsorted_map formatters. This patch attempts to fix these formatters by having them interogate the __compressed_pair values to determine whether they're pre- or post-r300140 variants, then access them accordingly. Reviewers: jingham, EricWF Reviewed By: jingham Differential Revision: https://reviews.llvm.org/D32554 Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp?rev=301493&r1=301492&r2=301493&view=diff == --- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp (original) +++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp Wed Apr 26 18:29:59 2017 @@ -219,6 +219,7 @@ size_t lldb_private::formatters::LibcxxS CalculateNumChildren() { static ConstString g___pair3_("__pair3_"); static ConstString g___first_("__first_"); + static ConstString g___value_("__value_"); if (m_count != UINT32_MAX) return m_count; @@ -227,7 +228,22 @@ size_t lldb_private::formatters::LibcxxS ValueObjectSP m_item(m_tree->GetChildMemberWithName(g___pair3_, true)); if (!m_item) return 0; - m_item = m_item->GetChildMemberWithName(g___first_, true); + + switch (m_item->GetCompilerType().GetNumDirectBaseClasses()) { + case 1: +// Assume a pre llvm r300140 __compressed_pair implementation: +m_item = m_item->GetChildMemberWithName(g___first_, true); +break; + case 2: { +// Assume a post llvm r300140 __compressed_pair implementation: +ValueObjectSP first_elem_parent = m_item->GetChildAtIndex(0, true); +m_item = first_elem_parent->GetChildMemberWithName(g___value_, true); +break; + } + default: +return false; + } + if (!m_item) return 0; m_count = m_item->GetValueAsUnsigned(0); Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp?rev=301493&r1=301492&r2=301493&view=diff == --- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp (original) +++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp Wed Apr 26 18:29:59 2017 @@ -94,9 +94,30 @@ lldb::ValueObjectSP lldb_private::format node_sp->GetChildMemberWithName(ConstString("__hash_"), true); if (!hash_sp || !value_sp) { if (!m_element_type) { -auto first_sp = m_backend.GetChildAtNamePath({ConstString("__table_"), - ConstString("__p1_"), - ConstString("__first_")}); +auto p1_sp = m_backend.GetChildAtNamePath({ConstString("__table_"), + ConstString("__p1_")}); +if (!p1_sp) + return nullptr; + +ValueObjectSP first_sp = nullptr; +switch (p1_sp->GetCompilerType().GetNumDirectBaseClasses()) { +case 1: + // Assume a pre llvm r300140 __compressed_pair implementation: + first_sp = p1_sp->GetChildMemberWithName(ConstString("__first_"), + true); + break; +case 2: { + // Assume a post llvm r300140 __compressed_pair implementation: + ValueObjectSP first_elem_parent_sp = +p1_sp->GetChildAtIndex(0, true); + first_sp = p1_sp->GetChildMemberWithName(ConstString("__value_"), + true); + break; +} +default: + return nullptr; +} + if (!first_sp) return nullptr; m_element_type = first_sp->GetCompilerType(); @@ -152,22 +173,39 @@ bool lldb_private::formatters::LibcxxStd m_backend.GetChildMemberWithName(ConstString("__table_"), true); if (!table_sp) return false; - ValueObjectSP num_elements_sp = table_sp->GetChildAtNamePath( - {ConstString("__p2_"), ConstString("__first_")}); + + ValueObjectSP p2_sp = table_sp->GetChildMemberWithName( +ConstString("__p2_"), true); + ValueObjectSP num_elements_sp = nullptr; + llvm::SmallVector next_path; + switch (p2_sp->GetCompilerType().GetNumDirectBaseClasses()) { + case 1: +// Assume a pre llvm r300140 __compressed_pair implemen
[Lldb-commits] [lldb] r301502 - Fix Windows bots broken by r301492
Author: cbieneman Date: Wed Apr 26 19:03:27 2017 New Revision: 301502 URL: http://llvm.org/viewvc/llvm-project?rev=301502&view=rev Log: Fix Windows bots broken by r301492 http://lab.llvm.org:8011/builders/lldb-x86-windows-msvc2015/builds/8644/ Modified: lldb/trunk/source/Host/common/TCPSocket.cpp Modified: lldb/trunk/source/Host/common/TCPSocket.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TCPSocket.cpp?rev=301502&r1=301501&r2=301502&view=diff == --- lldb/trunk/source/Host/common/TCPSocket.cpp (original) +++ lldb/trunk/source/Host/common/TCPSocket.cpp Wed Apr 26 19:03:27 2017 @@ -188,7 +188,9 @@ Error TCPSocket::Listen(llvm::StringRef // enable local address reuse int option_value = 1; -::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &option_value, +set_socket_option_arg_type option_value_p = +reinterpret_cast(&option_value); +::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p, sizeof(option_value)); address.SetPort(port); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r301504 - One more attempt to fix the broken bots.
Author: cbieneman Date: Wed Apr 26 19:23:41 2017 New Revision: 301504 URL: http://llvm.org/viewvc/llvm-project?rev=301504&view=rev Log: One more attempt to fix the broken bots. Modified: lldb/trunk/source/Host/common/TCPSocket.cpp Modified: lldb/trunk/source/Host/common/TCPSocket.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TCPSocket.cpp?rev=301504&r1=301503&r2=301504&view=diff == --- lldb/trunk/source/Host/common/TCPSocket.cpp (original) +++ lldb/trunk/source/Host/common/TCPSocket.cpp Wed Apr 26 19:23:41 2017 @@ -32,8 +32,10 @@ #ifdef LLVM_ON_WIN32 #define CLOSE_SOCKET closesocket +typedef const char *set_socket_option_arg_type; #else #define CLOSE_SOCKET ::close +typedef const void *set_socket_option_arg_type; #endif using namespace lldb; ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r301506 - One more try at the whole compiling thing...
Author: cbieneman Date: Wed Apr 26 19:47:19 2017 New Revision: 301506 URL: http://llvm.org/viewvc/llvm-project?rev=301506&view=rev Log: One more try at the whole compiling thing... Need to actually use the right type in both parts of the cast. Modified: lldb/trunk/source/Host/common/TCPSocket.cpp Modified: lldb/trunk/source/Host/common/TCPSocket.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TCPSocket.cpp?rev=301506&r1=301505&r2=301506&view=diff == --- lldb/trunk/source/Host/common/TCPSocket.cpp (original) +++ lldb/trunk/source/Host/common/TCPSocket.cpp Wed Apr 26 19:47:19 2017 @@ -191,7 +191,7 @@ Error TCPSocket::Listen(llvm::StringRef // enable local address reuse int option_value = 1; set_socket_option_arg_type option_value_p = -reinterpret_cast(&option_value); +reinterpret_cast(&option_value); ::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p, sizeof(option_value)); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits