[Lldb-commits] test/lldbtest.py fix
Hello, I'm new to LLDB community and recently started to dive into LLDB. I was running tests on my Ubuntu and noticed that sometimes lldb and inferior process remained in process list after test run is completed: ps -elf | grep lldb 0 S ovyalov 13653 4457 0 80 0 - 125362 futex_ 11:09 ? 00:00:00 /usr/local/home/ovyalov/projects/lldb/git/build/bin/lldb --no-lldbinit -b -o break set -n main -o run -o continue /usr/local/home/ovyalov/projects/lldb/git/lldb/test/driver/batch_mode/a.out -- CRASH 0 t ovyalov 13783 13653 0 80 0 - 1049 ptrace 11:09 pts/60 00:00:00 /usr/local/home/ovyalov/projects/lldb/git/lldb/test/driver/batch_mode/a.out CRASH 0 S ovyalov 14124 4457 0 80 0 - 125362 futex_ 11:43 ? 00:00:00 /usr/local/home/ovyalov/projects/lldb/git/build/bin/lldb --no-lldbinit -b -o break set -n main -o run -o continue /usr/local/home/ovyalov/projects/lldb/git/lldb/test/driver/batch_mode/a.out -- CRASH 0 t ovyalov 14299 14124 0 80 0 - 1049 ptrace 11:43 pts/67 00:00:00 /usr/local/home/ovyalov/projects/lldb/git/lldb/test/driver/batch_mode/a.out CRASH 0 S ovyalov 14803 14689 0 80 0 - 125297 futex_ 17:15 pts/55 00:00:00 ./lldb --no-lldbinit -b -o break set -n main -o run -o continue /usr/local/home/ovyalov/projects/lldb/git/lldb/test/driver/batch_mode/a.out -- NOCRASH 0 t ovyalov 14809 14803 0 80 0 - 1048 ptrace 17:15 pts/58 00:00:00 /usr/local/home/ovyalov/projects/lldb/git/lldb/test/driver/batch_mode/a.out NOCRASH 0 S ovyalov 14837 28698 0 80 0 - 5936 pipe_w 17:16 pts/57 00:00:00 grep --color=auto lldb As I found out, the problem is in lldbtest.py which improperly handles exceptions. I've attached a patch to address this issue - please let me know whether it looks okay. diff --git a/test/lldbtest.py b/test/lldbtest.py index 3c626fd..ed11ef8 100644 --- a/test/lldbtest.py +++ b/test/lldbtest.py @@ -1014,12 +1014,12 @@ class Base(unittest2.TestCase): self.child.sendline('settings set interpreter.prompt-on-quit false') self.child.sendline('quit') self.child.expect(pexpect.EOF) -except ValueError, ExceptionPexpect: +except (ValueError, pexpect.ExceptionPexpect): # child is already terminated pass - -# Give it one final blow to make sure the child is terminated. -self.child.close() +finally: + # Give it one final blow to make sure the child is terminated. + self.child.close() def tearDown(self): Thank you. -- Oleksiy Vyalov | Software Engineer | ovya...@google.com diff --git a/test/lldbtest.py b/test/lldbtest.py index 3c626fd..ed11ef8 100644 --- a/test/lldbtest.py +++ b/test/lldbtest.py @@ -1014,12 +1014,12 @@ class Base(unittest2.TestCase): self.child.sendline('settings set interpreter.prompt-on-quit false') self.child.sendline('quit') self.child.expect(pexpect.EOF) -except ValueError, ExceptionPexpect: +except (ValueError, pexpect.ExceptionPexpect): # child is already terminated pass - -# Give it one final blow to make sure the child is terminated. -self.child.close() + finally: + # Give it one final blow to make sure the child is terminated. + self.child.close() def tearDown(self): ___ lldb-commits mailing list lldb-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r220574 - Make ProcessWindows just use Host::LaunchProcess.
Author: zturner Date: Fri Oct 24 12:51:56 2014 New Revision: 220574 URL: http://llvm.org/viewvc/llvm-project?rev=220574view=rev Log: Make ProcessWindows just use Host::LaunchProcess. Modified: lldb/trunk/source/Host/windows/HostProcessWindows.cpp lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.cpp Modified: lldb/trunk/source/Host/windows/HostProcessWindows.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/HostProcessWindows.cpp?rev=220574r1=220573r2=220574view=diff == --- lldb/trunk/source/Host/windows/HostProcessWindows.cpp (original) +++ lldb/trunk/source/Host/windows/HostProcessWindows.cpp Fri Oct 24 12:51:56 2014 @@ -115,7 +115,7 @@ HostProcessWindows::MonitorThread(void * DWORD wait_result = ::WaitForSingleObject(info-process_handle, INFINITE); ::GetExitCodeProcess(info-process_handle, exit_code); info-callback(info-baton, ::GetProcessId(info-process_handle), true, 0, exit_code); - +::CloseHandle(info-process_handle); delete (info); } return 0; Modified: lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.cpp?rev=220574r1=220573r2=220574view=diff == --- lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.cpp (original) +++ lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.cpp Fri Oct 24 12:51:56 2014 @@ -89,11 +89,7 @@ Error ProcessWindows::DoLaunch(Module *exe_module, ProcessLaunchInfo launch_info) { -Error error; -ProcessLauncherWindows launcher; -HostProcess process = launcher.LaunchProcess(launch_info, error); -launch_info.SetProcessID(process.GetProcessId()); -return error; +return Host::LaunchProcess(launch_info); } Error ___ lldb-commits mailing list lldb-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r220591 - Remove duplicated new file content
Author: emaste Date: Fri Oct 24 15:49:50 2014 New Revision: 220591 URL: http://llvm.org/viewvc/llvm-project?rev=220591view=rev Log: Remove duplicated new file content Modified: lldb/trunk/test/python_api/section/Makefile lldb/trunk/test/python_api/section/TestSectionAPI.py lldb/trunk/test/python_api/section/main.c Modified: lldb/trunk/test/python_api/section/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/section/Makefile?rev=220591r1=220590r2=220591view=diff == --- lldb/trunk/test/python_api/section/Makefile (original) +++ lldb/trunk/test/python_api/section/Makefile Fri Oct 24 15:49:50 2014 @@ -3,8 +3,3 @@ LEVEL = ../../make C_SOURCES := main.c include $(LEVEL)/Makefile.rules -LEVEL = ../../make - -C_SOURCES := main.c - -include $(LEVEL)/Makefile.rules Modified: lldb/trunk/test/python_api/section/TestSectionAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/section/TestSectionAPI.py?rev=220591r1=220590r2=220591view=diff == --- lldb/trunk/test/python_api/section/TestSectionAPI.py (original) +++ lldb/trunk/test/python_api/section/TestSectionAPI.py Fri Oct 24 15:49:50 2014 @@ -58,63 +58,3 @@ if __name__ == '__main__': lldb.SBDebugger.Initialize() atexit.register(lambda: lldb.SBDebugger.Terminate()) unittest2.main() - -Test SBSection APIs. - - -import unittest2 -from lldbtest import * - -class SectionAPITestCase(TestBase): - -mydir = TestBase.compute_mydir(__file__) - -@unittest2.skipUnless(sys.platform.startswith(darwin), requires Darwin) -@python_api_test -@dsym_test -def test_get_target_byte_size_with_dsym(self): -d = {'EXE': 'a.out'} -self.buildDsym(dictionary=d) -self.setTearDownCleanup(dictionary=d) -target = self.create_simple_target('a.out') - -# find the .data section of the main module -data_section = self.find_data_section(target) - -self.assertEquals(data_section.target_byte_size, 1) - -@python_api_test -@dwarf_test -def test_get_target_byte_size_with_dwarf(self): -d = {'EXE': 'b.out'} -self.buildDwarf(dictionary=d) -self.setTearDownCleanup(dictionary=d) -target = self.create_simple_target('b.out') - -# find the .data section of the main module -data_section = self.find_data_section(target) - -self.assertEquals(data_section.target_byte_size, 1) - -def create_simple_target(self, fn): -exe = os.path.join(os.getcwd(), fn) -target = self.dbg.CreateTarget(exe) -self.assertTrue(target, VALID_TARGET) -return target - -def find_data_section(self, target): -mod = target.GetModuleAtIndex(0) -data_section = None -for s in mod.sections: -if .data == s.name: -data_section = s -break - -self.assertIsNotNone(data_section) -return data_section - -if __name__ == '__main__': -import atexit -lldb.SBDebugger.Initialize() -atexit.register(lambda: lldb.SBDebugger.Terminate()) -unittest2.main() Modified: lldb/trunk/test/python_api/section/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/section/main.c?rev=220591r1=220590r2=220591view=diff == --- lldb/trunk/test/python_api/section/main.c (original) +++ lldb/trunk/test/python_api/section/main.c Fri Oct 24 15:49:50 2014 @@ -26,31 +26,3 @@ int main (int argc, char const *argv[]) return my_global_var_of_char_type; } -//===-- main.c --*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===--===// -#include stdio.h -#include string.h - -// This simple program is to test the lldb Python API SBSection. It includes -// somes global data, and so the build process produces a DATA section, which -// the test code can use to query for the target byte size - -char my_global_var_of_char_type = 'X'; - -int main (int argc, char const *argv[]) -{ -// this code just does something with the global so that it is not -// optimised away -if (argc 1 strlen(argv[1])) -{ -my_global_var_of_char_type += argv[1][0]; -} - -return my_global_var_of_char_type; -} ___ lldb-commits mailing list lldb-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [lldb] r220511 - Fix a problem where an SBType was advertising its static type class even though a dynamic type was available. Solves rdar://18744420
Sean, is there any provision in lldbinline for saying “Darwin-only”? or any other attribute for that matter... On Oct 24, 2014, at 2:18 PM, Ed Maste ema...@freebsd.org wrote: On 23 October 2014 17:15, Enrico Granata egran...@apple.com wrote: Author: enrico Date: Thu Oct 23 16:15:20 2014 New Revision: 220511 URL: http://llvm.org/viewvc/llvm-project?rev=220511view=rev Log: Fix a problem where an SBType was advertising its static type class even though a dynamic type was available. Solves rdar://18744420 Hi Enrico, Can you please fix this testcase so that it only runs on Darwin. Thanks, - Enrico egranata@.com ☎️ 27683 ___ lldb-commits mailing list lldb-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r220596 - Implement explicit thread stack size specification on Windows.
Author: zturner Date: Fri Oct 24 17:06:29 2014 New Revision: 220596 URL: http://llvm.org/viewvc/llvm-project?rev=220596view=rev Log: Implement explicit thread stack size specification on Windows. Modified: lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Host/common/ThreadLauncher.cpp Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=220596r1=220595r2=220596view=diff == --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Fri Oct 24 17:06:29 2014 @@ -64,6 +64,7 @@ using namespace lldb_private; static uint32_t g_shared_debugger_refcount = 0; static lldb::user_id_t g_unique_id = 1; +static size_t g_debugger_event_thread_stack_bytes = 8 * 1024 * 1024; #pragma mark Static Functions @@ -3322,11 +3323,9 @@ Debugger::StartEventHandlerThread() { if (!m_event_handler_thread.IsJoinable()) { -m_event_handler_thread = ThreadLauncher::LaunchThread (lldb.debugger.event-handler, - EventHandlerThread, - this, - NULL, - 8*1024*1024); // Use larger 8MB stack for this thread +// Use larger 8MB stack for this thread +m_event_handler_thread = ThreadLauncher::LaunchThread(lldb.debugger.event-handler, EventHandlerThread, this, NULL, + g_debugger_event_thread_stack_bytes); } return m_event_handler_thread.IsJoinable(); } Modified: lldb/trunk/source/Host/common/ThreadLauncher.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/ThreadLauncher.cpp?rev=220596r1=220595r2=220596view=diff == --- lldb/trunk/source/Host/common/ThreadLauncher.cpp (original) +++ lldb/trunk/source/Host/common/ThreadLauncher.cpp Fri Oct 24 17:06:29 2014 @@ -32,7 +32,8 @@ ThreadLauncher::LaunchThread(llvm::Strin HostThreadCreateInfo *info_ptr = new HostThreadCreateInfo(name.data(), thread_function, thread_arg); lldb::thread_t thread; #ifdef _WIN32 -thread = (lldb::thread_t)::_beginthreadex(0, 0, HostNativeThread::ThreadCreateTrampoline, info_ptr, 0, NULL); +thread = +(lldb::thread_t)::_beginthreadex(0, (unsigned)min_stack_byte_size, HostNativeThread::ThreadCreateTrampoline, info_ptr, 0, NULL); if (thread == (lldb::thread_t)(-1L)) error.SetError(::GetLastError(), eErrorTypeWin32); #else ___ lldb-commits mailing list lldb-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r220602 - Setting breakpoints with name mask eFunctionNameTypeBase was broken for straight C names by 220432. Get
Author: jingham Date: Fri Oct 24 19:33:55 2014 New Revision: 220602 URL: http://llvm.org/viewvc/llvm-project?rev=220602view=rev Log: Setting breakpoints with name mask eFunctionNameTypeBase was broken for straight C names by 220432. Get that working again. Modified: lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Target/CPPLanguageRuntime.cpp Modified: lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h?rev=220602r1=220601r2=220602view=diff == --- lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h (original) +++ lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h Fri Oct 24 19:33:55 2014 @@ -132,9 +132,16 @@ public: static bool IsCPPMangledName(const char *name); - + +// Extract C++ context and identifier from a string using heuristic matching (as opposed to +// CPPLanguageRuntime::MethodName which has to have a fully qualified C++ name with parens and arguments. +// If the name is a lone C identifier (e.g. C) or a qualified C identifier (e.g. A::B::C) it will return true, +// and identifier will be the identifier (C and C respectively) and the context will be and A::B:: respectively. +// If the name fails the heuristic matching for a qualified or unqualified C/C++ identifier, then it will return false +// and identifier and context will be unchanged. + static bool -StripNamespacesFromVariableName (const char *name, const char *base_name_start, const char *base_name_end); +ExtractContextAndIdentifier (const char *name, llvm::StringRef context, llvm::StringRef identifier); // in some cases, compilers will output different names for one same type. when that happens, it might be impossible // to construct SBType objects for a valid type, because the name that is available is not the same as the name that Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=220602r1=220601r2=220602view=diff == --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Fri Oct 24 19:33:55 2014 @@ -1710,8 +1710,9 @@ Module::PrepareForFunctionNameLookup (co const char *name_cstr = name.GetCString(); lookup_name_type_mask = eFunctionNameTypeNone; match_name_after_lookup = false; -const char *base_name_start = NULL; -const char *base_name_end = NULL; + +llvm::StringRef basename; +llvm::StringRef context; if (name_type_mask eFunctionNameTypeAuto) { @@ -1725,18 +1726,16 @@ Module::PrepareForFunctionNameLookup (co lookup_name_type_mask |= eFunctionNameTypeSelector; CPPLanguageRuntime::MethodName cpp_method (name); -llvm::StringRef basename (cpp_method.GetBasename()); +basename = cpp_method.GetBasename(); if (basename.empty()) { -if (CPPLanguageRuntime::StripNamespacesFromVariableName (name_cstr, base_name_start, base_name_end)) +if (CPPLanguageRuntime::ExtractContextAndIdentifier (name_cstr, context, basename)) lookup_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase); else lookup_name_type_mask = eFunctionNameTypeFull; } else { -base_name_start = basename.data(); -base_name_end = base_name_start + basename.size(); lookup_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase); } } @@ -1751,9 +1750,7 @@ Module::PrepareForFunctionNameLookup (co CPPLanguageRuntime::MethodName cpp_method (name); if (cpp_method.IsValid()) { -llvm::StringRef basename (cpp_method.GetBasename()); -base_name_start = basename.data(); -base_name_end = base_name_start + basename.size(); +basename = cpp_method.GetBasename(); if (!cpp_method.GetQualifiers().empty()) { @@ -1766,12 +1763,9 @@ Module::PrepareForFunctionNameLookup (co } else { -if (!CPPLanguageRuntime::StripNamespacesFromVariableName (name_cstr, base_name_start, base_name_end)) -{ -lookup_name_type_mask = ~(eFunctionNameTypeMethod | eFunctionNameTypeBase); -if (lookup_name_type_mask == eFunctionNameTypeNone) -return; -} +// If the CPP method parser didn't manage to chop