[Lldb-commits] [PATCH] D32823: Remove an expensive lock from Timer
labath added a comment. Ok, then let's keep them. I don't mind changing all call sites -- having a separate category object is the cleanest solution with least magic. However see my comments about category naming and merging. Comment at: unittests/Core/TimerTest.cpp:39 std::this_thread::sleep_for(std::chrono::milliseconds(10)); -Timer t2("CAT1", ""); +// Explicitly testing the same category as above. +static Timer::Category tcat1b("CAT1"); Do we actually need to support that? Since we already have a nice Category object then I think we should use that as a unique key for everything (including printing). There no reason why the category needs to have local scope. If it really needs to be used from multiple places, we can expose the object at a higher scope. For the tests, this could be done by having a fixture which creates the categories in the SetUpTestCase static function. Alternatively, we could have Category object be based on llvm::ManagedStatic, so it would go away when you call llvm_shutdown, which would enable us to have truly isolated and leak-free tests. (Right now we don't call llvm_shutdown in the main app as we cannot shutdown cleanly, but it would be great if one day we could.) Comment at: unittests/Core/TimerTest.cpp:48 + // It should only appear once. + ASSERT_EQ(nullptr, strstr(strstr(ss.GetData(), "CAT1") + 1, "CAT1")); ASSERT_EQ(1, sscanf(ss.GetData(), "%lf sec for CAT1", &seconds)); ss.GetStringRef().count("CAT1") == 1 Repository: rL LLVM https://reviews.llvm.org/D32823 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32813: ABISysV_arm64: compute return value for large vectors correctly
tberghammer accepted this revision. tberghammer added a comment. This revision is now accepted and ready to land. Makes sense. Thank you for the explanation (I assumed homogeneous aggregate and vector are the same). https://reviews.llvm.org/D32813 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32899: [RuntimeDyld] Fix debug section relocation (pr20457)
labath created this revision. Herald added a subscriber: aprantl. Debug info sections, (or non-SHF_ALLOC sections in general) should be linked as if their load address was zero to emulate the behavior of the static linker. I've made two tests for this: One checks that we are able to properly process Modules with debug info in the ProcessAllSections mode. This tests the feature only indirectly, by making sure we don't assert when processing relocations, and it only does that on x86_64 linux builds with asserts. The second test directly verifies that the relocations were applied correctly, by directly inspecting the generated sections. This one works on all platforms, but it is a little cumbersome due to the need to construct a section with well-defined contents. Nonetheless, most of the code is boilerplate, and it could be shared if we end up having more tests like these. This bug was discovered because it was breaking lldb expression evaluation on linux. https://reviews.llvm.org/D32899 Files: lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp unittests/ExecutionEngine/MCJIT/MCJITTest.cpp Index: unittests/ExecutionEngine/MCJIT/MCJITTest.cpp === --- unittests/ExecutionEngine/MCJIT/MCJITTest.cpp +++ unittests/ExecutionEngine/MCJIT/MCJITTest.cpp @@ -12,9 +12,20 @@ // //===--===// +#include "MCJITTestBase.h" #include "llvm/ExecutionEngine/MCJIT.h" +#include "llvm/IR/DIBuilder.h" +#include "llvm/MC/MCAsmBackend.h" +#include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCCodeEmitter.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCInstrInfo.h" +#include "llvm/MC/MCObjectFileInfo.h" +#include "llvm/MC/MCRegisterInfo.h" +#include "llvm/MC/MCStreamer.h" +#include "llvm/Object/ObjectFile.h" #include "llvm/Support/DynamicLibrary.h" -#include "MCJITTestBase.h" +#include "llvm/Support/TargetRegistry.h" #include "gtest/gtest.h" using namespace llvm; @@ -281,4 +292,142 @@ EXPECT_FALSE(std::find(I, E, "Foo2") == E); } +static Function *insertMainWithDI(LLVMContext &Context, Module &M) { + DIBuilder DIB(M); + DIFile *File = DIB.createFile("-", "."); + DIB.createCompileUnit(dwarf::DW_LANG_C99, File, "producer", false, "", 0); + DISubroutineType *MainType = DIB.createSubroutineType({}); + DISubprogram *DIMain = DIB.createFunction(File, "main", "main", File, 1, +MainType, false, true, 1); + DILocation *Loc = DILocation::get(Context, 1, 1, DIMain, nullptr); + Function *Main = Function::Create(TypeBuilder::get(Context), +GlobalValue::ExternalLinkage, "main", &M); + Main->setSubprogram(DIMain); + BasicBlock *Entry = BasicBlock::Create(Context, "entry", Main); + ReturnInst *Ret = + IRBuilder<>(Entry).CreateRet(ConstantInt::get(Context, APInt(32, 47))); + Ret->setDebugLoc(Loc); + DIB.finalize(); + + return Main; +} + +TEST_F(MCJITTest, ProcessAllSections) { + Function *Main = insertMainWithDI(Context, *M); + + createJIT(std::move(M)); + TheJIT->setProcessAllSections(true); + TheJIT->finalizeObject(); + + uint64_t ptr = TheJIT->getFunctionAddress(Main->getName().str()); + ASSERT_NE(0u, ptr) << "Unable to get pointer to main() from JIT"; + + int (*FuncPtr)() = (int (*)())ptr; + int returnCode = FuncPtr(); + EXPECT_EQ(returnCode, 47); +} + +static void createObject(SmallVectorImpl &Object) { + LLVMInitializeX86TargetInfo(); + LLVMInitializeX86TargetMC(); + LLVMInitializeX86Target(); + LLVMInitializeX86AsmPrinter(); + + std::string ErrorStr; + Triple TheTriple("x86_64-pc-linux"); + const Target *TheTarget = + TargetRegistry::lookupTarget("", TheTriple, ErrorStr); + ASSERT_NE(nullptr, TheTarget) << ErrorStr; + + std::unique_ptr MRI( + TheTarget->createMCRegInfo(TheTriple.getTriple())); + ASSERT_NE(nullptr, MRI); + + std::unique_ptr MAB(TheTarget->createMCAsmBackend( + *MRI, TheTriple.getTriple(), "", MCTargetOptions())); + ASSERT_NE(nullptr, MAB); + + std::unique_ptr MAI( + TheTarget->createMCAsmInfo(*MRI, TheTriple.getTriple())); + ASSERT_NE(nullptr, MAI); + + auto MOFI = llvm::make_unique(); + + std::unique_ptr MII(TheTarget->createMCInstrInfo()); + ASSERT_NE(nullptr, MII); + + MCContext MC(MAI.get(), MRI.get(), MOFI.get()); + MOFI->InitMCObjectFileInfo(TheTriple, false, CodeModel::Default, MC); + + std::unique_ptr MCE( + TheTarget->createMCCodeEmitter(*MII, *MRI, MC)); + ASSERT_NE(nullptr, MCE); + + std::unique_ptr MSTI( + TheTarget->createMCSubtargetInfo(TheTriple.getTriple(), "", "")); + + raw_svector_ostream Stream(Object); + + std::unique_ptr Streamer(TheTarget->createMCObjectStreamer( + TheTriple, MC, *MAB.release(), Stream, MCE.release(), *MSTI, false, false, + false)); + + Streamer->SwitchSection(MOFI->getDwarfFrameSection()); + MCSymbol *SectionEnd = MC.createTempSymbol(); + Streamer->EmitSymbolVal
[Lldb-commits] [lldb] r302220 - ABISysV_arm64: compute return value for large vectors correctly
Author: labath Date: Fri May 5 05:50:02 2017 New Revision: 302220 URL: http://llvm.org/viewvc/llvm-project?rev=302220&view=rev Log: ABISysV_arm64: compute return value for large vectors correctly Summary: Arm64 Procedure Call Standard specifies than only vectors up to 16 bytes are stored in v0 (which makes sense, as that's the size of the register). 32-byte vector types are passed as regular structs via x8 pointer. Treat them as such. This fixes TestReturnValue for arm64-clang. I also split the test case into two so I can avoid the if(gcc) line, and annotate each test instead. (It seems the vector type tests fail with gcc only when targetting x86 arches). Reviewers: tberghammer, eugene Subscribers: aemerson, omjavaid, rengolin, srhines, lldb-commits Differential Revision: https://reviews.llvm.org/D32813 Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py?rev=302220&r1=302219&r2=302220&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py Fri May 5 05:50:02 2017 @@ -171,17 +171,45 @@ class ReturnValueTestCase(TestBase): #self.return_and_test_struct_value ("return_one_int_one_double_packed") self.return_and_test_struct_value("return_one_int_one_long") -# icc and gcc don't support this extension. -if self.getCompiler().endswith('clang'): -self.return_and_test_struct_value("return_vector_size_float32_8") -self.return_and_test_struct_value("return_vector_size_float32_16") -self.return_and_test_struct_value("return_vector_size_float32_32") -self.return_and_test_struct_value( -"return_ext_vector_size_float32_2") -self.return_and_test_struct_value( -"return_ext_vector_size_float32_4") -self.return_and_test_struct_value( -"return_ext_vector_size_float32_8") +@expectedFailureAll(oslist=["freebsd"], archs=["i386"]) +@expectedFailureAll(oslist=["macosx"], archs=["i386"], bugnumber="") +@expectedFailureAll( +oslist=["linux"], +compiler="clang", +compiler_version=[ +"<=", +"3.6"], +archs=["i386"]) +@expectedFailureAll( +bugnumber="llvm.org/pr25785", +hostoslist=["windows"], +compiler="gcc", +archs=["i386"], +triple='.*-android') +@expectedFailureAll(compiler=["gcc"], archs=["x86_64", "i386"]) +@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") +def test_vector_values(self): +self.build() +exe = os.path.join(os.getcwd(), "a.out") +error = lldb.SBError() + +self.target = self.dbg.CreateTarget(exe) +self.assertTrue(self.target, VALID_TARGET) + +main_bktp = self.target.BreakpointCreateByName("main", exe) +self.assertTrue(main_bktp, VALID_BREAKPOINT) + +self.process = self.target.LaunchSimple( +None, None, self.get_process_working_directory()) +self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint( +self.process, main_bktp)), 1) + +self.return_and_test_struct_value("return_vector_size_float32_8") +self.return_and_test_struct_value("return_vector_size_float32_16") +self.return_and_test_struct_value("return_vector_size_float32_32") +self.return_and_test_struct_value("return_ext_vector_size_float32_2") +self.return_and_test_struct_value("return_ext_vector_size_float32_4") +self.return_and_test_struct_value("return_ext_vector_size_float32_8") def return_and_test_struct_value(self, func_name): """Pass in the name of the function to return from - takes in value, returns value.""" Modified: lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp?rev=302220&r1=302219&r2=302220&view=diff == --- lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp (original) +++ lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp Fri May 5 05:50:02 2017 @@ -2362,32 +2362,30 @@ ValueObjectSP ABISysV_arm64::GetReturnVa if (success) return_valobj_sp = ValueObjectConstResult::Create( thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); - } else if (type_flags & eTypeIsVector) { + }
[Lldb-commits] [PATCH] D32813: ABISysV_arm64: compute return value for large vectors correctly
This revision was automatically updated to reflect the committed changes. Closed by commit rL302220: ABISysV_arm64: compute return value for large vectors correctly (authored by labath). Changed prior to commit: https://reviews.llvm.org/D32813?vs=97676&id=97927#toc Repository: rL LLVM https://reviews.llvm.org/D32813 Files: lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py === --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py @@ -171,17 +171,45 @@ #self.return_and_test_struct_value ("return_one_int_one_double_packed") self.return_and_test_struct_value("return_one_int_one_long") -# icc and gcc don't support this extension. -if self.getCompiler().endswith('clang'): -self.return_and_test_struct_value("return_vector_size_float32_8") -self.return_and_test_struct_value("return_vector_size_float32_16") -self.return_and_test_struct_value("return_vector_size_float32_32") -self.return_and_test_struct_value( -"return_ext_vector_size_float32_2") -self.return_and_test_struct_value( -"return_ext_vector_size_float32_4") -self.return_and_test_struct_value( -"return_ext_vector_size_float32_8") +@expectedFailureAll(oslist=["freebsd"], archs=["i386"]) +@expectedFailureAll(oslist=["macosx"], archs=["i386"], bugnumber="") +@expectedFailureAll( +oslist=["linux"], +compiler="clang", +compiler_version=[ +"<=", +"3.6"], +archs=["i386"]) +@expectedFailureAll( +bugnumber="llvm.org/pr25785", +hostoslist=["windows"], +compiler="gcc", +archs=["i386"], +triple='.*-android') +@expectedFailureAll(compiler=["gcc"], archs=["x86_64", "i386"]) +@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") +def test_vector_values(self): +self.build() +exe = os.path.join(os.getcwd(), "a.out") +error = lldb.SBError() + +self.target = self.dbg.CreateTarget(exe) +self.assertTrue(self.target, VALID_TARGET) + +main_bktp = self.target.BreakpointCreateByName("main", exe) +self.assertTrue(main_bktp, VALID_BREAKPOINT) + +self.process = self.target.LaunchSimple( +None, None, self.get_process_working_directory()) +self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint( +self.process, main_bktp)), 1) + +self.return_and_test_struct_value("return_vector_size_float32_8") +self.return_and_test_struct_value("return_vector_size_float32_16") +self.return_and_test_struct_value("return_vector_size_float32_32") +self.return_and_test_struct_value("return_ext_vector_size_float32_2") +self.return_and_test_struct_value("return_ext_vector_size_float32_4") +self.return_and_test_struct_value("return_ext_vector_size_float32_8") def return_and_test_struct_value(self, func_name): """Pass in the name of the function to return from - takes in value, returns value.""" Index: lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp === --- lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp +++ lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp @@ -2362,32 +2362,30 @@ if (success) return_valobj_sp = ValueObjectConstResult::Create( thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); - } else if (type_flags & eTypeIsVector) { + } else if (type_flags & eTypeIsVector && byte_size <= 16) { if (byte_size > 0) { const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0); if (v0_info) { -if (byte_size <= v0_info->byte_size) { - std::unique_ptr heap_data_ap( - new DataBufferHeap(byte_size, 0)); - const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder(); - RegisterValue reg_value; - if (reg_ctx->ReadRegister(v0_info, reg_value)) { -Error error; -if (reg_value.GetAsMemoryData(v0_info, heap_data_ap->GetBytes(), - heap_data_ap->GetByteSize(), - byte_order, error)) { - DataExtractor data(DataBufferSP(heap_data_ap.release()), - byte_order, - exe_ctx.GetProcessRef().GetAddressByteSize()); - return_valobj_sp = ValueObjectConstResult::Creat
[Lldb-commits] [PATCH] D32820: Parallelize demangling
labath added inline comments. Comment at: source/Symbol/Symtab.cpp:257 -// The "const char *" in "class_contexts" must come from a -// ConstString::GetCString() -std::set class_contexts; -UniqueCStringMap mangled_name_to_index; -std::vector symbol_contexts(num_symbols, nullptr); - -for (entry.value = 0; entry.value < num_symbols; ++entry.value) { - const Symbol *symbol = &m_symbols[entry.value]; +auto symbol_fn = [&states, this](size_t value) { + const Symbol *symbol = &m_symbols[value]; The function looks big enough to deserve a name. (== Please move the lambda out of line) Repository: rL LLVM https://reviews.llvm.org/D32820 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32757: Add TaskMap for iterating a function over a set of integers
labath accepted this revision. labath added a comment. I can do the pushing. :) Thanks for the patch. Comment at: include/lldb/Utility/TaskPool.h:89 +void TaskMapOverInt(size_t begin, size_t end, +std::function const &func); Making this a template would enable you to get rid of the std::function wrapper overhead. I have no idea whether it would make a difference in practice. Repository: rL LLVM https://reviews.llvm.org/D32757 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r302223 - Add TaskMap for iterating a function over a set of integers
Author: labath Date: Fri May 5 06:16:59 2017 New Revision: 302223 URL: http://llvm.org/viewvc/llvm-project?rev=302223&view=rev Log: Add TaskMap for iterating a function over a set of integers Summary: Many parallel tasks just want to iterate over all the possible numbers from 0 to N-1. Rather than enqueue N work items, instead just "map" the function across the requested integer space. Reviewers: clayborg, labath, tberghammer, zturner Reviewed By: clayborg, zturner Subscribers: zturner, lldb-commits Differential Revision: https://reviews.llvm.org/D32757 Patch by Scott Smith . Modified: lldb/trunk/include/lldb/Utility/TaskPool.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Utility/TaskPool.cpp lldb/trunk/unittests/Utility/TaskPoolTest.cpp Modified: lldb/trunk/include/lldb/Utility/TaskPool.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/TaskPool.h?rev=302223&r1=30&r2=302223&view=diff == --- lldb/trunk/include/lldb/Utility/TaskPool.h (original) +++ lldb/trunk/include/lldb/Utility/TaskPool.h Fri May 5 06:16:59 2017 @@ -53,50 +53,6 @@ private: static void AddTaskImpl(std::function &&task_fn); }; -// Wrapper class around the global TaskPool implementation to make it possible -// to create a set of -// tasks and then wait for the tasks to be completed by the -// WaitForNextCompletedTask call. This -// class should be used when WaitForNextCompletedTask is needed because this -// class add no other -// extra functionality to the TaskPool class and it have a very minor -// performance overhead. -template // The return type of the tasks what will be added to this - // task runner - class TaskRunner { -public: - // Add a task to the task runner what will also add the task to the global - // TaskPool. The - // function doesn't return the std::future for the task because it will be - // supplied by the - // WaitForNextCompletedTask after the task is completed. - template void AddTask(F &&f, Args &&... args); - - // Wait for the next task in this task runner to finish and then return the - // std::future what - // belongs to the finished task. If there is no task in this task runner - // (neither pending nor - // comleted) then this function will return an invalid future. Usually this - // function should be - // called in a loop processing the results of the tasks until it returns an - // invalid std::future - // what means that all task in this task runner is completed. - std::future WaitForNextCompletedTask(); - - // Convenience method to wait for all task in this TaskRunner to finish. Do - // NOT use this class - // just because of this method. Use TaskPool instead and wait for each - // std::future returned by - // AddTask in a loop. - void WaitForAllTasks(); - -private: - std::list> m_ready; - std::list> m_pending; - std::mutex m_mutex; - std::condition_variable m_cv; -}; - template std::future::type> TaskPool::AddTask(F &&f, Args &&... args) { @@ -126,64 +82,10 @@ template <> struct TaskPool::RunTaskImpl static void Run() {} }; -template -template -void TaskRunner::AddTask(F &&f, Args &&... args) { - std::unique_lock lock(m_mutex); - auto it = m_pending.emplace(m_pending.end()); - *it = std::move(TaskPool::AddTask( - [this, it](F f, Args... args) { -T &&r = f(std::forward(args)...); - -std::unique_lock lock(this->m_mutex); -this->m_ready.splice(this->m_ready.end(), this->m_pending, it); -lock.unlock(); - -this->m_cv.notify_one(); -return r; - }, - std::forward(f), std::forward(args)...)); -} - -template <> -template -void TaskRunner::AddTask(F &&f, Args &&... args) { - std::unique_lock lock(m_mutex); - auto it = m_pending.emplace(m_pending.end()); - *it = std::move(TaskPool::AddTask( - [this, it](F f, Args... args) { -f(std::forward(args)...); - -std::unique_lock lock(this->m_mutex); -this->m_ready.emplace_back(std::move(*it)); -this->m_pending.erase(it); -lock.unlock(); - -this->m_cv.notify_one(); - }, - std::forward(f), std::forward(args)...)); -} - -template std::future TaskRunner::WaitForNextCompletedTask() { - std::unique_lock lock(m_mutex); - if (m_ready.empty() && m_pending.empty()) -return std::future(); // No more tasks - - if (m_ready.empty()) -m_cv.wait(lock, [this]() { return !this->m_ready.empty(); }); - - std::future res = std::move(m_ready.front()); - m_ready.pop_front(); - - lock.unlock(); - res.wait(); - - return std::move(res); -} - -template void TaskRunner::WaitForAllTasks() { - while (WaitForNextCompletedTask().valid()) -; -} +// Run 'func' on every value from begin .. end-1. Each worker will grab +// 'batch_size' numbers at a time to work on, so for very fast functions, batch +//
[Lldb-commits] [PATCH] D32757: Add TaskMap for iterating a function over a set of integers
This revision was automatically updated to reflect the committed changes. Closed by commit rL302223: Add TaskMap for iterating a function over a set of integers (authored by labath). Changed prior to commit: https://reviews.llvm.org/D32757?vs=97907&id=97931#toc Repository: rL LLVM https://reviews.llvm.org/D32757 Files: lldb/trunk/include/lldb/Utility/TaskPool.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Utility/TaskPool.cpp lldb/trunk/unittests/Utility/TaskPoolTest.cpp Index: lldb/trunk/unittests/Utility/TaskPoolTest.cpp === --- lldb/trunk/unittests/Utility/TaskPoolTest.cpp +++ lldb/trunk/unittests/Utility/TaskPoolTest.cpp @@ -30,25 +30,14 @@ ASSERT_EQ(17, r[3]); } -TEST(TaskPoolTest, TaskRunner) { - auto fn = [](int x) { return std::make_pair(x, x * x); }; - - TaskRunner> tr; - tr.AddTask(fn, 1); - tr.AddTask(fn, 2); - tr.AddTask(fn, 3); - tr.AddTask(fn, 4); - - int count = 0; - while (true) { -auto f = tr.WaitForNextCompletedTask(); -if (!f.valid()) - break; - -++count; -std::pair v = f.get(); -ASSERT_EQ(v.first * v.first, v.second); - } - - ASSERT_EQ(4, count); +TEST(TaskPoolTest, TaskMap) { + int data[4]; + auto fn = [&data](int x) { data[x] = x * x; }; + + TaskMapOverInt(0, 4, fn); + + ASSERT_EQ(data[0], 0); + ASSERT_EQ(data[1], 1); + ASSERT_EQ(data[2], 4); + ASSERT_EQ(data[3], 9); } Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp === --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1946,7 +1946,9 @@ std::vector type_index(num_compile_units); std::vector namespace_index(num_compile_units); -std::vector clear_cu_dies(num_compile_units, false); +// std::vector might be implemented using bit test-and-set, so use +// uint8_t instead. +std::vector clear_cu_dies(num_compile_units, false); auto parser_fn = [debug_info, &function_basename_index, &function_fullname_index, &function_method_index, &function_selector_index, &objc_class_selectors_index, @@ -1963,22 +1965,18 @@ return cu_idx; }; -auto extract_fn = [debug_info](uint32_t cu_idx) { +auto extract_fn = [debug_info, &clear_cu_dies](uint32_t cu_idx) { DWARFCompileUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx); if (dwarf_cu) { // dwarf_cu->ExtractDIEsIfNeeded(false) will return zero if the // DIEs for a compile unit have already been parsed. -return std::make_pair(cu_idx, dwarf_cu->ExtractDIEsIfNeeded(false) > 1); +if (dwarf_cu->ExtractDIEsIfNeeded(false) > 1) + clear_cu_dies[cu_idx] = true; } - return std::make_pair(cu_idx, false); }; // Create a task runner that extracts dies for each DWARF compile unit in a // separate thread -TaskRunner> task_runner_extract; -for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) - task_runner_extract.AddTask(extract_fn, cu_idx); - //-- // First figure out which compile units didn't have their DIEs already // parsed and remember this. If no DIEs were parsed prior to this index @@ -1988,48 +1986,37 @@ // a DIE in one compile unit refers to another and the indexes accesses // those DIEs. //-- -while (true) { - auto f = task_runner_extract.WaitForNextCompletedTask(); - if (!f.valid()) -break; - unsigned cu_idx; - bool clear; - std::tie(cu_idx, clear) = f.get(); - clear_cu_dies[cu_idx] = clear; -} +TaskMapOverInt(0, num_compile_units, extract_fn); // Now create a task runner that can index each DWARF compile unit in a // separate // thread so we can index quickly. -TaskRunner task_runner; -for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) - task_runner.AddTask(parser_fn, cu_idx); - -while (true) { - std::future f = task_runner.WaitForNextCompletedTask(); - if (!f.valid()) -break; - uint32_t cu_idx = f.get(); +TaskMapOverInt(0, num_compile_units, parser_fn); + +auto finalize_fn = [](NameToDIE &index, std::vector &srcs) { + for (auto &src : srcs) +index.Append(src); + index.Finalize(); +}; - m_function_basename_index.Append(function_basename_index[cu_idx]); - m_function_fullname_index.Append(function_fullname_index[cu_idx]); - m_function_method_index.Append(function_method_index[cu_idx]); - m_function_selector_index.Append(function_selector_index[cu_idx]); - m_objc_class_selectors_index.Append(objc_class_selectors_index[cu_idx]);
[Lldb-commits] [PATCH] D32421: Fix segfault resulting from empty print prompt
This revision was automatically updated to reflect the committed changes. Closed by commit rL302225: Fix segfault resulting from empty print prompt (authored by labath). Changed prior to commit: https://reviews.llvm.org/D32421?vs=97717&id=97937#toc Repository: rL LLVM https://reviews.llvm.org/D32421 Files: lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py lldb/trunk/source/Host/common/Editline.cpp Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py === --- lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py +++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py @@ -12,6 +12,7 @@ class MultilineExpressionsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) +NO_DEBUG_INFO_TESTCASE = True def setUp(self): # Call super's setUp(). @@ -60,3 +61,30 @@ child.expect_exact(prompt) self.expect(child.before, exe=False, patterns=['= 5']) + +@skipIfRemote +@expectedFailureAll( +oslist=["windows"], +bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") +def test_empty_list(self): +"""Test printing an empty list of expressions""" +import pexpect +prompt = "(lldb) " + +# So that the child gets torn down after the test +self.child = pexpect.spawn( +"%s %s" % +(lldbtest_config.lldbExec, self.lldbOption)) +child = self.child + +# Turn on logging for what the child sends back. +if self.TraceOn(): +child.logfile_read = sys.stdout + +# We expect a prompt, then send "print" to start a list of expressions, +# then an empty line. We expect a prompt back. +child.expect_exact(prompt) +child.sendline("print") +child.expect_exact('1:') +child.sendline("") +child.expect_exact(prompt) Index: lldb/trunk/source/Host/common/Editline.cpp === --- lldb/trunk/source/Host/common/Editline.cpp +++ lldb/trunk/source/Host/common/Editline.cpp @@ -367,7 +367,7 @@ if (to == CursorLocation::EditingCursor) { toColumn = editline_cursor_position - (editline_cursor_row * m_terminal_width) + 1; - } else if (to == CursorLocation::BlockEnd) { + } else if (to == CursorLocation::BlockEnd && !m_input_lines.empty()) { toColumn = ((m_input_lines[m_input_lines.size() - 1].length() + GetPromptWidth()) % 80) + Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py === --- lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py +++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py @@ -12,6 +12,7 @@ class MultilineExpressionsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) +NO_DEBUG_INFO_TESTCASE = True def setUp(self): # Call super's setUp(). @@ -60,3 +61,30 @@ child.expect_exact(prompt) self.expect(child.before, exe=False, patterns=['= 5']) + +@skipIfRemote +@expectedFailureAll( +oslist=["windows"], +bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") +def test_empty_list(self): +"""Test printing an empty list of expressions""" +import pexpect +prompt = "(lldb) " + +# So that the child gets torn down after the test +self.child = pexpect.spawn( +"%s %s" % +(lldbtest_config.lldbExec, self.lldbOption)) +child = self.child + +# Turn on logging for what the child sends back. +if self.TraceOn(): +child.logfile_read = sys.stdout + +# We expect a prompt, then send "print" to start a list of expressions, +# then an empty line. We expect a prompt back. +child.expect_exact(prompt) +child.sendline("print") +child.expect_exact('1:') +child.sendline("") +child.expect_exact(prompt) Index: lldb/trunk/source/Host/common/Editline.cpp === --- lldb/trunk/source/Host/common/Editline.cpp +++ lldb/trunk/source/Host/common/Editline.cpp @@ -367,7 +367,7 @@ if (to == CursorLocation::EditingCursor) { toColumn = editline_cursor_position - (editline_cursor_row * m_terminal_width) + 1; - } else if (to == CursorLocation::BlockEnd) { + } else if (to == CursorLocation::BlockEnd && !m_input_lines.empty()) { toColumn = ((m_input_lines[m_input_lines.size() -
[Lldb-commits] [lldb] r302225 - Fix segfault resulting from empty print prompt
Author: labath Date: Fri May 5 06:51:21 2017 New Revision: 302225 URL: http://llvm.org/viewvc/llvm-project?rev=302225&view=rev Log: Fix segfault resulting from empty print prompt Summary: I have found a way to segfault lldb in 7 keystrokes! Steps to reproduce: 1) Launch lldb 2) Type `print` and hit enter. lldb will now prompt you to type a list of expressions, followed by an empty line. 3) Hit enter, indicating the end of your input. 4) Segfault! After some investigation, I've found the issue in Host/common/Editline.cpp. Editline::MoveCursor() relies on m_input_lines not being empty when the `to` argument is CursorPosition::BlockEnd. This scenario, as far as I can tell, occurs in one specific instance: In Editline::EndOrAddLineCommand() when the list of lines being processed contains exactly one string (""). Meeting this condition is fairly simple, I have posted steps to reproduce above. Reviewers: krytarowski, zturner, labath Reviewed By: labath Subscribers: scott.smith, lldb-commits Differential Revision: https://reviews.llvm.org/D32421 Patch by Alex Langford. Modified: lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py lldb/trunk/source/Host/common/Editline.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py?rev=302225&r1=302224&r2=302225&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py Fri May 5 06:51:21 2017 @@ -12,6 +12,7 @@ from lldbsuite.test import lldbutil class MultilineExpressionsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) +NO_DEBUG_INFO_TESTCASE = True def setUp(self): # Call super's setUp(). @@ -60,3 +61,30 @@ class MultilineExpressionsTestCase(TestB child.expect_exact(prompt) self.expect(child.before, exe=False, patterns=['= 5']) + +@skipIfRemote +@expectedFailureAll( +oslist=["windows"], +bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") +def test_empty_list(self): +"""Test printing an empty list of expressions""" +import pexpect +prompt = "(lldb) " + +# So that the child gets torn down after the test +self.child = pexpect.spawn( +"%s %s" % +(lldbtest_config.lldbExec, self.lldbOption)) +child = self.child + +# Turn on logging for what the child sends back. +if self.TraceOn(): +child.logfile_read = sys.stdout + +# We expect a prompt, then send "print" to start a list of expressions, +# then an empty line. We expect a prompt back. +child.expect_exact(prompt) +child.sendline("print") +child.expect_exact('1:') +child.sendline("") +child.expect_exact(prompt) Modified: lldb/trunk/source/Host/common/Editline.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Editline.cpp?rev=302225&r1=302224&r2=302225&view=diff == --- lldb/trunk/source/Host/common/Editline.cpp (original) +++ lldb/trunk/source/Host/common/Editline.cpp Fri May 5 06:51:21 2017 @@ -367,7 +367,7 @@ void Editline::MoveCursor(CursorLocation if (to == CursorLocation::EditingCursor) { toColumn = editline_cursor_position - (editline_cursor_row * m_terminal_width) + 1; - } else if (to == CursorLocation::BlockEnd) { + } else if (to == CursorLocation::BlockEnd && !m_input_lines.empty()) { toColumn = ((m_input_lines[m_input_lines.size() - 1].length() + GetPromptWidth()) % 80) + ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32421: Fix segfault resulting from empty print prompt
labath added a comment. Committed as 302225. I've fixed the indentation in your test, and added a couple of decorators to match other pexpect tests. Thanks for the patch! Repository: rL LLVM https://reviews.llvm.org/D32421 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32022: Fix backtrace of noreturn functions situated at the end of a module
labath added a comment. Jason, any thoughts on my comments above? https://reviews.llvm.org/D32022 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32820: Parallelize demangling
scott.smith added inline comments. Comment at: source/Symbol/Symtab.cpp:257 -// The "const char *" in "class_contexts" must come from a -// ConstString::GetCString() -std::set class_contexts; -UniqueCStringMap mangled_name_to_index; -std::vector symbol_contexts(num_symbols, nullptr); - -for (entry.value = 0; entry.value < num_symbols; ++entry.value) { - const Symbol *symbol = &m_symbols[entry.value]; +auto symbol_fn = [&states, this](size_t value) { + const Symbol *symbol = &m_symbols[value]; labath wrote: > The function looks big enough to deserve a name. (== Please move the lambda > out of line) ok but now's your chance to review it as a diff rather than a sea of red and green Repository: rL LLVM https://reviews.llvm.org/D32820 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D32757: Add TaskMap for iterating a function over a set of integers
Don't even need a template. Use llvm::function_ref On Fri, May 5, 2017 at 4:30 AM Pavel Labath via Phabricator < revi...@reviews.llvm.org> wrote: > This revision was automatically updated to reflect the committed changes. > Closed by commit rL302223: Add TaskMap for iterating a function over a set > of integers (authored by labath). > > Changed prior to commit: > https://reviews.llvm.org/D32757?vs=97907&id=97931#toc > > Repository: > rL LLVM > > https://reviews.llvm.org/D32757 > > Files: > lldb/trunk/include/lldb/Utility/TaskPool.h > lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp > lldb/trunk/source/Utility/TaskPool.cpp > lldb/trunk/unittests/Utility/TaskPoolTest.cpp > > ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32823: Remove an expensive lock from Timer
scott.smith updated this revision to Diff 97973. scott.smith marked 2 inline comments as done. scott.smith added a comment. remove same-name-different-site support from Timer::Category Repository: rL LLVM https://reviews.llvm.org/D32823 Files: include/lldb/Core/Timer.h source/API/SystemInitializerFull.cpp source/Commands/CommandObjectTarget.cpp source/Core/Disassembler.cpp source/Core/Mangled.cpp source/Core/Module.cpp source/Core/Timer.cpp source/Host/common/Symbols.cpp source/Initialization/SystemInitializerCommon.cpp source/Interpreter/CommandInterpreter.cpp source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp source/Symbol/DWARFCallFrameInfo.cpp source/Symbol/ObjectFile.cpp source/Symbol/Symtab.cpp source/Target/Target.cpp source/Target/TargetList.cpp unittests/Core/TimerTest.cpp Index: unittests/Core/TimerTest.cpp === --- unittests/Core/TimerTest.cpp +++ unittests/Core/TimerTest.cpp @@ -18,7 +18,8 @@ TEST(TimerTest, CategoryTimes) { Timer::ResetCategoryTimes(); { -Timer t("CAT1", ""); +static Timer::Category tcat("CAT1"); +Timer t(tcat, ""); std::this_thread::sleep_for(std::chrono::milliseconds(10)); } StreamString ss; @@ -32,14 +33,18 @@ TEST(TimerTest, CategoryTimesNested) { Timer::ResetCategoryTimes(); { -Timer t1("CAT1", ""); +static Timer::Category tcat1("CAT1"); +Timer t1(tcat1, ""); std::this_thread::sleep_for(std::chrono::milliseconds(10)); -Timer t2("CAT1", ""); +// Explicitly testing the same category as above. +Timer t2(tcat1, ""); std::this_thread::sleep_for(std::chrono::milliseconds(10)); } StreamString ss; Timer::DumpCategoryTimes(&ss); double seconds; + // It should only appear once. + ASSERT_EQ(ss.GetString().count("CAT1"), 1U); ASSERT_EQ(1, sscanf(ss.GetData(), "%lf sec for CAT1", &seconds)); EXPECT_LT(0.002, seconds); EXPECT_GT(0.2, seconds); @@ -48,9 +53,11 @@ TEST(TimerTest, CategoryTimes2) { Timer::ResetCategoryTimes(); { -Timer t1("CAT1", ""); +static Timer::Category tcat1("CAT1"); +Timer t1(tcat1, ""); std::this_thread::sleep_for(std::chrono::milliseconds(100)); -Timer t2("CAT2", ""); +static Timer::Category tcat2("CAT2"); +Timer t2(tcat2, ""); std::this_thread::sleep_for(std::chrono::milliseconds(10)); } StreamString ss; Index: source/Target/TargetList.cpp === --- source/Target/TargetList.cpp +++ source/Target/TargetList.cpp @@ -325,10 +325,10 @@ lldb::PlatformSP &platform_sp, lldb::TargetSP &target_sp, bool is_dummy_target) { - Timer scoped_timer(LLVM_PRETTY_FUNCTION, - "TargetList::CreateTarget (file = '%s', arch = '%s')", - user_exe_path.str().c_str(), - specified_arch.GetArchitectureName()); + static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); + Timer scoped_timer( + func_cat, "TargetList::CreateTarget (file = '%s', arch = '%s')", + user_exe_path.str().c_str(), specified_arch.GetArchitectureName()); Error error; ArchSpec arch(specified_arch); Index: source/Target/Target.cpp === --- source/Target/Target.cpp +++ source/Target/Target.cpp @@ -1235,7 +1235,8 @@ ClearModules(false); if (executable_sp) { -Timer scoped_timer(LLVM_PRETTY_FUNCTION, +static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); +Timer scoped_timer(func_cat, "Target::SetExecutableModule (executable = '%s')", executable_sp->GetFileSpec().GetPath().c_str()); Index: source/Symbol/Symtab.cpp === --- source/Symbol/Symtab.cpp +++ source/Symbol/Symtab.cpp @@ -220,7 +220,8 @@ // Protected function, no need to lock mutex... if (!m_name_indexes_computed) { m_name_indexes_computed = true; -Timer scoped_timer(LLVM_PRETTY_FUNCTION, "%s", LLVM_PRETTY_FUNCTION); +static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); +Timer scoped_timer(func_cat, "%s
[Lldb-commits] [PATCH] D32823: Remove an expensive lock from Timer
scott.smith added inline comments. Comment at: unittests/Core/TimerTest.cpp:39 std::this_thread::sleep_for(std::chrono::milliseconds(10)); -Timer t2("CAT1", ""); +// Explicitly testing the same category as above. +static Timer::Category tcat1b("CAT1"); labath wrote: > Do we actually need to support that? Since we already have a nice Category > object then I think we should use that as a unique key for everything > (including printing). There no reason why the category needs to have local > scope. If it really needs to be used from multiple places, we can expose the > object at a higher scope. For the tests, this could be done by having a > fixture which creates the categories in the SetUpTestCase static function. > Alternatively, we could have Category object be based on llvm::ManagedStatic, > so it would go away when you call llvm_shutdown, which would enable us to > have truly isolated and leak-free tests. (Right now we don't call > llvm_shutdown in the main app as we cannot shutdown cleanly, but it would be > great if one day we could.) I don't think so. git grep Timer::Category | grep -v LLVM_PRETTY_FUNCTION shows one place (other than the unit test) where the name is explicitly set, and that's because that function already has its own scoped timer. All the other places are unique (one per function). The test might be testing for recursion-safe timers, in which case I can just change the declaration of t2: Timer t2(tcat1a, "") so it uses the same category object. Repository: rL LLVM https://reviews.llvm.org/D32823 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32820: Parallelize demangling
clayborg added a comment. What are the measured improvements here? We can't slow things down on any platforms. I know MacOS didn't respond well to making demangling run in parallel. I want to see some numbers here. And please don't quote numbers with tcmalloc or any special allocator unless you have a patch in LLDB already to make this a build option. Comment at: source/Symbol/Symtab.cpp:233-239 + // Don't let trampolines get into the lookup by name map + // If we ever need the trampoline symbols to be searchable by name + // we can remove this and then possibly add a new bool to any of the + // Symtab functions that lookup symbols by name to indicate if they + // want trampolines. + if (symbol.IsTrampoline()) +return; Not being able to search for symbols by name when they are trampolines? If you lookup symbols by name I would expect things not to fail and I would expect that I would get all the answers, not just ones that are omitted for performance reasons. I would also not expect to have to specify extra flags. Please remove Repository: rL LLVM https://reviews.llvm.org/D32820 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32823: Remove an expensive lock from Timer
labath accepted this revision. labath added a comment. This revision is now accepted and ready to land. lgtm, thank you. Comment at: unittests/Core/TimerTest.cpp:39 std::this_thread::sleep_for(std::chrono::milliseconds(10)); -Timer t2("CAT1", ""); +// Explicitly testing the same category as above. +static Timer::Category tcat1b("CAT1"); scott.smith wrote: > labath wrote: > > Do we actually need to support that? Since we already have a nice Category > > object then I think we should use that as a unique key for everything > > (including printing). There no reason why the category needs to have local > > scope. If it really needs to be used from multiple places, we can expose > > the object at a higher scope. For the tests, this could be done by having a > > fixture which creates the categories in the SetUpTestCase static function. > > Alternatively, we could have Category object be based on > > llvm::ManagedStatic, so it would go away when you call llvm_shutdown, which > > would enable us to have truly isolated and leak-free tests. (Right now we > > don't call llvm_shutdown in the main app as we cannot shutdown cleanly, but > > it would be great if one day we could.) > I don't think so. > > git grep Timer::Category | grep -v LLVM_PRETTY_FUNCTION > shows one place (other than the unit test) where the name is explicitly set, > and that's because that function already has its own scoped timer. All the > other places are unique (one per function). > > The test might be testing for recursion-safe timers, in which case I can just > change the declaration of t2: > Timer t2(tcat1a, "") > > so it uses the same category object. Yes, the test was testing recursive timers (I wrote it). Repository: rL LLVM https://reviews.llvm.org/D32823 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r302260 - Add missing 'arch' key to valid qHostInfo keys
Author: fjricci Date: Fri May 5 12:18:08 2017 New Revision: 302260 URL: http://llvm.org/viewvc/llvm-project?rev=302260&view=rev Log: Add missing 'arch' key to valid qHostInfo keys Summary: 'arch' is a valid qHostInfo key, but the unit test for qHostInfo did not include it in the set of possible keys. Reviewers: tfiala, labath Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D32711 Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py?rev=302260&r1=302259&r2=302260&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py Fri May 5 12:18:08 2017 @@ -14,6 +14,7 @@ class TestGdbRemoteHostInfo(GdbRemoteTes mydir = TestBase.compute_mydir(__file__) KNOWN_HOST_INFO_KEYS = set([ +"arch", "cputype", "cpusubtype", "distribution_id", ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32711: Add missing 'arch' key to valid qHostInfo keys
This revision was automatically updated to reflect the committed changes. Closed by commit rL302260: Add missing 'arch' key to valid qHostInfo keys (authored by fjricci). Changed prior to commit: https://reviews.llvm.org/D32711?vs=97322&id=97983#toc Repository: rL LLVM https://reviews.llvm.org/D32711 Files: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py Index: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py === --- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py +++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py @@ -14,6 +14,7 @@ mydir = TestBase.compute_mydir(__file__) KNOWN_HOST_INFO_KEYS = set([ +"arch", "cputype", "cpusubtype", "distribution_id", Index: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py === --- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py +++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py @@ -14,6 +14,7 @@ mydir = TestBase.compute_mydir(__file__) KNOWN_HOST_INFO_KEYS = set([ +"arch", "cputype", "cpusubtype", "distribution_id", ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32820: Parallelize demangling
scott.smith marked an inline comment as done. scott.smith added a comment. In https://reviews.llvm.org/D32820#747309, @clayborg wrote: > What are the measured improvements here? We can't slow things down on any > platforms. I know MacOS didn't respond well to making demangling run in > parallel. I want to see some numbers here. And please don't quote numbers > with tcmalloc or any special allocator unless you have a patch in LLDB > already to make this a build option. Without tcmalloc, on Ubuntu 14.04, 40 core VM: 13% With tcmalloc, on Ubuntu 14.04, 40 core VM: 24% (built using cmake ... -DCMAKE_EXE_LINKER_FLAGS=-ltcmalloc_minimal, which amazingly only works when building with clang, not gcc...) I don't have access to a Mac, and of course YMMV depending on the application. so yeah, it's a bigger improvement with tcmalloc. Interestingly, I tried adding back the demangler improvements I had queued up (which reduced memory allocations), and they didn't matter much, which makes me think this is contention allocating const strings. I could be wrong though. By far the biggest performance improvement I have queued up is loading the shared libraries in parallel (https://reviews.llvm.org/D32597), but that's waiting on pulling parallel_for_each from LLD into LLVM (I think). If you're really leery of this change, I could just make the structural changes to allow parallelization, and then keep a small patch internally to enable it. Or enabling it could be platform dependent. Or ... ? Comment at: source/Symbol/Symtab.cpp:233-239 + // Don't let trampolines get into the lookup by name map + // If we ever need the trampoline symbols to be searchable by name + // we can remove this and then possibly add a new bool to any of the + // Symtab functions that lookup symbols by name to indicate if they + // want trampolines. + if (symbol.IsTrampoline()) +return; clayborg wrote: > Not being able to search for symbols by name when they are trampolines? If > you lookup symbols by name I would expect things not to fail and I would > expect that I would get all the answers, not just ones that are omitted for > performance reasons. I would also not expect to have to specify extra flags. > Please remove This is just moved code, not new code. You can use the phabricator history tool above to diff baseline against #97908, and see that the only change I made was continue->return, due to changing it from a loop to a lambda (now a separate function). This is why I pubished D32708 separately - I wanted to separate the functional change from the structural change. Repository: rL LLVM https://reviews.llvm.org/D32820 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32597: Initiate loading of shared libraries in parallel
clayborg added a comment. I would suggest adding Pavel and Tamas, or anyone that has contributed to DynamicLoaderPOSIXDYLD as this will affect them. Repository: rL LLVM https://reviews.llvm.org/D32597 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r302282 - Fix UDP Socket connections
Author: cbieneman Date: Fri May 5 15:35:50 2017 New Revision: 302282 URL: http://llvm.org/viewvc/llvm-project?rev=302282&view=rev Log: Fix UDP Socket connections Some of the refactoring in r301492 broke UDP socket connections. This is a partial revert of that refactoring. At some point I'll spend more time diagnosing where the refactoring went wrong and how to better clean up this code, but I don't have time to do that today. Modified: lldb/trunk/include/lldb/Host/common/UDPSocket.h lldb/trunk/source/Host/common/UDPSocket.cpp Modified: lldb/trunk/include/lldb/Host/common/UDPSocket.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/UDPSocket.h?rev=302282&r1=302281&r2=302282&view=diff == --- lldb/trunk/include/lldb/Host/common/UDPSocket.h (original) +++ lldb/trunk/include/lldb/Host/common/UDPSocket.h Fri May 5 15:35:50 2017 @@ -21,15 +21,13 @@ public: Socket *&socket); private: - UDPSocket(NativeSocket socket, const UDPSocket &listen_socket); + UDPSocket(NativeSocket socket); size_t Send(const void *buf, const size_t num_bytes) override; Error Connect(llvm::StringRef name) override; Error Listen(llvm::StringRef name, int backlog) override; Error Accept(Socket *&socket) override; - Error CreateSocket(); - SocketAddress m_sockaddr; }; } Modified: lldb/trunk/source/Host/common/UDPSocket.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/UDPSocket.cpp?rev=302282&r1=302281&r2=302282&view=diff == --- lldb/trunk/source/Host/common/UDPSocket.cpp (original) +++ lldb/trunk/source/Host/common/UDPSocket.cpp Fri May 5 15:35:50 2017 @@ -28,31 +28,41 @@ const int kDomain = AF_INET; const int kType = SOCK_DGRAM; static const char *g_not_supported_error = "Not supported"; -} // namespace - -UDPSocket::UDPSocket(bool should_close, bool child_processes_inherit) -: Socket(ProtocolUdp, should_close, child_processes_inherit) {} +} -UDPSocket::UDPSocket(NativeSocket socket, const UDPSocket &listen_socket) -: Socket(ProtocolUdp, listen_socket.m_should_close_fd, - listen_socket.m_child_processes_inherit) { +UDPSocket::UDPSocket(NativeSocket socket) : Socket(ProtocolUdp, true, true) { m_socket = socket; } +UDPSocket::UDPSocket(bool should_close, bool child_processes_inherit) +: Socket(ProtocolUdp, should_close, child_processes_inherit) {} + size_t UDPSocket::Send(const void *buf, const size_t num_bytes) { return ::sendto(m_socket, static_cast(buf), num_bytes, 0, m_sockaddr, m_sockaddr.GetLength()); } Error UDPSocket::Connect(llvm::StringRef name) { + return Error("%s", g_not_supported_error); +} + +Error UDPSocket::Listen(llvm::StringRef name, int backlog) { + return Error("%s", g_not_supported_error); +} + +Error UDPSocket::Accept(Socket *&socket) { + return Error("%s", g_not_supported_error); +} + +Error UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit, + Socket *&socket) { + std::unique_ptr final_socket; + Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); if (log) log->Printf("UDPSocket::%s (host/port = %s)", __FUNCTION__, name.data()); Error error; - if (error.Fail()) -return error; - std::string host_str; std::string port_str; int32_t port = INT32_MIN; @@ -84,11 +94,12 @@ Error UDPSocket::Connect(llvm::StringRef for (struct addrinfo *service_info_ptr = service_info_list; service_info_ptr != nullptr; service_info_ptr = service_info_ptr->ai_next) { -m_socket = Socket::CreateSocket( +auto send_fd = CreateSocket( service_info_ptr->ai_family, service_info_ptr->ai_socktype, -service_info_ptr->ai_protocol, m_child_processes_inherit, error); +service_info_ptr->ai_protocol, child_processes_inherit, error); if (error.Success()) { - m_sockaddr = service_info_ptr; + final_socket.reset(new UDPSocket(send_fd)); + final_socket->m_sockaddr = service_info_ptr; break; } else continue; @@ -96,17 +107,16 @@ Error UDPSocket::Connect(llvm::StringRef ::freeaddrinfo(service_info_list); - if (IsValid()) + if (!final_socket) return error; SocketAddress bind_addr; // Only bind to the loopback address if we are expecting a connection from // localhost to avoid any firewall issues. - const bool bind_addr_success = - (host_str == "127.0.0.1" || host_str == "localhost") - ? bind_addr.SetToLocalhost(kDomain, port) - : bind_addr.SetToAnyAddress(kDomain, port); + const bool bind_addr_success = (host_str == "127.0.0.1" || host_str == "localhost") + ? bind_addr.SetToLocalhost(kDomain, port) + : bind_addr.SetToAnyAddres
[Lldb-commits] [lldb] r302314 - Add DidStartExecuting/WillFinishExecuting methods to Expression.
Author: lhames Date: Fri May 5 17:42:13 2017 New Revision: 302314 URL: http://llvm.org/viewvc/llvm-project?rev=302314&view=rev Log: Add DidStartExecuting/WillFinishExecuting methods to Expression. These methods can be used by the derived expression types to perform expression specific and/or language specific actions before and after the expression runs. (ThreadPlanCallUserExpression is modified to call these methods on the expression immediately before/after execution of the expression). The immediate motivation is allowing Swift expressions to notify the swift runtime that exclusivity enforcement should be suspended while the expression runs (we want LLDB expressions to be able to access variables even when they're considered exclusively owned by someone else in the original program). Reviewed in https://reviews.llvm.org/D32889 Modified: lldb/trunk/include/lldb/Expression/Expression.h lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp Modified: lldb/trunk/include/lldb/Expression/Expression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/Expression.h?rev=302314&r1=302313&r2=302314&view=diff == --- lldb/trunk/include/lldb/Expression/Expression.h (original) +++ lldb/trunk/include/lldb/Expression/Expression.h Fri May 5 17:42:13 2017 @@ -99,6 +99,16 @@ public: //-- lldb::addr_t StartAddress() { return m_jit_start_addr; } + //-- + /// Called to notify the expression that it is about to be executed. + //-- + virtual void WillStartExecuting() {} + + //-- + /// Called to notify the expression that its execution has finished. + //-- + virtual void DidFinishExecuting() {} + virtual ExpressionTypeSystemHelper *GetTypeSystemHelper() { return nullptr; } protected: Modified: lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h?rev=302314&r1=302313&r2=302314&view=diff == --- lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h Fri May 5 17:42:13 2017 @@ -117,7 +117,7 @@ protected: lldb::addr_t &start_load_addr, lldb::addr_t &function_load_addr); - void DoTakedown(bool success); + virtual void DoTakedown(bool success); void SetBreakpoints(); Modified: lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h?rev=302314&r1=302313&r2=302314&view=diff == --- lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h Fri May 5 17:42:13 2017 @@ -35,6 +35,8 @@ public: void GetDescription(Stream *s, lldb::DescriptionLevel level) override; + void DidPush() override; + void WillPop() override; lldb::StopInfoSP GetRealStopInfo() override; @@ -48,6 +50,7 @@ public: } protected: + void DoTakedown(bool success) override; private: lldb::UserExpressionSP m_user_expression_sp; // This is currently just used to ensure the Modified: lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp?rev=302314&r1=302313&r2=302314&view=diff == --- lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp Fri May 5 17:42:13 2017 @@ -60,6 +60,12 @@ void ThreadPlanCallUserExpression::GetDe ThreadPlanCallFunction::GetDescription(s, level); } +void ThreadPlanCallUserExpression::DidPush() { + ThreadPlanCallFunction::DidPush(); + if (m_user_expression_sp) +m_user_expression_sp->WillStartExecuting(); +} + void ThreadPlanCallUserExpression::WillPop() { ThreadPlanCallFunction::WillPop(); if (m_user_expression_sp) @@ -113,3 +119,8 @@ StopInfoSP ThreadPlanCallUserExpression: return stop_info_sp; } + +void ThreadPlanCallUserExpression::DoTakedown(bool success) { + ThreadPlanCallFunction::DoTakedown(success); + m_user_expression_sp->DidFinishExecuting(); +} _
[Lldb-commits] [lldb] r302323 - Added "info threads", "thread 1" and "apropos".
Author: jingham Date: Fri May 5 18:38:26 2017 New Revision: 302323 URL: http://llvm.org/viewvc/llvm-project?rev=302323&view=rev Log: Added "info threads", "thread 1" and "apropos". Modified: lldb/trunk/www/lldb-gdb.html Modified: lldb/trunk/www/lldb-gdb.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/lldb-gdb.html?rev=302323&r1=302322&r2=302323&view=diff == --- lldb/trunk/www/lldb-gdb.html (original) +++ lldb/trunk/www/lldb-gdb.html Fri May 5 18:38:26 2017 @@ -772,6 +772,27 @@ +List the threads in your program. + + +(gdb) info threads + + +(lldb) thread list + + + +Select thread 1 as the default thread for subsequent commands. + + +(gdb) thread 1 + + +(lldb) thread select 1 +(lldb) t 1 + + + Show the stack backtrace for the current thread. @@ -1250,6 +1271,16 @@ LLDB +Search command help for a keyword. + + +(gdb) apropos keyword + + +(lldb) apropos keyword + + + Echo text to the screen. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D32930: New framework for lldb client-server communication tests.
jmajors created this revision. Herald added a subscriber: mgorny. This is a new C++ test framework based on Google Test, and one working example test. The intention is to replace the existing tests in packages/Python/lldbsuite/test/tools/lldb-server/ with this suite and use this framework for all new client server tests. https://reviews.llvm.org/D32930 Files: unittests/CMakeLists.txt unittests/tools/CMakeLists.txt unittests/tools/lldb-server/.gitignore unittests/tools/lldb-server/CMakeLists.txt unittests/tools/lldb-server/inferior/thread_inferior.cpp unittests/tools/lldb-server/tests/CMakeLists.txt unittests/tools/lldb-server/tests/MessageObjects.cpp unittests/tools/lldb-server/tests/MessageObjects.h unittests/tools/lldb-server/tests/TestClient.cpp unittests/tools/lldb-server/tests/TestClient.h unittests/tools/lldb-server/tests/TestClientException.cpp unittests/tools/lldb-server/tests/TestClientException.h unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp unittests/tools/lldb-server/tests/gtest_common.h Index: unittests/tools/lldb-server/tests/gtest_common.h === --- /dev/null +++ unittests/tools/lldb-server/tests/gtest_common.h @@ -0,0 +1,26 @@ +//===-- gtest_common.h --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#if defined(LLDB_GTEST_COMMON_H) +#error "gtest_common.h should not be included manually." +#else +#define LLDB_GTEST_COMMON_H +#endif + +// This header file is force included by all of LLDB's unittest compilation +// units. Be very leary about putting anything in this file. + +#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0) +// Due to a bug in , when _HAS_EXCEPTIONS == 0 the header will try to +// call +// uncaught_exception() without having a declaration for it. The fix for this +// is +// to manually #include , which contains this declaration. +#include +#endif Index: unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp === --- /dev/null +++ unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp @@ -0,0 +1,52 @@ +//===-- ThreadsInJstopinfoTest.cpp --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include +#include + +#include + +#include "gtest/gtest.h" +#include "TestClient.h" + +using namespace std; +using namespace CommunicationTests; + +TEST(ThreadsInJstopinfoTest, TestStopReplyContainsThreadPcsLlgs) { + vector inferior_args; + // This inferior spawns N threads, then forces a break. + inferior_args.push_back(THREAD_INFERIOR); + inferior_args.push_back("4"); + + auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); + + TestClient client(test_info->name(), test_info->test_case_name()); + client.StartDebugger(); + client.SetInferior(inferior_args); + client.ListThreadsInStopReply(); + client.Continue(); + unsigned int pc_reg = client.GetPcRegisterId(); + + JThreadsInfo jthreads_info = client.GetJThreadsInfo(); + auto stop_reply = client.GetLatestStopReply(); + auto stop_reply_pcs = stop_reply->GetThreadPcs(); + auto thread_infos = jthreads_info.GetThreadInfos(); + + ASSERT_EQ(stop_reply_pcs.size(), thread_infos.size()) +<< "Thread count mismatch."; + for (auto stop_reply_pc : stop_reply_pcs) { +unsigned long tid = stop_reply_pc.first; +ASSERT_TRUE(thread_infos.find(tid) != thread_infos.end()) + << "Thread ID: " << tid << " not in JThreadsInfo."; +ASSERT_EQ(stop_reply_pcs[tid], thread_infos[tid].ReadRegister(pc_reg)) + << "Mismatched PC for thread: " << tid; + } + + client.StopDebugger(); +} Index: unittests/tools/lldb-server/tests/TestClientException.h === --- /dev/null +++ unittests/tools/lldb-server/tests/TestClientException.h @@ -0,0 +1,21 @@ +//===-- TestClient.h *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include +#include + +namespace CommunicationTests { +class TestClientException : public std::exception { +public: + TestClientException(const std::string& message); + const char* what() const noexcept; +private: + std::string message; +}; +}
[Lldb-commits] [lldb] r302327 - Be a little more permissive in DynamicLoaderMacOS::CanLoadImage
Author: jingham Date: Fri May 5 20:15:47 2017 New Revision: 302327 URL: http://llvm.org/viewvc/llvm-project?rev=302327&view=rev Log: Be a little more permissive in DynamicLoaderMacOS::CanLoadImage If we can't find the "is dyld locked" symbol, assume it is safe to load the image unless we only have 1 image loaded - in which case we are in _dyld_start and it is definitely NOT safe. Also add a little better errors to that function, and better logging in SBProcess.cpp. Modified: lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=302327&r1=302326&r2=302327&view=diff == --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Fri May 5 20:15:47 2017 @@ -1157,22 +1157,34 @@ uint32_t SBProcess::LoadImage(lldb::SBFi uint32_t SBProcess::LoadImage(const lldb::SBFileSpec &sb_local_image_spec, const lldb::SBFileSpec &sb_remote_image_spec, lldb::SBError &sb_error) { + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); ProcessSP process_sp(GetSP()); if (process_sp) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { + if (log) +log->Printf("SBProcess(%p)::LoadImage() => calling Platform::LoadImage" +"for: %s", +static_cast(process_sp.get()), +sb_local_image_spec.GetFilename()); + std::lock_guard guard( - process_sp->GetTarget().GetAPIMutex()); +process_sp->GetTarget().GetAPIMutex()); PlatformSP platform_sp = process_sp->GetTarget().GetPlatform(); return platform_sp->LoadImage(process_sp.get(), *sb_local_image_spec, *sb_remote_image_spec, sb_error.ref()); } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (log) log->Printf("SBProcess(%p)::LoadImage() => error: process is running", static_cast(process_sp.get())); sb_error.SetErrorString("process is running"); } + } else { +if (log) + log->Printf("SBProcess(%p)::LoadImage() => error: called with invalid" +" process", +static_cast(process_sp.get())); +sb_error.SetErrorString("process is invalid"); } return LLDB_INVALID_IMAGE_TOKEN; } Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp?rev=302327&r1=302326&r2=302327&view=diff == --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp Fri May 5 20:15:47 2017 @@ -434,24 +434,25 @@ Error DynamicLoaderMacOS::CanLoadImage() // Default assumption is that it is OK to load images. // Only say that we cannot load images if we find the symbol in libdyld and it - // indicates that - // we cannot. + // indicates that we cannot. if (symbol_address != LLDB_INVALID_ADDRESS) { { int lock_held = m_process->ReadUnsignedIntegerFromMemory(symbol_address, 4, 0, error); if (lock_held != 0) { -error.SetErrorToGenericError(); +error.SetErrorString("dyld lock held - unsafe to load images."); } } } else { // If we were unable to find _dyld_global_lock_held in any modules, or it is -// not loaded into -// memory yet, we may be at process startup (sitting at _dyld_start) - so we -// should not allow -// dlopen calls. -error.SetErrorToGenericError(); +// not loaded into memory yet, we may be at process startup (sitting +// at _dyld_start) - so we should not allow dlopen calls. +// But if we found more than one module then we are clearly past _dyld_start +// so in that case we'll default to "it's safe". +if (num_modules <= 1) +error.SetErrorString("could not find the dyld library or " + "the dyld lock symbol"); } return error; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits