aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/Python/lldbsuite/test/README-TestSuite7
-rw-r--r--packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py2
-rw-r--r--packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp6
-rw-r--r--packages/Python/lldbsuite/test/configuration.py10
-rw-r--r--packages/Python/lldbsuite/test/dosep.py2
-rw-r--r--packages/Python/lldbsuite/test/dotest.py270
-rw-r--r--packages/Python/lldbsuite/test/dotest_args.py9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py10
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/main.cpp6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/Makefile6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py114
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp51
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile8
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py63
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.cpp3
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/Makefile9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py120
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/main.cpp12
-rw-r--r--packages/Python/lldbsuite/test/functionalities/darwin_log/.categories1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/darwin_log/basic/TestDarwinLogBasic.py1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py10
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py53
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py52
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py23
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py33
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py38
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp3
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py45
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp13
-rw-r--r--packages/Python/lldbsuite/test/functionalities/disassembly/TestFrameDisassemble.py68
-rw-r--r--packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/frame-language/Makefile12
-rw-r--r--packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py87
-rw-r--r--packages/Python/lldbsuite/test/functionalities/frame-language/main.cpp10
-rw-r--r--packages/Python/lldbsuite/test/functionalities/frame-language/other-2.cpp7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/frame-language/other.cpp10
-rw-r--r--packages/Python/lldbsuite/test/functionalities/frame-language/other.h7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/frame-language/somefunc.c7
-rw-r--r--packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py67
-rw-r--r--packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py17
-rw-r--r--packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py22
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.corebin0 -> 24576 bytes
-rwxr-xr-xpackages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.outbin0 -> 3576 bytes
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.corebin0 -> 28672 bytes
-rwxr-xr-xpackages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.outbin0 -> 2792 bytes
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.corebin0 -> 28672 bytes
-rwxr-xr-xpackages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.outbin0 -> 2872 bytes
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py8
-rw-r--r--packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/Makefile8
-rw-r--r--packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/TestPreRunDylibs.py38
-rw-r--r--packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.cpp3
-rw-r--r--packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.h6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/main.cpp9
-rw-r--r--packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py16
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp2
-rw-r--r--packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile3
-rw-r--r--packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py67
-rw-r--r--packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c25
-rw-r--r--packages/Python/lldbsuite/test/lang/c/register_variables/Makefile2
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile4
-rw-r--r--packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py5
-rw-r--r--packages/Python/lldbsuite/test/lldbinline.py8
-rw-r--r--packages/Python/lldbsuite/test/lldbplatformutil.py12
-rw-r--r--packages/Python/lldbsuite/test/lldbtest.py65
-rw-r--r--packages/Python/lldbsuite/test/macosx/queues/TestQueues.py2
-rw-r--r--packages/Python/lldbsuite/test/make/Android.rules91
-rw-r--r--packages/Python/lldbsuite/test/make/Makefile.rules81
-rw-r--r--packages/Python/lldbsuite/test/make/pseudo_barrier.h20
-rw-r--r--packages/Python/lldbsuite/test/make/test_common.h39
-rw-r--r--packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py26
-rw-r--r--packages/Python/lldbsuite/test/python_api/name_lookup/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py66
-rw-r--r--packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp54
-rw-r--r--packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py20
-rw-r--r--packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py3
-rw-r--r--packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py16
-rw-r--r--packages/Python/lldbsuite/test/sample_test/Makefile6
-rw-r--r--packages/Python/lldbsuite/test/sample_test/TestSampleInlineTest.py10
-rw-r--r--packages/Python/lldbsuite/test/sample_test/TestSampleTest.py74
-rw-r--r--packages/Python/lldbsuite/test/sample_test/main.c13
-rw-r--r--packages/Python/lldbsuite/test/test_categories.py18
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiEnvironmentCd.py1
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py3
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py4
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py9
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py1
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py1
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py44
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp13
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py14
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py8
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py8
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py8
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/TestMiLexicalScope.py68
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp33
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py4
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py1
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py4
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py3
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py1
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py3
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py6
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/.clang-format1
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py (renamed from packages/Python/lldbsuite/test/tools/lldb-server/host-info/TestGdbRemoteHostInfo.py)0
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py119
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py60
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp630
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py18
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp50
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/main.cpp639
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/main.cpp7
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py115
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/main.cpp37
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/thread-name/Makefile (renamed from packages/Python/lldbsuite/test/tools/lldb-server/host-info/Makefile)4
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/thread-name/TestGdbRemoteThreadName.py41
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/thread-name/main.cpp22
-rw-r--r--packages/Python/lldbsuite/test_event/formatter/results_formatter.py31
-rw-r--r--packages/Python/lldbsuite/test_event/formatter/xunit.py2
139 files changed, 2922 insertions, 1286 deletions
diff --git a/packages/Python/lldbsuite/test/README-TestSuite b/packages/Python/lldbsuite/test/README-TestSuite
index 70e4c91b8894..92649fc9963c 100644
--- a/packages/Python/lldbsuite/test/README-TestSuite
+++ b/packages/Python/lldbsuite/test/README-TestSuite
@@ -54,6 +54,10 @@ o subdirectories of 'test'
C/C++/ObjC source files; they were created to house the Python test case which
does not involve lldb reading in an executable file at all.
+ The sample_test directory contains examples of both a full and an "inline"
+ testcase that run a process to a breakpoint and check a local variable. These
+ are convenient starting points for adding new tests.
+
o make directory
Contains Makefile.rules, which can be utilized by test cases to write Makefile
@@ -158,6 +162,9 @@ o Writing test cases:
from the command in the command return object, and all the part where you are driving the
debugger to the point you want to test will be more robust.
+ The sample_test directory contains a standard and an "inline" test that are good starting
+ points for writing a new test.
+
o Attaching in test cases:
If you need to attach to inferiors in your tests, you must make sure the inferior calls
diff --git a/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py b/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py
index 20e41f0f4121..dc1a0d19f83e 100644
--- a/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py
+++ b/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py
@@ -6,6 +6,7 @@ from __future__ import print_function
import os
import re
import subprocess
+import sys
import lldb
from lldbsuite.test.decorators import *
@@ -18,6 +19,7 @@ class TestMultipleSimultaneousDebuggers(TestBase):
mydir = TestBase.compute_mydir(__file__)
@skipIfNoSBHeaders
+ @expectedFailureAll(bugnumber="rdar://30564102")
@expectedFailureAll(
archs="i[3-6]86",
bugnumber="multi-process-driver.cpp creates an x64 target")
diff --git a/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp b/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
index 448304d83c75..15170a3e5eb5 100644
--- a/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
+++ b/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
@@ -15,7 +15,7 @@
#include <stdio.h>
#include <stdlib.h>
-
+#include <string.h>
#include "lldb/API/LLDB.h"
#include "lldb/API/SBCommandInterpreter.h"
@@ -217,6 +217,10 @@ void *do_one_debugger (void *in)
int main (int argc, char **argv)
{
+#if !defined(_MSC_VER)
+ signal(SIGPIPE, SIG_IGN);
+#endif
+
SBDebugger::Initialize();
completed_threads_array = (bool *) malloc (sizeof (bool) * NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS);
diff --git a/packages/Python/lldbsuite/test/configuration.py b/packages/Python/lldbsuite/test/configuration.py
index a0553a72c19d..120f8247c695 100644
--- a/packages/Python/lldbsuite/test/configuration.py
+++ b/packages/Python/lldbsuite/test/configuration.py
@@ -66,7 +66,7 @@ categoriesList = None
# set to true if we are going to use categories for cherry-picking test cases
useCategories = False
# Categories we want to skip
-skipCategories = []
+skipCategories = ["darwin-log"]
# use this to track per-category failures
failuresPerCategory = {}
@@ -76,11 +76,9 @@ lldbFrameworkPath = None
# Test suite repeat count. Can be overwritten with '-# count'.
count = 1
-# The 'archs' and 'compilers' can be specified via command line. The corresponding
-# options can be specified more than once. For example, "-A x86_64 -A i386"
-# => archs=['x86_64', 'i386'] and "-C gcc -C clang" => compilers=['gcc', 'clang'].
-archs = None # Must be initialized after option parsing
-compilers = None # Must be initialized after option parsing
+# The 'arch' and 'compiler' can be specified via command line.
+arch = None # Must be initialized after option parsing
+compiler = None # Must be initialized after option parsing
# The arch might dictate some specific CFLAGS to be passed to the toolchain to build
# the inferior programs. The global variable cflags_extras provides a hook to do
diff --git a/packages/Python/lldbsuite/test/dosep.py b/packages/Python/lldbsuite/test/dosep.py
index 6e98beb90cca..763793af93ed 100644
--- a/packages/Python/lldbsuite/test/dosep.py
+++ b/packages/Python/lldbsuite/test/dosep.py
@@ -1653,7 +1653,7 @@ def main(num_threads, test_subdir, test_runner_name, results_formatter):
# will be passed along to the timeout pre-kill handler and allows for loose
# coupling of its implementation.
runner_context = {
- "archs": configuration.archs,
+ "arch": configuration.arch,
"platform_name": configuration.lldb_platform_name,
"platform_url": configuration.lldb_platform_url,
"platform_working_dir": configuration.lldb_platform_working_dir,
diff --git a/packages/Python/lldbsuite/test/dotest.py b/packages/Python/lldbsuite/test/dotest.py
index 6b6b2574e638..7d739acba952 100644
--- a/packages/Python/lldbsuite/test/dotest.py
+++ b/packages/Python/lldbsuite/test/dotest.py
@@ -25,6 +25,7 @@ from __future__ import print_function
import atexit
import os
import errno
+import logging
import platform
import re
import signal
@@ -274,22 +275,28 @@ def parseOptionsAndInitTestdirs():
if args.h:
do_help = True
- if args.compilers:
- configuration.compilers = args.compilers
+ if args.compiler:
+ configuration.compiler = os.path.realpath(args.compiler)
+ if not is_exe(configuration.compiler):
+ configuration.compiler = which(args.compiler)
+ if not is_exe(configuration.compiler):
+ logging.error(
+ '%s is not a valid compiler executable; aborting...',
+ args.compiler)
+ sys.exit(-1)
else:
# Use a compiler appropriate appropriate for the Apple SDK if one was
# specified
if platform_system == 'Darwin' and args.apple_sdk:
- configuration.compilers = [
- seven.get_command_output(
- 'xcrun -sdk "%s" -find clang 2> /dev/null' %
- (args.apple_sdk))]
+ configuration.compiler = seven.get_command_output(
+ 'xcrun -sdk "%s" -find clang 2> /dev/null' %
+ (args.apple_sdk))
else:
# 'clang' on ubuntu 14.04 is 3.4 so we try clang-3.5 first
candidateCompilers = ['clang-3.5', 'clang', 'gcc']
for candidate in candidateCompilers:
if which(candidate):
- configuration.compilers = [candidate]
+ configuration.compiler = candidate
break
if args.channels:
@@ -304,18 +311,17 @@ def parseOptionsAndInitTestdirs():
'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' %
(args.apple_sdk))
- if args.archs:
- configuration.archs = args.archs
- for arch in configuration.archs:
- if arch.startswith(
- 'arm') and platform_system == 'Darwin' and not args.apple_sdk:
+ if args.arch:
+ configuration.arch = args.arch
+ if configuration.arch.startswith(
+ 'arm') and platform_system == 'Darwin' and not args.apple_sdk:
+ os.environ['SDKROOT'] = seven.get_command_output(
+ 'xcrun --sdk iphoneos.internal --show-sdk-path 2> /dev/null')
+ if not os.path.exists(os.environ['SDKROOT']):
os.environ['SDKROOT'] = seven.get_command_output(
- 'xcrun --sdk iphoneos.internal --show-sdk-path 2> /dev/null')
- if not os.path.exists(os.environ['SDKROOT']):
- os.environ['SDKROOT'] = seven.get_command_output(
- 'xcrun --sdk iphoneos --show-sdk-path 2> /dev/null')
+ 'xcrun --sdk iphoneos --show-sdk-path 2> /dev/null')
else:
- configuration.archs = [platform_machine]
+ configuration.arch = platform_machine
if args.categoriesList:
configuration.categoriesList = set(
@@ -363,7 +369,18 @@ def parseOptionsAndInitTestdirs():
configuration.lldbFrameworkPath = args.framework
if args.executable:
+ # lldb executable is passed explicitly
lldbtest_config.lldbExec = os.path.realpath(args.executable)
+ if not is_exe(lldbtest_config.lldbExec):
+ lldbtest_config.lldbExec = which(args.executable)
+ if not is_exe(lldbtest_config.lldbExec):
+ logging.error(
+ '%s is not a valid executable to test; aborting...',
+ args.executable)
+ sys.exit(-1)
+
+ if args.server:
+ os.environ['LLDB_DEBUGSERVER_PATH'] = args.server
if args.excluded:
for excl_file in args.excluded:
@@ -1025,6 +1042,49 @@ def setDefaultTripleForPlatform():
return {}
+def checkCompiler():
+ # Add some intervention here to sanity check that the compiler requested is sane.
+ # If found not to be an executable program, we abort.
+ c = configuration.compiler
+ if which(c):
+ return
+
+ if not sys.platform.startswith("darwin"):
+ raise Exception(c + " is not a valid compiler")
+
+ pipe = subprocess.Popen(
+ ['xcrun', '-find', c], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ cmd_output = pipe.stdout.read()
+ if not cmd_output or "not found" in cmd_output:
+ raise Exception(c + " is not a valid compiler")
+
+ configuration.compiler = cmd_output.split('\n')[0]
+ print("'xcrun -find %s' returning %s" % (c, configuration.compiler))
+
+def canRunLibcxxTests():
+ from lldbsuite.test import lldbplatformutil
+
+ platform = lldbplatformutil.getPlatform()
+
+ if lldbplatformutil.target_is_android() or lldbplatformutil.platformIsDarwin():
+ return True, "libc++ always present"
+
+ if platform == "linux":
+ if not os.path.isdir("/usr/include/c++/v1"):
+ return False, "Unable to find libc++ installation"
+ return True, "Headers found, let's hope they work"
+
+ return False, "Don't know how to build with libc++ on %s" % platform
+
+def checkLibcxxSupport():
+ result, reason = canRunLibcxxTests()
+ if result:
+ return # libc++ supported
+ if "libc++" in configuration.categoriesList:
+ return # libc++ category explicitly requested, let it run.
+ print("Libc++ tests will not be run because: " + reason)
+ configuration.skipCategories.append("libc++")
+
def run_suite():
# On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults
# does not exist before proceeding to running the test suite.
@@ -1110,8 +1170,15 @@ def run_suite():
if configuration.lldb_platform_working_dir:
print("Setting remote platform working directory to '%s'..." %
(configuration.lldb_platform_working_dir))
- lldb.remote_platform.SetWorkingDirectory(
- configuration.lldb_platform_working_dir)
+ error = lldb.remote_platform.MakeDirectory(
+ configuration.lldb_platform_working_dir, 448) # 448 = 0o700
+ if error.Fail():
+ raise Exception("making remote directory '%s': %s" % (
+ remote_test_dir, error))
+
+ if not lldb.remote_platform.SetWorkingDirectory(
+ configuration.lldb_platform_working_dir):
+ raise Exception("failed to set working directory '%s'" % remote_test_dir)
lldb.DBG.SetSelectedPlatform(lldb.remote_platform)
else:
lldb.remote_platform = None
@@ -1120,6 +1187,8 @@ def run_suite():
target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
+ checkLibcxxSupport()
+
# Don't do debugserver tests on everything except OS X.
configuration.dont_do_debugserver_test = "linux" in target_platform or "freebsd" in target_platform or "windows" in target_platform
@@ -1174,124 +1243,65 @@ def run_suite():
raise
#
- # Invoke the default TextTestRunner to run the test suite, possibly iterating
- # over different configurations.
+ # Invoke the default TextTestRunner to run the test suite
#
+ checkCompiler()
- iterArchs = False
- iterCompilers = False
+ if not configuration.parsable:
+ print("compiler=%s" % configuration.compiler)
- if isinstance(configuration.archs, list) and len(configuration.archs) >= 1:
- iterArchs = True
+ # Iterating over all possible architecture and compiler combinations.
+ os.environ["ARCH"] = configuration.arch
+ os.environ["CC"] = configuration.compiler
+ configString = "arch=%s compiler=%s" % (configuration.arch,
+ configuration.compiler)
+
+ # Translate ' ' to '-' for pathname component.
+ if six.PY2:
+ import string
+ tbl = string.maketrans(' ', '-')
+ else:
+ tbl = str.maketrans(' ', '-')
+ configPostfix = configString.translate(tbl)
- #
- # Add some intervention here to sanity check that the compilers requested are sane.
- # If found not to be an executable program, the invalid one is dropped
- # from the list.
- for i in range(len(configuration.compilers)):
- c = configuration.compilers[i]
- if which(c):
- continue
- else:
- if sys.platform.startswith("darwin"):
- pipe = subprocess.Popen(
- ['xcrun', '-find', c], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- cmd_output = pipe.stdout.read()
- if cmd_output:
- if "not found" in cmd_output:
- print("dropping %s from the compilers used" % c)
- configuration.compilers.remove(i)
- else:
- configuration.compilers[i] = cmd_output.split('\n')[0]
- print(
- "'xcrun -find %s' returning %s" %
- (c, configuration.compilers[i]))
+ # Output the configuration.
+ if not configuration.parsable:
+ sys.stderr.write("\nConfiguration: " + configString + "\n")
+ # First, write out the number of collected test cases.
if not configuration.parsable:
- print("compilers=%s" % str(configuration.compilers))
-
- if not configuration.compilers or len(configuration.compilers) == 0:
- print("No eligible compiler found, exiting.")
- exitTestSuite(1)
-
- if isinstance(
- configuration.compilers,
- list) and len(
- configuration.compilers) >= 1:
- iterCompilers = True
-
- # If we iterate on archs or compilers, there is a chance we want to split
- # stderr/stdout.
- if iterArchs or iterCompilers:
- old_stderr = sys.stderr
- old_stdout = sys.stdout
- new_stderr = None
- new_stdout = None
+ sys.stderr.write(configuration.separator + "\n")
+ sys.stderr.write(
+ "Collected %d test%s\n\n" %
+ (configuration.suite.countTestCases(),
+ configuration.suite.countTestCases() != 1 and "s" or ""))
- # Iterating over all possible architecture and compiler combinations.
- for ia in range(len(configuration.archs) if iterArchs else 1):
- archConfig = ""
- if iterArchs:
- os.environ["ARCH"] = configuration.archs[ia]
- archConfig = "arch=%s" % configuration.archs[ia]
- for ic in range(len(configuration.compilers) if iterCompilers else 1):
- if iterCompilers:
- os.environ["CC"] = configuration.compilers[ic]
- configString = "%s compiler=%s" % (
- archConfig, configuration.compilers[ic])
- else:
- configString = archConfig
-
- if iterArchs or iterCompilers:
- # Translate ' ' to '-' for pathname component.
- if six.PY2:
- import string
- tbl = string.maketrans(' ', '-')
- else:
- tbl = str.maketrans(' ', '-')
- configPostfix = configString.translate(tbl)
-
- # Output the configuration.
- if not configuration.parsable:
- sys.stderr.write("\nConfiguration: " + configString + "\n")
-
- #print("sys.stderr name is", sys.stderr.name)
- #print("sys.stdout name is", sys.stdout.name)
-
- # First, write out the number of collected test cases.
- if not configuration.parsable:
- sys.stderr.write(configuration.separator + "\n")
- sys.stderr.write(
- "Collected %d test%s\n\n" %
- (configuration.suite.countTestCases(),
- configuration.suite.countTestCases() != 1 and "s" or ""))
-
- if configuration.parsable:
- v = 0
- else:
- v = configuration.verbose
-
- # Invoke the test runner.
- if configuration.count == 1:
- result = unittest2.TextTestRunner(
- stream=sys.stderr,
- verbosity=v,
- resultclass=test_result.LLDBTestResult).run(
- configuration.suite)
- else:
- # We are invoking the same test suite more than once. In this case,
- # mark __ignore_singleton__ flag as True so the signleton pattern is
- # not enforced.
- test_result.LLDBTestResult.__ignore_singleton__ = True
- for i in range(configuration.count):
-
- result = unittest2.TextTestRunner(
- stream=sys.stderr,
- verbosity=v,
- resultclass=test_result.LLDBTestResult).run(
- configuration.suite)
-
- configuration.failed = configuration.failed or not result.wasSuccessful()
+ if configuration.parsable:
+ v = 0
+ else:
+ v = configuration.verbose
+
+ # Invoke the test runner.
+ if configuration.count == 1:
+ result = unittest2.TextTestRunner(
+ stream=sys.stderr,
+ verbosity=v,
+ resultclass=test_result.LLDBTestResult).run(
+ configuration.suite)
+ else:
+ # We are invoking the same test suite more than once. In this case,
+ # mark __ignore_singleton__ flag as True so the signleton pattern is
+ # not enforced.
+ test_result.LLDBTestResult.__ignore_singleton__ = True
+ for i in range(configuration.count):
+
+ result = unittest2.TextTestRunner(
+ stream=sys.stderr,
+ verbosity=v,
+ resultclass=test_result.LLDBTestResult).run(
+ configuration.suite)
+
+ configuration.failed = not result.wasSuccessful()
if configuration.sdir_has_content and not configuration.parsable:
sys.stderr.write(
diff --git a/packages/Python/lldbsuite/test/dotest_args.py b/packages/Python/lldbsuite/test/dotest_args.py
index fc896d53c0be..bc43a6fc04a9 100644
--- a/packages/Python/lldbsuite/test/dotest_args.py
+++ b/packages/Python/lldbsuite/test/dotest_args.py
@@ -69,10 +69,9 @@ def create_parser():
'-A',
'--arch',
metavar='arch',
- action='append',
- dest='archs',
+ dest='arch',
help=textwrap.dedent('''Specify the architecture(s) to test. This option can be specified more than once'''))
- group.add_argument('-C', '--compiler', metavar='compiler', dest='compilers', action='append', help=textwrap.dedent(
+ group.add_argument('-C', '--compiler', metavar='compiler', dest='compiler', help=textwrap.dedent(
'''Specify the compiler(s) used to build the inferior executables. The compiler path can be an executable basename or a full path to a compiler executable. This option can be specified multiple times.'''))
if sys.platform == 'darwin':
group.add_argument('--apple-sdk', metavar='apple_sdk', dest='apple_sdk', default="macosx", help=textwrap.dedent(
@@ -124,6 +123,10 @@ def create_parser():
metavar='executable-path',
help='The path to the lldb executable')
group.add_argument(
+ '--server',
+ metavar='server-path',
+ help='The path to the debug server executable to use')
+ group.add_argument(
'-s',
metavar='name',
help='Specify the name of the dir created to store the session files of tests with errored or failed status. If not specified, the test driver uses the timestamp as the session dir name')
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py
index c0c2267a8362..871363b7aed3 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py
@@ -45,14 +45,6 @@ class BreakpointOptionsTestCase(TestBase):
extra_options="-K 0",
num_expected_locations=1)
- # This should create a breakpoint 0 locations.
- lldbutil.run_break_set_by_file_and_line(
- self,
- "main.cpp",
- self.line,
- extra_options="-m 0",
- num_expected_locations=0)
-
# Run the program.
self.runCmd("run", RUN_SUCCEEDED)
@@ -68,8 +60,6 @@ class BreakpointOptionsTestCase(TestBase):
"1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" %
self.line,
"2: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" %
- self.line,
- "3: file = 'main.cpp', line = %d, exact_match = 1, locations = 0" %
self.line])
# Continue the program, there should be another stop.
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/main.cpp
index 363b90003d76..b2e8f523c84d 100644
--- a/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_options/main.cpp
@@ -1,8 +1,4 @@
-// Set break point at this line.
-
extern "C" int foo(void);
-int
-main (int argc, char **argv)
-{
+int main (int argc, char **argv) { // Set break point at this line.
return foo();
}
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/Makefile
new file mode 100644
index 000000000000..3665ae323e7b
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../../make
+
+ENABLE_THREADS := YES
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
new file mode 100644
index 000000000000..21fe084d3dfb
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
@@ -0,0 +1,114 @@
+"""
+Test hardware breakpoints for multiple threads.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+# Hardware breakpoints are supported only by platforms mentioned in oslist.
+@skipUnlessPlatform(oslist=['linux'])
+class HardwareBreakpointMultiThreadTestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ # LLDB supports hardware breakpoints for arm and aarch64 architectures.
+ @skipIf(archs=no_match(['arm', 'aarch64']))
+ @expectedFailureAndroid
+ def test_hw_break_set_delete_multi_thread(self):
+ self.build()
+ self.setTearDownCleanup()
+ self.break_multi_thread('delete')
+
+ # LLDB supports hardware breakpoints for arm and aarch64 architectures.
+ @skipIf(archs=no_match(['arm', 'aarch64']))
+ @expectedFailureAndroid
+ def test_hw_break_set_disable_multi_thread(self):
+ self.build()
+ self.setTearDownCleanup()
+ self.break_multi_thread('disable')
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Our simple source filename.
+ self.source = 'main.cpp'
+ # Find the line number to break inside main().
+ self.first_stop = line_number(
+ self.source, 'Starting thread creation with hardware breakpoint set')
+
+ def break_multi_thread(self, removal_type):
+ """Test that lldb hardware breakpoints work for multiple threads."""
+ self.runCmd(
+ "file %s" %
+ os.path.join(
+ os.getcwd(),
+ 'a.out'),
+ CURRENT_EXECUTABLE_SET)
+
+ # Stop in main before creating any threads.
+ lldbutil.run_break_set_by_file_and_line(
+ self, None, self.first_stop, num_expected_locations=1)
+
+ # Run the program.
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # We should be stopped again due to the breakpoint.
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+ # Now set a hardware breakpoint in thread function.
+ self.expect("breakpoint set -b hw_break_function --hardware",
+ substrs=[
+ 'Breakpoint',
+ 'hw_break_function',
+ 'address = 0x'])
+
+ # We should stop in hw_break_function function for 4 threads.
+ count = 0
+
+ while count < 2 :
+
+ self.runCmd("process continue")
+
+ # We should be stopped in hw_break_function
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=[
+ 'stop reason = breakpoint',
+ 'hw_break_function'])
+
+ # Continue the loop and test that we are stopped 4 times.
+ count += 1
+
+ if removal_type == 'delete':
+ self.runCmd("settings set auto-confirm true")
+
+ # Now 'breakpoint delete' should just work fine without confirmation
+ # prompt from the command interpreter.
+ self.expect("breakpoint delete",
+ startstr="All breakpoints removed")
+
+ # Restore the original setting of auto-confirm.
+ self.runCmd("settings clear auto-confirm")
+
+ elif removal_type == 'disable':
+ self.expect("breakpoint disable",
+ startstr="All breakpoints disabled.")
+
+ # Continue. Program should exit without stopping anywhere.
+ self.runCmd("process continue")
+
+ # Process should have stopped and exited with status = 0
+ self.expect("process status", PROCESS_STOPPED,
+ patterns=['Process .* exited with status = 0'])
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp
new file mode 100644
index 000000000000..d13393095c61
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/main.cpp
@@ -0,0 +1,51 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <chrono>
+#include <cstdio>
+#include <mutex>
+#include <random>
+#include <thread>
+
+#define NUM_OF_THREADS 4
+
+std::mutex hw_break_mutex;
+
+void
+hw_break_function (uint32_t thread_index) {
+ printf ("%s called by Thread #%u...\n", __FUNCTION__, thread_index);
+}
+
+
+void
+thread_func (uint32_t thread_index) {
+ printf ("%s (thread index = %u) starting...\n", __FUNCTION__, thread_index);
+
+ hw_break_mutex.lock();
+
+ hw_break_function(thread_index); // Call hw_break_function
+
+ hw_break_mutex.unlock();
+}
+
+
+int main (int argc, char const *argv[])
+{
+ std::thread threads[NUM_OF_THREADS];
+
+ printf ("Starting thread creation with hardware breakpoint set...\n");
+
+ for (auto &thread : threads)
+ thread = std::thread{thread_func, std::distance(threads, &thread)};
+
+ for (auto &thread : threads)
+ thread.join();
+
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile
new file mode 100644
index 000000000000..e7a1cab7e195
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/Makefile
@@ -0,0 +1,8 @@
+LEVEL = ../../../make
+
+DYLIB_NAME := foo
+DYLIB_CXX_SOURCES := foo.cpp
+CXX_SOURCES := main.cpp
+CFLAGS_EXTRAS += -fPIC
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py
new file mode 100644
index 000000000000..26041c313e57
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/TestMoveNearest.py
@@ -0,0 +1,63 @@
+from __future__ import print_function
+
+
+import unittest2
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class TestMoveNearest(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.line1 = line_number('foo.h', '// !BR1')
+ self.line2 = line_number('foo.h', '// !BR2')
+ self.line_main = line_number('main.cpp', '// !BR_main')
+
+ def test(self):
+ """Test target.move-to-nearest logic"""
+
+ self.build()
+ target = self.dbg.CreateTarget("a.out")
+ self.assertTrue(target, VALID_TARGET)
+
+ lldbutil.run_break_set_by_symbol(self, 'main', sym_exact=True)
+ environment = self.registerSharedLibrariesWithTarget(target, ["foo"])
+ process = target.LaunchSimple(None, environment, self.get_process_working_directory())
+ self.assertEquals(process.GetState(), lldb.eStateStopped)
+
+ # Regardless of the -m value the breakpoint should have exactly one
+ # location on the foo functions
+ self.runCmd("settings set target.move-to-nearest-code true")
+ lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line1,
+ loc_exact=True, extra_options="-m 1")
+ lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line2,
+ loc_exact=True, extra_options="-m 1")
+
+ self.runCmd("settings set target.move-to-nearest-code false")
+ lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line1,
+ loc_exact=True, extra_options="-m 0")
+ lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line2,
+ loc_exact=True, extra_options="-m 0")
+
+
+ # Make sure we set a breakpoint in main with -m 1 for various lines in
+ # the function declaration
+ # "int"
+ lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
+ self.line_main-1, extra_options="-m 1")
+ # "main()"
+ lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
+ self.line_main, extra_options="-m 1")
+ # "{"
+ lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
+ self.line_main+1, extra_options="-m 1")
+ # "return .."
+ lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
+ self.line_main+2, extra_options="-m 1")
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.cpp
new file mode 100644
index 000000000000..8dad0a23f368
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.cpp
@@ -0,0 +1,3 @@
+#include "foo.h"
+
+int call_foo1() { return foo1(); }
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h
new file mode 100644
index 000000000000..060b91f5a5ea
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/foo.h
@@ -0,0 +1,6 @@
+LLDB_TEST_API inline int foo1() { return 1; } // !BR1
+
+LLDB_TEST_API inline int foo2() { return 2; } // !BR2
+
+LLDB_TEST_API extern int call_foo1();
+LLDB_TEST_API extern int call_foo2();
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp
new file mode 100644
index 000000000000..c9295a5c7d3c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/move_nearest/main.cpp
@@ -0,0 +1,9 @@
+#include "foo.h"
+
+int call_foo2() { return foo2(); }
+
+int
+main() // !BR_main
+{
+ return call_foo1() + call_foo2();
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/Makefile
new file mode 100644
index 000000000000..f89b52a972e9
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/Makefile
@@ -0,0 +1,9 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+ifneq (,$(findstring icc,$(CC)))
+ CXXFLAGS += -debug inline-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
new file mode 100644
index 000000000000..00ddc628607c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
@@ -0,0 +1,120 @@
+"""
+Test that breakpoints do not affect stepping.
+Check for correct StopReason when stepping to the line with breakpoint
+which chould be eStopReasonBreakpoint in general,
+and eStopReasonPlanComplete when breakpoint's condition fails.
+"""
+
+from __future__ import print_function
+
+import unittest2
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class StepOverBreakpointsTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ TestBase.setUp(self)
+
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+ src = lldb.SBFileSpec("main.cpp")
+
+ # Create a target by the debugger.
+ self.target = self.dbg.CreateTarget(exe)
+ self.assertTrue(self.target, VALID_TARGET)
+
+ # Setup four breakpoints, two of them with false condition
+ self.line1 = line_number('main.cpp', "breakpoint_1")
+ self.line4 = line_number('main.cpp', "breakpoint_4")
+
+ self.breakpoint1 = self.target.BreakpointCreateByLocation(src, self.line1)
+ self.assertTrue(
+ self.breakpoint1 and self.breakpoint1.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+
+ self.breakpoint2 = self.target.BreakpointCreateBySourceRegex("breakpoint_2", src)
+ self.breakpoint2.GetLocationAtIndex(0).SetCondition('false')
+
+ self.breakpoint3 = self.target.BreakpointCreateBySourceRegex("breakpoint_3", src)
+ self.breakpoint3.GetLocationAtIndex(0).SetCondition('false')
+
+ self.breakpoint4 = self.target.BreakpointCreateByLocation(src, self.line4)
+
+ # Start debugging
+ self.process = self.target.LaunchSimple(
+ None, None, self.get_process_working_directory())
+ self.assertIsNotNone(self.process, PROCESS_IS_VALID)
+ self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint1)
+ self.assertIsNotNone(self.thread, "Didn't stop at breakpoint 1.")
+
+ def test_step_instruction(self):
+ # Count instructions between breakpoint_1 and breakpoint_4
+ contextList = self.target.FindFunctions('main', lldb.eFunctionNameTypeAuto)
+ self.assertEquals(contextList.GetSize(), 1)
+ symbolContext = contextList.GetContextAtIndex(0)
+ function = symbolContext.GetFunction()
+ self.assertTrue(function)
+ instructions = function.GetInstructions(self.target)
+ addr_1 = self.breakpoint1.GetLocationAtIndex(0).GetAddress()
+ addr_4 = self.breakpoint4.GetLocationAtIndex(0).GetAddress()
+ for i in range(instructions.GetSize()) :
+ addr = instructions.GetInstructionAtIndex(i).GetAddress()
+ if (addr == addr_1) : index_1 = i
+ if (addr == addr_4) : index_4 = i
+
+ steps_expected = index_4 - index_1
+ step_count = 0
+ # Step from breakpoint_1 to breakpoint_4
+ while True:
+ self.thread.StepInstruction(True)
+ step_count = step_count + 1
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertTrue(self.thread.GetStopReason() == lldb.eStopReasonPlanComplete or
+ self.thread.GetStopReason() == lldb.eStopReasonBreakpoint)
+ if (self.thread.GetStopReason() == lldb.eStopReasonBreakpoint) :
+ # we should not stop on breakpoint_2 and _3 because they have false condition
+ self.assertEquals(self.thread.GetFrameAtIndex(0).GetLineEntry().GetLine(), self.line4)
+ # breakpoint_2 and _3 should not affect step count
+ self.assertTrue(step_count >= steps_expected)
+ break
+
+ # Run the process until termination
+ self.process.Continue()
+ self.assertEquals(self.process.GetState(), lldb.eStateExited)
+
+ @skipIf(bugnumber="llvm.org/pr31972", hostoslist=["windows"])
+ def test_step_over(self):
+ #lldb.DBG.EnableLog("lldb", ["step","breakpoint"])
+
+ self.thread.StepOver()
+ # We should be stopped at the breakpoint_2 line with stop plan complete reason
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete)
+
+ self.thread.StepOver()
+ # We should be stopped at the breakpoint_3 line with stop plan complete reason
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete)
+
+ self.thread.StepOver()
+ # We should be stopped at the breakpoint_4
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonBreakpoint)
+ thread1 = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint4)
+ self.assertEquals(self.thread, thread1, "Didn't stop at breakpoint 4.")
+
+ # Check that stepping does not affect breakpoint's hit count
+ self.assertEquals(self.breakpoint1.GetHitCount(), 1)
+ self.assertEquals(self.breakpoint2.GetHitCount(), 0)
+ self.assertEquals(self.breakpoint3.GetHitCount(), 0)
+ self.assertEquals(self.breakpoint4.GetHitCount(), 1)
+
+ # Run the process until termination
+ self.process.Continue()
+ self.assertEquals(self.process.GetState(), lldb.eStateExited)
+
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/main.cpp
new file mode 100644
index 000000000000..8cfd34b73b55
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/main.cpp
@@ -0,0 +1,12 @@
+
+int func() { return 1; }
+
+int
+main(int argc, char const *argv[])
+{
+ int a = 0; // breakpoint_1
+ int b = func(); // breakpoint_2
+ a = b + func(); // breakpoint_3
+ return 0; // breakpoint_4
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/.categories b/packages/Python/lldbsuite/test/functionalities/darwin_log/.categories
new file mode 100644
index 000000000000..ea135483a483
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/.categories
@@ -0,0 +1 @@
+darwin-log
diff --git a/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/TestDarwinLogBasic.py b/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/TestDarwinLogBasic.py
index 85281a97c572..f65b1b89d35b 100644
--- a/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/TestDarwinLogBasic.py
+++ b/packages/Python/lldbsuite/test/functionalities/darwin_log/basic/TestDarwinLogBasic.py
@@ -22,6 +22,7 @@ class TestDarwinLogBasic(darwin_log.DarwinLogEventBasedTestBase):
@decorators.add_test_categories(['pyapi'])
@decorators.skipUnlessDarwin
@decorators.expectedFailureAll(archs=["i386"], bugnumber="rdar://28655626")
+ @decorators.expectedFailureAll(bugnumber="rdar://30645203")
def test_SBStructuredData_gets_broadcasted(self):
"""Exercise SBStructuredData API."""
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
index 6a832e02990a..63eb5e087e14 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
@@ -23,8 +23,7 @@ class LibCxxFunctionTestCase(TestBase):
var.SetPreferSyntheticValue(True)
return var
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows yet
+ @add_test_categories(["libc++"])
def test(self):
"""Test that std::function as defined by libc++ is correctly printed by LLDB"""
self.build()
@@ -36,9 +35,6 @@ class LibCxxFunctionTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
index 5d23fcef04ce..9b4308f54095 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
@@ -22,9 +22,10 @@ class LibcxxIteratorDataFormatterTestCase(TestBase):
TestBase.setUp(self)
# Find the line number to break at.
self.line = line_number('main.cpp', '// Set break point at this line.')
+ ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+ self.namespace = 'std::__' + ns + '1'
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows yet
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
"""Test that libc++ iterators format properly."""
self.build()
@@ -35,9 +36,6 @@ class LibcxxIteratorDataFormatterTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
@@ -57,8 +55,6 @@ class LibcxxIteratorDataFormatterTestCase(TestBase):
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
- self.expect('image list', substrs=self.getLibcPlusPlusLibs())
-
self.expect('frame variable ivI', substrs=['item = 3'])
self.expect('expr ivI', substrs=['item = 3'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py
index e2e082c795f7..e1ebbd5c226d 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py
@@ -19,9 +19,8 @@ class LibcxxListDataFormatterTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows yet
- @add_test_categories(["pyapi"])
+ @add_test_categories(["libc++"])
+ @expectedFailureAndroid(bugnumber="llvm.org/pr32592")
@skipIfDarwin # rdar://25499635
def test_with_run_command(self):
self.build()
@@ -40,8 +39,6 @@ class LibcxxListDataFormatterTestCase(TestBase):
# Run the program, it should stop at breakpoint 1.
process = target.LaunchSimple(
None, None, self.get_process_working_directory())
- lldbutil.skip_if_library_missing(
- self, target, lldbutil.PrintableRegex("libc\+\+"))
self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
self.assertEqual(
len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint1)), 1)
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
index 7433a0b0da2c..fc4714ea94e2 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
@@ -17,8 +17,12 @@ class LibcxxMapDataFormatterTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows yet
+ def setUp(self):
+ TestBase.setUp(self)
+ ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+ self.namespace = 'std::__' + ns + '1'
+
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
"""Test that that file and class static variables display correctly."""
self.build()
@@ -30,9 +34,6 @@ class LibcxxMapDataFormatterTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
@@ -52,16 +53,16 @@ class LibcxxMapDataFormatterTestCase(TestBase):
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
- self.expect('image list', substrs=self.getLibcPlusPlusLibs())
-
+ ns = self.namespace
self.expect('frame variable ii',
- substrs=['size=0',
+ substrs=['%s::map' % ns,
+ 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ii',
- substrs=['size=2',
+ substrs=['%s::map' % ns, 'size=2',
'[0] = ',
'first = 0',
'second = 0',
@@ -72,7 +73,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ii',
- substrs=['size=4',
+ substrs=['%s::map' % ns, 'size=4',
'[2] = ',
'first = 2',
'second = 0',
@@ -83,7 +84,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable ii",
- substrs=['size=8',
+ substrs=['%s::map' % ns, 'size=8',
'[5] = ',
'first = 5',
'second = 0',
@@ -92,7 +93,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
'second = 1'])
self.expect("p ii",
- substrs=['size=8',
+ substrs=['%s::map' % ns, 'size=8',
'[5] = ',
'first = 5',
'second = 0',
@@ -124,17 +125,17 @@ class LibcxxMapDataFormatterTestCase(TestBase):
self.runCmd("continue")
self.expect('frame variable ii',
- substrs=['size=0',
+ substrs=['%s::map' % ns, 'size=0',
'{}'])
self.expect('frame variable si',
- substrs=['size=0',
+ substrs=['%s::map' % ns, 'size=0',
'{}'])
self.runCmd("continue")
self.expect('frame variable si',
- substrs=['size=1',
+ substrs=['%s::map' % ns, 'size=1',
'[0] = ',
'first = \"zero\"',
'second = 0'])
@@ -142,7 +143,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable si",
- substrs=['size=4',
+ substrs=['%s::map' % ns, 'size=4',
'[0] = ',
'first = \"zero\"',
'second = 0',
@@ -157,7 +158,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
'second = 3'])
self.expect("p si",
- substrs=['size=4',
+ substrs=['%s::map' % ns, 'size=4',
'[0] = ',
'first = \"zero\"',
'second = 0',
@@ -192,19 +193,19 @@ class LibcxxMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable si',
- substrs=['size=0',
+ substrs=['%s::map' % ns, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable is',
- substrs=['size=0',
+ substrs=['%s::map' % ns, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable is",
- substrs=['size=4',
+ substrs=['%s::map' % ns, 'size=4',
'[0] = ',
'second = \"goofy\"',
'first = 85',
@@ -219,7 +220,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
'first = 3'])
self.expect("p is",
- substrs=['size=4',
+ substrs=['%s::map' % ns, 'size=4',
'[0] = ',
'second = \"goofy\"',
'first = 85',
@@ -254,19 +255,19 @@ class LibcxxMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable is',
- substrs=['size=0',
+ substrs=['%s::map' % ns, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ss',
- substrs=['size=0',
+ substrs=['%s::map' % ns, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable ss",
- substrs=['size=3',
+ substrs=['%s::map' % ns, 'size=3',
'[0] = ',
'second = \"hello\"',
'first = \"ciao\"',
@@ -278,7 +279,7 @@ class LibcxxMapDataFormatterTestCase(TestBase):
'first = \"gatto\"'])
self.expect("p ss",
- substrs=['size=3',
+ substrs=['%s::map' % ns, 'size=3',
'[0] = ',
'second = \"hello\"',
'first = \"ciao\"',
@@ -309,5 +310,5 @@ class LibcxxMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ss',
- substrs=['size=0',
+ substrs=['%s::map' % ns, 'size=0',
'{}'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py
index 66091e6e113f..b28a7e6bc31b 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py
@@ -18,8 +18,12 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows # libc++ not ported to Windows yet
- @skipIf(compiler="gcc")
+ def setUp(self):
+ TestBase.setUp(self)
+ ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+ self.namespace = 'std::__' + ns + '1'
+
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
"""Test that that file and class static variables display correctly."""
self.build()
@@ -31,9 +35,6 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
@@ -53,16 +54,15 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
- self.expect('image list', substrs=self.getLibcPlusPlusLibs())
-
+ multimap = self.namespace + "::multimap"
self.expect('frame variable ii',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ii',
- substrs=['size=2',
+ substrs=[multimap, 'size=2',
'[0] = ',
'first = 0',
'second = 0',
@@ -73,7 +73,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ii',
- substrs=['size=4',
+ substrs=[multimap, 'size=4',
'[2] = ',
'first = 2',
'second = 0',
@@ -84,7 +84,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable ii",
- substrs=['size=8',
+ substrs=[multimap, 'size=8',
'[5] = ',
'first = 5',
'second = 0',
@@ -93,7 +93,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
'second = 1'])
self.expect("p ii",
- substrs=['size=8',
+ substrs=[multimap, 'size=8',
'[5] = ',
'first = 5',
'second = 0',
@@ -125,17 +125,17 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ii',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
self.expect('frame variable si',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable si',
- substrs=['size=1',
+ substrs=[multimap, 'size=1',
'[0] = ',
'first = \"zero\"',
'second = 0'])
@@ -143,7 +143,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable si",
- substrs=['size=4',
+ substrs=[multimap, 'size=4',
'[0] = ',
'first = \"zero\"',
'second = 0',
@@ -158,7 +158,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
'second = 3'])
self.expect("p si",
- substrs=['size=4',
+ substrs=[multimap, 'size=4',
'[0] = ',
'first = \"zero\"',
'second = 0',
@@ -193,19 +193,19 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable si',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable is',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable is",
- substrs=['size=4',
+ substrs=[multimap, 'size=4',
'[0] = ',
'second = \"goofy\"',
'first = 85',
@@ -220,7 +220,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
'first = 3'])
self.expect("p is",
- substrs=['size=4',
+ substrs=[multimap, 'size=4',
'[0] = ',
'second = \"goofy\"',
'first = 85',
@@ -255,19 +255,19 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable is',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ss',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable ss",
- substrs=['size=3',
+ substrs=[multimap, 'size=3',
'[0] = ',
'second = \"hello\"',
'first = \"ciao\"',
@@ -279,7 +279,7 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
'first = \"gatto\"'])
self.expect("p ss",
- substrs=['size=3',
+ substrs=[multimap, 'size=3',
'[0] = ',
'second = \"hello\"',
'first = \"ciao\"',
@@ -310,5 +310,5 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect('frame variable ss',
- substrs=['size=0',
+ substrs=[multimap, 'size=0',
'{}'])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py
index d40bce83e0af..2f448e8fd115 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py
@@ -17,8 +17,17 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows yet
+ def setUp(self):
+ TestBase.setUp(self)
+ ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+ self.namespace = 'std::__' + ns + '1'
+
+ def getVariableType(self, name):
+ var = self.frame().FindVariable(name)
+ self.assertTrue(var.IsValid())
+ return var.GetType().GetCanonicalType().GetName()
+
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
"""Test that that file and class static variables display correctly."""
self.build()
@@ -30,9 +39,6 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
@@ -52,7 +58,9 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase):
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
- self.expect('image list', substrs=self.getLibcPlusPlusLibs())
+ ii_type = self.getVariableType("ii")
+ self.assertTrue(ii_type.startswith(self.namespace + "::multiset"),
+ "Type: " + ii_type)
self.expect("frame variable ii", substrs=["size=0", "{}"])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
@@ -86,6 +94,9 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase):
self.expect("frame variable ii", substrs=["size=0", "{}"])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable ii", substrs=["size=0", "{}"])
+ ss_type = self.getVariableType("ss")
+ self.assertTrue(ss_type.startswith(self.namespace + "::multiset"),
+ "Type: " + ss_type)
self.expect("frame variable ss", substrs=["size=0", "{}"])
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect(
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
index b0e84121dded..5b9b14d549e5 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
@@ -23,9 +23,10 @@ class LibcxxStringDataFormatterTestCase(TestBase):
TestBase.setUp(self)
# Find the line number to break at.
self.line = line_number('main.cpp', '// Set break point at this line.')
+ ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+ self.namespace = 'std::__' + ns + '1'
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows yet
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
"""Test that that file and class static variables display correctly."""
self.build()
@@ -36,9 +37,6 @@ class LibcxxStringDataFormatterTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
@@ -58,17 +56,18 @@ class LibcxxStringDataFormatterTestCase(TestBase):
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
+ ns = self.namespace
self.expect(
"frame variable",
substrs=[
- '(std::__1::wstring) s = L"hello world! מזל טוב!"',
- '(std::__1::wstring) S = L"!!!!"',
+ '(%s::wstring) s = L"hello world! מזל טוב!"'%ns,
+ '(%s::wstring) S = L"!!!!"'%ns,
'(const wchar_t *) mazeltov = 0x',
'L"מזל טוב"',
- '(std::__1::string) q = "hello world"',
- '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"',
- '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"',
- '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'])
+ '(%s::string) q = "hello world"'%ns,
+ '(%s::string) Q = "quite a long std::strin with lots of info inside it"'%ns,
+ '(%s::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"'%ns,
+ '(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'%ns])
self.runCmd("n")
@@ -91,11 +90,11 @@ class LibcxxStringDataFormatterTestCase(TestBase):
self.expect(
"frame variable",
substrs=[
- '(std::__1::wstring) s = L"hello world! מזל טוב!"',
- '(std::__1::wstring) S = L"!!!!!"',
+ '(%s::wstring) s = L"hello world! מזל טוב!"'%ns,
+ '(%s::wstring) S = L"!!!!!"'%ns,
'(const wchar_t *) mazeltov = 0x',
'L"מזל טוב"',
- '(std::__1::string) q = "hello world"',
- '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"',
- '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"',
- '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'])
+ '(%s::string) q = "hello world"'%ns,
+ '(%s::string) Q = "quite a long std::strin with lots of info inside it"'%ns,
+ '(%s::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"'%ns,
+ '(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'%ns])
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py
index 8a08d38975cf..f61a715a4d3e 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py
@@ -17,10 +17,13 @@ class LibcxxUnorderedDataFormatterTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows # libc++ not ported to Windows yet
- @skipIf(compiler="gcc")
+ def setUp(self):
+ TestBase.setUp(self)
+ ns = 'ndk' if lldbplatformutil.target_is_android() else ''
+ self.namespace = 'std::__' + ns + '1'
+
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
- """Test that that file and class static variables display correctly."""
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
@@ -29,9 +32,6 @@ class LibcxxUnorderedDataFormatterTestCase(TestBase):
self.runCmd("run", RUN_SUCCEEDED)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
@@ -51,30 +51,30 @@ class LibcxxUnorderedDataFormatterTestCase(TestBase):
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
- self.expect('image list', substrs=self.getLibcPlusPlusLibs())
-
+ ns = self.namespace
self.look_for_content_and_continue(
- "map", ['size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+ "map", ['%s::unordered_map' %
+ ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
self.look_for_content_and_continue(
- "mmap", ['size=6 {', 'first = 3', 'second = "this"',
- 'first = 2', 'second = "hello"'])
+ "mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 'second = "this"',
+ 'first = 2', 'second = "hello"'])
self.look_for_content_and_continue(
- "iset", ['size=5 {', '\[\d\] = 5', '\[\d\] = 3', '\[\d\] = 2'])
+ "iset", ['%s::unordered_set' %
+ ns, 'size=5 {', '\[\d\] = 5', '\[\d\] = 3', '\[\d\] = 2'])
self.look_for_content_and_continue(
- "sset", ['size=5 {', '\[\d\] = "is"', '\[\d\] = "world"',
- '\[\d\] = "hello"'])
+ "sset", ['%s::unordered_set' % ns, 'size=5 {', '\[\d\] = "is"', '\[\d\] = "world"',
+ '\[\d\] = "hello"'])
self.look_for_content_and_continue(
- "imset", ['size=6 {', '(\[\d\] = 3(\\n|.)+){3}',
- '\[\d\] = 2', '\[\d\] = 1'])
+ "imset", ['%s::unordered_multiset' % ns, 'size=6 {', '(\[\d\] = 3(\\n|.)+){3}',
+ '\[\d\] = 2', '\[\d\] = 1'])
self.look_for_content_and_continue(
- "smset",
- ['size=5 {', '(\[\d\] = "is"(\\n|.)+){2}',
- '(\[\d\] = "world"(\\n|.)+){2}'])
+ "smset", ['%s::unordered_multiset' % ns, 'size=5 {', '(\[\d\] = "is"(\\n|.)+){2}',
+ '(\[\d\] = "world"(\\n|.)+){2}'])
def look_for_content_and_continue(self, var_name, patterns):
self.expect(("frame variable %s" % var_name), patterns=patterns)
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py
index 43d5ad4f1033..a7a00068383f 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py
@@ -23,16 +23,12 @@ class LibcxxVBoolDataFormatterTestCase(TestBase):
# Find the line number to break at.
self.line = line_number('main.cpp', '// Set break point at this line.')
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows.
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
"""Test that that file and class static variables display correctly."""
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
lldbutil.run_break_set_by_file_and_line(
self, "main.cpp", self.line, num_expected_locations=-1)
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp
index 7b9956ed36ea..91fe509465e7 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp
@@ -65,5 +65,6 @@ int main()
vBool.push_back(true);
vBool.push_back(true);
- return 0; // Set break point at this line.
+ printf ("size: %d", (int) vBool.size()); // Set break point at this line.
+ return 0;
}
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
index 719ed7300505..9e226a100a10 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
@@ -17,16 +17,12 @@ class LibcxxVectorDataFormatterTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIf(compiler="gcc")
- @skipIfWindows # libc++ not ported to Windows yet
+ @add_test_categories(["libc++"])
def test_with_run_command(self):
"""Test that that file and class static variables display correctly."""
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
- lldbutil.skip_if_library_missing(
- self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
-
bkpt = self.target().FindBreakpointByID(
lldbutil.run_break_set_by_source_regexp(
self, "break here"))
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
index 770d87178f50..37adb28d7d59 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py
@@ -34,21 +34,25 @@ class StdUniquePtrDataFormatterTestCase(TestBase):
self.assertTrue(frame.IsValid())
self.expect("frame variable nup", substrs=['nup = nullptr'])
- self.expect("frame variable iup", substrs=['iup = 0x', 'object = 123'])
- self.expect("frame variable sup", substrs=['sup = 0x', 'object = "foobar"'])
+ self.expect("frame variable iup", substrs=['iup = 0x'])
+ self.expect("frame variable sup", substrs=['sup = 0x'])
self.expect("frame variable ndp", substrs=['ndp = nullptr'])
- self.expect("frame variable idp", substrs=['idp = 0x', 'object = 456', 'deleter = ', 'a = 1', 'b = 2'])
- self.expect("frame variable sdp", substrs=['sdp = 0x', 'object = "baz"', 'deleter = ', 'a = 3', 'b = 4'])
-
+ self.expect("frame variable idp", substrs=['idp = 0x', 'deleter = ', 'a = 1', 'b = 2'])
+ self.expect("frame variable sdp", substrs=['sdp = 0x', 'deleter = ', 'a = 3', 'b = 4'])
+
self.assertEqual(123, frame.GetValueForVariablePath("iup.object").GetValueAsUnsigned())
+ self.assertEqual(123, frame.GetValueForVariablePath("*iup").GetValueAsUnsigned())
self.assertFalse(frame.GetValueForVariablePath("iup.deleter").IsValid())
self.assertEqual('"foobar"', frame.GetValueForVariablePath("sup.object").GetSummary())
+ self.assertEqual('"foobar"', frame.GetValueForVariablePath("*sup").GetSummary())
self.assertFalse(frame.GetValueForVariablePath("sup.deleter").IsValid())
self.assertEqual(456, frame.GetValueForVariablePath("idp.object").GetValueAsUnsigned())
+ self.assertEqual(456, frame.GetValueForVariablePath("*idp").GetValueAsUnsigned())
self.assertEqual('"baz"', frame.GetValueForVariablePath("sdp.object").GetSummary())
+ self.assertEqual('"baz"', frame.GetValueForVariablePath("*sdp").GetSummary())
idp_deleter = frame.GetValueForVariablePath("idp.deleter")
self.assertTrue(idp_deleter.IsValid())
@@ -59,3 +63,34 @@ class StdUniquePtrDataFormatterTestCase(TestBase):
self.assertTrue(sdp_deleter.IsValid())
self.assertEqual(3, sdp_deleter.GetChildMemberWithName("a").GetValueAsUnsigned())
self.assertEqual(4, sdp_deleter.GetChildMemberWithName("b").GetValueAsUnsigned())
+
+ @skipIfFreeBSD
+ @skipIfWindows # libstdcpp not ported to Windows
+ @skipIfDarwin # doesn't compile on Darwin
+ def test_recursive_unique_ptr(self):
+ # Tests that LLDB can handle when we have a loop in the unique_ptr
+ # reference chain and that it correctly handles the different options
+ # for the frame variable command in this case.
+ self.build()
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ lldbutil.run_break_set_by_source_regexp(
+ self, "Set break point at this line.")
+ self.runCmd("run", RUN_SUCCEEDED)
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped', 'stop reason = breakpoint'])
+
+ self.expect("frame variable f1->fp",
+ substrs=['fp = 0x'])
+ self.expect("frame variable --ptr-depth=1 f1->fp",
+ substrs=['data = 2', 'fp = 0x'])
+ self.expect("frame variable --ptr-depth=2 f1->fp",
+ substrs=['data = 2', 'fp = 0x', 'data = 1'])
+
+ frame = self.frame()
+ self.assertTrue(frame.IsValid())
+ self.assertEqual(2, frame.GetValueForVariablePath("f1->fp.object.data").GetValueAsUnsigned())
+ self.assertEqual(2, frame.GetValueForVariablePath("f1->fp->data").GetValueAsUnsigned())
+ self.assertEqual(1, frame.GetValueForVariablePath("f1->fp.object.fp.object.data").GetValueAsUnsigned())
+ self.assertEqual(1, frame.GetValueForVariablePath("f1->fp->fp->data").GetValueAsUnsigned())
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp
index 4a40309338c1..dd0072764d4e 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp
@@ -8,6 +8,11 @@ struct Deleter {
int b;
};
+struct Foo {
+ int data;
+ std::unique_ptr<Foo> fp;
+};
+
int main() {
std::unique_ptr<char> nup;
std::unique_ptr<int> iup(new int{123});
@@ -18,5 +23,13 @@ int main() {
std::unique_ptr<std::string, Deleter> sdp(new std::string("baz"),
Deleter{3, 4});
+ std::unique_ptr<Foo> fp(new Foo{3});
+
+ // Set up a structure where we have a loop in the unique_ptr chain.
+ Foo* f1 = new Foo{1};
+ Foo* f2 = new Foo{2};
+ f1->fp.reset(f2);
+ f2->fp.reset(f1);
+
return 0; // Set break point at this line.
}
diff --git a/packages/Python/lldbsuite/test/functionalities/disassembly/TestFrameDisassemble.py b/packages/Python/lldbsuite/test/functionalities/disassembly/TestFrameDisassemble.py
new file mode 100644
index 000000000000..47357cf4f71d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/disassembly/TestFrameDisassemble.py
@@ -0,0 +1,68 @@
+"""
+Test to ensure SBFrame::Disassemble produces SOME output
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class FrameDisassembleTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_frame_disassemble(self):
+ """Sample test to ensure SBFrame::Disassemble produces SOME output."""
+ self.build()
+ self.frame_disassemble_test()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def frame_disassemble_test(self):
+ """Sample test to ensure SBFrame::Disassemble produces SOME output"""
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint in main.c at the source matching
+ # "Set a breakpoint here"
+ breakpoint = target.BreakpointCreateBySourceRegex(
+ "Set a breakpoint here", lldb.SBFileSpec("main.cpp"))
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() >= 1,
+ VALID_BREAKPOINT)
+
+ error = lldb.SBError()
+ # This is the launch info. If you want to launch with arguments or
+ # environment variables, add them using SetArguments or
+ # SetEnvironmentEntries
+
+ launch_info = lldb.SBLaunchInfo(None)
+ process = target.Launch(launch_info, error)
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # Did we hit our breakpoint?
+ from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
+ threads = get_threads_stopped_at_breakpoint(process, breakpoint)
+ self.assertTrue(
+ len(threads) == 1,
+ "There should be a thread stopped at our breakpoint")
+
+ # The hit count for the breakpoint should be 1.
+ self.assertTrue(breakpoint.GetHitCount() == 1)
+
+ frame = threads[0].GetFrameAtIndex(0)
+ disassembly = frame.Disassemble()
+ self.assertTrue(len(disassembly) != 0, "Disassembly was empty.")
diff --git a/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp b/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp
index 8813647f6b72..93925829ec82 100644
--- a/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp
@@ -20,7 +20,7 @@ main(int argc, char const *argv[])
int array[3];
- array[0] = sum (1238, 78392);
+ array[0] = sum (1238, 78392); // Set a breakpoint here
array[1] = sum (379265, 23674);
array[2] = sum (872934, 234);
diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/Makefile b/packages/Python/lldbsuite/test/functionalities/frame-language/Makefile
new file mode 100644
index 000000000000..089fc237b054
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/frame-language/Makefile
@@ -0,0 +1,12 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp other.cpp other-2.cpp
+C_SOURCES := somefunc.c
+
+include $(LEVEL)/Makefile.rules
+
+other-2.o: other-2.cpp
+ $(CXX) $(CFLAGS_NO_DEBUG) -c other-2.cpp
+
+somefunc.o: somefunc.c
+ $(CC) $(CFLAGS) -std=c99 -c somefunc.c \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py b/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py
new file mode 100644
index 000000000000..178e165f3cbe
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py
@@ -0,0 +1,87 @@
+"""
+Test the SB API SBFrame::GuessLanguage.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class TestFrameGuessLanguage(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ # If your test case doesn't stress debug info, the
+ # set this to true. That way it won't be run once for
+ # each debug info format.
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_guess_language(self):
+ """Test GuessLanguage for C and C++."""
+ self.build()
+ self.do_test()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def check_language(self, thread, frame_no, test_lang):
+ frame = thread.frames[frame_no]
+ self.assertTrue(frame.IsValid(), "Frame %d was not valid."%(frame_no))
+ lang = frame.GuessLanguage()
+ self.assertEqual(lang, test_lang)
+
+ def do_test(self):
+ """Test GuessLanguage for C & C++."""
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint in main.c at the source matching
+ # "Set a breakpoint here"
+ breakpoint = target.BreakpointCreateBySourceRegex(
+ "Set breakpoint here", lldb.SBFileSpec("somefunc.c"))
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() >= 1,
+ VALID_BREAKPOINT)
+
+ error = lldb.SBError()
+ # This is the launch info. If you want to launch with arguments or
+ # environment variables, add them using SetArguments or
+ # SetEnvironmentEntries
+
+ launch_info = lldb.SBLaunchInfo(None)
+ process = target.Launch(launch_info, error)
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # Did we hit our breakpoint?
+ from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
+ threads = get_threads_stopped_at_breakpoint(process, breakpoint)
+ self.assertTrue(
+ len(threads) == 1,
+ "There should be a thread stopped at our breakpoint")
+
+ # The hit count for the breakpoint should be 1.
+ self.assertTrue(breakpoint.GetHitCount() == 1)
+
+ thread = threads[0]
+
+ c_frame_language = lldb.eLanguageTypeC99
+ # gcc emits DW_LANG_C89 even if -std=c99 was specified
+ if "gcc" in self.getCompiler():
+ c_frame_language = lldb.eLanguageTypeC89
+
+ self.check_language(thread, 0, c_frame_language)
+ self.check_language(thread, 1, lldb.eLanguageTypeC_plus_plus)
+ self.check_language(thread, 2, lldb.eLanguageTypeC_plus_plus)
+
+
+
diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/main.cpp b/packages/Python/lldbsuite/test/functionalities/frame-language/main.cpp
new file mode 100644
index 000000000000..f5449f217908
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/frame-language/main.cpp
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include "other.h"
+
+int
+main()
+{
+ int test_var = 10;
+ Other::DoSomethingElse();
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/other-2.cpp b/packages/Python/lldbsuite/test/functionalities/frame-language/other-2.cpp
new file mode 100644
index 000000000000..77632de3ceb0
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/frame-language/other-2.cpp
@@ -0,0 +1,7 @@
+#include "other.h"
+
+void
+Other::DoSomethingElse()
+{
+ DoSomething();
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/other.cpp b/packages/Python/lldbsuite/test/functionalities/frame-language/other.cpp
new file mode 100644
index 000000000000..41f4f26079ad
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/frame-language/other.cpp
@@ -0,0 +1,10 @@
+#include "other.h"
+
+extern "C" void some_func();
+
+void
+Other::DoSomething()
+{
+ some_func();
+}
+
diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/other.h b/packages/Python/lldbsuite/test/functionalities/frame-language/other.h
new file mode 100644
index 000000000000..0a2c125e6b42
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/frame-language/other.h
@@ -0,0 +1,7 @@
+class Other
+{
+ public:
+ static void DoSomething();
+ static void DoSomethingElse();
+};
+
diff --git a/packages/Python/lldbsuite/test/functionalities/frame-language/somefunc.c b/packages/Python/lldbsuite/test/functionalities/frame-language/somefunc.c
new file mode 100644
index 000000000000..a4b4f47f32ec
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/frame-language/somefunc.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+void
+some_func()
+{
+ printf("Set breakpoint here.");
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py b/packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py
deleted file mode 100644
index 85741f548f33..000000000000
--- a/packages/Python/lldbsuite/test/functionalities/llvm/TestLLVM.py
+++ /dev/null
@@ -1,67 +0,0 @@
-"""
-Test lldb 'commands regex' command which allows the user to create a regular expression command.
-"""
-
-from __future__ import print_function
-
-
-import os
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestHomeDirectory(TestBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- @expectedFailureAll(
- hostoslist=["windows"],
- bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
- @no_debug_info_test
- def test_tilde_home_directory(self):
- """Test that we can resolve "~/" in paths correctly.
- When a path starts with "~/", we use llvm::sys::path::home_directory() to
- resolve the home directory. This currently relies on "HOME" being set in the
- environment. While this is usually set, we can't rely upon that. We might
- eventually get a fix into llvm::sys::path::home_directory() so it doesn't rely
- on having to have an environment variable set, but until then we have work around
- code in FileSpec::ResolveUsername (llvm::SmallVectorImpl<char> &path) to ensure
- this always works. This test tests that we get the correct answer for with and
- without "HOME" being set in the environment."""
- import pexpect
- prompt = "(lldb) "
-
- child = pexpect.spawn(
- '%s --no-use-colors %s' %
- (lldbtest_config.lldbExec, self.lldbOption))
- # Turn on logging for what the child sends back.
- if self.TraceOn():
- child.logfile_read = sys.stdout
- # So that the spawned lldb session gets shutdown durng teardown.
- self.child = child
-
- # Resolve "~/." to the full path of our home directory + "/."
- if 'HOME' in os.environ:
- home_dir = os.environ['HOME']
- if self.TraceOn():
- print("home directory is: '%s'" % (home_dir))
- if os.path.exists(home_dir):
- home_dir_slash_dot = home_dir + '/.'
- child.expect_exact(prompt)
- child.sendline('''script str(lldb.SBFileSpec("~/.", True))''')
- child.expect_exact(home_dir)
- child.expect_exact(prompt)
- child.sendline(
- '''script import os; os.unsetenv('HOME'); str(lldb.SBFileSpec("~/", True))''')
- child.expect_exact(home_dir)
- child.expect_exact(prompt)
- elif self.TraceOn():
- print(
- '''home directory "%s" doesn't exist, skipping home directory test''' %
- (home_dir))
- elif self.TraceOn():
- print('"HOME" not in environment, skipping home directory test')
-
- child.sendline('quit')
diff --git a/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py b/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py
index 9d4e44c96bbc..91342fdaf1c3 100644
--- a/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py
+++ b/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py
@@ -118,3 +118,20 @@ class MemoryReadTestCase(TestBase):
'16',
'18',
'20'])
+
+ # the gdb format specifier and the size in characters for
+ # the returned values including the 0x prefix.
+ variations = [['b', 4], ['h', 6], ['w', 10], ['g', 18]]
+ for v in variations:
+ formatter = v[0]
+ expected_object_length = v[1]
+ self.runCmd(
+ "memory read --gdb-format 4%s &my_uint64s" % formatter)
+ lines = self.res.GetOutput().splitlines()
+ objects_read = []
+ for l in lines:
+ objects_read.extend(l.split(':')[1].split())
+ # Check that we got back 4 0x0000 etc bytes
+ for o in objects_read:
+ self.assertTrue (len(o) == expected_object_length)
+ self.assertTrue(len(objects_read) == 4)
diff --git a/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp b/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp
index cd367ff318ab..fdc7b8bdba18 100644
--- a/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp
@@ -7,12 +7,14 @@
//
//===----------------------------------------------------------------------===//
#include <stdio.h>
+#include <stdint.h>
int main (int argc, char const *argv[])
{
char my_string[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 0};
double my_double = 1234.5678;
int my_ints[] = {2,4,6,8,10,12,14,16,18,20,22};
+ uint64_t my_uint64s[] = {0, 1, 2, 3, 4, 5, 6, 7};
printf("my_string=%s\n", my_string); // Set break point at this line.
printf("my_double=%g\n", my_double);
return 0;
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
index 7a987aeafb5b..38b55ef40c6b 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -21,10 +21,14 @@ class LinuxCoreTestCase(TestBase):
_i386_pid = 32306
_x86_64_pid = 32259
_s390x_pid = 1045
+ _mips64_n64_pid = 25619
+ _mips64_n32_pid = 3670
+ _mips_o32_pid = 3532
_i386_regions = 4
_x86_64_regions = 5
_s390x_regions = 2
+ _mips_regions = 5
def setUp(self):
super(LinuxCoreTestCase, self).setUp()
@@ -35,24 +39,40 @@ class LinuxCoreTestCase(TestBase):
super(LinuxCoreTestCase, self).tearDown()
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_i386(self):
"""Test that lldb can read the process information from an i386 linux core file."""
self.do_test("linux-i386", self._i386_pid, self._i386_regions)
+ def test_mips_o32(self):
+ """Test that lldb can read the process information from an MIPS O32 linux core file."""
+ self.do_test("linux-mipsel-gnuabio32", self._mips_o32_pid, self._mips_regions)
+
+ def test_mips_n32(self):
+ """Test that lldb can read the process information from an MIPS N32 linux core file """
+ self.do_test("linux-mips64el-gnuabin32", self._mips64_n32_pid, self._mips_regions)
+
+ def test_mips_n64(self):
+ """Test that lldb can read the process information from an MIPS N64 linux core file """
+ self.do_test("linux-mips64el-gnuabi64", self._mips64_n64_pid, self._mips_regions)
+
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_x86_64(self):
"""Test that lldb can read the process information from an x86_64 linux core file."""
self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions)
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_s390x(self):
"""Test that lldb can read the process information from an s390x linux core file."""
self.do_test("linux-s390x", self._s390x_pid, self._s390x_regions)
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_same_pid_running(self):
"""Test that we read the information from the core correctly even if we have a running
@@ -82,6 +102,7 @@ class LinuxCoreTestCase(TestBase):
self.RemoveTempFile("linux-x86_64-pid.core")
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_two_cores_same_pid(self):
"""Test that we handle the situation if we have two core files with the same PID
@@ -111,6 +132,7 @@ class LinuxCoreTestCase(TestBase):
self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions)
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_FPR_SSE(self):
# check x86_64 core file
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py
index 5a11a52e93a6..5b398c1ccf0c 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py
@@ -23,12 +23,14 @@ class GCoreTestCase(TestBase):
_x86_64_pid = 5669
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_i386(self):
"""Test that lldb can read the process information from an i386 linux core file."""
self.do_test("linux-i386", self._i386_pid)
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_x86_64(self):
"""Test that lldb can read the process information from an x86_64 linux core file."""
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp
index 9908faffb6eb..f53ce2f35924 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp
@@ -9,7 +9,7 @@
// This test verifies the correct handling of child thread exits.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <thread>
#include <csignal>
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core
new file mode 100644
index 000000000000..272c627cd244
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core
Binary files differ
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out
new file mode 100755
index 000000000000..a230aa4251ae
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out
Binary files differ
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core
new file mode 100644
index 000000000000..19c8100bdb11
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core
Binary files differ
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out
new file mode 100755
index 000000000000..d1293a71a856
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out
Binary files differ
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core
new file mode 100644
index 000000000000..2ad41395a2e0
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core
Binary files differ
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out
new file mode 100755
index 000000000000..dc809c8da482
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out
Binary files differ
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
index 7cc3c0775ced..4895c051d63e 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
@@ -27,12 +27,14 @@ class LinuxCoreThreadsTestCase(TestBase):
_x86_64_tid = 5250
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_i386(self):
"""Test that lldb can read the process information from an i386 linux core file."""
self.do_test("linux-i386", self._i386_pid, self._i386_tid)
@skipIf(oslist=['windows'])
+ @skipIfDarwin # <rdar://problem/31380097>, fails started happening with r299199
@skipIf(triple='^mips')
def test_x86_64(self):
"""Test that lldb can read the process information from an x86_64 linux core file."""
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp
index 826d9d3fa972..7e09662edb2d 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp
@@ -9,7 +9,7 @@
// This test verifies the correct handling of child thread exits.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <thread>
#include <csignal>
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
index 44a42fdfe9d1..9becd8756318 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -23,6 +23,14 @@ class MiniDumpNewTestCase(TestBase):
_linux_x86_64_not_crashed_pid = 29939
_linux_x86_64_not_crashed_pid_offset = 0xD967
+ def setUp(self):
+ super(MiniDumpNewTestCase, self).setUp()
+ self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+ def tearDown(self):
+ lldb.DBG.SetSelectedPlatform(self._initial_platform)
+ super(MiniDumpNewTestCase, self).tearDown()
+
def test_process_info_in_minidump(self):
"""Test that lldb can read the process information from the Minidump."""
# target create -c linux-x86_64.dmp
diff --git a/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/Makefile b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/Makefile
new file mode 100644
index 000000000000..c4855ca9b12d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/Makefile
@@ -0,0 +1,8 @@
+LEVEL = ../../make
+
+DYLIB_NAME := unlikely_name
+DYLIB_CXX_SOURCES := foo.cpp
+CXX_SOURCES := main.cpp
+CFLAGS_EXTRAS += -fPIC
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/TestPreRunDylibs.py b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/TestPreRunDylibs.py
new file mode 100644
index 000000000000..258c3d3fbb9f
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/TestPreRunDylibs.py
@@ -0,0 +1,38 @@
+from __future__ import print_function
+
+import unittest2
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+
+class TestPreRunLibraries(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ @skipIf(oslist=no_match(['darwin','macos']))
+ def test(self):
+ """Test that we find directly linked dylib pre-run."""
+
+ self.build()
+ target = self.dbg.CreateTarget("a.out")
+ self.assertTrue(target, VALID_TARGET)
+
+ # I don't know what the name of a shared library
+ # extension is in general, so instead of using FindModule,
+ # I'll iterate through the module and do a basename match.
+ found_it = False
+ for module in target.modules:
+ file_name = module.GetFileSpec().GetFilename()
+ if file_name.find("unlikely_name") != -1:
+ found_it = True
+ break
+
+ self.assertTrue(found_it, "Couldn't find unlikely_to_occur_name in loaded libraries.")
+
+
diff --git a/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.cpp b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.cpp
new file mode 100644
index 000000000000..8dad0a23f368
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.cpp
@@ -0,0 +1,3 @@
+#include "foo.h"
+
+int call_foo1() { return foo1(); }
diff --git a/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.h b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.h
new file mode 100644
index 000000000000..060b91f5a5ea
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/foo.h
@@ -0,0 +1,6 @@
+LLDB_TEST_API inline int foo1() { return 1; } // !BR1
+
+LLDB_TEST_API inline int foo2() { return 2; } // !BR2
+
+LLDB_TEST_API extern int call_foo1();
+LLDB_TEST_API extern int call_foo2();
diff --git a/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/main.cpp b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/main.cpp
new file mode 100644
index 000000000000..c9295a5c7d3c
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/main.cpp
@@ -0,0 +1,9 @@
+#include "foo.h"
+
+int call_foo2() { return foo2(); }
+
+int
+main() // !BR_main
+{
+ return call_foo1() + call_foo2();
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py b/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
index 6fcf29a2f58f..6dccaa55a103 100644
--- a/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
+++ b/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
@@ -15,6 +15,7 @@ from lldbsuite.test import lldbutil
class TestYMMRegister(TestBase):
mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
@skipIfFreeBSD
@skipIfiOSSimulator
diff --git a/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py b/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
index 157a0a8bd982..cc1389ca6b01 100644
--- a/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
+++ b/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
@@ -18,6 +18,7 @@ from lldbsuite.test import lldbutil
class RegisterCommandsTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
def setUp(self):
TestBase.setUp(self)
@@ -139,17 +140,10 @@ class RegisterCommandsTestCase(TestBase):
# This intentionally checks the host platform rather than the target
# platform as logging is host side.
self.platform = ""
- if sys.platform.startswith("darwin"):
- self.platform = "" # TODO: add support for "log enable darwin registers"
-
- if sys.platform.startswith("freebsd"):
- self.platform = "freebsd"
-
- if sys.platform.startswith("linux"):
- self.platform = "linux"
-
- if sys.platform.startswith("netbsd"):
- self.platform = "netbsd"
+ if (sys.platform.startswith("freebsd") or
+ sys.platform.startswith("linux") or
+ sys.platform.startswith("netbsd")):
+ self.platform = "posix"
if self.platform != "":
self.log_file = os.path.join(os.getcwd(), 'TestRegisters.log')
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp
index f9f33fda82bb..f06761936d12 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/break_after_join/main.cpp
@@ -13,7 +13,7 @@
// breakpoint is hit. The test case should be flexible enough to treat that
// as success.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <chrono>
#include <thread>
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
index 10b55bff3ba4..540b5148aefa 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/main.cpp
@@ -13,7 +13,7 @@
// the main thread (before any worker threads are spawned) and modify variables
// which control the number of threads that are spawned for each action.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <vector>
using namespace std;
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
index 70681fd11603..f927e3d9d496 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/main.cpp
@@ -10,7 +10,7 @@
// This test is intended to create a situation in which one thread will be
// created while the debugger is stepping in another thread.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <thread>
#define do_nothing()
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp
index a032da835ea6..e41fbebf380d 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/main.cpp
@@ -13,7 +13,7 @@
// breakpoint is hit. The test case should be flexible enough to treat that
// as success.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <chrono>
#include <thread>
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp
index 45adf28ce813..c7affd2a59ab 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/main.cpp
@@ -10,6 +10,7 @@
// This test is intended to create a situation in which one thread will exit
// while the debugger is stepping in another thread.
+#include "pseudo_barrier.h"
#include <thread>
#define do_nothing()
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp
index c3d695dbc745..d46038109fc2 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/multi_break/main.cpp
@@ -12,7 +12,7 @@
// the breakpoint in the second thread will be hit while the breakpoint handler
// in the first thread is trying to stop all threads.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <thread>
pseudo_barrier_t g_barrier;
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp
index 31f9a1576b92..ecc0571f2bd3 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/step_out/main.cpp
@@ -10,7 +10,7 @@
// This test is intended to create a situation in which two threads are stopped
// at a breakpoint and the debugger issues a step-out command.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <thread>
pseudo_barrier_t g_barrier;
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp
index c57db9f48527..f9508cf6ecca 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/main.cpp
@@ -9,7 +9,7 @@
// This test verifies the correct handling of child thread exits.
-#include <atomic>
+#include "pseudo_barrier.h"
#include <thread>
pseudo_barrier_t g_barrier1;
diff --git a/packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile b/packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile
new file mode 100644
index 000000000000..cd9ca5c86d84
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/find_struct_type/Makefile
@@ -0,0 +1,3 @@
+LEVEL = ../../../make
+C_SOURCES := main.c
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py b/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py
new file mode 100644
index 000000000000..bbe5be67c08d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/find_struct_type/TestFindStructTypes.py
@@ -0,0 +1,67 @@
+"""
+Make sure FindTypes finds struct types with the struct prefix.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class TestFindTypesOnStructType(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ # If your test case doesn't stress debug info, the
+ # set this to true. That way it won't be run once for
+ # each debug info format.
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_find_types_struct_type(self):
+ """Make sure FindTypes actually finds 'struct typename' not just 'typename'."""
+ self.build()
+ self.do_test()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def do_test(self):
+ """Make sure FindTypes actually finds 'struct typename' not just 'typename'."""
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Make sure this works with struct
+ type_list = target.FindTypes("struct mytype")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with struct")
+
+ # Make sure this works without the struct:
+ type_list = target.FindTypes("mytype")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without struct")
+
+ # Make sure it works with union
+ type_list = target.FindTypes("union myunion")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with union")
+
+ # Make sure this works without the union:
+ type_list = target.FindTypes("myunion")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without union")
+
+ # Make sure it works with typedef
+ type_list = target.FindTypes("typedef MyType")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type with typedef")
+
+ # Make sure this works without the typedef:
+ type_list = target.FindTypes("MyType")
+ self.assertEqual(type_list.GetSize(), 1, "Found one instance of the type without typedef")
+
+
+
diff --git a/packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c b/packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c
new file mode 100644
index 000000000000..fa009af27e17
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/c/find_struct_type/main.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <stdlib.h>
+struct mytype {
+ int c;
+ int d;
+};
+
+union myunion {
+ int num;
+ char *str;
+};
+
+typedef struct mytype MyType;
+
+int main()
+{
+ struct mytype v;
+ MyType *v_ptr = &v;
+
+ union myunion u = {5};
+ v.c = u.num;
+ v.d = 10;
+ return v.c + v.d;
+}
+
diff --git a/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile b/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile
index a09f73fb3fa7..a98622100ff4 100644
--- a/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile
+++ b/packages/Python/lldbsuite/test/lang/c/register_variables/Makefile
@@ -2,6 +2,6 @@ LEVEL = ../../../make
C_SOURCES := test.c
-CFLAGS_EXTRAS += -O1
+CFLAGS_EXTRAS += -O1 -D_FORTIFY_SOURCE=0
include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
index 6595e33b7269..bea4bf96e601 100644
--- a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
+++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
@@ -13,10 +13,10 @@ endif
all: limit nolimit
limit: main.o length_limit.o a.o
- $(CXX) $(LDFLAGS) main.o length_limit.o a.o -o limit
+ $(CXX) main.o length_limit.o a.o -o limit $(LDFLAGS)
nolimit: main.o length_nolimit.o a.o
- $(CXX) $(LDFLAGS) main.o length_nolimit.o a.o -o nolimit
+ $(CXX) main.o length_nolimit.o a.o -o nolimit $(LDFLAGS)
main.o: main.cpp
$(CXX) $(CFLAGS_LIMIT) main.cpp -o main.o
diff --git a/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py b/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py
index 82ed362ff609..068594701507 100644
--- a/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py
+++ b/packages/Python/lldbsuite/test/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py
@@ -16,10 +16,7 @@ from lldbsuite.test import lldbutil
class CreateDuringInstructionStepTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
-
- def setUp(self):
- # Call super's setUp().
- TestBase.setUp(self)
+ NO_DEBUG_INFO_TESTCASE = True
@skipUnlessPlatform(['linux'])
@expectedFailureAndroid('llvm.org/pr24737', archs=['arm'])
diff --git a/packages/Python/lldbsuite/test/lldbinline.py b/packages/Python/lldbsuite/test/lldbinline.py
index 240a75a1a82a..727e69d412a2 100644
--- a/packages/Python/lldbsuite/test/lldbinline.py
+++ b/packages/Python/lldbsuite/test/lldbinline.py
@@ -226,19 +226,19 @@ def MakeInlineTest(__file, __globals, decorators=None):
target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
if test_categories.is_supported_on_platform(
- "dsym", target_platform, configuration.compilers):
+ "dsym", target_platform, configuration.compiler):
test.test_with_dsym = ApplyDecoratorsToFunction(
test._InlineTest__test_with_dsym, decorators)
if test_categories.is_supported_on_platform(
- "dwarf", target_platform, configuration.compilers):
+ "dwarf", target_platform, configuration.compiler):
test.test_with_dwarf = ApplyDecoratorsToFunction(
test._InlineTest__test_with_dwarf, decorators)
if test_categories.is_supported_on_platform(
- "dwo", target_platform, configuration.compilers):
+ "dwo", target_platform, configuration.compiler):
test.test_with_dwo = ApplyDecoratorsToFunction(
test._InlineTest__test_with_dwo, decorators)
if test_categories.is_supported_on_platform(
- "gmodules", target_platform, configuration.compilers):
+ "gmodules", target_platform, configuration.compiler):
test.test_with_gmodules = ApplyDecoratorsToFunction(
test._InlineTest__test_with_gmodules, decorators)
diff --git a/packages/Python/lldbsuite/test/lldbplatformutil.py b/packages/Python/lldbsuite/test/lldbplatformutil.py
index 0d5254bc0e7a..89ce1d468bd0 100644
--- a/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -52,12 +52,12 @@ def _run_adb_command(cmd, device_id):
return p.returncode, stdout, stderr
-def _target_is_android():
- if not hasattr(_target_is_android, 'result'):
+def target_is_android():
+ if not hasattr(target_is_android, 'result'):
triple = lldb.DBG.GetSelectedPlatform().GetTriple()
match = re.match(".*-.*-.*-android", triple)
- _target_is_android.result = match is not None
- return _target_is_android.result
+ target_is_android.result = match is not None
+ return target_is_android.result
def android_device_api():
@@ -84,7 +84,7 @@ def android_device_api():
def match_android_device(device_arch, valid_archs=None, valid_api_levels=None):
- if not _target_is_android():
+ if not target_is_android():
return False
if valid_archs is not None and device_arch not in valid_archs:
return False
@@ -95,7 +95,7 @@ def match_android_device(device_arch, valid_archs=None, valid_api_levels=None):
def finalize_build_dictionary(dictionary):
- if _target_is_android():
+ if target_is_android():
if dictionary is None:
dictionary = {}
dictionary["OS"] = "Android"
diff --git a/packages/Python/lldbsuite/test/lldbtest.py b/packages/Python/lldbsuite/test/lldbtest.py
index ba41d5d31912..bc0fb1b686ad 100644
--- a/packages/Python/lldbsuite/test/lldbtest.py
+++ b/packages/Python/lldbsuite/test/lldbtest.py
@@ -692,31 +692,30 @@ class Base(unittest2.TestCase):
if not lldb.remote_platform or not configuration.lldb_platform_working_dir:
return
- remote_test_dir = lldbutil.join_remote_paths(
- configuration.lldb_platform_working_dir,
- self.getArchitecture(),
- str(self.test_number),
- self.mydir)
- error = lldb.remote_platform.MakeDirectory(
- remote_test_dir, 448) # 448 = 0o700
- if error.Success():
- lldb.remote_platform.SetWorkingDirectory(remote_test_dir)
-
- # This function removes all files from the current working directory while leaving
- # the directories in place. The cleaup is required to reduce the disk space required
- # by the test suit while leaving the directories untached is neccessary because
- # sub-directories might belong to an other test
- def clean_working_directory():
- # TODO: Make it working on Windows when we need it for remote debugging support
- # TODO: Replace the heuristic to remove the files with a logic what collects the
- # list of files we have to remove during test runs.
- shell_cmd = lldb.SBPlatformShellCommand(
- "rm %s/*" % remote_test_dir)
- lldb.remote_platform.Run(shell_cmd)
- self.addTearDownHook(clean_working_directory)
- else:
- print("error: making remote directory '%s': %s" % (
- remote_test_dir, error))
+ components = [str(self.test_number)] + self.mydir.split(os.path.sep)
+ remote_test_dir = configuration.lldb_platform_working_dir
+ for c in components:
+ remote_test_dir = lldbutil.join_remote_paths(remote_test_dir, c)
+ error = lldb.remote_platform.MakeDirectory(
+ remote_test_dir, 448) # 448 = 0o700
+ if error.Fail():
+ raise Exception("making remote directory '%s': %s" % (
+ remote_test_dir, error))
+
+ lldb.remote_platform.SetWorkingDirectory(remote_test_dir)
+
+ # This function removes all files from the current working directory while leaving
+ # the directories in place. The cleaup is required to reduce the disk space required
+ # by the test suit while leaving the directories untached is neccessary because
+ # sub-directories might belong to an other test
+ def clean_working_directory():
+ # TODO: Make it working on Windows when we need it for remote debugging support
+ # TODO: Replace the heuristic to remove the files with a logic what collects the
+ # list of files we have to remove during test runs.
+ shell_cmd = lldb.SBPlatformShellCommand(
+ "rm %s/*" % remote_test_dir)
+ lldb.remote_platform.Run(shell_cmd)
+ self.addTearDownHook(clean_working_directory)
def setUp(self):
"""Fixture for unittest test case setup.
@@ -1119,8 +1118,11 @@ class Base(unittest2.TestCase):
compiler = compiler[2:]
if os.path.altsep is not None:
compiler = compiler.replace(os.path.altsep, os.path.sep)
- components.extend(
- [x for x in compiler.split(os.path.sep) if x != ""])
+ path_components = [x for x in compiler.split(os.path.sep) if x != ""]
+
+ # Add at most 4 path components to avoid generating very long
+ # filenames
+ components.extend(path_components[-4:])
elif c == 'a':
components.append(self.getArchitecture())
elif c == 'm':
@@ -1227,6 +1229,13 @@ class Base(unittest2.TestCase):
# (enables reading of the current test configuration)
# ====================================================
+ def isMIPS(self):
+ """Returns true if the architecture is MIPS."""
+ arch = self.getArchitecture()
+ if re.match("mips", arch):
+ return True
+ return False
+
def getArchitecture(self):
"""Returns the architecture in effect the test suite is running with."""
module = builder_module()
@@ -1704,7 +1713,7 @@ class LLDBTestCaseFactory(type):
supported_categories = [
x for x in categories if test_categories.is_supported_on_platform(
- x, target_platform, configuration.compilers)]
+ x, target_platform, configuration.compiler)]
if "dsym" in supported_categories:
@decorators.add_test_categories(["dsym"])
@wraps(attrvalue)
diff --git a/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py b/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
index 972021e192b9..eae4ae2e42a3 100644
--- a/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
+++ b/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
@@ -18,7 +18,7 @@ class TestQueues(TestBase):
@skipUnlessDarwin
@add_test_categories(['pyapi'])
- @expectedFailureAll(bugnumber="rdar://28658529")
+ @expectedFailureAll(bugnumber="rdar://30915340")
def test_with_python_api(self):
"""Test queues inspection SB APIs."""
self.build()
diff --git a/packages/Python/lldbsuite/test/make/Android.rules b/packages/Python/lldbsuite/test/make/Android.rules
new file mode 100644
index 000000000000..3e6a093f4bae
--- /dev/null
+++ b/packages/Python/lldbsuite/test/make/Android.rules
@@ -0,0 +1,91 @@
+NDK_ROOT := $(shell dirname $(CC))/../../../../..
+
+ifeq "$(findstring 64, $(ARCH))" "64"
+ # lowest 64-bit API level
+ API_LEVEL := 21
+else ifeq "$(ARCH)" "i386"
+ # clone(2) declaration is present only since this api level
+ API_LEVEL := 17
+else
+ # lowest supported 32-bit API level
+ API_LEVEL := 9
+endif
+
+ifeq "$(ARCH)" "arm"
+ SYSROOT_ARCH := arm
+ STL_ARCH := armeabi-v7a
+ TRIPLE := armv7-none-linux-androideabi
+ ARCH_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm
+else ifeq "$(ARCH)" "aarch64"
+ SYSROOT_ARCH := arm64
+ TRIPLE := aarch64-none-linux-android
+ STL_ARCH := arm64-v8a
+else ifeq "$(ARCH)" "i386"
+ SYSROOT_ARCH := x86
+ STL_ARCH := x86
+ TRIPLE := i686-none-linux-android
+else ifeq "$(ARCH)" "mips64r6"
+ SYSROOT_ARCH := mips64
+ STL_ARCH := mips64
+ TRIPLE := mips64el-none-linux-android
+else ifeq "$(ARCH)" "mips32"
+ SYSROOT_ARCH := mips
+ STL_ARCH := mips
+ TRIPLE := mipsel-none-linux-android
+else
+ SYSROOT_ARCH := $(ARCH)
+ STL_ARCH := $(ARCH)
+ TRIPLE := $(ARCH)-none-linux-android
+endif
+
+ifeq "$(findstring 86,$(ARCH))" "86"
+ TOOLCHAIN_DIR := $(STL_ARCH)-4.9
+else ifeq "$(ARCH)" "arm"
+ TOOLCHAIN_DIR := arm-linux-androideabi-4.9
+else
+ TOOLCHAIN_DIR := $(subst -none,,$(TRIPLE))-4.9
+endif
+
+ifeq "$(ARCH)" "arm"
+ TOOL_PREFIX := arm-linux-androideabi
+else
+ TOOL_PREFIX := $(subst -none,,$(TRIPLE))
+endif
+
+ifeq "$(HOST_OS)" "Linux"
+ HOST_TAG := linux-x86_64
+else ifeq "$(HOST_OS)" "Darwin"
+ HOST_TAG := darwin-x86_64
+else
+ HOST_TAG := windows-x86_64
+endif
+
+GCC_TOOLCHAIN = $(NDK_ROOT)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG)
+
+OBJCOPY ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-objcopy
+
+ifeq "$(findstring clang,$(CC))" "clang"
+ ARCH_CFLAGS += -target $(TRIPLE) -gcc-toolchain $(GCC_TOOLCHAIN)
+ ARCH_LDFLAGS += -target $(TRIPLE) -gcc-toolchain $(GCC_TOOLCHAIN)
+endif
+
+ARCH_CFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH)
+ARCH_LDFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm
+
+ifeq (1,$(USE_LIBCPP))
+ ARCH_CFLAGS += \
+ -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \
+ -isystem $(NDK_ROOT)/sources/android/support/include \
+ -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include
+
+ ARCH_LDFLAGS += \
+ -L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \
+ $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++.a
+else
+ ARCH_CFLAGS += \
+ -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include \
+ -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/include \
+ -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward
+
+ ARCH_LDFLAGS += $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/libgnustl_static.a
+endif
diff --git a/packages/Python/lldbsuite/test/make/Makefile.rules b/packages/Python/lldbsuite/test/make/Makefile.rules
index 5abbc85e649b..a7b94ef57380 100644
--- a/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -32,10 +32,26 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)../../../../../
#----------------------------------------------------------------------
+# If OS is not defined, use 'uname -s' to determine the OS name.
+#
+# uname on Windows gives "windows32", but most environments standardize
+# on "Windows_NT", so we'll make it consistent here. When running
+# tests from Visual Studio, the environment variable isn't inherited
+# all the way down to the process spawned for make.
+#----------------------------------------------------------------------
+HOST_OS = $(shell uname -s)
+ifeq "$(HOST_OS)" "windows32"
+ HOST_OS = Windows_NT
+endif
+ifeq "$(OS)" ""
+ OS = $(HOST_OS)
+endif
+
+#----------------------------------------------------------------------
# If TRIPLE is not defined try to set the ARCH, CC, CFLAGS, and more
# from the triple alone
#----------------------------------------------------------------------
-TRIPLE_CFLAGS :=
+ARCH_CFLAGS :=
ifneq "$(TRIPLE)" ""
triple_space = $(subst -, ,$(TRIPLE))
ARCH =$(word 1, $(triple_space))
@@ -52,33 +68,20 @@ ifneq "$(TRIPLE)" ""
ifeq "$(TRIPLE_VERSION)" ""
TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
endif
- TRIPLE_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
+ ARCH_CFLAGS :=-mios-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
else
SDKROOT = $(shell xcrun --sdk iphonesimulator --show-sdk-path)
ifeq "$(TRIPLE_VERSION)" ""
TRIPLE_VERSION =$(shell echo $(notdir $(SDKROOT)) | sed -e 's/.*\([0-9]\.[0-9]\).*/\1/')
endif
- TRIPLE_CFLAGS :=-mios-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
+ ARCH_CFLAGS :=-mios-simulator-version-min=$(TRIPLE_VERSION) -isysroot "$(SDKROOT)"
endif
endif
endif
endif
endif
-
-#----------------------------------------------------------------------
-# If OS is not defined, use 'uname -s' to determine the OS name.
-#
-# uname on Windows gives "windows32", but most environments standardize
-# on "Windows_NT", so we'll make it consistent here. When running
-# tests from Visual Studio, the environment variable isn't inherited
-# all the way down to the process spawned for make.
-#----------------------------------------------------------------------
-HOST_OS = $(shell uname -s)
-ifeq "$(HOST_OS)" "windows32"
- HOST_OS = Windows_NT
-endif
-ifeq "$(OS)" ""
- OS = $(HOST_OS)
+ifeq "$(OS)" "Android"
+ include $(THIS_FILE_DIR)/Android.rules
endif
#----------------------------------------------------------------------
@@ -199,13 +202,13 @@ else
CFLAGS += $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) -I$(LLDB_BASE_DIR)include
endif
-CFLAGS += -include $(THIS_FILE_DIR)test_common.h $(TRIPLE_CFLAGS)
+CFLAGS += -include $(THIS_FILE_DIR)test_common.h -I$(THIS_FILE_DIR) $(ARCH_CFLAGS)
# Use this one if you want to build one part of the result without debug information:
ifeq "$(OS)" "Darwin"
- CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(TRIPLE_CFLAGS)
+ CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(ARCH_CFLAGS)
else
- CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(TRIPLE_CFLAGS)
+ CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG)$(ARCH) $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) $(ARCH_CFLAGS)
endif
ifeq "$(MAKE_DWO)" "YES"
@@ -221,7 +224,7 @@ CXXFLAGS += -std=c++11
CXXFLAGS += $(subst -fmodules,, $(CFLAGS))
LD = $(CC)
LDFLAGS ?= $(CFLAGS)
-LDFLAGS += $(LD_EXTRAS)
+LDFLAGS += $(LD_EXTRAS) $(ARCH_LDFLAGS)
ifeq (,$(filter $(OS), Windows_NT Android))
ifneq (,$(filter YES,$(ENABLE_THREADS)))
LDFLAGS += -pthread
@@ -297,10 +300,12 @@ ifeq "$(OS)" "Windows_NT"
# Clang for Windows doesn't support C++ Exceptions
CXXFLAGS += -fno-exceptions
CXXFLAGS += -D_HAS_EXCEPTIONS=0
- ifeq "$(VisualStudioVersion)" "14.0"
- CXXFLAGS += -fms-compatibility-version=19.0
- override CXXFLAGS := $(subst -std=c++11,-std=c++14,$(CXXFLAGS))
- endif
+
+ # MSVC 2015 or higher is required, which depends on c++14, so
+ # append these values unconditionally.
+ CXXFLAGS += -fms-compatibility-version=19.0
+ override CXXFLAGS := $(subst -std=c++11,-std=c++14,$(CXXFLAGS))
+
# The MSVC linker doesn't understand long section names
# generated by the clang compiler.
LDFLAGS += -fuse-ld=lld
@@ -319,19 +324,21 @@ ifeq (1,$(USE_LIBSTDCPP))
endif
ifeq (1,$(USE_LIBCPP))
- # Clang requires an extra flag: -stdlib=libstdc++
- ifneq (,$(findstring clang,$(CC)))
- ifeq "$(OS)" "Linux"
- # This is the default install location on Ubuntu 14.04
- ifneq ($(wildcard /usr/include/c++/v1/.),)
- CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP
- LDFLAGS += -stdlib=libc++
- CXXFLAGS += -I/usr/include/c++/v1
- endif
- else
- CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP
+ CXXFLAGS += -DLLDB_USING_LIBCPP
+ ifeq "$(OS)" "Linux"
+ ifneq (,$(findstring clang,$(CC)))
+ CXXFLAGS += -stdlib=libc++
LDFLAGS += -stdlib=libc++
+ else
+ CXXFLAGS += -isystem /usr/include/c++/v1
+ LDFLAGS += -lc++
endif
+ else ifeq "$(OS)" "Android"
+ # Nothing to do, this is already handled in
+ # Android.rules.
+ else
+ CXXFLAGS += -stdlib=libc++
+ LDFLAGS += -stdlib=libc++
endif
endif
diff --git a/packages/Python/lldbsuite/test/make/pseudo_barrier.h b/packages/Python/lldbsuite/test/make/pseudo_barrier.h
new file mode 100644
index 000000000000..592000ddea4d
--- /dev/null
+++ b/packages/Python/lldbsuite/test/make/pseudo_barrier.h
@@ -0,0 +1,20 @@
+#include <atomic>
+
+// Note that although hogging the CPU while waiting for a variable to change
+// would be terrible in production code, it's great for testing since it
+// avoids a lot of messy context switching to get multiple threads synchronized.
+
+typedef std::atomic<int> pseudo_barrier_t;
+#define pseudo_barrier_wait(barrier) \
+ do \
+ { \
+ --(barrier); \
+ while ((barrier).load() > 0) \
+ ; \
+ } while (0)
+
+#define pseudo_barrier_init(barrier, count) \
+ do \
+ { \
+ (barrier) = (count); \
+ } while (0)
diff --git a/packages/Python/lldbsuite/test/make/test_common.h b/packages/Python/lldbsuite/test/make/test_common.h
index 575ca62c2fc0..529d0952ed3e 100644
--- a/packages/Python/lldbsuite/test/make/test_common.h
+++ b/packages/Python/lldbsuite/test/make/test_common.h
@@ -10,14 +10,6 @@
#define LLDB_TEST_API
#endif
-#if defined(__cplusplus) && defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
-// Compiling MSVC libraries with _HAS_EXCEPTIONS=0, eliminates most but not all
-// calls to __uncaught_exception. Unfortunately, it does seem to eliminate
-// the delcaration of __uncaught_excpeiton. Including <eh.h> ensures that it is
-// declared. This may not be necessary after MSVC 12.
-#include <eh.h>
-#endif
-
#if defined(_WIN32)
#define LLVM_PRETTY_FUNCTION __FUNCSIG__
#else
@@ -53,34 +45,3 @@
#define lldb_enable_attach()
#endif
-
-#if defined(__APPLE__) && defined(LLDB_USING_LIBSTDCPP)
-
-// on Darwin, libstdc++ is missing <atomic>, so this would cause any test to fail building
-// since this header file is being included in every C-family test case, we need to not include it
-// on Darwin, most tests use libc++ by default, so this will only affect tests that explicitly require libstdc++
-
-#else
-#ifdef __cplusplus
-#include <atomic>
-
-// Note that although hogging the CPU while waiting for a variable to change
-// would be terrible in production code, it's great for testing since it
-// avoids a lot of messy context switching to get multiple threads synchronized.
-
-typedef std::atomic<int> pseudo_barrier_t;
-#define pseudo_barrier_wait(barrier) \
- do \
- { \
- --(barrier); \
- while ((barrier).load() > 0) \
- ; \
- } while (0)
-
-#define pseudo_barrier_init(barrier, count) \
- do \
- { \
- (barrier) = (count); \
- } while (0)
-#endif // __cplusplus
-#endif // defined(__APPLE__) && defined(LLDB_USING_LIBSTDCPP)
diff --git a/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py b/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py
index 39975632dcb6..4bd4781c7ef5 100644
--- a/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py
+++ b/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py
@@ -17,6 +17,7 @@ from lldbsuite.test import lldbutil
class BreakpointAPITestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
@add_test_categories(['pyapi'])
def test_breakpoint_is_valid(self):
@@ -49,3 +50,28 @@ class BreakpointAPITestCase(TestBase):
self.assertTrue(
not breakpoint,
"Breakpoint we deleted is no longer valid.")
+
+ @add_test_categories(['pyapi'])
+ def test_target_delete(self):
+ """Make sure that if an SBTarget gets deleted the associated
+ Breakpoint's IsValid returns false."""
+
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint on main.c by name 'AFunction'.
+ breakpoint = target.BreakpointCreateByName('AFunction', 'a.out')
+ #print("breakpoint:", breakpoint)
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+ location = breakpoint.GetLocationAtIndex(0)
+ self.assertTrue(location.IsValid())
+
+ self.assertTrue(self.dbg.DeleteTarget(target))
+ self.assertFalse(breakpoint.IsValid())
+ self.assertFalse(location.IsValid())
diff --git a/packages/Python/lldbsuite/test/python_api/name_lookup/Makefile b/packages/Python/lldbsuite/test/python_api/name_lookup/Makefile
new file mode 100644
index 000000000000..8a7102e347af
--- /dev/null
+++ b/packages/Python/lldbsuite/test/python_api/name_lookup/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py b/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py
new file mode 100644
index 000000000000..b7a683f25f62
--- /dev/null
+++ b/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py
@@ -0,0 +1,66 @@
+"""
+Test SBTarget APIs.
+"""
+
+from __future__ import print_function
+
+
+import unittest2
+import os
+import time
+import re
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestNameLookup(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @add_test_categories(['pyapi'])
+ def test_target(self):
+ """Exercise SBTarget.FindFunctions() with various name masks.
+
+ A previous regression caused mangled names to not be able to be looked up.
+ This test verifies that using a mangled name with eFunctionNameTypeFull works
+ and that using a function basename with eFunctionNameTypeFull works for all
+ C++ functions that are at the global namespace level."""
+ self.build();
+ exe = os.path.join(os.getcwd(), 'a.out')
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ exe_module = target.FindModule(target.GetExecutable())
+
+ c_name_to_symbol = {}
+ cpp_name_to_symbol = {}
+ mangled_to_symbol = {}
+ num_symbols = exe_module.GetNumSymbols();
+ for i in range(num_symbols):
+ symbol = exe_module.GetSymbolAtIndex(i);
+ name = symbol.GetName()
+ if name and 'unique_function_name' in name and '__PRETTY_FUNCTION__' not in name:
+ mangled = symbol.GetMangledName()
+ if mangled:
+ mangled_to_symbol[mangled] = symbol
+ if name:
+ cpp_name_to_symbol[name] = symbol
+ elif name:
+ c_name_to_symbol[name] = symbol
+
+ # Make sure each mangled name turns up exactly one match when looking up
+ # functions by full name and using the mangled name as the name in the
+ # lookup
+ self.assertGreaterEqual(len(mangled_to_symbol), 6)
+ for mangled in mangled_to_symbol.keys():
+ symbol_contexts = target.FindFunctions(mangled, lldb.eFunctionNameTypeFull)
+ self.assertTrue(symbol_contexts.GetSize() == 1)
+ for symbol_context in symbol_contexts:
+ self.assertTrue(symbol_context.GetFunction().IsValid())
+ self.assertTrue(symbol_context.GetSymbol().IsValid())
+
+
diff --git a/packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp b/packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp
new file mode 100644
index 000000000000..79aa2d0452f4
--- /dev/null
+++ b/packages/Python/lldbsuite/test/python_api/name_lookup/main.cpp
@@ -0,0 +1,54 @@
+#include <stdio.h>
+
+extern "C" int unique_function_name(int i)
+{
+ return puts(__PRETTY_FUNCTION__);
+}
+
+int unique_function_name()
+{
+ return puts(__PRETTY_FUNCTION__);
+}
+
+int unique_function_name(float f)
+{
+ return puts(__PRETTY_FUNCTION__);
+}
+
+namespace e
+{
+ int unique_function_name()
+ {
+ return puts(__PRETTY_FUNCTION__);
+ }
+
+ namespace g
+ {
+ int unique_function_name()
+ {
+ return puts(__PRETTY_FUNCTION__);
+ }
+ }
+}
+
+class g
+{
+public:
+ int unique_function_name()
+ {
+ return puts(__PRETTY_FUNCTION__);
+ }
+
+ int unique_function_name(int i)
+ {
+ return puts(__PRETTY_FUNCTION__);
+ }
+};
+
+int main (int argc, char const *argv[])
+{
+ g g;
+ g.unique_function_name();
+ g.unique_function_name(argc);
+ return 0;
+} \ No newline at end of file
diff --git a/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py b/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py
index e853d6567e73..0560ac502dcf 100644
--- a/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py
+++ b/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py
@@ -22,6 +22,26 @@ class SBDataAPICase(TestBase):
self.line = line_number('main.cpp', '// set breakpoint here')
@add_test_categories(['pyapi'])
+ def test_byte_order_and_address_byte_size(self):
+ """Test the SBData::SetData() to ensure the byte order and address
+ byte size are obeyed"""
+ addr_data = '\x11\x22\x33\x44\x55\x66\x77\x88'
+ error = lldb.SBError()
+ data = lldb.SBData()
+ data.SetData(error, addr_data, lldb.eByteOrderBig, 4)
+ addr = data.GetAddress(error, 0)
+ self.assertTrue(addr == 0x11223344);
+ data.SetData(error, addr_data, lldb.eByteOrderBig, 8)
+ addr = data.GetAddress(error, 0)
+ self.assertTrue(addr == 0x1122334455667788);
+ data.SetData(error, addr_data, lldb.eByteOrderLittle, 4)
+ addr = data.GetAddress(error, 0)
+ self.assertTrue(addr == 0x44332211);
+ data.SetData(error, addr_data, lldb.eByteOrderLittle, 8)
+ addr = data.GetAddress(error, 0)
+ self.assertTrue(addr == 0x8877665544332211);
+
+ @add_test_categories(['pyapi'])
def test_with_run_command(self):
"""Test the SBData APIs."""
self.build()
diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py b/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
index e4f2c5c7a182..bc925ee693d4 100644
--- a/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
+++ b/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py
@@ -108,3 +108,6 @@ class SetWatchpointAPITestCase(TestBase):
self.assertTrue(
process.GetState() == lldb.eStateExited,
PROCESS_EXITED)
+
+ self.dbg.DeleteTarget(target)
+ self.assertFalse(watchpoint.IsValid())
diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
index 1bef9968b4ab..2685ef819cad 100644
--- a/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
+++ b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
@@ -56,7 +56,7 @@ class WatchpointIgnoreCountTestCase(TestBase):
# We should be stopped due to the breakpoint. Get frame #0.
process = target.GetProcess()
- self.assertTrue(process.GetState() == lldb.eStateStopped,
+ self.assertEqual(process.GetState(), lldb.eStateStopped,
PROCESS_STOPPED)
thread = lldbutil.get_stopped_thread(
process, lldb.eStopReasonBreakpoint)
@@ -75,12 +75,12 @@ class WatchpointIgnoreCountTestCase(TestBase):
self.HideStdout()
# There should be only 1 watchpoint location under the target.
- self.assertTrue(target.GetNumWatchpoints() == 1)
+ self.assertEqual(target.GetNumWatchpoints(), 1)
watchpoint = target.GetWatchpointAtIndex(0)
self.assertTrue(watchpoint.IsEnabled())
- self.assertTrue(watchpoint.GetIgnoreCount() == 0)
+ self.assertEqual(watchpoint.GetIgnoreCount(), 0)
watch_id = watchpoint.GetID()
- self.assertTrue(watch_id != 0)
+ self.assertNotEqual(watch_id, 0)
print(watchpoint)
# Now immediately set the ignore count to 2. When we continue, expect the
@@ -90,12 +90,10 @@ class WatchpointIgnoreCountTestCase(TestBase):
process.Continue()
# At this point, the inferior process should have exited.
- self.assertTrue(
- process.GetState() == lldb.eStateExited,
- PROCESS_EXITED)
+ self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED)
# Verify some vital statistics.
self.assertTrue(watchpoint)
- self.assertTrue(watchpoint.GetWatchSize() == 4)
- self.assertTrue(watchpoint.GetHitCount() == 2)
+ self.assertEqual(watchpoint.GetWatchSize(), 4)
+ self.assertEqual(watchpoint.GetHitCount(), 2)
print(watchpoint)
diff --git a/packages/Python/lldbsuite/test/sample_test/Makefile b/packages/Python/lldbsuite/test/sample_test/Makefile
new file mode 100644
index 000000000000..0e5a537bbec8
--- /dev/null
+++ b/packages/Python/lldbsuite/test/sample_test/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../make
+
+C_SOURCES := main.c
+CFLAGS_EXTRAS += -std=c99
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/sample_test/TestSampleInlineTest.py b/packages/Python/lldbsuite/test/sample_test/TestSampleInlineTest.py
new file mode 100644
index 000000000000..29fad79de811
--- /dev/null
+++ b/packages/Python/lldbsuite/test/sample_test/TestSampleInlineTest.py
@@ -0,0 +1,10 @@
+"""
+Describe the purpose of the test here.
+"""
+
+from __future__ import absolute_import
+
+from lldbsuite.test import lldbinline
+
+lldbinline.MakeInlineTest(
+ __file__, globals(), None)
diff --git a/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py b/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py
new file mode 100644
index 000000000000..bb34727ff81b
--- /dev/null
+++ b/packages/Python/lldbsuite/test/sample_test/TestSampleTest.py
@@ -0,0 +1,74 @@
+"""
+Describe the purpose of the test class here.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+
+class RenameThisSampleTestTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ # If your test case doesn't stress debug info, the
+ # set this to true. That way it won't be run once for
+ # each debug info format.
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_sample_rename_this(self):
+ """There can be many tests in a test case - describe this test here."""
+ self.build()
+ self.sample_test()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def sample_test(self):
+ """You might use the test implementation in several ways, say so here."""
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint in main.c at the source matching
+ # "Set a breakpoint here"
+ breakpoint = target.BreakpointCreateBySourceRegex(
+ "Set a breakpoint here", lldb.SBFileSpec("main.c"))
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() >= 1,
+ VALID_BREAKPOINT)
+
+ error = lldb.SBError()
+ # This is the launch info. If you want to launch with arguments or
+ # environment variables, add them using SetArguments or
+ # SetEnvironmentEntries
+
+ launch_info = lldb.SBLaunchInfo(None)
+ process = target.Launch(launch_info, error)
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # Did we hit our breakpoint?
+ from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
+ threads = get_threads_stopped_at_breakpoint(process, breakpoint)
+ self.assertTrue(
+ len(threads) == 1,
+ "There should be a thread stopped at our breakpoint")
+
+ # The hit count for the breakpoint should be 1.
+ self.assertTrue(breakpoint.GetHitCount() == 1)
+
+ frame = threads[0].GetFrameAtIndex(0)
+ test_var = frame.FindVariable("test_var")
+ self.assertTrue(test_var.GetError().Success(), "Failed to fetch test_var")
+ test_value = test_var.GetValueAsUnsigned()
+ self.assertEqual(test_value, 10, "Got the right value for test_var")
+
diff --git a/packages/Python/lldbsuite/test/sample_test/main.c b/packages/Python/lldbsuite/test/sample_test/main.c
new file mode 100644
index 000000000000..0164d7155b09
--- /dev/null
+++ b/packages/Python/lldbsuite/test/sample_test/main.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+
+int
+main()
+{
+ int test_var = 10;
+ printf ("Set a breakpoint here: %d.\n", test_var);
+ //% test_var = self.frame().FindVariable("test_var")
+ //% test_value = test_var.GetValueAsUnsigned()
+ //% self.assertTrue(test_var.GetError().Success(), "Failed to fetch test_var")
+ //% self.assertEqual(test_value, 10, "Failed to get the right value for test_var")
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/test_categories.py b/packages/Python/lldbsuite/test/test_categories.py
index e2bec304832f..a1c2859536d1 100644
--- a/packages/Python/lldbsuite/test/test_categories.py
+++ b/packages/Python/lldbsuite/test/test_categories.py
@@ -25,6 +25,7 @@ all_categories = {
'dsym': 'Tests that can be run with DSYM debug information',
'gmodules': 'Tests that can be run with -gmodules debug information',
'expression': 'Tests related to the expression parser',
+ 'libc++': 'Test for libc++ data formatters',
'objc': 'Tests related to the Objective-C programming language support',
'pyapi': 'Tests related to the Python API',
'basic_process': 'Basic process execution sniff tests.',
@@ -32,7 +33,8 @@ all_categories = {
'dyntype': 'Tests related to dynamic type support',
'stresstest': 'Tests related to stressing lldb limits',
'flakey': 'Flakey test cases, i.e. tests that do not reliably pass at each execution',
- 'lldb-mi': 'lldb-mi tests'}
+ 'lldb-mi': 'lldb-mi tests',
+ 'darwin-log': 'Darwin log tests'}
def unique_string_match(yourentry, list):
@@ -46,7 +48,7 @@ def unique_string_match(yourentry, list):
return candidate
-def is_supported_on_platform(category, platform, compiler_paths):
+def is_supported_on_platform(category, platform, compiler_path):
if category == "dwo":
# -gsplit-dwarf is not implemented by clang on Windows.
return platform in ["linux", "freebsd"]
@@ -56,17 +58,7 @@ def is_supported_on_platform(category, platform, compiler_paths):
# First, check to see if the platform can even support gmodules.
if platform not in ["linux", "freebsd", "darwin", "macosx", "ios"]:
return False
- # If all compilers specified support gmodules, we'll enable it.
- for compiler_path in compiler_paths:
- if not gmodules.is_compiler_clang_with_gmodules(compiler_path):
- # Ideally in a multi-compiler scenario during a single test run, this would
- # allow gmodules on compilers that support it and not on ones that don't.
- # However, I didn't see an easy way for all the callers of this to know
- # the compiler being used for a test invocation. As we tend to run with
- # a single compiler per test run, this shouldn't be a major
- # issue.
- return False
- return True
+ return gmodules.is_compiler_clang_with_gmodules(compiler_path)
return True
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiEnvironmentCd.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiEnvironmentCd.py
index 786c842bb514..d62224d976c9 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiEnvironmentCd.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiEnvironmentCd.py
@@ -18,6 +18,7 @@ class MiEnvironmentCdTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfDarwin # Disabled while I investigate the failure on buildbot.
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_environment_cd(self):
"""Test that 'lldb-mi --interpreter' changes working directory for inferior."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py
index 0cc50370b164..4f3562d42de8 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiExit.py
@@ -18,6 +18,7 @@ class MiExitTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_exit(self):
"""Test that '-gdb-exit' terminates local debug session and exits."""
@@ -44,6 +45,7 @@ class MiExitTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_quit(self):
"""Test that 'quit' exits immediately."""
@@ -69,6 +71,7 @@ class MiExitTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_q(self):
"""Test that 'q' exits immediately."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
index 7a99ecf7d1e5..1eea89f4fff4 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
@@ -17,6 +17,7 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_file_exec_and_symbols_file(self):
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols exe."""
@@ -33,6 +34,7 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_file_exec_and_symbols_absolute_path(self):
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols fullpath/exe."""
@@ -51,6 +53,7 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_file_exec_and_symbols_relative_path(self):
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols relpath/exe."""
@@ -68,6 +71,7 @@ class MiFileTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_file_exec_and_symbols_unknown_path(self):
"""Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols badpath/exe."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py
index 9b575c49bcb0..6bb7619e60b8 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiGdbSetShow.py
@@ -20,6 +20,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_target_async_default(self):
"""Test that 'lldb-mi --interpreter' switches to async mode by default."""
@@ -42,6 +43,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@expectedFlakeyLinux("llvm.org/pr26028") # Fails in ~1% of cases
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_target_async_on(self):
"""Test that 'lldb-mi --interpreter' can execute commands in async mode."""
@@ -75,6 +77,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
@expectedFailureAll(
oslist=["linux"],
bugnumber="Failing in ~11/600 dosep runs (build 3120-3122)")
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_target_async_off(self):
"""Test that 'lldb-mi --interpreter' can execute commands in sync mode."""
@@ -101,6 +104,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_show_target_async(self):
"""Test that 'lldb-mi --interpreter' in async mode by default."""
@@ -114,6 +118,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_show_language(self):
"""Test that 'lldb-mi --interpreter' can get current language."""
@@ -138,6 +143,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@unittest2.expectedFailure("-gdb-set ignores unknown properties")
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_unknown(self):
"""Test that 'lldb-mi --interpreter' fails when setting an unknown property."""
@@ -151,6 +157,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
oslist=["windows"],
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@unittest2.expectedFailure("-gdb-show ignores unknown properties")
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_show_unknown(self):
"""Test that 'lldb-mi --interpreter' fails when showing an unknown property."""
@@ -165,6 +172,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_ouptut_radix(self):
"""Test that 'lldb-mi --interpreter' works for -gdb-set output-radix."""
@@ -211,6 +219,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
@expectedFailureAll(
bugnumber="llvm.org/pr31485: data-disassemble doesn't follow flavor settings")
def test_lldbmi_gdb_set_disassembly_flavor(self):
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
index 68d670c9cd1e..a597ae1397ad 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
@@ -17,6 +17,7 @@ class MiLibraryLoadedTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_library_loaded(self):
"""Test that 'lldb-mi --interpreter' shows the =library-loaded notifications."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py
index b853673211bb..20e48ac8dc7c 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py
@@ -17,6 +17,7 @@ class MiPromptTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_prompt(self):
"""Test that 'lldb-mi --interpreter' echos '(gdb)' after commands and events."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
index 38c6b1f0b179..16f71fe8130c 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
@@ -19,6 +19,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@expectedFlakeyLinux("llvm.org/pr24717")
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_break_insert_function_pending(self):
"""Test that 'lldb-mi --interpreter' works for pending function breakpoints."""
@@ -45,6 +46,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_break_insert_function(self):
"""Test that 'lldb-mi --interpreter' works for function breakpoints."""
@@ -113,6 +115,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_break_insert_file_line_pending(self):
"""Test that 'lldb-mi --interpreter' works for pending file:line breakpoints."""
@@ -142,6 +145,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_break_insert_file_line(self):
"""Test that 'lldb-mi --interpreter' works for file:line breakpoints."""
@@ -179,6 +183,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_break_insert_file_line_absolute_path(self):
"""Test that 'lldb-mi --interpreter' works for file:line breakpoints."""
@@ -206,6 +211,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_break_insert_settings(self):
"""Test that 'lldb-mi --interpreter' can set breakpoints accoridng to global options."""
@@ -220,38 +226,47 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd(
"-interpreter-exec console \"settings set target.move-to-nearest-code off\"")
self.expect("\^done")
- line = line_number('main.cpp', '// BP_before_main')
- self.runCmd("-break-insert -f main.cpp:%d" % line)
+ line_decl = line_number('main.cpp', '// BP_main_decl')
+ line_in = line_number('main.cpp', '// BP_in_main')
+ self.runCmd("-break-insert -f main.cpp:%d" % line_in)
self.expect("\^done,bkpt={number=\"1\"")
# Test that non-pending BP will not be set on non-existing line if target.move-to-nearest-code=off
# Note: this increases the BP number by 1 even though BP #2 is invalid.
- self.runCmd("-break-insert main.cpp:%d" % line)
+ self.runCmd("-break-insert main.cpp:%d" % line_in)
self.expect(
"\^error,msg=\"Command 'break-insert'. Breakpoint location 'main.cpp:%d' not found\"" %
- line)
+ line_in)
# Set target.move-to-nearest-code=on and target.skip-prologue=on and
- # set BP #3
+ # set BP #3 & #4
self.runCmd(
"-interpreter-exec console \"settings set target.move-to-nearest-code on\"")
self.runCmd(
"-interpreter-exec console \"settings set target.skip-prologue on\"")
self.expect("\^done")
- self.runCmd("-break-insert main.cpp:%d" % line)
+ self.runCmd("-break-insert main.cpp:%d" % line_in)
self.expect("\^done,bkpt={number=\"3\"")
+ self.runCmd("-break-insert main.cpp:%d" % line_decl)
+ self.expect("\^done,bkpt={number=\"4\"")
- # Set target.skip-prologue=off and set BP #4
+ # Set target.skip-prologue=off and set BP #5
self.runCmd(
"-interpreter-exec console \"settings set target.skip-prologue off\"")
self.expect("\^done")
- self.runCmd("-break-insert main.cpp:%d" % line)
- self.expect("\^done,bkpt={number=\"4\"")
+ self.runCmd("-break-insert main.cpp:%d" % line_decl)
+ self.expect("\^done,bkpt={number=\"5\"")
- # Test that BP #4 is located before BP #3
+ # Test that BP #5 is located before BP #4
self.runCmd("-exec-run")
self.expect("\^running")
self.expect(
+ "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"5\"")
+
+ # Test that BP #4 is hit
+ self.runCmd("-exec-continue")
+ self.expect("\^running")
+ self.expect(
"\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"4\"")
# Test that BP #3 is hit
@@ -260,7 +275,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect(
"\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"3\"")
- # Test that the target.language=pascal setting works and that BP #5 is
+ # Test that the target.language=pascal setting works and that BP #6 is
# NOT set
self.runCmd(
"-interpreter-exec console \"settings set target.language c\"")
@@ -268,16 +283,16 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-break-insert ns.foo1")
self.expect("\^error")
- # Test that the target.language=c++ setting works and that BP #6 is hit
+ # Test that the target.language=c++ setting works and that BP #7 is hit
self.runCmd(
"-interpreter-exec console \"settings set target.language c++\"")
self.expect("\^done")
self.runCmd("-break-insert ns::foo1")
- self.expect("\^done,bkpt={number=\"6\"")
+ self.expect("\^done,bkpt={number=\"7\"")
self.runCmd("-exec-continue")
self.expect("\^running")
self.expect(
- "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"6\"")
+ "\*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"7\"")
# Test that BP #1 and #2 weren't set by running to program exit
self.runCmd("-exec-continue")
@@ -286,6 +301,7 @@ class MiBreakTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_break_enable_disable(self):
"""Test that 'lldb-mi --interpreter' works for enabling / disabling breakpoints."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp
index 9416a0d01c7d..366c53c3143f 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp
@@ -15,13 +15,16 @@ namespace ns
int foo2(void) { printf("In foo2\n"); return 2; }
}
-// BP_before_main
-
int x;
-int
-main(int argc, char const *argv[])
-{
+int main(int argc, char const *argv[]) { // BP_main_decl
printf("Print a formatted string so that GCC does not optimize this printf call: %s\n", argv[0]);
+ // This is a long comment with no code inside
+ // This is a long comment with no code inside
+ // This is a long comment with no code inside
+ // BP_in_main
+ // This is a long comment with no code inside
+ // This is a long comment with no code inside
+ // This is a long comment with no code inside
x = ns::foo1() + ns::foo2();
return 0; // BP_return
}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py b/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
index 2c0de4238c38..b4e90c71721c 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
@@ -260,7 +260,7 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
self.expect("\^running")
# Depending on compiler, it can stop at different line
self.expect(
- "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(29|30|31)\"")
+ "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(28|29|30|31)\"")
# Test that an invalid --thread is handled
self.runCmd("-exec-next-instruction --thread 0")
@@ -382,7 +382,17 @@ class MiExecTestCase(lldbmi_testcase.MiTestCaseBase):
# Test that -exec-step-instruction steps into g_MyFunction
# instruction (and that --thread is optional)
- self.runCmd("-exec-step-instruction --frame 0")
+
+ # In case of MIPS, there might be more than one instruction
+ # before actual call instruction (like load, move and call instructions).
+ # The -exec-step-instruction would step one assembly instruction.
+ # Thus we may not enter into g_MyFunction function. The -exec-step would definitely
+ # step into the function.
+
+ if self.isMIPS():
+ self.runCmd("-exec-step --frame 0")
+ else:
+ self.runCmd("-exec-step-instruction --frame 0")
self.expect("\^running")
self.expect(
"\*stopped,reason=\"end-stepping-range\".+?func=\"g_MyFunction.*?\"")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py b/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py
index 7281ae305dbe..0b521812384e 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py
@@ -77,7 +77,13 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase):
# Linux: {address="0x0000000000400642",func-name="hello_world()",offset="18",size="5",inst="callq 0x4004d0; symbol stub for: printf"}
# To match the escaped characters in the ouptut, we must use four backslashes per matches backslash
# See https://docs.python.org/2/howto/regex.html#the-backslash-plague
- self.expect(["{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; \\\\\"Hello, World!\\\\\\\\n\\\\\"\"}",
+
+ # The MIPS disassembler never prints stub name
+ if self.isMIPS():
+ self.expect(["{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; \\\\\"Hello, World!\\\\\\\\n\\\\\"\"}",
+ "{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?\"}"])
+ else:
+ self.expect(["{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; \\\\\"Hello, World!\\\\\\\\n\\\\\"\"}",
"{address=\"0x[0-9a-f]+\",func-name=\"hello_world\(\)\",offset=\"[0-9]+\",size=\"[0-9]+\",inst=\".+?; symbol stub for: printf\"}"])
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py
index 24b3881c1be1..7a28f297a1c8 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py
@@ -17,6 +17,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_target_create(self):
"""Test that 'lldb-mi --interpreter' can create target by 'target create' command."""
@@ -36,6 +37,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_breakpoint_set(self):
"""Test that 'lldb-mi --interpreter' can set breakpoint by 'breakpoint set' command."""
@@ -59,6 +61,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_settings_set_target_run_args_before(self):
"""Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command before than target was created."""
@@ -84,6 +87,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_settings_set_target_run_args_after(self):
"""Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command after than target was created."""
@@ -109,6 +113,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_process_launch(self):
"""Test that 'lldb-mi --interpreter' can launch process by "process launch" command."""
@@ -132,6 +137,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_thread_step_in(self):
"""Test that 'lldb-mi --interpreter' can step in by "thread step-in" command."""
@@ -164,6 +170,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_thread_step_over(self):
"""Test that 'lldb-mi --interpreter' can step over by "thread step-over" command."""
@@ -189,6 +196,7 @@ class MiCliSupportTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_thread_continue(self):
"""Test that 'lldb-mi --interpreter' can continue execution by "thread continue" command."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
index 23da825d591b..2f207928db7d 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
@@ -17,6 +17,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_target_create(self):
"""Test that 'lldb-mi --interpreter' can create target by 'target create' command."""
@@ -37,6 +38,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_breakpoint_set(self):
"""Test that 'lldb-mi --interpreter' can set breakpoint by 'breakpoint set' command."""
@@ -60,6 +62,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@expectedFlakeyLinux(bugnumber="llvm.org/pr25470")
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_settings_set_target_run_args_before(self):
"""Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command before than target was created."""
@@ -95,6 +98,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@expectedFailureAll(
oslist=["linux"],
bugnumber="Failing in ~9/600 dosep runs (build 3120-3122)")
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_settings_set_target_run_args_after(self):
"""Test that 'lldb-mi --interpreter' can set target arguments by 'setting set target.run-args' command after than target was created."""
@@ -138,6 +142,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_process_launch(self):
"""Test that 'lldb-mi --interpreter' can launch process by "process launch" command."""
@@ -160,6 +165,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_thread_step_in(self):
"""Test that 'lldb-mi --interpreter' can step in by "thread step-in" command."""
@@ -191,6 +197,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_thread_step_over(self):
"""Test that 'lldb-mi --interpreter' can step over by "thread step-over" command."""
@@ -216,6 +223,7 @@ class MiInterpreterExecTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@expectedFlakeyLinux("llvm.org/pr25470")
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_thread_continue(self):
"""Test that 'lldb-mi --interpreter' can continue execution by "thread continue" command."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/Makefile b/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/TestMiLexicalScope.py b/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/TestMiLexicalScope.py
new file mode 100644
index 000000000000..a4186fdc4d01
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/TestMiLexicalScope.py
@@ -0,0 +1,68 @@
+"""
+Test lldb-mi -stack-list-locals -stack-list-variables and -var-create commands
+for variables with the same name in sibling lexical scopes.
+"""
+
+from __future__ import print_function
+
+
+import lldbmi_testcase
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class MiLexicalScopeTestCase(lldbmi_testcase.MiTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
+ def test_lldbmi_var_create_in_sibling_scope(self):
+ """Test that 'lldb-mi --interpreter' works with sibling lexical scopes."""
+
+ self.spawnLldbMi(args=None)
+
+ # Load executable
+ self.runCmd("-file-exec-and-symbols %s" % self.myexe)
+ self.expect("\^done")
+
+ # Breakpoint inside first scope
+ line = line_number('main.cpp', '// BP_first')
+ self.runCmd("-break-insert --file main.cpp:%d" % line)
+ self.expect("\^done,bkpt={number=\"\d+\"")
+
+ # Breakpoint inside second scope
+ line = line_number('main.cpp', '// BP_second')
+ self.runCmd("-break-insert --file main.cpp:%d" % line)
+ self.expect("\^done,bkpt={number=\"\d+\"")
+
+ # Run to the first scope
+ self.runCmd("-exec-run")
+ self.expect("\^running")
+ self.expect("\*stopped,reason=\"breakpoint-hit\"")
+
+ # Check that only variables a and b exist with expected values
+ self.runCmd("-stack-list-locals --thread 1 --frame 0 --all-values")
+ self.expect("\^done,locals=\[{name=\"a\",value=\"1\"},{name=\"b\",value=\"2\"}\]")
+
+ # Create variable object for local variable b
+ self.runCmd("-var-create - * \"b\"")
+ self.expect(
+ "\^done,name=\"var\d+\",numchild=\"0\",value=\"2\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
+
+ # Run to the second scope
+ self.runCmd("-exec-continue")
+ self.expect("\^running")
+ self.expect("\*stopped,reason=\"breakpoint-hit\"")
+
+ # Check that only variables a and b exist with expected values,
+ # but variable b is different from previous breakpoint
+ self.runCmd("-stack-list-variables --thread 1 --frame 0 --all-values")
+ self.expect("\^done,variables=\[{name=\"a\",value=\"1\"},{name=\"b\",value=\"3\"}\]")
+
+ # Create variable object for local variable b
+ self.runCmd("-var-create - * \"b\"")
+ self.expect(
+ "\^done,name=\"var\d+\",numchild=\"0\",value=\"3\",type=\"short\",thread-id=\"1\",has_more=\"0\"")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp
new file mode 100644
index 000000000000..b9a7bff37af1
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp
@@ -0,0 +1,33 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+void
+some_func (void)
+{
+}
+
+void test_sibling_scope (void)
+{
+ int a = 1;
+ {
+ int b = 2;
+ some_func(); // BP_first
+ }
+ {
+ short b = 3;
+ some_func(); // BP_second
+ }
+}
+
+int
+main (int argc, char **argv)
+{
+ test_sibling_scope();
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py
index e4cd98b22928..597969dd6c53 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py
@@ -17,6 +17,7 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Fails on FreeBSD apparently due to thread race conditions
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_stopped_when_interrupt(self):
"""Test that 'lldb-mi --interpreter' interrupt and resume a looping app."""
@@ -56,6 +57,7 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Fails on FreeBSD apparently due to thread race conditions
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_stopped_when_stopatentry_local(self):
"""Test that 'lldb-mi --interpreter' notifies after it was stopped on entry (local)."""
@@ -88,6 +90,7 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipUnlessDarwin
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_stopped_when_stopatentry_remote(self):
"""Test that 'lldb-mi --interpreter' notifies after it was stopped on entry (remote)."""
@@ -134,6 +137,7 @@ class MiSignalTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_stopped_when_segfault_local(self):
"""Test that 'lldb-mi --interpreter' notifies after it was stopped when segfault occurred (local)."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
index 23374330ba1f..6ac9bf813563 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/symbol/TestMiSymbol.py
@@ -17,6 +17,7 @@ class MiSymbolTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
@expectedFailureAll(
oslist=["linux"],
bugnumber="new failure after r256863")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
index 8e45c95927ba..93f599317c6c 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
@@ -18,6 +18,7 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_tokens(self):
"""Test that 'lldb-mi --interpreter' prints command tokens."""
@@ -41,6 +42,7 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_specialchars(self):
"""Test that 'lldb-mi --interpreter' handles complicated strings."""
@@ -66,6 +68,7 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
@expectedFailureAll(
oslist=["linux"],
bugnumber="Failing in ~6/600 dosep runs (build 3120-3122)")
@@ -88,6 +91,7 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
@expectedFailureAll(oslist=["macosx"], bugnumber="rdar://28805064")
def test_lldbmi_output_grammar(self):
"""Test that 'lldb-mi --interpreter' uses standard output syntax."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py b/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py
index 31a05ff402ed..137408a2bd2b 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py
@@ -17,6 +17,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # cannot attach to process on linux
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_target_attach_wait_for(self):
"""Test that 'lldb-mi --interpreter' works for -target-attach -n <name> --waitfor."""
@@ -59,6 +60,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # cannot attach to process on linux
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_target_attach_name(self):
"""Test that 'lldb-mi --interpreter' works for -target-attach -n <name>."""
@@ -95,6 +97,7 @@ class MiTargetTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # cannot attach to process on linux
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_target_attach_pid(self):
"""Test that 'lldb-mi --interpreter' works for -target-attach <pid>."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py b/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py
index 729674e6e111..f9830e6d2024 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py
@@ -16,6 +16,7 @@ class MiThreadInfoTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # pthreads not supported on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_thread_info(self):
"""Test that -thread-info prints thread info and the current-thread-id"""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
index 61d54cab055a..4384c79fc845 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
@@ -34,6 +34,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_show_print_char_array_as_string(self):
"""Test that 'lldb-mi --interpreter' can print array of chars as string."""
@@ -173,6 +174,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows
@expectedFailureAll(compiler="gcc", bugnumber="llvm.org/pr23357")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_show_print_expand_aggregates(self):
"""Test that 'lldb-mi --interpreter' can expand aggregates everywhere."""
@@ -247,6 +249,7 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows
@expectedFailureAll(compiler="gcc", bugnumber="llvm.org/pr23357")
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_gdb_set_show_print_aggregate_field_names(self):
"""Test that 'lldb-mi --interpreter' can expand aggregates everywhere."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
index b76b59ab97e3..d4685d39791a 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
@@ -17,6 +17,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_eval(self):
"""Test that 'lldb-mi --interpreter' works for evaluating."""
@@ -158,6 +159,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_var_update(self):
"""Test that 'lldb-mi --interpreter' works for -var-update."""
@@ -227,6 +229,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_var_create_register(self):
"""Test that 'lldb-mi --interpreter' works for -var-create $regname."""
@@ -270,6 +273,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_var_list_children(self):
"""Test that 'lldb-mi --interpreter' works for -var-list-children."""
@@ -389,6 +393,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_var_create_for_stl_types(self):
"""Test that 'lldb-mi --interpreter' print summary for STL types."""
@@ -414,6 +419,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
@skipIfWindows # llvm.org/pr24452: Get lldb-mi working on Windows
@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
@skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ @skipIfRemote # We do not currently support remote debugging via the MI.
def test_lldbmi_var_create_for_unnamed_objects(self):
"""Test that 'lldb-mi --interpreter' can expand unnamed structures and unions."""
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/.clang-format b/packages/Python/lldbsuite/test/tools/lldb-server/.clang-format
new file mode 100644
index 000000000000..9b3aa8b7213b
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/.clang-format
@@ -0,0 +1 @@
+BasedOnStyle: LLVM
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/host-info/TestGdbRemoteHostInfo.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py
index 5089ee85773f..5089ee85773f 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/host-info/TestGdbRemoteHostInfo.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
index 57d4d5ab4bb1..b361b9e6d915 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
@@ -1,11 +1,13 @@
from __future__ import print_function
+import json
+import re
+
import gdbremote_testcase
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
-
class TestGdbRemoteThreadsInStopReply(
gdbremote_testcase.GdbRemoteTestCaseBase):
@@ -16,7 +18,8 @@ class TestGdbRemoteThreadsInStopReply(
"send packet: $OK#00",
]
- def gather_stop_reply_threads(self, post_startup_log_lines, thread_count):
+ def gather_stop_reply_fields(self, post_startup_log_lines, thread_count,
+ field_names):
# Set up the inferior args.
inferior_args = []
for i in range(thread_count - 1):
@@ -25,6 +28,9 @@ class TestGdbRemoteThreadsInStopReply(
procs = self.prep_debug_monitor_and_inferior(
inferior_args=inferior_args)
+ self.add_register_info_collection_packets()
+ self.add_process_info_collection_packets()
+
# Assumes test_sequence has anything added needed to setup the initial state.
# (Like optionally enabling QThreadsInStopReply.)
if post_startup_log_lines:
@@ -34,6 +40,7 @@ class TestGdbRemoteThreadsInStopReply(
], True)
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
+ hw_info = self.parse_hw_info(context)
# Give threads time to start up, then break.
time.sleep(1)
@@ -77,14 +84,89 @@ class TestGdbRemoteThreadsInStopReply(
kv_dict = self.parse_key_val_dict(key_vals_text)
self.assertIsNotNone(kv_dict)
+ result = dict();
+ result["pc_register"] = hw_info["pc_register"]
+ result["little_endian"] = hw_info["little_endian"]
+ for key_field in field_names:
+ result[key_field] = kv_dict.get(key_field)
+
+ return result
+
+ def gather_stop_reply_threads(self, post_startup_log_lines, thread_count):
# Pull out threads from stop response.
- stop_reply_threads_text = kv_dict.get("threads")
+ stop_reply_threads_text = self.gather_stop_reply_fields(
+ post_startup_log_lines, thread_count, ["threads"])["threads"]
if stop_reply_threads_text:
return [int(thread_id, 16)
for thread_id in stop_reply_threads_text.split(",")]
else:
return []
+ def gather_stop_reply_pcs(self, post_startup_log_lines, thread_count):
+ results = self.gather_stop_reply_fields( post_startup_log_lines,
+ thread_count, ["threads", "thread-pcs"])
+ if not results:
+ return []
+
+ threads_text = results["threads"]
+ pcs_text = results["thread-pcs"]
+ thread_ids = threads_text.split(",")
+ pcs = pcs_text.split(",")
+ self.assertTrue(len(thread_ids) == len(pcs))
+
+ thread_pcs = dict()
+ for i in range(0, len(pcs)):
+ thread_pcs[int(thread_ids[i], 16)] = pcs[i]
+
+ result = dict()
+ result["thread_pcs"] = thread_pcs
+ result["pc_register"] = results["pc_register"]
+ result["little_endian"] = results["little_endian"]
+ return result
+
+ def switch_endian(self, egg):
+ return "".join(reversed(re.findall("..", egg)))
+
+ def parse_hw_info(self, context):
+ self.assertIsNotNone(context)
+ process_info = self.parse_process_info_response(context)
+ endian = process_info.get("endian")
+ reg_info = self.parse_register_info_packets(context)
+ (pc_lldb_reg_index, pc_reg_info) = self.find_pc_reg_info(reg_info)
+
+ hw_info = dict()
+ hw_info["pc_register"] = pc_lldb_reg_index
+ hw_info["little_endian"] = (endian == "little")
+ return hw_info
+
+ def gather_threads_info_pcs(self, pc_register, little_endian):
+ self.reset_test_sequence()
+ self.test_sequence.add_log_lines(
+ [
+ "read packet: $jThreadsInfo#c1",
+ {
+ "direction": "send",
+ "regex": r"^\$(.*)#[0-9a-fA-F]{2}$",
+ "capture": {
+ 1: "threads_info"}},
+ ],
+ True)
+
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+ threads_info = context.get("threads_info")
+ register = str(pc_register)
+ # The jThreadsInfo response is not valid JSON data, so we have to
+ # clean it up first.
+ jthreads_info = json.loads(re.sub(r"}]", "}", threads_info))
+ thread_pcs = dict()
+ for thread_info in jthreads_info:
+ tid = thread_info["tid"]
+ pc = thread_info["registers"][register]
+ thread_pcs[tid] = self.switch_endian(pc) if little_endian else pc
+
+ return thread_pcs
+
def QListThreadsInStopReply_supported(self):
procs = self.prep_debug_monitor_and_inferior()
self.test_sequence.add_log_lines(
@@ -183,3 +265,34 @@ class TestGdbRemoteThreadsInStopReply(
self.build()
self.set_inferior_startup_launch()
self.stop_reply_reports_correct_threads(5)
+
+ def stop_reply_contains_thread_pcs(self, thread_count):
+ results = self.gather_stop_reply_pcs(
+ self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, thread_count)
+ stop_reply_pcs = results["thread_pcs"]
+ pc_register = results["pc_register"]
+ little_endian = results["little_endian"]
+ self.assertEqual(len(stop_reply_pcs), thread_count)
+
+ threads_info_pcs = self.gather_threads_info_pcs(pc_register,
+ little_endian)
+
+ self.assertEqual(len(threads_info_pcs), thread_count)
+ for thread_id in stop_reply_pcs:
+ self.assertTrue(thread_id in threads_info_pcs)
+ self.assertTrue(int(stop_reply_pcs[thread_id], 16)
+ == int(threads_info_pcs[thread_id], 16))
+
+ @llgs_test
+ def test_stop_reply_contains_thread_pcs_llgs(self):
+ self.init_llgs_test()
+ self.build()
+ self.set_inferior_startup_launch()
+ self.stop_reply_contains_thread_pcs(5)
+
+ @debugserver_test
+ def test_stop_reply_contains_thread_pcs_debugserver(self):
+ self.init_debugserver_test()
+ self.build()
+ self.set_inferior_startup_launch()
+ self.stop_reply_contains_thread_pcs(5)
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py b/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
index b69ac3f8d2a3..6f36fbea470b 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -1082,7 +1082,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
self.set_inferior_startup_launch()
self.qMemoryRegionInfo_reports_heap_address_as_readable_writeable()
- def software_breakpoint_set_and_remove_work(self):
+ def breakpoint_set_and_remove_work(self, want_hardware=False):
# Start up the inferior.
procs = self.prep_debug_monitor_and_inferior(
inferior_args=[
@@ -1126,15 +1126,27 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
self.assertIsNotNone(context.get("function_address"))
function_address = int(context.get("function_address"), 16)
+ # Get current target architecture
+ target_arch = self.getArchitecture()
+
# Set the breakpoint.
- if self.getArchitecture() == "arm":
+ if (target_arch == "arm") or (target_arch == "aarch64"):
# TODO: Handle case when setting breakpoint in thumb code
BREAKPOINT_KIND = 4
else:
BREAKPOINT_KIND = 1
+
+ # Set default packet type to Z0 (software breakpoint)
+ z_packet_type = 0
+
+ # If hardware breakpoint is requested set packet type to Z1
+ if want_hardware == True:
+ z_packet_type = 1
+
self.reset_test_sequence()
self.add_set_breakpoint_packets(
function_address,
+ z_packet_type,
do_continue=True,
breakpoint_kind=BREAKPOINT_KIND)
@@ -1182,13 +1194,15 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
# Verify that a breakpoint remove and continue gets us the expected
# output.
self.reset_test_sequence()
+
+ # Add breakpoint remove packets
+ self.add_remove_breakpoint_packets(
+ function_address,
+ z_packet_type,
+ breakpoint_kind=BREAKPOINT_KIND)
+
self.test_sequence.add_log_lines(
[
- # Remove the breakpoint.
- "read packet: $z0,{0:x},{1}#00".format(
- function_address, BREAKPOINT_KIND),
- # Verify the stub could unset it.
- "send packet: $OK#00",
# Continue running.
"read packet: $c#63",
# We should now receive the output from the call.
@@ -1209,7 +1223,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
else:
self.build()
self.set_inferior_startup_launch()
- self.software_breakpoint_set_and_remove_work()
+ self.breakpoint_set_and_remove_work(want_hardware=False)
@llgs_test
@expectedFlakeyLinux("llvm.org/pr25652")
@@ -1221,7 +1235,35 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
else:
self.build()
self.set_inferior_startup_launch()
- self.software_breakpoint_set_and_remove_work()
+ self.breakpoint_set_and_remove_work(want_hardware=False)
+
+ @debugserver_test
+ @skipUnlessPlatform(oslist=['linux'])
+ @expectedFailureAndroid
+ @skipIf(archs=no_match(['arm', 'aarch64']))
+ def test_hardware_breakpoint_set_and_remove_work_debugserver(self):
+ self.init_debugserver_test()
+ if self.getArchitecture() == "arm":
+ # TODO: Handle case when setting breakpoint in thumb code
+ self.build(dictionary={'CFLAGS_EXTRAS': '-marm'})
+ else:
+ self.build()
+ self.set_inferior_startup_launch()
+ self.breakpoint_set_and_remove_work(want_hardware=True)
+
+ @llgs_test
+ @skipUnlessPlatform(oslist=['linux'])
+ @expectedFailureAndroid
+ @skipIf(archs=no_match(['arm', 'aarch64']))
+ def test_hardware_breakpoint_set_and_remove_work_llgs(self):
+ self.init_llgs_test()
+ if self.getArchitecture() == "arm":
+ # TODO: Handle case when setting breakpoint in thumb code
+ self.build(dictionary={'CFLAGS_EXTRAS': '-marm'})
+ else:
+ self.build()
+ self.set_inferior_startup_launch()
+ self.breakpoint_set_and_remove_work(want_hardware=True)
def qSupported_returns_known_stub_features(self):
# Start up the stub and start/prep the inferior.
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
index b97c6ebc18e3..a3691a8d42b9 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/exit-code/main.cpp
@@ -15,22 +15,24 @@
#if defined(__APPLE__)
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
-int pthread_threadid_np(pthread_t,__uint64_t*);
+int pthread_threadid_np(pthread_t, __uint64_t *);
#elif defined(__linux__)
#include <sys/syscall.h>
+#elif defined(__NetBSD__)
+#include <lwp.h>
#endif
-static const char *const RETVAL_PREFIX = "retval:";
-static const char *const SLEEP_PREFIX = "sleep:";
-static const char *const STDERR_PREFIX = "stderr:";
-static const char *const SET_MESSAGE_PREFIX = "set-message:";
-static const char *const PRINT_MESSAGE_COMMAND = "print-message:";
-static const char *const GET_DATA_ADDRESS_PREFIX = "get-data-address-hex:";
-static const char *const GET_STACK_ADDRESS_COMMAND = "get-stack-address-hex:";
-static const char *const GET_HEAP_ADDRESS_COMMAND = "get-heap-address-hex:";
+static const char *const RETVAL_PREFIX = "retval:";
+static const char *const SLEEP_PREFIX = "sleep:";
+static const char *const STDERR_PREFIX = "stderr:";
+static const char *const SET_MESSAGE_PREFIX = "set-message:";
+static const char *const PRINT_MESSAGE_COMMAND = "print-message:";
+static const char *const GET_DATA_ADDRESS_PREFIX = "get-data-address-hex:";
+static const char *const GET_STACK_ADDRESS_COMMAND = "get-stack-address-hex:";
+static const char *const GET_HEAP_ADDRESS_COMMAND = "get-heap-address-hex:";
-static const char *const GET_CODE_ADDRESS_PREFIX = "get-code-address-hex:";
-static const char *const CALL_FUNCTION_PREFIX = "call-function:";
+static const char *const GET_CODE_ADDRESS_PREFIX = "get-code-address-hex:";
+static const char *const CALL_FUNCTION_PREFIX = "call-function:";
static const char *const THREAD_PREFIX = "thread:";
static const char *const THREAD_COMMAND_NEW = "new";
@@ -50,342 +52,304 @@ static char g_message[256];
static volatile char g_c1 = '0';
static volatile char g_c2 = '1';
-static void
-print_thread_id ()
-{
- // Put in the right magic here for your platform to spit out the thread id (tid) that debugserver/lldb-gdbserver would see as a TID.
- // Otherwise, let the else clause print out the unsupported text so that the unit test knows to skip verifying thread ids.
+static void print_thread_id() {
+// Put in the right magic here for your platform to spit out the thread id (tid)
+// that debugserver/lldb-gdbserver would see as a TID. Otherwise, let the else
+// clause print out the unsupported text so that the unit test knows to skip
+// verifying thread ids.
#if defined(__APPLE__)
- __uint64_t tid = 0;
- pthread_threadid_np(pthread_self(), &tid);
- printf ("%" PRIx64, tid);
-#elif defined (__linux__)
- // This is a call to gettid() via syscall.
- printf ("%" PRIx64, static_cast<uint64_t> (syscall (__NR_gettid)));
+ __uint64_t tid = 0;
+ pthread_threadid_np(pthread_self(), &tid);
+ printf("%" PRIx64, tid);
+#elif defined(__linux__)
+ // This is a call to gettid() via syscall.
+ printf("%" PRIx64, static_cast<uint64_t>(syscall(__NR_gettid)));
+#elif defined(__NetBSD__)
+ // Technically lwpid_t is 32-bit signed integer
+ printf("%" PRIx64, static_cast<uint64_t>(_lwp_self()));
#else
- printf("{no-tid-support}");
+ printf("{no-tid-support}");
#endif
}
-static void
-signal_handler (int signo)
-{
- const char *signal_name = nullptr;
- switch (signo)
- {
- case SIGUSR1: signal_name = "SIGUSR1"; break;
- case SIGSEGV: signal_name = "SIGSEGV"; break;
- default: signal_name = nullptr;
- }
-
- // Print notice that we received the signal on a given thread.
- pthread_mutex_lock (&g_print_mutex);
- if (signal_name)
- printf ("received %s on thread id: ", signal_name);
- else
- printf ("received signo %d (%s) on thread id: ", signo, strsignal (signo));
- print_thread_id ();
- printf ("\n");
- pthread_mutex_unlock (&g_print_mutex);
-
- // Reset the signal handler if we're one of the expected signal handlers.
- switch (signo)
- {
- case SIGSEGV:
- if (g_is_segfaulting)
- {
- // Fix up the pointer we're writing to. This needs to happen if nothing intercepts the SIGSEGV
- // (i.e. if somebody runs this from the command line).
- longjmp(g_jump_buffer, 1);
- }
- break;
- case SIGUSR1:
- if (g_is_segfaulting)
- {
- // Fix up the pointer we're writing to. This is used to test gdb remote signal delivery.
- // A SIGSEGV will be raised when the thread is created, switched out for a SIGUSR1, and
- // then this code still needs to fix the seg fault.
- // (i.e. if somebody runs this from the command line).
- longjmp(g_jump_buffer, 1);
- }
- break;
- }
-
- // Reset the signal handler.
- sig_t sig_result = signal (signo, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set signal handler: errno=%d\n", errno);
- exit (1);
- }
+static void signal_handler(int signo) {
+ const char *signal_name = nullptr;
+ switch (signo) {
+ case SIGUSR1:
+ signal_name = "SIGUSR1";
+ break;
+ case SIGSEGV:
+ signal_name = "SIGSEGV";
+ break;
+ default:
+ signal_name = nullptr;
+ }
+
+ // Print notice that we received the signal on a given thread.
+ pthread_mutex_lock(&g_print_mutex);
+ if (signal_name)
+ printf("received %s on thread id: ", signal_name);
+ else
+ printf("received signo %d (%s) on thread id: ", signo, strsignal(signo));
+ print_thread_id();
+ printf("\n");
+ pthread_mutex_unlock(&g_print_mutex);
+
+ // Reset the signal handler if we're one of the expected signal handlers.
+ switch (signo) {
+ case SIGSEGV:
+ if (g_is_segfaulting) {
+ // Fix up the pointer we're writing to. This needs to happen if nothing
+ // intercepts the SIGSEGV (i.e. if somebody runs this from the command
+ // line).
+ longjmp(g_jump_buffer, 1);
+ }
+ break;
+ case SIGUSR1:
+ if (g_is_segfaulting) {
+ // Fix up the pointer we're writing to. This is used to test gdb remote
+ // signal delivery. A SIGSEGV will be raised when the thread is created,
+ // switched out for a SIGUSR1, and then this code still needs to fix the
+ // seg fault. (i.e. if somebody runs this from the command line).
+ longjmp(g_jump_buffer, 1);
+ }
+ break;
+ }
+
+ // Reset the signal handler.
+ sig_t sig_result = signal(signo, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set signal handler: errno=%d\n", errno);
+ exit(1);
+ }
}
-static void
-swap_chars ()
-{
- g_c1 = '1';
- g_c2 = '0';
+static void swap_chars() {
+ g_c1 = '1';
+ g_c2 = '0';
- g_c1 = '0';
- g_c2 = '1';
+ g_c1 = '0';
+ g_c2 = '1';
}
-static void
-hello ()
-{
- pthread_mutex_lock (&g_print_mutex);
- printf ("hello, world\n");
- pthread_mutex_unlock (&g_print_mutex);
+static void hello() {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("hello, world\n");
+ pthread_mutex_unlock(&g_print_mutex);
}
-static void*
-thread_func (void *arg)
-{
- static pthread_mutex_t s_thread_index_mutex = PTHREAD_MUTEX_INITIALIZER;
- static int s_thread_index = 1;
-
- pthread_mutex_lock (&s_thread_index_mutex);
- const int this_thread_index = s_thread_index++;
- pthread_mutex_unlock (&s_thread_index_mutex);
-
- if (g_print_thread_ids)
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("thread %d id: ", this_thread_index);
- print_thread_id ();
- printf ("\n");
- pthread_mutex_unlock (&g_print_mutex);
- }
-
- if (g_threads_do_segfault)
- {
- // Sleep for a number of seconds based on the thread index.
- // TODO add ability to send commands to test exe so we can
- // handle timing more precisely. This is clunky. All we're
- // trying to do is add predictability as to the timing of
- // signal generation by created threads.
- int sleep_seconds = 2 * (this_thread_index - 1);
- while (sleep_seconds > 0)
- sleep_seconds = sleep(sleep_seconds);
-
- // Test creating a SEGV.
- pthread_mutex_lock (&g_jump_buffer_mutex);
- g_is_segfaulting = true;
- int *bad_p = nullptr;
- if (setjmp(g_jump_buffer) == 0)
- {
- // Force a seg fault signal on this thread.
- *bad_p = 0;
- }
- else
- {
- // Tell the system we're no longer seg faulting.
- // Used by the SIGUSR1 signal handler that we inject
- // in place of the SIGSEGV so it only tries to
- // recover from the SIGSEGV if this seg fault code
- // was in play.
- g_is_segfaulting = false;
- }
- pthread_mutex_unlock (&g_jump_buffer_mutex);
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("thread ");
- print_thread_id ();
- printf (": past SIGSEGV\n");
- pthread_mutex_unlock (&g_print_mutex);
- }
-
- int sleep_seconds_remaining = 60;
- while (sleep_seconds_remaining > 0)
- {
- sleep_seconds_remaining = sleep (sleep_seconds_remaining);
- }
-
- return nullptr;
+static void *thread_func(void *arg) {
+ static pthread_mutex_t s_thread_index_mutex = PTHREAD_MUTEX_INITIALIZER;
+ static int s_thread_index = 1;
+
+ pthread_mutex_lock(&s_thread_index_mutex);
+ const int this_thread_index = s_thread_index++;
+ pthread_mutex_unlock(&s_thread_index_mutex);
+
+ if (g_print_thread_ids) {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("thread %d id: ", this_thread_index);
+ print_thread_id();
+ printf("\n");
+ pthread_mutex_unlock(&g_print_mutex);
+ }
+
+ if (g_threads_do_segfault) {
+ // Sleep for a number of seconds based on the thread index.
+ // TODO add ability to send commands to test exe so we can
+ // handle timing more precisely. This is clunky. All we're
+ // trying to do is add predictability as to the timing of
+ // signal generation by created threads.
+ int sleep_seconds = 2 * (this_thread_index - 1);
+ while (sleep_seconds > 0)
+ sleep_seconds = sleep(sleep_seconds);
+
+ // Test creating a SEGV.
+ pthread_mutex_lock(&g_jump_buffer_mutex);
+ g_is_segfaulting = true;
+ int *bad_p = nullptr;
+ if (setjmp(g_jump_buffer) == 0) {
+ // Force a seg fault signal on this thread.
+ *bad_p = 0;
+ } else {
+ // Tell the system we're no longer seg faulting.
+ // Used by the SIGUSR1 signal handler that we inject
+ // in place of the SIGSEGV so it only tries to
+ // recover from the SIGSEGV if this seg fault code
+ // was in play.
+ g_is_segfaulting = false;
+ }
+ pthread_mutex_unlock(&g_jump_buffer_mutex);
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("thread ");
+ print_thread_id();
+ printf(": past SIGSEGV\n");
+ pthread_mutex_unlock(&g_print_mutex);
+ }
+
+ int sleep_seconds_remaining = 60;
+ while (sleep_seconds_remaining > 0) {
+ sleep_seconds_remaining = sleep(sleep_seconds_remaining);
+ }
+
+ return nullptr;
}
-int main (int argc, char **argv)
-{
- lldb_enable_attach();
-
- std::vector<pthread_t> threads;
- std::unique_ptr<uint8_t[]> heap_array_up;
- int return_value = 0;
-
- // Set the signal handler.
- sig_t sig_result = signal (SIGALRM, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set SIGALRM signal handler: errno=%d\n", errno);
- exit (1);
- }
-
- sig_result = signal (SIGUSR1, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
- exit (1);
- }
-
- sig_result = signal (SIGSEGV, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
- exit (1);
- }
-
- // Process command line args.
- for (int i = 1; i < argc; ++i)
- {
- if (std::strstr (argv[i], STDERR_PREFIX))
- {
- // Treat remainder as text to go to stderr.
- fprintf (stderr, "%s\n", (argv[i] + strlen (STDERR_PREFIX)));
- }
- else if (std::strstr (argv[i], RETVAL_PREFIX))
- {
- // Treat as the return value for the program.
- return_value = std::atoi (argv[i] + strlen (RETVAL_PREFIX));
- }
- else if (std::strstr (argv[i], SLEEP_PREFIX))
- {
- // Treat as the amount of time to have this process sleep (in seconds).
- int sleep_seconds_remaining = std::atoi (argv[i] + strlen (SLEEP_PREFIX));
-
- // Loop around, sleeping until all sleep time is used up. Note that
- // signals will cause sleep to end early with the number of seconds remaining.
- for (int i = 0; sleep_seconds_remaining > 0; ++i)
- {
- sleep_seconds_remaining = sleep (sleep_seconds_remaining);
- // std::cout << "sleep result (call " << i << "): " << sleep_seconds_remaining << std::endl;
- }
- }
- else if (std::strstr (argv[i], SET_MESSAGE_PREFIX))
- {
- // Copy the contents after "set-message:" to the g_message buffer.
- // Used for reading inferior memory and verifying contents match expectations.
- strncpy (g_message, argv[i] + strlen (SET_MESSAGE_PREFIX), sizeof (g_message));
-
- // Ensure we're null terminated.
- g_message[sizeof (g_message) - 1] = '\0';
-
- }
- else if (std::strstr (argv[i], PRINT_MESSAGE_COMMAND))
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("message: %s\n", g_message);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_DATA_ADDRESS_PREFIX))
- {
- volatile void *data_p = nullptr;
-
- if (std::strstr (argv[i] + strlen (GET_DATA_ADDRESS_PREFIX), "g_message"))
- data_p = &g_message[0];
- else if (std::strstr (argv[i] + strlen (GET_DATA_ADDRESS_PREFIX), "g_c1"))
- data_p = &g_c1;
- else if (std::strstr (argv[i] + strlen (GET_DATA_ADDRESS_PREFIX), "g_c2"))
- data_p = &g_c2;
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("data address: %p\n", data_p);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_HEAP_ADDRESS_COMMAND))
- {
- // Create a byte array if not already present.
- if (!heap_array_up)
- heap_array_up.reset (new uint8_t[32]);
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("heap address: %p\n", heap_array_up.get ());
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_STACK_ADDRESS_COMMAND))
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("stack address: %p\n", &return_value);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_CODE_ADDRESS_PREFIX))
- {
- void (*func_p)() = nullptr;
-
- if (std::strstr (argv[i] + strlen (GET_CODE_ADDRESS_PREFIX), "hello"))
- func_p = hello;
- else if (std::strstr (argv[i] + strlen (GET_CODE_ADDRESS_PREFIX), "swap_chars"))
- func_p = swap_chars;
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("code address: %p\n", func_p);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], CALL_FUNCTION_PREFIX))
- {
- // Defaut to providing the address of main.
- if (std::strcmp (argv[i] + strlen (CALL_FUNCTION_PREFIX), "hello") == 0)
- hello();
- else if (std::strcmp (argv[i] + strlen (CALL_FUNCTION_PREFIX), "swap_chars") == 0)
- swap_chars();
- else
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("unknown function: %s\n", argv[i] + strlen (CALL_FUNCTION_PREFIX));
- pthread_mutex_unlock (&g_print_mutex);
- }
- }
- else if (std::strstr (argv[i], THREAD_PREFIX))
- {
- // Check if we're creating a new thread.
- if (std::strstr (argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_NEW))
- {
- // Create a new thread.
- pthread_t new_thread;
- const int err = ::pthread_create (&new_thread, nullptr, thread_func, nullptr);
- if (err)
- {
- fprintf (stderr, "pthread_create() failed with error code %d\n", err);
- exit (err);
- }
- threads.push_back (new_thread);
- }
- else if (std::strstr (argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_PRINT_IDS))
- {
- // Turn on thread id announcing.
- g_print_thread_ids = true;
-
- // And announce us.
- pthread_mutex_lock (&g_print_mutex);
- printf ("thread 0 id: ");
- print_thread_id ();
- printf ("\n");
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_SEGFAULT))
- {
- g_threads_do_segfault = true;
- }
- else
- {
- // At this point we don't do anything else with threads.
- // Later use thread index and send command to thread.
- }
- }
- else
- {
- // Treat the argument as text for stdout.
- printf("%s\n", argv[i]);
+int main(int argc, char **argv) {
+ lldb_enable_attach();
+
+ std::vector<pthread_t> threads;
+ std::unique_ptr<uint8_t[]> heap_array_up;
+ int return_value = 0;
+
+ // Set the signal handler.
+ sig_t sig_result = signal(SIGALRM, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set SIGALRM signal handler: errno=%d\n", errno);
+ exit(1);
+ }
+
+ sig_result = signal(SIGUSR1, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
+ exit(1);
+ }
+
+ sig_result = signal(SIGSEGV, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
+ exit(1);
+ }
+
+ // Process command line args.
+ for (int i = 1; i < argc; ++i) {
+ if (std::strstr(argv[i], STDERR_PREFIX)) {
+ // Treat remainder as text to go to stderr.
+ fprintf(stderr, "%s\n", (argv[i] + strlen(STDERR_PREFIX)));
+ } else if (std::strstr(argv[i], RETVAL_PREFIX)) {
+ // Treat as the return value for the program.
+ return_value = std::atoi(argv[i] + strlen(RETVAL_PREFIX));
+ } else if (std::strstr(argv[i], SLEEP_PREFIX)) {
+ // Treat as the amount of time to have this process sleep (in seconds).
+ int sleep_seconds_remaining = std::atoi(argv[i] + strlen(SLEEP_PREFIX));
+
+ // Loop around, sleeping until all sleep time is used up. Note that
+ // signals will cause sleep to end early with the number of seconds
+ // remaining.
+ for (int i = 0; sleep_seconds_remaining > 0; ++i) {
+ sleep_seconds_remaining = sleep(sleep_seconds_remaining);
+ // std::cout << "sleep result (call " << i << "): " <<
+ // sleep_seconds_remaining << std::endl;
+ }
+ } else if (std::strstr(argv[i], SET_MESSAGE_PREFIX)) {
+ // Copy the contents after "set-message:" to the g_message buffer.
+ // Used for reading inferior memory and verifying contents match
+ // expectations.
+ strncpy(g_message, argv[i] + strlen(SET_MESSAGE_PREFIX),
+ sizeof(g_message));
+
+ // Ensure we're null terminated.
+ g_message[sizeof(g_message) - 1] = '\0';
+
+ } else if (std::strstr(argv[i], PRINT_MESSAGE_COMMAND)) {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("message: %s\n", g_message);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_DATA_ADDRESS_PREFIX)) {
+ volatile void *data_p = nullptr;
+
+ if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_message"))
+ data_p = &g_message[0];
+ else if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_c1"))
+ data_p = &g_c1;
+ else if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_c2"))
+ data_p = &g_c2;
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("data address: %p\n", data_p);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_HEAP_ADDRESS_COMMAND)) {
+ // Create a byte array if not already present.
+ if (!heap_array_up)
+ heap_array_up.reset(new uint8_t[32]);
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("heap address: %p\n", heap_array_up.get());
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_STACK_ADDRESS_COMMAND)) {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("stack address: %p\n", &return_value);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_CODE_ADDRESS_PREFIX)) {
+ void (*func_p)() = nullptr;
+
+ if (std::strstr(argv[i] + strlen(GET_CODE_ADDRESS_PREFIX), "hello"))
+ func_p = hello;
+ else if (std::strstr(argv[i] + strlen(GET_CODE_ADDRESS_PREFIX),
+ "swap_chars"))
+ func_p = swap_chars;
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("code address: %p\n", func_p);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], CALL_FUNCTION_PREFIX)) {
+ // Defaut to providing the address of main.
+ if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX), "hello") == 0)
+ hello();
+ else if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX),
+ "swap_chars") == 0)
+ swap_chars();
+ else {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("unknown function: %s\n",
+ argv[i] + strlen(CALL_FUNCTION_PREFIX));
+ pthread_mutex_unlock(&g_print_mutex);
+ }
+ } else if (std::strstr(argv[i], THREAD_PREFIX)) {
+ // Check if we're creating a new thread.
+ if (std::strstr(argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_NEW)) {
+ // Create a new thread.
+ pthread_t new_thread;
+ const int err =
+ ::pthread_create(&new_thread, nullptr, thread_func, nullptr);
+ if (err) {
+ fprintf(stderr, "pthread_create() failed with error code %d\n", err);
+ exit(err);
}
+ threads.push_back(new_thread);
+ } else if (std::strstr(argv[i] + strlen(THREAD_PREFIX),
+ THREAD_COMMAND_PRINT_IDS)) {
+ // Turn on thread id announcing.
+ g_print_thread_ids = true;
+
+ // And announce us.
+ pthread_mutex_lock(&g_print_mutex);
+ printf("thread 0 id: ");
+ print_thread_id();
+ printf("\n");
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i] + strlen(THREAD_PREFIX),
+ THREAD_COMMAND_SEGFAULT)) {
+ g_threads_do_segfault = true;
+ } else {
+ // At this point we don't do anything else with threads.
+ // Later use thread index and send command to thread.
+ }
+ } else {
+ // Treat the argument as text for stdout.
+ printf("%s\n", argv[i]);
}
-
- // If we launched any threads, join them
- for (std::vector<pthread_t>::iterator it = threads.begin (); it != threads.end (); ++it)
- {
- void *thread_retval = nullptr;
- const int err = ::pthread_join (*it, &thread_retval);
- if (err != 0)
- fprintf (stderr, "pthread_join() failed with error code %d\n", err);
- }
-
- return return_value;
+ }
+
+ // If we launched any threads, join them
+ for (std::vector<pthread_t>::iterator it = threads.begin();
+ it != threads.end(); ++it) {
+ void *thread_retval = nullptr;
+ const int err = ::pthread_join(*it, &thread_retval);
+ if (err != 0)
+ fprintf(stderr, "pthread_join() failed with error code %d\n", err);
+ }
+
+ return return_value;
}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index ef6a0a21aaeb..23cb86935857 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -883,12 +883,13 @@ class GdbRemoteTestCaseBase(TestBase):
def add_set_breakpoint_packets(
self,
address,
+ z_packet_type=0,
do_continue=True,
breakpoint_kind=1):
self.test_sequence.add_log_lines(
[ # Set the breakpoint.
- "read packet: $Z0,{0:x},{1}#00".format(
- address, breakpoint_kind),
+ "read packet: $Z{2},{0:x},{1}#00".format(
+ address, breakpoint_kind, z_packet_type),
# Verify the stub could set it.
"send packet: $OK#00",
], True)
@@ -904,11 +905,15 @@ class GdbRemoteTestCaseBase(TestBase):
2: "stop_thread_id"}},
], True)
- def add_remove_breakpoint_packets(self, address, breakpoint_kind=1):
+ def add_remove_breakpoint_packets(
+ self,
+ address,
+ z_packet_type=0,
+ breakpoint_kind=1):
self.test_sequence.add_log_lines(
[ # Remove the breakpoint.
- "read packet: $z0,{0:x},{1}#00".format(
- address, breakpoint_kind),
+ "read packet: $z{2},{0:x},{1}#00".format(
+ address, breakpoint_kind, z_packet_type),
# Verify the stub could unset it.
"send packet: $OK#00",
], True)
@@ -929,7 +934,8 @@ class GdbRemoteTestCaseBase(TestBase):
"qXfer:libraries:read",
"qXfer:libraries-svr4:read",
"qXfer:features:read",
- "qEcho"
+ "qEcho",
+ "QPassSignals"
]
def parse_qSupported_response(self, context):
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp
index 69d60071aa45..ced7f7125088 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp
@@ -2,38 +2,30 @@
#include <cstring>
#include <iostream>
-namespace
-{
- const char *const SEGFAULT_COMMAND = "segfault";
- const char *const ABORT_COMMAND = "abort";
+namespace {
+const char *const SEGFAULT_COMMAND = "segfault";
+const char *const ABORT_COMMAND = "abort";
}
-int main (int argc, char **argv)
-{
- if (argc < 2)
- {
- std::cout << "expected at least one command provided on the command line" << std::endl;
- }
+int main(int argc, char **argv) {
+ if (argc < 2) {
+ std::cout << "expected at least one command provided on the command line"
+ << std::endl;
+ }
- // Process command line args.
- for (int i = 1; i < argc; ++i)
- {
- const char *const command = argv[i];
- if (std::strstr (command, SEGFAULT_COMMAND))
- {
- // Perform a null pointer access.
- int *const null_int_ptr = nullptr;
- *null_int_ptr = 0xDEAD;
- }
- else if (std::strstr (command, ABORT_COMMAND))
- {
- std::abort();
- }
- else
- {
- std::cout << "Unsupported command: " << command << std::endl;
- }
+ // Process command line args.
+ for (int i = 1; i < argc; ++i) {
+ const char *const command = argv[i];
+ if (std::strstr(command, SEGFAULT_COMMAND)) {
+ // Perform a null pointer access.
+ int *const null_int_ptr = nullptr;
+ *null_int_ptr = 0xDEAD;
+ } else if (std::strstr(command, ABORT_COMMAND)) {
+ std::abort();
+ } else {
+ std::cout << "Unsupported command: " << command << std::endl;
}
+ }
- return 0;
+ return 0;
}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
index b97c6ebc18e3..a574b41abf67 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
@@ -1,3 +1,12 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
#include <cstdlib>
#include <cstring>
#include <errno.h>
@@ -15,22 +24,24 @@
#if defined(__APPLE__)
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
-int pthread_threadid_np(pthread_t,__uint64_t*);
+int pthread_threadid_np(pthread_t, __uint64_t *);
#elif defined(__linux__)
#include <sys/syscall.h>
+#elif defined(__NetBSD__)
+#include <lwp.h>
#endif
-static const char *const RETVAL_PREFIX = "retval:";
-static const char *const SLEEP_PREFIX = "sleep:";
-static const char *const STDERR_PREFIX = "stderr:";
-static const char *const SET_MESSAGE_PREFIX = "set-message:";
-static const char *const PRINT_MESSAGE_COMMAND = "print-message:";
-static const char *const GET_DATA_ADDRESS_PREFIX = "get-data-address-hex:";
-static const char *const GET_STACK_ADDRESS_COMMAND = "get-stack-address-hex:";
-static const char *const GET_HEAP_ADDRESS_COMMAND = "get-heap-address-hex:";
+static const char *const RETVAL_PREFIX = "retval:";
+static const char *const SLEEP_PREFIX = "sleep:";
+static const char *const STDERR_PREFIX = "stderr:";
+static const char *const SET_MESSAGE_PREFIX = "set-message:";
+static const char *const PRINT_MESSAGE_COMMAND = "print-message:";
+static const char *const GET_DATA_ADDRESS_PREFIX = "get-data-address-hex:";
+static const char *const GET_STACK_ADDRESS_COMMAND = "get-stack-address-hex:";
+static const char *const GET_HEAP_ADDRESS_COMMAND = "get-heap-address-hex:";
-static const char *const GET_CODE_ADDRESS_PREFIX = "get-code-address-hex:";
-static const char *const CALL_FUNCTION_PREFIX = "call-function:";
+static const char *const GET_CODE_ADDRESS_PREFIX = "get-code-address-hex:";
+static const char *const CALL_FUNCTION_PREFIX = "call-function:";
static const char *const THREAD_PREFIX = "thread:";
static const char *const THREAD_COMMAND_NEW = "new";
@@ -50,342 +61,304 @@ static char g_message[256];
static volatile char g_c1 = '0';
static volatile char g_c2 = '1';
-static void
-print_thread_id ()
-{
- // Put in the right magic here for your platform to spit out the thread id (tid) that debugserver/lldb-gdbserver would see as a TID.
- // Otherwise, let the else clause print out the unsupported text so that the unit test knows to skip verifying thread ids.
+static void print_thread_id() {
+// Put in the right magic here for your platform to spit out the thread id (tid)
+// that debugserver/lldb-gdbserver would see as a TID. Otherwise, let the else
+// clause print out the unsupported text so that the unit test knows to skip
+// verifying thread ids.
#if defined(__APPLE__)
- __uint64_t tid = 0;
- pthread_threadid_np(pthread_self(), &tid);
- printf ("%" PRIx64, tid);
-#elif defined (__linux__)
- // This is a call to gettid() via syscall.
- printf ("%" PRIx64, static_cast<uint64_t> (syscall (__NR_gettid)));
+ __uint64_t tid = 0;
+ pthread_threadid_np(pthread_self(), &tid);
+ printf("%" PRIx64, tid);
+#elif defined(__linux__)
+ // This is a call to gettid() via syscall.
+ printf("%" PRIx64, static_cast<uint64_t>(syscall(__NR_gettid)));
+#elif defined(__NetBSD__)
+ // Technically lwpid_t is 32-bit signed integer
+ printf("%" PRIx64, static_cast<uint64_t>(_lwp_self()));
#else
- printf("{no-tid-support}");
+ printf("{no-tid-support}");
#endif
}
-static void
-signal_handler (int signo)
-{
- const char *signal_name = nullptr;
- switch (signo)
- {
- case SIGUSR1: signal_name = "SIGUSR1"; break;
- case SIGSEGV: signal_name = "SIGSEGV"; break;
- default: signal_name = nullptr;
- }
-
- // Print notice that we received the signal on a given thread.
- pthread_mutex_lock (&g_print_mutex);
- if (signal_name)
- printf ("received %s on thread id: ", signal_name);
- else
- printf ("received signo %d (%s) on thread id: ", signo, strsignal (signo));
- print_thread_id ();
- printf ("\n");
- pthread_mutex_unlock (&g_print_mutex);
-
- // Reset the signal handler if we're one of the expected signal handlers.
- switch (signo)
- {
- case SIGSEGV:
- if (g_is_segfaulting)
- {
- // Fix up the pointer we're writing to. This needs to happen if nothing intercepts the SIGSEGV
- // (i.e. if somebody runs this from the command line).
- longjmp(g_jump_buffer, 1);
- }
- break;
- case SIGUSR1:
- if (g_is_segfaulting)
- {
- // Fix up the pointer we're writing to. This is used to test gdb remote signal delivery.
- // A SIGSEGV will be raised when the thread is created, switched out for a SIGUSR1, and
- // then this code still needs to fix the seg fault.
- // (i.e. if somebody runs this from the command line).
- longjmp(g_jump_buffer, 1);
- }
- break;
- }
-
- // Reset the signal handler.
- sig_t sig_result = signal (signo, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set signal handler: errno=%d\n", errno);
- exit (1);
- }
+static void signal_handler(int signo) {
+ const char *signal_name = nullptr;
+ switch (signo) {
+ case SIGUSR1:
+ signal_name = "SIGUSR1";
+ break;
+ case SIGSEGV:
+ signal_name = "SIGSEGV";
+ break;
+ default:
+ signal_name = nullptr;
+ }
+
+ // Print notice that we received the signal on a given thread.
+ pthread_mutex_lock(&g_print_mutex);
+ if (signal_name)
+ printf("received %s on thread id: ", signal_name);
+ else
+ printf("received signo %d (%s) on thread id: ", signo, strsignal(signo));
+ print_thread_id();
+ printf("\n");
+ pthread_mutex_unlock(&g_print_mutex);
+
+ // Reset the signal handler if we're one of the expected signal handlers.
+ switch (signo) {
+ case SIGSEGV:
+ if (g_is_segfaulting) {
+ // Fix up the pointer we're writing to. This needs to happen if nothing
+ // intercepts the SIGSEGV (i.e. if somebody runs this from the command
+ // line).
+ longjmp(g_jump_buffer, 1);
+ }
+ break;
+ case SIGUSR1:
+ if (g_is_segfaulting) {
+ // Fix up the pointer we're writing to. This is used to test gdb remote
+ // signal delivery. A SIGSEGV will be raised when the thread is created,
+ // switched out for a SIGUSR1, and then this code still needs to fix the
+ // seg fault. (i.e. if somebody runs this from the command line).
+ longjmp(g_jump_buffer, 1);
+ }
+ break;
+ }
+
+ // Reset the signal handler.
+ sig_t sig_result = signal(signo, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set signal handler: errno=%d\n", errno);
+ exit(1);
+ }
}
-static void
-swap_chars ()
-{
- g_c1 = '1';
- g_c2 = '0';
+static void swap_chars() {
+ g_c1 = '1';
+ g_c2 = '0';
- g_c1 = '0';
- g_c2 = '1';
+ g_c1 = '0';
+ g_c2 = '1';
}
-static void
-hello ()
-{
- pthread_mutex_lock (&g_print_mutex);
- printf ("hello, world\n");
- pthread_mutex_unlock (&g_print_mutex);
+static void hello() {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("hello, world\n");
+ pthread_mutex_unlock(&g_print_mutex);
}
-static void*
-thread_func (void *arg)
-{
- static pthread_mutex_t s_thread_index_mutex = PTHREAD_MUTEX_INITIALIZER;
- static int s_thread_index = 1;
-
- pthread_mutex_lock (&s_thread_index_mutex);
- const int this_thread_index = s_thread_index++;
- pthread_mutex_unlock (&s_thread_index_mutex);
-
- if (g_print_thread_ids)
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("thread %d id: ", this_thread_index);
- print_thread_id ();
- printf ("\n");
- pthread_mutex_unlock (&g_print_mutex);
- }
-
- if (g_threads_do_segfault)
- {
- // Sleep for a number of seconds based on the thread index.
- // TODO add ability to send commands to test exe so we can
- // handle timing more precisely. This is clunky. All we're
- // trying to do is add predictability as to the timing of
- // signal generation by created threads.
- int sleep_seconds = 2 * (this_thread_index - 1);
- while (sleep_seconds > 0)
- sleep_seconds = sleep(sleep_seconds);
-
- // Test creating a SEGV.
- pthread_mutex_lock (&g_jump_buffer_mutex);
- g_is_segfaulting = true;
- int *bad_p = nullptr;
- if (setjmp(g_jump_buffer) == 0)
- {
- // Force a seg fault signal on this thread.
- *bad_p = 0;
- }
- else
- {
- // Tell the system we're no longer seg faulting.
- // Used by the SIGUSR1 signal handler that we inject
- // in place of the SIGSEGV so it only tries to
- // recover from the SIGSEGV if this seg fault code
- // was in play.
- g_is_segfaulting = false;
- }
- pthread_mutex_unlock (&g_jump_buffer_mutex);
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("thread ");
- print_thread_id ();
- printf (": past SIGSEGV\n");
- pthread_mutex_unlock (&g_print_mutex);
- }
-
- int sleep_seconds_remaining = 60;
- while (sleep_seconds_remaining > 0)
- {
- sleep_seconds_remaining = sleep (sleep_seconds_remaining);
- }
-
- return nullptr;
+static void *thread_func(void *arg) {
+ static pthread_mutex_t s_thread_index_mutex = PTHREAD_MUTEX_INITIALIZER;
+ static int s_thread_index = 1;
+
+ pthread_mutex_lock(&s_thread_index_mutex);
+ const int this_thread_index = s_thread_index++;
+ pthread_mutex_unlock(&s_thread_index_mutex);
+
+ if (g_print_thread_ids) {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("thread %d id: ", this_thread_index);
+ print_thread_id();
+ printf("\n");
+ pthread_mutex_unlock(&g_print_mutex);
+ }
+
+ if (g_threads_do_segfault) {
+ // Sleep for a number of seconds based on the thread index.
+ // TODO add ability to send commands to test exe so we can
+ // handle timing more precisely. This is clunky. All we're
+ // trying to do is add predictability as to the timing of
+ // signal generation by created threads.
+ int sleep_seconds = 2 * (this_thread_index - 1);
+ while (sleep_seconds > 0)
+ sleep_seconds = sleep(sleep_seconds);
+
+ // Test creating a SEGV.
+ pthread_mutex_lock(&g_jump_buffer_mutex);
+ g_is_segfaulting = true;
+ int *bad_p = nullptr;
+ if (setjmp(g_jump_buffer) == 0) {
+ // Force a seg fault signal on this thread.
+ *bad_p = 0;
+ } else {
+ // Tell the system we're no longer seg faulting.
+ // Used by the SIGUSR1 signal handler that we inject
+ // in place of the SIGSEGV so it only tries to
+ // recover from the SIGSEGV if this seg fault code
+ // was in play.
+ g_is_segfaulting = false;
+ }
+ pthread_mutex_unlock(&g_jump_buffer_mutex);
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("thread ");
+ print_thread_id();
+ printf(": past SIGSEGV\n");
+ pthread_mutex_unlock(&g_print_mutex);
+ }
+
+ int sleep_seconds_remaining = 60;
+ while (sleep_seconds_remaining > 0) {
+ sleep_seconds_remaining = sleep(sleep_seconds_remaining);
+ }
+
+ return nullptr;
}
-int main (int argc, char **argv)
-{
- lldb_enable_attach();
-
- std::vector<pthread_t> threads;
- std::unique_ptr<uint8_t[]> heap_array_up;
- int return_value = 0;
-
- // Set the signal handler.
- sig_t sig_result = signal (SIGALRM, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set SIGALRM signal handler: errno=%d\n", errno);
- exit (1);
- }
-
- sig_result = signal (SIGUSR1, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
- exit (1);
- }
-
- sig_result = signal (SIGSEGV, signal_handler);
- if (sig_result == SIG_ERR)
- {
- fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
- exit (1);
- }
-
- // Process command line args.
- for (int i = 1; i < argc; ++i)
- {
- if (std::strstr (argv[i], STDERR_PREFIX))
- {
- // Treat remainder as text to go to stderr.
- fprintf (stderr, "%s\n", (argv[i] + strlen (STDERR_PREFIX)));
- }
- else if (std::strstr (argv[i], RETVAL_PREFIX))
- {
- // Treat as the return value for the program.
- return_value = std::atoi (argv[i] + strlen (RETVAL_PREFIX));
- }
- else if (std::strstr (argv[i], SLEEP_PREFIX))
- {
- // Treat as the amount of time to have this process sleep (in seconds).
- int sleep_seconds_remaining = std::atoi (argv[i] + strlen (SLEEP_PREFIX));
-
- // Loop around, sleeping until all sleep time is used up. Note that
- // signals will cause sleep to end early with the number of seconds remaining.
- for (int i = 0; sleep_seconds_remaining > 0; ++i)
- {
- sleep_seconds_remaining = sleep (sleep_seconds_remaining);
- // std::cout << "sleep result (call " << i << "): " << sleep_seconds_remaining << std::endl;
- }
- }
- else if (std::strstr (argv[i], SET_MESSAGE_PREFIX))
- {
- // Copy the contents after "set-message:" to the g_message buffer.
- // Used for reading inferior memory and verifying contents match expectations.
- strncpy (g_message, argv[i] + strlen (SET_MESSAGE_PREFIX), sizeof (g_message));
-
- // Ensure we're null terminated.
- g_message[sizeof (g_message) - 1] = '\0';
-
- }
- else if (std::strstr (argv[i], PRINT_MESSAGE_COMMAND))
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("message: %s\n", g_message);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_DATA_ADDRESS_PREFIX))
- {
- volatile void *data_p = nullptr;
-
- if (std::strstr (argv[i] + strlen (GET_DATA_ADDRESS_PREFIX), "g_message"))
- data_p = &g_message[0];
- else if (std::strstr (argv[i] + strlen (GET_DATA_ADDRESS_PREFIX), "g_c1"))
- data_p = &g_c1;
- else if (std::strstr (argv[i] + strlen (GET_DATA_ADDRESS_PREFIX), "g_c2"))
- data_p = &g_c2;
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("data address: %p\n", data_p);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_HEAP_ADDRESS_COMMAND))
- {
- // Create a byte array if not already present.
- if (!heap_array_up)
- heap_array_up.reset (new uint8_t[32]);
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("heap address: %p\n", heap_array_up.get ());
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_STACK_ADDRESS_COMMAND))
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("stack address: %p\n", &return_value);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], GET_CODE_ADDRESS_PREFIX))
- {
- void (*func_p)() = nullptr;
-
- if (std::strstr (argv[i] + strlen (GET_CODE_ADDRESS_PREFIX), "hello"))
- func_p = hello;
- else if (std::strstr (argv[i] + strlen (GET_CODE_ADDRESS_PREFIX), "swap_chars"))
- func_p = swap_chars;
-
- pthread_mutex_lock (&g_print_mutex);
- printf ("code address: %p\n", func_p);
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i], CALL_FUNCTION_PREFIX))
- {
- // Defaut to providing the address of main.
- if (std::strcmp (argv[i] + strlen (CALL_FUNCTION_PREFIX), "hello") == 0)
- hello();
- else if (std::strcmp (argv[i] + strlen (CALL_FUNCTION_PREFIX), "swap_chars") == 0)
- swap_chars();
- else
- {
- pthread_mutex_lock (&g_print_mutex);
- printf ("unknown function: %s\n", argv[i] + strlen (CALL_FUNCTION_PREFIX));
- pthread_mutex_unlock (&g_print_mutex);
- }
- }
- else if (std::strstr (argv[i], THREAD_PREFIX))
- {
- // Check if we're creating a new thread.
- if (std::strstr (argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_NEW))
- {
- // Create a new thread.
- pthread_t new_thread;
- const int err = ::pthread_create (&new_thread, nullptr, thread_func, nullptr);
- if (err)
- {
- fprintf (stderr, "pthread_create() failed with error code %d\n", err);
- exit (err);
- }
- threads.push_back (new_thread);
- }
- else if (std::strstr (argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_PRINT_IDS))
- {
- // Turn on thread id announcing.
- g_print_thread_ids = true;
-
- // And announce us.
- pthread_mutex_lock (&g_print_mutex);
- printf ("thread 0 id: ");
- print_thread_id ();
- printf ("\n");
- pthread_mutex_unlock (&g_print_mutex);
- }
- else if (std::strstr (argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_SEGFAULT))
- {
- g_threads_do_segfault = true;
- }
- else
- {
- // At this point we don't do anything else with threads.
- // Later use thread index and send command to thread.
- }
- }
- else
- {
- // Treat the argument as text for stdout.
- printf("%s\n", argv[i]);
+int main(int argc, char **argv) {
+ lldb_enable_attach();
+
+ std::vector<pthread_t> threads;
+ std::unique_ptr<uint8_t[]> heap_array_up;
+ int return_value = 0;
+
+ // Set the signal handler.
+ sig_t sig_result = signal(SIGALRM, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set SIGALRM signal handler: errno=%d\n", errno);
+ exit(1);
+ }
+
+ sig_result = signal(SIGUSR1, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
+ exit(1);
+ }
+
+ sig_result = signal(SIGSEGV, signal_handler);
+ if (sig_result == SIG_ERR) {
+ fprintf(stderr, "failed to set SIGUSR1 handler: errno=%d\n", errno);
+ exit(1);
+ }
+
+ // Process command line args.
+ for (int i = 1; i < argc; ++i) {
+ if (std::strstr(argv[i], STDERR_PREFIX)) {
+ // Treat remainder as text to go to stderr.
+ fprintf(stderr, "%s\n", (argv[i] + strlen(STDERR_PREFIX)));
+ } else if (std::strstr(argv[i], RETVAL_PREFIX)) {
+ // Treat as the return value for the program.
+ return_value = std::atoi(argv[i] + strlen(RETVAL_PREFIX));
+ } else if (std::strstr(argv[i], SLEEP_PREFIX)) {
+ // Treat as the amount of time to have this process sleep (in seconds).
+ int sleep_seconds_remaining = std::atoi(argv[i] + strlen(SLEEP_PREFIX));
+
+ // Loop around, sleeping until all sleep time is used up. Note that
+ // signals will cause sleep to end early with the number of seconds
+ // remaining.
+ for (int i = 0; sleep_seconds_remaining > 0; ++i) {
+ sleep_seconds_remaining = sleep(sleep_seconds_remaining);
+ // std::cout << "sleep result (call " << i << "): " <<
+ // sleep_seconds_remaining << std::endl;
+ }
+ } else if (std::strstr(argv[i], SET_MESSAGE_PREFIX)) {
+ // Copy the contents after "set-message:" to the g_message buffer.
+ // Used for reading inferior memory and verifying contents match
+ // expectations.
+ strncpy(g_message, argv[i] + strlen(SET_MESSAGE_PREFIX),
+ sizeof(g_message));
+
+ // Ensure we're null terminated.
+ g_message[sizeof(g_message) - 1] = '\0';
+
+ } else if (std::strstr(argv[i], PRINT_MESSAGE_COMMAND)) {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("message: %s\n", g_message);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_DATA_ADDRESS_PREFIX)) {
+ volatile void *data_p = nullptr;
+
+ if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_message"))
+ data_p = &g_message[0];
+ else if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_c1"))
+ data_p = &g_c1;
+ else if (std::strstr(argv[i] + strlen(GET_DATA_ADDRESS_PREFIX), "g_c2"))
+ data_p = &g_c2;
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("data address: %p\n", data_p);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_HEAP_ADDRESS_COMMAND)) {
+ // Create a byte array if not already present.
+ if (!heap_array_up)
+ heap_array_up.reset(new uint8_t[32]);
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("heap address: %p\n", heap_array_up.get());
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_STACK_ADDRESS_COMMAND)) {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("stack address: %p\n", &return_value);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], GET_CODE_ADDRESS_PREFIX)) {
+ void (*func_p)() = nullptr;
+
+ if (std::strstr(argv[i] + strlen(GET_CODE_ADDRESS_PREFIX), "hello"))
+ func_p = hello;
+ else if (std::strstr(argv[i] + strlen(GET_CODE_ADDRESS_PREFIX),
+ "swap_chars"))
+ func_p = swap_chars;
+
+ pthread_mutex_lock(&g_print_mutex);
+ printf("code address: %p\n", func_p);
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i], CALL_FUNCTION_PREFIX)) {
+ // Defaut to providing the address of main.
+ if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX), "hello") == 0)
+ hello();
+ else if (std::strcmp(argv[i] + strlen(CALL_FUNCTION_PREFIX),
+ "swap_chars") == 0)
+ swap_chars();
+ else {
+ pthread_mutex_lock(&g_print_mutex);
+ printf("unknown function: %s\n",
+ argv[i] + strlen(CALL_FUNCTION_PREFIX));
+ pthread_mutex_unlock(&g_print_mutex);
+ }
+ } else if (std::strstr(argv[i], THREAD_PREFIX)) {
+ // Check if we're creating a new thread.
+ if (std::strstr(argv[i] + strlen(THREAD_PREFIX), THREAD_COMMAND_NEW)) {
+ // Create a new thread.
+ pthread_t new_thread;
+ const int err =
+ ::pthread_create(&new_thread, nullptr, thread_func, nullptr);
+ if (err) {
+ fprintf(stderr, "pthread_create() failed with error code %d\n", err);
+ exit(err);
}
+ threads.push_back(new_thread);
+ } else if (std::strstr(argv[i] + strlen(THREAD_PREFIX),
+ THREAD_COMMAND_PRINT_IDS)) {
+ // Turn on thread id announcing.
+ g_print_thread_ids = true;
+
+ // And announce us.
+ pthread_mutex_lock(&g_print_mutex);
+ printf("thread 0 id: ");
+ print_thread_id();
+ printf("\n");
+ pthread_mutex_unlock(&g_print_mutex);
+ } else if (std::strstr(argv[i] + strlen(THREAD_PREFIX),
+ THREAD_COMMAND_SEGFAULT)) {
+ g_threads_do_segfault = true;
+ } else {
+ // At this point we don't do anything else with threads.
+ // Later use thread index and send command to thread.
+ }
+ } else {
+ // Treat the argument as text for stdout.
+ printf("%s\n", argv[i]);
}
-
- // If we launched any threads, join them
- for (std::vector<pthread_t>::iterator it = threads.begin (); it != threads.end (); ++it)
- {
- void *thread_retval = nullptr;
- const int err = ::pthread_join (*it, &thread_retval);
- if (err != 0)
- fprintf (stderr, "pthread_join() failed with error code %d\n", err);
- }
-
- return return_value;
+ }
+
+ // If we launched any threads, join them
+ for (std::vector<pthread_t>::iterator it = threads.begin();
+ it != threads.end(); ++it) {
+ void *thread_retval = nullptr;
+ const int err = ::pthread_join(*it, &thread_retval);
+ if (err != 0)
+ fprintf(stderr, "pthread_join() failed with error code %d\n", err);
+ }
+
+ return return_value;
}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/main.cpp
index 70ae5094fde7..c7ebe0759a40 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/main.cpp
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/main.cpp
@@ -1,7 +1,6 @@
#include <cstdio>
-int main (int argc, char **argv)
-{
- printf("argc: %d\n", argc);
- return argv[0][0];
+int main(int argc, char **argv) {
+ printf("argc: %d\n", argc);
+ return argv[0][0];
}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/Makefile b/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/Makefile
new file mode 100644
index 000000000000..314f1cb2f077
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py b/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py
new file mode 100644
index 000000000000..7105bcb078bc
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py
@@ -0,0 +1,115 @@
+# This test makes sure that lldb-server supports and properly handles
+# QPassSignals GDB protocol package.
+from __future__ import print_function
+
+import gdbremote_testcase
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestGdbRemote_QPassSignals(gdbremote_testcase.GdbRemoteTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def expect_signal(self, expected_signo):
+ self.test_sequence.add_log_lines(["read packet: $vCont;c#a8",
+ {"direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]{2}).*#[0-9a-fA-F]{2}$",
+ "capture": {1: "hex_exit_code"}},
+ ],
+ True)
+
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+
+ hex_exit_code = context.get("hex_exit_code")
+ self.assertIsNotNone(hex_exit_code)
+ self.assertEqual(int(hex_exit_code, 16), expected_signo)
+
+ def expect_exit_code(self, exit_code):
+ self.test_sequence.add_log_lines(
+ ["read packet: $vCont;c#a8",
+ "send packet: $W{0:02x}#00".format(exit_code)],
+ True)
+ self.expect_gdbremote_sequence()
+
+
+ def ignore_signals(self, signals):
+ def signal_name_to_hex(signame):
+ return format(lldbutil.get_signal_number(signame), 'x')
+ signals_str = ";".join(map(signal_name_to_hex, signals))
+
+ self.test_sequence.add_log_lines(["read packet: $QPassSignals:"
+ + signals_str + " #00",
+ "send packet: $OK#00"],
+ True)
+
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+
+ @llgs_test
+ @skipUnlessPlatform(["linux", "android"])
+ def test_q_pass_signals(self):
+ self.init_llgs_test()
+ self.build()
+ self.set_inferior_startup_launch()
+ procs = self.prep_debug_monitor_and_inferior()
+ expected_signals = ["SIGSEGV",
+ "SIGALRM", "SIGFPE", "SIGBUS", "SIGINT", "SIGHUP"]
+ signals_to_ignore = ["SIGUSR1", "SIGUSR2"]
+ self.ignore_signals(signals_to_ignore)
+ for signal_name in expected_signals:
+ signo = lldbutil.get_signal_number(signal_name)
+ self.expect_signal(signo)
+ self.expect_exit_code(len(signals_to_ignore))
+
+ @llgs_test
+ @skipUnlessPlatform(["linux", "android"])
+ def test_change_signals_at_runtime(self):
+ self.init_llgs_test()
+ self.build()
+ self.set_inferior_startup_launch()
+ procs = self.prep_debug_monitor_and_inferior()
+ expected_signals = ["SIGSEGV", "SIGUSR1", "SIGUSR2",
+ "SIGALRM", "SIGHUP"]
+ signals_to_ignore = ["SIGFPE", "SIGBUS", "SIGINT"]
+
+ for signal_name in expected_signals:
+ signo = lldbutil.get_signal_number(signal_name)
+ self.expect_signal(signo)
+ if signal_name == "SIGALRM":
+ self.ignore_signals(signals_to_ignore)
+ self.expect_exit_code(len(signals_to_ignore))
+
+ @llgs_test
+ def test_default_signals_behavior(self):
+ self.init_llgs_test()
+ self.build()
+ self.set_inferior_startup_launch()
+ procs = self.prep_debug_monitor_and_inferior()
+ expected_signals = ["SIGSEGV", "SIGUSR1", "SIGUSR2",
+ "SIGALRM", "SIGFPE", "SIGBUS", "SIGINT", "SIGHUP"]
+ for signal_name in expected_signals:
+ signo = lldbutil.get_signal_number(signal_name)
+ self.expect_signal(signo)
+ self.expect_exit_code(0)
+
+
+ @llgs_test
+ @skipUnlessPlatform(["linux", "android"])
+ def test_support_q_pass_signals(self):
+ self.init_llgs_test()
+ self.build()
+
+ # Start up the stub and start/prep the inferior.
+ self.set_inferior_startup_launch()
+ procs = self.prep_debug_monitor_and_inferior()
+ self.add_qSupported_packets()
+
+ # Run the packet stream.
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+
+ # Retrieve the qSupported features and check QPassSignals+
+ supported_dict = self.parse_qSupported_response(context)
+ self.assertEqual(supported_dict["QPassSignals"], "+")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/main.cpp
new file mode 100644
index 000000000000..4991259fe46e
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/signal-filtering/main.cpp
@@ -0,0 +1,37 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <signal.h>
+#include <stdio.h>
+#include <vector>
+
+static int signal_counter = 0;
+
+static void count_signal(int signo) {
+ ++signal_counter;
+ printf("Signal %d\n", signo);
+}
+
+static void raise_signals() {
+ std::vector<int> signals(
+ {SIGSEGV, SIGUSR1, SIGUSR2, SIGALRM, SIGFPE, SIGBUS, SIGINT, SIGHUP});
+
+ for (int signal_num : signals) {
+ signal(signal_num, count_signal);
+ }
+
+ for (int signal_num : signals) {
+ raise(signal_num);
+ }
+}
+
+int main() {
+ raise_signals();
+ return signal_counter;
+}
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/host-info/Makefile b/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/Makefile
index 1370b53b5a67..8817fff55e8c 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/host-info/Makefile
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/Makefile
@@ -1,10 +1,6 @@
LEVEL = ../../../make
-VPATH = ..
-
-override CFLAGS_EXTRAS += -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS
ENABLE_THREADS := YES
CXX_SOURCES := main.cpp
-MAKE_DSYM :=NO
include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/TestGdbRemoteThreadName.py b/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/TestGdbRemoteThreadName.py
new file mode 100644
index 000000000000..5bfcd660c2ac
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/TestGdbRemoteThreadName.py
@@ -0,0 +1,41 @@
+from __future__ import print_function
+
+import gdbremote_testcase
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestGdbRemoteThreadName(gdbremote_testcase.GdbRemoteTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def run_and_check_name(self, expected_name):
+ self.test_sequence.add_log_lines(["read packet: $vCont;c#a8",
+ {"direction": "send",
+ "regex":
+ r"^\$T([0-9a-fA-F]{2})([^#]+)#[0-9a-fA-F]{2}$",
+ "capture": {
+ 1: "signal",
+ 2: "key_vals_text"}},
+ ],
+ True)
+
+ context = self.expect_gdbremote_sequence()
+ self.assertIsNotNone(context)
+
+ sigint = lldbutil.get_signal_number("SIGINT")
+ self.assertEqual(sigint, int(context.get("signal"), 16))
+ kv_dict = self.parse_key_val_dict(context.get("key_vals_text"))
+ self.assertEqual(expected_name, kv_dict.get("name"))
+
+ @llgs_test
+ def test(self):
+ """ Make sure lldb-server can retrieve inferior thread name"""
+ self.init_llgs_test()
+ self.build()
+ self.set_inferior_startup_launch()
+ procs = self.prep_debug_monitor_and_inferior()
+
+ self.run_and_check_name("hello world")
+ self.run_and_check_name("goodbye world")
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/main.cpp
new file mode 100644
index 000000000000..0403031143ba
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/thread-name/main.cpp
@@ -0,0 +1,22 @@
+#include <pthread.h>
+#include <signal.h>
+
+void set_thread_name(const char *name) {
+#if defined(__APPLE__)
+ ::pthread_setname_np(name);
+#elif defined(__FreeBSD__)
+ ::pthread_set_name_np(::pthread_self(), name);
+#elif defined(__linux__)
+ ::pthread_setname_np(::pthread_self(), name);
+#elif defined(__NetBSD__)
+ ::pthread_setname_np(::pthread_self(), "%s", name);
+#endif
+}
+
+int main() {
+ set_thread_name("hello world");
+ raise(SIGINT);
+ set_thread_name("goodbye world");
+ raise(SIGINT);
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test_event/formatter/results_formatter.py b/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
index 35a9fa8d5d56..8e341cb2ce84 100644
--- a/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
+++ b/packages/Python/lldbsuite/test_event/formatter/results_formatter.py
@@ -126,19 +126,6 @@ class ResultsFormatter(object):
self.terminate_called = False
self.file_is_stream = file_is_stream
- # Store counts of test_result events by status.
- self.result_status_counts = {
- EventBuilder.STATUS_SUCCESS: 0,
- EventBuilder.STATUS_EXPECTED_FAILURE: 0,
- EventBuilder.STATUS_EXPECTED_TIMEOUT: 0,
- EventBuilder.STATUS_SKIP: 0,
- EventBuilder.STATUS_UNEXPECTED_SUCCESS: 0,
- EventBuilder.STATUS_FAILURE: 0,
- EventBuilder.STATUS_ERROR: 0,
- EventBuilder.STATUS_TIMEOUT: 0,
- EventBuilder.STATUS_EXCEPTIONAL_EXIT: 0
- }
-
# Track the most recent test start event by worker index.
# We'll use this to assign TIMEOUT and exceptional
# exits to the most recent test started on a given
@@ -359,18 +346,12 @@ class ResultsFormatter(object):
if event_type == "terminate":
self.terminate_called = True
elif event_type in EventBuilder.RESULT_TYPES:
- # Keep track of event counts per test/job result status
- # type. The only job (i.e. inferior process) results that
- # make it here are ones that cannot be remapped to the most
- # recently started test for the given worker index.
- status = test_event["status"]
- self.result_status_counts[status] += 1
# Clear the most recently started test for the related
# worker.
worker_index = test_event.get("worker_index", None)
if worker_index is not None:
self.started_tests_by_worker.pop(worker_index, None)
-
+ status = test_event["status"]
if status in EventBuilder.TESTRUN_ERROR_STATUS_VALUES:
# A test/job status value in any of those status values
# causes a testrun failure. If such a test fails, check
@@ -393,12 +374,6 @@ class ResultsFormatter(object):
# the need to run a low-load, single-worker test run can
# have the final run's results to always be used.
if test_key in self.result_events:
- # We are replacing the result of something that was
- # already counted by the base class. Remove the double
- # counting by reducing by one the count for the test
- # result status.
- old_status = self.result_events[test_key]["status"]
- self.result_status_counts[old_status] -= 1
self.test_method_rerun_count += 1
self.result_events[test_key] = test_event
elif event_type == EventBuilder.TYPE_TEST_START:
@@ -494,7 +469,9 @@ class ResultsFormatter(object):
@return an integer returning the number of test methods matching
the given test result status.
"""
- return self.result_status_counts[status]
+ return len([
+ [key, event] for (key, event) in self.result_events.items()
+ if event.get("status", "") == status])
@classmethod
def _event_sort_key(cls, event):
diff --git a/packages/Python/lldbsuite/test_event/formatter/xunit.py b/packages/Python/lldbsuite/test_event/formatter/xunit.py
index d3ea8677f0a6..91487cd2c3a1 100644
--- a/packages/Python/lldbsuite/test_event/formatter/xunit.py
+++ b/packages/Python/lldbsuite/test_event/formatter/xunit.py
@@ -336,7 +336,7 @@ class XunitFormatter(ResultsFormatter):
test_event,
inner_content=(
'<error type={} message={}></error>'.format(
- "timeout",
+ XunitFormatter._quote_attribute("timeout"),
XunitFormatter._quote_attribute(message))
))
with self.lock: