diff options
| author | Bill Wendling <isanbard@gmail.com> | 2012-04-18 21:39:23 +0000 |
|---|---|---|
| committer | Bill Wendling <isanbard@gmail.com> | 2012-04-18 21:39:23 +0000 |
| commit | 392e4fbdd9b152efff4c051286f6b2c21270c902 (patch) | |
| tree | 4ac339be2c4c7c596f068b59d5e512b157c7b433 /lldb/test/python_api/module_section | |
| parent | eb1c2bdc1f55fbc5d1e7bb86e9f0e038b0f5adb7 (diff) | |
Creating release_31 branchllvmorg-3.1.0-rc1
llvm-svn: 155059
llvm-svn: 155053
llvm-svn: 155051
Diffstat (limited to 'lldb/test/python_api/module_section')
| -rw-r--r-- | lldb/test/python_api/module_section/Makefile | 6 | ||||
| -rw-r--r-- | lldb/test/python_api/module_section/TestModuleAndSection.py | 139 | ||||
| -rw-r--r-- | lldb/test/python_api/module_section/b.cpp | 3 | ||||
| -rw-r--r-- | lldb/test/python_api/module_section/c.cpp | 3 | ||||
| -rw-r--r-- | lldb/test/python_api/module_section/main.cpp | 128 |
5 files changed, 0 insertions, 279 deletions
diff --git a/lldb/test/python_api/module_section/Makefile b/lldb/test/python_api/module_section/Makefile deleted file mode 100644 index 5738d5684daf..000000000000 --- a/lldb/test/python_api/module_section/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -LEVEL = ../../make - -CXX_SOURCES := main.cpp b.cpp c.cpp -MAKE_DSYM :=NO - -include $(LEVEL)/Makefile.rules diff --git a/lldb/test/python_api/module_section/TestModuleAndSection.py b/lldb/test/python_api/module_section/TestModuleAndSection.py deleted file mode 100644 index 7038d6e71090..000000000000 --- a/lldb/test/python_api/module_section/TestModuleAndSection.py +++ /dev/null @@ -1,139 +0,0 @@ -""" -Test some SBModule and SBSection APIs. -""" - -import os, time -import re -import unittest2 -import lldb -from lldbtest import * -from lldbutil import symbol_type_to_str - -class ModuleAndSectionAPIsTestCase(TestBase): - - mydir = os.path.join("python_api", "module_section") - - @python_api_test - def test_module_and_section(self): - """Test module and section APIs.""" - self.buildDefault() - self.module_and_section() - - @python_api_test - def test_module_and_section_boundary_condition(self): - """Test module and section APIs by passing None when it expects a Python string.""" - self.buildDefault() - self.module_and_section_boundary_condition() - - @python_api_test - def test_module_compile_unit_iter(self): - """Test module's compile unit iterator APIs.""" - self.buildDefault() - self.module_compile_unit_iter() - - def module_and_section(self): - exe = os.path.join(os.getcwd(), "a.out") - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - self.assertTrue(target.GetNumModules() > 0) - - # Hide stdout if not running with '-t' option. - if not self.TraceOn(): - self.HideStdout() - - print "Number of modules for the target: %d" % target.GetNumModules() - for module in target.module_iter(): - print module - - # Get the executable module at index 0. - exe_module = target.GetModuleAtIndex(0) - - print "Exe module: %s" % str(exe_module) - print "Number of sections: %d" % exe_module.GetNumSections() - INDENT = ' ' * 4 - INDENT2 = INDENT * 2 - for sec in exe_module.section_iter(): - print sec - print INDENT + "Number of subsections: %d" % sec.GetNumSubSections() - if sec.GetNumSubSections() == 0: - for sym in exe_module.symbol_in_section_iter(sec): - print INDENT + str(sym) - print INDENT + "symbol type: %s" % symbol_type_to_str(sym.GetType()) - else: - for subsec in sec: - print INDENT + str(subsec) - # Now print the symbols belonging to the subsection.... - for sym in exe_module.symbol_in_section_iter(subsec): - print INDENT2 + str(sym) - print INDENT2 + "symbol type: %s" % symbol_type_to_str(sym.GetType()) - - def module_and_section_boundary_condition(self): - exe = os.path.join(os.getcwd(), "a.out") - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - self.assertTrue(target.GetNumModules() > 0) - - # Hide stdout if not running with '-t' option. - if not self.TraceOn(): - self.HideStdout() - - print "Number of modules for the target: %d" % target.GetNumModules() - for module in target.module_iter(): - print module - - # Get the executable module at index 0. - exe_module = target.GetModuleAtIndex(0) - - print "Exe module: %s" % str(exe_module) - print "Number of sections: %d" % exe_module.GetNumSections() - - # Boundary condition testings. Should not crash lldb! - exe_module.FindFirstType(None) - exe_module.FindTypes(None) - exe_module.FindGlobalVariables(target, None, 1) - exe_module.FindFunctions(None, 0) - exe_module.FindSection(None) - - # Get the section at index 1. - if exe_module.GetNumSections() > 1: - sec1 = exe_module.GetSectionAtIndex(1) - print sec1 - else: - sec1 = None - - if sec1: - sec1.FindSubSection(None) - - def module_compile_unit_iter(self): - exe = os.path.join(os.getcwd(), "a.out") - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - self.assertTrue(target.GetNumModules() > 0) - - # Hide stdout if not running with '-t' option. - if not self.TraceOn(): - self.HideStdout() - - print "Number of modules for the target: %d" % target.GetNumModules() - for module in target.module_iter(): - print module - - # Get the executable module at index 0. - exe_module = target.GetModuleAtIndex(0) - - print "Exe module: %s" % str(exe_module) - print "Number of compile units: %d" % exe_module.GetNumCompileUnits() - INDENT = ' ' * 4 - INDENT2 = INDENT * 2 - for cu in exe_module.compile_unit_iter(): - print cu - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() diff --git a/lldb/test/python_api/module_section/b.cpp b/lldb/test/python_api/module_section/b.cpp deleted file mode 100644 index 4e3e54138e5b..000000000000 --- a/lldb/test/python_api/module_section/b.cpp +++ /dev/null @@ -1,3 +0,0 @@ -int b_function(int input) { - return input * 2; -} diff --git a/lldb/test/python_api/module_section/c.cpp b/lldb/test/python_api/module_section/c.cpp deleted file mode 100644 index 3c87bfe30c6c..000000000000 --- a/lldb/test/python_api/module_section/c.cpp +++ /dev/null @@ -1,3 +0,0 @@ -int c_function(int input) { - return input * 3; -} diff --git a/lldb/test/python_api/module_section/main.cpp b/lldb/test/python_api/module_section/main.cpp deleted file mode 100644 index c7dcba4884c7..000000000000 --- a/lldb/test/python_api/module_section/main.cpp +++ /dev/null @@ -1,128 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// C includes -#include <pthread.h> -#include <stdio.h> -#include <stdint.h> -#include <stdlib.h> -#include <unistd.h> - -pthread_t g_thread_1 = NULL; -pthread_t g_thread_2 = NULL; -pthread_t g_thread_3 = NULL; - -typedef enum { - eGet, - eAssign, - eClearBits -} MaskAction; - -uint32_t mask_access (MaskAction action, uint32_t mask = 0); - -uint32_t -mask_access (MaskAction action, uint32_t mask) -{ - static pthread_mutex_t g_mask_mutex = PTHREAD_MUTEX_INITIALIZER; - static uint32_t g_mask = 0; - ::pthread_mutex_lock (&g_mask_mutex); - switch (action) - { - case eGet: - break; - - case eAssign: - g_mask |= mask; - break; - - case eClearBits: - g_mask &= ~mask; - break; - } - uint32_t new_mask = g_mask; - ::pthread_mutex_unlock (&g_mask_mutex); - return new_mask; -} - -void * -thread_func (void *arg) -{ - uint32_t thread_index = *((uint32_t *)arg); - uint32_t thread_mask = (1u << (thread_index)); - printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index); - - while (mask_access(eGet) & thread_mask) - { - // random micro second sleep from zero to 3 seconds - int usec = ::rand() % 3000000; - printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, thread_index, usec); - ::usleep (usec); - printf ("%s (thread = %u) after usleep ...\n", __FUNCTION__, thread_index); // Set break point at this line. - } - printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index); - return NULL; -} - - -int main (int argc, char const *argv[]) -{ - int err; - void *thread_result = NULL; - uint32_t thread_index_1 = 1; - uint32_t thread_index_2 = 2; - uint32_t thread_index_3 = 3; - uint32_t thread_mask_1 = (1u << thread_index_1); - uint32_t thread_mask_2 = (1u << thread_index_2); - uint32_t thread_mask_3 = (1u << thread_index_3); - - // Make a mask that will keep all threads alive - mask_access (eAssign, thread_mask_1 | thread_mask_2 | thread_mask_3); // And that line. - - // Create 3 threads - err = ::pthread_create (&g_thread_1, NULL, thread_func, &thread_index_1); - err = ::pthread_create (&g_thread_2, NULL, thread_func, &thread_index_2); - err = ::pthread_create (&g_thread_3, NULL, thread_func, &thread_index_3); - - char line[64]; - while (mask_access(eGet) != 0) - { - printf ("Enter thread index to kill or ENTER for all:\n"); - fflush (stdout); - // Kill threads by index, or ENTER for all threads - - if (fgets (line, sizeof(line), stdin)) - { - if (line[0] == '\n' || line[0] == '\r' || line[0] == '\0') - { - printf ("Exiting all threads...\n"); - break; - } - int32_t index = strtoul (line, NULL, 0); - switch (index) - { - case 1: mask_access (eClearBits, thread_mask_1); break; - case 2: mask_access (eClearBits, thread_mask_2); break; - case 3: mask_access (eClearBits, thread_mask_3); break; - } - continue; - } - - break; - } - - // Clear all thread bits to they all exit - mask_access (eClearBits, UINT32_MAX); - - // Join all of our threads - err = ::pthread_join (g_thread_1, &thread_result); - err = ::pthread_join (g_thread_2, &thread_result); - err = ::pthread_join (g_thread_3, &thread_result); - - return 0; -} |
