Fixup gtest layout, add Linux ThreadStateCoordinator.cpp.

This change does the following:
* Remove test/c++/...
* Add gtest.
* Add gtest/unittest directory for unittesting individual classes.
* Add an initial Plugins/Process?linux/ThreadStateCoordinatorTest.cpp.
  - currently failing a test (intentional).
  - added a bare-bones ThreadStateCoordinator.cpp to Plugins/Process/Linux,
    more soon. Just enough to prove out running gtest on Ubuntu and MacOSX.
* Added recursive make machinery so that doing a 'make' in gtest/ is
  sufficient to kick off the existing test several directories down.
  - Caveat - I currently short circuit from gtest/unittest/Makefile directly to
    the one and only gtest/unittest/Plugins/Process/Linux directory.  We'll need
    to add the intervening layers.  I haven't done this yet since to fix the
    Xcode test failure correspondence, I may need to add a python layer which
    might just handle the directory crawling.
* Added an Xcode project to the lldb workspace for gtest.
  - Runs the recursive make system in gtest/Makefile.
  - Default target is 'test'.  test and clean are supported.
  - Currently does not support test failure file/line correspondence.
    Requires a bit of text transformation to hook that up.

llvm-svn: 218460
This commit is contained in:
Todd Fiala 2014-09-25 19:25:07 +00:00
parent 1fa1ce6112
commit b3185e710e
14 changed files with 535 additions and 80 deletions

5
lldb/gtest/Makefile Normal file
View File

@ -0,0 +1,5 @@
LEVEL := ./make
SUBDIRS := unittest
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,232 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXFileReference section */
236ED33319D49076008CA7D7 /* ThreadStateCoordinatorTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadStateCoordinatorTest.cpp; sourceTree = "<group>"; };
236ED33419D49081008CA7D7 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
236ED33619D490B0008CA7D7 /* Makefile.rules */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Makefile.rules; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXGroup section */
236ED32F19D4901D008CA7D7 /* unittest */ = {
isa = PBXGroup;
children = (
236ED33019D4903E008CA7D7 /* Plugins */,
);
path = unittest;
sourceTree = "<group>";
};
236ED33019D4903E008CA7D7 /* Plugins */ = {
isa = PBXGroup;
children = (
236ED33119D4904B008CA7D7 /* Process */,
);
path = Plugins;
sourceTree = "<group>";
};
236ED33119D4904B008CA7D7 /* Process */ = {
isa = PBXGroup;
children = (
236ED33219D4905B008CA7D7 /* Linux */,
);
path = Process;
sourceTree = "<group>";
};
236ED33219D4905B008CA7D7 /* Linux */ = {
isa = PBXGroup;
children = (
236ED33419D49081008CA7D7 /* Makefile */,
236ED33319D49076008CA7D7 /* ThreadStateCoordinatorTest.cpp */,
);
path = Linux;
sourceTree = "<group>";
};
236ED33519D49098008CA7D7 /* make */ = {
isa = PBXGroup;
children = (
236ED33619D490B0008CA7D7 /* Makefile.rules */,
);
path = make;
sourceTree = "<group>";
};
23CDD8EE19D4790700461DDC = {
isa = PBXGroup;
children = (
236ED33519D49098008CA7D7 /* make */,
236ED32F19D4901D008CA7D7 /* unittest */,
);
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXLegacyTarget section */
23CDD8F319D4790700461DDC /* gtest */ = {
isa = PBXLegacyTarget;
buildArgumentsString = "$(ACTION)";
buildConfigurationList = 23CDD8F619D4790700461DDC /* Build configuration list for PBXLegacyTarget "gtest" */;
buildPhases = (
);
buildToolPath = /usr/bin/make;
buildWorkingDirectory = .;
dependencies = (
);
name = gtest;
passBuildSettingsInEnvironment = 1;
productName = gtest;
};
/* End PBXLegacyTarget section */
/* Begin PBXProject section */
23CDD8EF19D4790700461DDC /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0600;
ORGANIZATIONNAME = LLVM;
TargetAttributes = {
23CDD8F319D4790700461DDC = {
CreatedOnToolsVersion = 6.1;
};
};
};
buildConfigurationList = 23CDD8F219D4790700461DDC /* Build configuration list for PBXProject "gtest" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 23CDD8EE19D4790700461DDC;
projectDirPath = "";
projectRoot = "";
targets = (
23CDD8F319D4790700461DDC /* gtest */,
);
};
/* End PBXProject section */
/* Begin XCBuildConfiguration section */
23CDD8F419D4790700461DDC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
23CDD8F519D4790700461DDC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
};
name = Release;
};
23CDD8F719D4790700461DDC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEBUGGING_SYMBOLS = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
23CDD8F819D4790700461DDC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
23CDD8F219D4790700461DDC /* Build configuration list for PBXProject "gtest" */ = {
isa = XCConfigurationList;
buildConfigurations = (
23CDD8F419D4790700461DDC /* Debug */,
23CDD8F519D4790700461DDC /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
23CDD8F619D4790700461DDC /* Build configuration list for PBXLegacyTarget "gtest" */ = {
isa = XCConfigurationList;
buildConfigurations = (
23CDD8F719D4790700461DDC /* Debug */,
23CDD8F819D4790700461DDC /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 23CDD8EF19D4790700461DDC /* Project object */;
}

View File

@ -0,0 +1,91 @@
# Retrieve this Makefile's location.
THIS_FILE_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/
# Set default target to be test
.DEFAULT_GOAL := test
# Set up GTEST for canonical Linux and MacOSX source trees.
ifneq ($(wildcard $(THIS_FILE_DIR)../../llvm/utils/unittest/googletest),)
# Assume lldb/llvm (MacOSX Xcode) directory form.
LLVM_BASE_DIR := $(realpath $(THIS_FILE_DIR)../../llvm)
else
# Assume llvm/tools/lldb (Non-MacOSX) directory form.
LLVM_BASE_DIR := $(realpath $(THIS_FILE_DIR)../../../..)
endif
ifeq ($(GTEST_DIR),)
GTEST_DIR := $(LLVM_BASE_DIR)/utils/unittest/googletest
endif
GTEST_INCLUDE_DIR := $(GTEST_DIR)/include
ifeq ($(LLVM_BUILD_DIR),)
ifneq ($(wildcard $(THIS_FILE_DIR)../../llvm-build/Release+Asserts/x86_64/Release+Asserts),)
LLVM_BUILD_DIR := $(realpath $(THIS_FILE_DIR)../../llvm-build/Release+Asserts/x86_64/Release+Asserts)
else ifneq ($(wildcard $(THIS_FILE_DIR)../../../../../build-debug/lib),)
LLVM_BUILD_DIR := $(realpath $(THIS_FILE_DIR)../../../../../build-debug)
endif
endif
ifeq ($(LLVM_BUILD_DIR),)
$(error Could not find LLVM build output dir, please set it with LLVM_BUILD_DIR)
endif
GTEST_STATIC_LIB_DIR := $(LLVM_BUILD_DIR)/lib
ifeq ($(LLVM_BUILD_INCLUDE_DIR),)
ifneq ($(wildcard $(LLVM_BUILD_DIR)/../include),)
LLVM_BUILD_INCLUDE_DIR := $(realpath $(LLVM_BUILD_DIR)/../include)
else ifneq ($(wildcard $(LLVM_BUILD_DIR)/include),)
LLVM_BUILD_INCLUDE_DIR := $(realpath $(LLVM_BUILD_DIR)/include)
endif
endif
ifeq ($(LLVM_BUILD_INCLUDE_DIR),)
$(error Could not find LLVM build directory include dir, please set it with LLVM_BUILD_INCLUDE_DIR)
endif
# $(info LLVM_BASE_DIR = $(LLVM_BASE_DIR))
# $(info LLVM_BUILD_DIR = $(LLVM_BUILD_DIR))
# $(info GTEST_DIR = $(GTEST_DIR))
# $(info GTEST_INCLUDE_DIR = $(GTEST_INCLUDE_DIR))
# $(info GTEST_STATIC_LIB_DIR = $(GTEST_STATIC_LIB_DIR))
# Note lldb/include is already added for us by test/make/Makefile.rules
LLDB_HEADER_DIRS += \
-I $(realpath $(THIS_FILE_DIR)../../source/)
# -I $(realpath $(THIS_FILE_DIR)../../include)
CFLAGS_EXTRAS += -I $(GTEST_INCLUDE_DIR) -I $(LLVM_BASE_DIR)/include -I $(LLVM_BUILD_INCLUDE_DIR) $(LLDB_HEADER_DIRS)
LD_EXTRAS += $(GTEST_STATIC_LIB_DIR)/libgtest.a $(GTEST_STATIC_LIB_DIR)/libgtest_main.a $(GTEST_STATIC_LIB_DIR)/libLLVMSupport.a
.PHONY: clean test
# Handle subdirs
ifneq ($(SUBDIRS),)
.PHONY: subdirs $(SUBDIRS)
subdirs: $(SUBDIRS)
test:: subdirs
clean:: subdirs
$(SUBDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)
endif
# Skip pulling in build rules when we don't have an CXX_SOURCES defined.
# If this is the case, then we're just recursing directories.
# Consider doing directory handling/makefile running via a python script
# like test/dotest.py.
ifneq ($(CXX_SOURCES),)
include $(realpath $(THIS_FILE_DIR)../../test/make/Makefile.rules)
test:: $(EXE)
$(realpath $(EXE))
endif

View File

@ -0,0 +1,7 @@
LEVEL := ../make
SUBDIRS := Plugins/Process/Linux
$(info in unittest Makefile)
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,17 @@
THIS_FILE_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/
LEVEL := $(realpath $(THIS_FILE_DIR)../../../../make)
CFLAGS_EXTRAS := -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
ENABLE_THREADS := YES
CXX_SOURCES := $(wildcard *.cpp) \
$(realpath $(LEVEL)/../../source/Plugins/Process/Linux/ThreadStateCoordinator.cpp)
MAKE_DSYM := NO
OS := $(shell uname -s)
# $(info OS $(OS))
ifeq ($(OS),Linux)
LD_EXTRAS := -lncurses -ldl
endif
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,49 @@
#include <limits.h>
#include "gtest/gtest.h"
#include "Plugins/Process/Linux/ThreadStateCoordinator.h"
using namespace lldb_private;
namespace
{
const ThreadStateCoordinator::ThreadIDSet EMPTY_THREAD_ID_SET;
void
NOPLogger (const char *format, va_list args)
{
// Do nothing.
}
}
TEST(ThreadStateCoordinatorTest, StopCoordinatorWorksNoPriorEvents)
{
ThreadStateCoordinator coordinator(NOPLogger);
coordinator.StopCoordinator ();
ASSERT_EQ(coordinator.ProcessNextEvent (), false);
}
TEST(ThreadStateCoordinatorTest, CallAfterThreadsStopFiresWhenNoPendingStops)
{
ThreadStateCoordinator coordinator(NOPLogger);
const lldb::tid_t TRIGGERING_TID = 4105;
bool call_after_fired = false;
// Notify we have a trigger that needs to be fired when all threads in the wait tid set have stopped.
coordinator.CallAfterThreadsStop (TRIGGERING_TID,
EMPTY_THREAD_ID_SET,
[](lldb::tid_t tid) {},
[&](lldb::tid_t tid) { call_after_fired = true; });
// Notification trigger shouldn't go off yet.
ASSERT_EQ (call_after_fired, false);
// Process next event. This will pick up the call after threads stop event.
ASSERT_EQ(coordinator.ProcessNextEvent (), true);
// Now the trigger should have fired.
ASSERT_EQ(call_after_fired, true);
}

View File

@ -69,6 +69,7 @@
233B007F1960CB280090E598 /* ProcessLaunchInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 233B007E1960CB280090E598 /* ProcessLaunchInfo.cpp */; };
236124A41986B4E2004EFC37 /* IOObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 236124A21986B4E2004EFC37 /* IOObject.cpp */; };
236124A51986B4E2004EFC37 /* Socket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 236124A31986B4E2004EFC37 /* Socket.cpp */; };
23CDD8FB19D47B3600461DDC /* ThreadStateCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23CDD8E819D3E13200461DDC /* ThreadStateCoordinator.cpp */; };
23DDF226196C3EE600BB8417 /* CommandOptionValidators.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23DDF224196C3EE600BB8417 /* CommandOptionValidators.cpp */; };
23EDE33319269E7C00F6A132 /* NativeRegisterContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EDE3301926839700F6A132 /* NativeRegisterContext.cpp */; };
23EFE389193D1ABC00E54E54 /* SBTypeEnumMember.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EFE388193D1ABC00E54E54 /* SBTypeEnumMember.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -980,6 +981,8 @@
23AB0530199FF639003B8084 /* ProcessFreeBSD.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProcessFreeBSD.h; sourceTree = "<group>"; };
23AB0531199FF639003B8084 /* ProcessMonitor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ProcessMonitor.cpp; sourceTree = "<group>"; };
23AB0532199FF639003B8084 /* ProcessMonitor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProcessMonitor.h; sourceTree = "<group>"; };
23B6FF4119D38D48004CC8C3 /* ThreadStateCoordinator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ThreadStateCoordinator.h; sourceTree = "<group>"; };
23CDD8E819D3E13200461DDC /* ThreadStateCoordinator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadStateCoordinator.cpp; sourceTree = "<group>"; };
23DDF224196C3EE600BB8417 /* CommandOptionValidators.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandOptionValidators.cpp; path = source/Interpreter/CommandOptionValidators.cpp; sourceTree = "<group>"; };
23EDE3301926839700F6A132 /* NativeRegisterContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = NativeRegisterContext.cpp; path = source/Target/NativeRegisterContext.cpp; sourceTree = "<group>"; };
23EDE3311926843600F6A132 /* NativeRegisterContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NativeRegisterContext.h; path = include/lldb/Target/NativeRegisterContext.h; sourceTree = "<group>"; };
@ -2370,6 +2373,8 @@
233B009319610B1F0090E598 /* ProcessMonitor.h */,
233B00A2196113730090E598 /* ProcFileReader.h */,
233B00A1196113730090E598 /* ProcFileReader.cpp */,
23B6FF4119D38D48004CC8C3 /* ThreadStateCoordinator.h */,
23CDD8E819D3E13200461DDC /* ThreadStateCoordinator.cpp */,
);
path = Linux;
sourceTree = "<group>";
@ -5255,6 +5260,7 @@
AF26703B1852D01E00B6CC36 /* QueueList.cpp in Sources */,
267C012B136880DF006E963E /* OptionGroupValueObjectDisplay.cpp in Sources */,
26BCFC521368AE38006DC050 /* OptionGroupFormat.cpp in Sources */,
23CDD8FB19D47B3600461DDC /* ThreadStateCoordinator.cpp in Sources */,
AF81DEFA1828A23F0042CF19 /* SystemRuntime.cpp in Sources */,
267C01371368C49C006E963E /* OptionGroupOutputFile.cpp in Sources */,
260E07C6136FA69E00CF21D3 /* OptionGroupUUID.cpp in Sources */,

View File

@ -10,4 +10,7 @@
<FileRef
location = "group:tools/lldb-perf/lldbperf.xcodeproj">
</FileRef>
<FileRef
location = "group:gtest/gtest.xcodeproj">
</FileRef>
</Workspace>

View File

@ -5,12 +5,13 @@ include_directories(../POSIX)
include_directories(../Utility)
add_lldb_library(lldbPluginProcessLinux
LinuxThread.cpp
NativeProcessLinux.cpp
NativeRegisterContextLinux_x86_64.cpp
NativeThreadLinux.cpp
ProcessLinux.cpp
ProcessMonitor.cpp
ProcFileReader.cpp
LinuxThread.cpp
ThreadStateCoordinator.cpp
)

View File

@ -0,0 +1,38 @@
//===-- ThreadStateCoordinator.cpp ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "ThreadStateCoordinator.h"
using namespace lldb_private;
ThreadStateCoordinator::ThreadStateCoordinator (const LogFunc &log_func) :
m_done_b (false),
m_log_func (log_func)
{
}
void
ThreadStateCoordinator::CallAfterThreadsStop (const lldb::tid_t triggering_tid,
const ThreadIDSet &wait_for_stop_tids,
const ThreadIDFunc &request_thread_stop_func,
const ThreadIDFunc &call_after_func)
{
}
void
ThreadStateCoordinator::StopCoordinator ()
{
m_done_b = true;
}
bool
ThreadStateCoordinator::ProcessNextEvent ()
{
return !m_done_b;
}

View File

@ -0,0 +1,85 @@
//===-- ThreadStateCoordinator.h --------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef lldb_ThreadStateCoordinator_h
#define lldb_ThreadStateCoordinator_h
#include <functional>
#include <unordered_set>
#include "lldb/lldb-types.h"
namespace lldb_private
{
class ThreadStateCoordinator
{
public:
// Typedefs.
typedef std::unordered_set<lldb::tid_t> ThreadIDSet;
// Callback definitions.
typedef std::function<void (lldb::tid_t tid)> ThreadIDFunc;
typedef std::function<void (const char *format, va_list args)> LogFunc;
// constructors
ThreadStateCoordinator (const LogFunc &log_func);
// The main purpose of the class: triggering an action after
// a given set of threads stop.
void
CallAfterThreadsStop (const lldb::tid_t triggering_tid,
const ThreadIDSet &wait_for_stop_tids,
const ThreadIDFunc &request_thread_stop_func,
const ThreadIDFunc &call_after_func);
// Notifications called when various state changes occur.
void
NotifyThreadStop (lldb::tid_t tid);
void
NotifyThreadResume (lldb::tid_t tid);
void
NotifyThreadCreate (lldb::tid_t tid);
void
NotifyThreadDeath (lldb::tid_t tid);
// Indicate when the coordinator should shut down.
void
StopCoordinator ();
// Process the next event, returning false when the coordinator is all done.
// This call is synchronous and blocks when there are no events pending.
// Expected usage is to run this in a separate thread until the function
// returns false.
bool
ProcessNextEvent ();
private:
enum EventType
{
eInvalid,
eEventTypeCallAfterThreadsStop,
eEventTypeThreadStopped,
eEventTypeThreadResumed,
eEventTypeThreadCreated,
eEventTypeThreadDied,
};
bool m_done_b;
LogFunc m_log_func;
};
}
#endif

View File

@ -1,58 +0,0 @@
# Retrieve this Makefile's location.
THIS_FILE_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/
# Set default target to be test
.DEFAULT_GOAL := test
# Set up GTEST for canonical Linux and MacOSX source trees.
ifeq ($(wildcard ../../../../llvm/utils/unittest/googletest),)
# Assume llvm/tools/lldb (Non-MacOSX) directory form.
LLVM_BASE_DIR := $(realpath ../../../../../..)
else
# Assume lldb/llvm (MacOSX Xcode) directory form.
LLVM_BASE_DIR := $(realpath ../../../../llvm)
endif
ifeq ($(GTEST_DIR),)
GTEST_DIR := $(LLVM_BASE_DIR)/utils/unittest/googletest
endif
GTEST_INCLUDE_DIR := $(GTEST_DIR)/include
ifeq ($(LLVM_BUILD_DIR),)
ifneq ($(wildcard $(THIS_FILE_DIR)../../../llvm-build/Release+Asserts/x86_64/Release+Asserts),)
LLVM_BUILD_DIR := $(realpath $(THIS_FILE_DIR)../../../llvm-build/Release+Asserts/x86_64/Release+Asserts)
else ifneq ($(wildcard $(THIS_FILE_DIR)../../../../../../build-debug/lib),)
LLVM_BUILD_DIR := $(realpath $(THIS_FILE_DIR)../../../../../../build-debug)
endif
endif
ifeq ($(LLVM_BUILD_DIR),)
$(error Could not find LLVM build output dir, please set it with LLVM_BUILD_DIR)
endif
GTEST_STATIC_LIB_DIR := $(LLVM_BUILD_DIR)/lib
ifeq ($(LLVM_BUILD_INCLUDE_DIR),)
ifneq ($(wildcard $(LLVM_BUILD_DIR)/../include),)
LLVM_BUILD_INCLUDE_DIR := $(realpath $(LLVM_BUILD_DIR)/../include)
else ifneq ($(wildcard $(LLVM_BUILD_DIR)/include),)
LLVM_BUILD_INCLUDE_DIR := $(realpath $(LLVM_BUILD_DIR)/include)
endif
endif
ifeq ($(LLVM_BUILD_INCLUDE_DIR),)
$(error Could not find LLVM build directory include dir, please set it with LLVM_BUILD_INCLUDE_DIR)
endif
$(info LLVM_BASE_DIR = $(LLVM_BASE_DIR))
$(info LLVM_BUILD_DIR = $(LLVM_BUILD_DIR))
$(info GTEST_DIR = $(GTEST_DIR))
$(info GTEST_INCLUDE_DIR = $(GTEST_INCLUDE_DIR))
$(info GTEST_STATIC_LIB_DIR = $(GTEST_STATIC_LIB_DIR))
CFLAGS_EXTRAS += -I $(GTEST_INCLUDE_DIR) -I $(LLVM_BASE_DIR)/include -I $(LLVM_BUILD_INCLUDE_DIR)
LD_EXTRAS += $(GTEST_STATIC_LIB_DIR)/libgtest.a $(GTEST_STATIC_LIB_DIR)/libgtest_main.a $(GTEST_STATIC_LIB_DIR)/libLLVMSupport.a
include $(THIS_FILE_DIR)../../make/Makefile.rules
test:: $(EXE)
$(realpath $(EXE))

View File

@ -1,14 +0,0 @@
LEVEL = ../../make
CFLAGS_EXTRAS := -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
ENABLE_THREADS := YES
CXX_SOURCES := $(wildcard *.cpp)
MAKE_DSYM :=NO
OS := $(shell uname -s)
$(info OS $(OS))
ifeq ($(OS),Linux)
LD_EXTRAS += -lncurses -ldl
endif
include $(LEVEL)/Makefile.rules

View File

@ -1,7 +0,0 @@
#include <limits.h>
#include "gtest/gtest.h"
TEST(ThreadStateCoordinatorTest, ExpectEqualsWorks)
{
EXPECT_EQ(1, 1);
}