[Lldb-commits] [lldb] r285361 - Revert "[Test Suite] Pull generateSource into lldbtest"

Chris Bieneman via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 27 16:18:52 PDT 2016


Author: cbieneman
Date: Thu Oct 27 18:18:52 2016
New Revision: 285361

URL: http://llvm.org/viewvc/llvm-project?rev=285361&view=rev
Log:
Revert "[Test Suite] Pull generateSource into lldbtest"

This reverts commit r285357.

I committed this patch accidentally out of order. Will recommit when the change this depends on is landed.

Added:
    lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp
      - copied, changed from r285357, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template
    lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp
      - copied, changed from r285357, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp.template
    lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/lldb-headers.h
    lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp
      - copied, changed from r285357, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp.template
    lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp
      - copied, changed from r285357, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp.template
    lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp
      - copied, changed from r285357, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp.template
    lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp
      - copied, changed from r285357, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp.template
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp
      - copied, changed from r285357, lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template
Removed:
    lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template
    lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp.template
    lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp.template
    lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp.template
    lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp.template
    lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp.template
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template
Modified:
    lldb/trunk/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py
    lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py
    lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py?rev=285361&r1=285360&r2=285361&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py Thu Oct 27 18:18:52 2016
@@ -19,9 +19,9 @@ class SBDirCheckerCase(TestBase):
 
     def setUp(self):
         TestBase.setUp(self)
+        self.template = 'main.cpp.template'
         self.source = 'main.cpp'
         self.exe_name = 'a.out'
-        self.generateSource(self.source)
 
     @skipIfNoSBHeaders
     def test_sb_api_directory(self):
@@ -34,9 +34,40 @@ class SBDirCheckerCase(TestBase):
             self.skipTest(
                 "LLDB is 64-bit and cannot be linked to 32-bit test program.")
 
+        # Generate main.cpp, build it, and execute.
+        self.generate_main_cpp()
         self.buildDriver(self.source, self.exe_name)
         self.sanity_check_executable(self.exe_name)
 
+    def generate_main_cpp(self):
+        """Generate main.cpp from main.cpp.template."""
+        temp = os.path.join(os.getcwd(), self.template)
+        with open(temp, 'r') as f:
+            content = f.read()
+
+        public_api_dir = os.path.join(
+            os.environ["LLDB_SRC"], "include", "lldb", "API")
+
+        # Look under the include/lldb/API directory and add #include statements
+        # for all the SB API headers.
+        public_headers = os.listdir(public_api_dir)
+        # For different platforms, the include statement can vary.
+        if self.platformIsDarwin():
+            include_stmt = "'#include <%s>' % os.path.join('LLDB', header)"
+        if self.getPlatform() == "freebsd" or self.getPlatform(
+        ) == "linux" or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile':
+            include_stmt = "'#include <%s>' % os.path.join(public_api_dir, header)"
+        list = [eval(include_stmt) for header in public_headers if (
+            header.startswith("SB") and header.endswith(".h"))]
+        includes = '\n'.join(list)
+        new_content = content.replace('%include_SB_APIs%', includes)
+        src = os.path.join(os.getcwd(), self.source)
+        with open(src, 'w') as f:
+            f.write(new_content)
+
+        # The main.cpp has been generated, add a teardown hook to remove it.
+        self.addTearDownHook(lambda: os.remove(src))
+
     def sanity_check_executable(self, exe_name):
         """Sanity check executable compiled from the auto-generated program."""
         exe = os.path.join(os.getcwd(), exe_name)

Modified: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py?rev=285361&r1=285360&r2=285361&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py Thu Oct 27 18:18:52 2016
@@ -15,15 +15,6 @@ import subprocess
 
 class SBBreakpointCallbackCase(TestBase):
 
-    def setUp(self):
-        TestBase.setUp(self)
-        self.generateSource('driver.cpp')
-        self.generateSource('listener_test.cpp')
-        self.generateSource('test_breakpoint_callback.cpp')
-        self.generateSource('test_listener_event_description.cpp')
-        self.generateSource('test_listener_event_process_state.cpp')
-        self.generateSource('test_listener_resume.cpp')
-
     mydir = TestBase.compute_mydir(__file__)
 
     @skipIfRemote

Copied: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp (from r285357, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp?p2=lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template&r1=285357&r2=285361&rev=285361&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp Thu Oct 27 18:18:52 2016
@@ -7,7 +7,7 @@
 #include <string>
 #include <vector>
 
-%include_SB_APIs%
+#include "lldb-headers.h"
 
 #include "common.h"
 

Removed: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template?rev=285360&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template (removed)
@@ -1,38 +0,0 @@
-
-/// LLDB C API Test Driver
-
-#include <algorithm>
-#include <iostream>
-#include <iterator>
-#include <string>
-#include <vector>
-
-%include_SB_APIs%
-
-#include "common.h"
-
-using namespace std;
-using namespace lldb;
-
-void test(SBDebugger &dbg, std::vector<string> args);
-
-int main(int argc, char** argv) {
-  int code = 0;
-
-  SBDebugger::Initialize();
-  SBDebugger dbg = SBDebugger::Create();
-
-  try {
-    if (!dbg.IsValid())
-      throw Exception("invalid debugger");
-    vector<string> args(argv + 1, argv + argc);
-
-    test(dbg, args);
-  } catch (Exception &e) {
-    cout << "ERROR: " << e.what() << endl;
-    code = 1;
-  }
-
-  SBDebugger::Destroy(dbg);
-  return code;
-}

Copied: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp (from r285357, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp.template)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp?p2=lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp.template&r1=285357&r2=285361&rev=285361&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp.template (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp Thu Oct 27 18:18:52 2016
@@ -7,7 +7,7 @@
 #include <thread>
 #include <vector>
 
-%include_SB_APIs%
+#include "lldb-headers.h"
 #include "common.h"
 
 using namespace lldb;

Removed: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp.template
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp.template?rev=285360&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp.template (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp.template (removed)
@@ -1,74 +0,0 @@
-// LLDB test snippet that registers a listener with a process that hits
-// a breakpoint.
-
-#include <atomic>
-#include <iostream>
-#include <string>
-#include <thread>
-#include <vector>
-
-%include_SB_APIs%
-#include "common.h"
-
-using namespace lldb;
-using namespace std;
-
-void listener_func();
-void check_listener(SBDebugger &dbg);
-
-// Listener thread and related variables
-atomic<bool> g_done; 
-SBListener g_listener("test-listener");
-thread g_listener_thread;
-
-void shutdown_listener() {
-  g_done.store(true);
-  if (g_listener_thread.joinable())
-    g_listener_thread.join();
-}
-
-void test(SBDebugger &dbg, std::vector<string> args) {
-  try {
-    g_done.store(false);
-    SBTarget target = dbg.CreateTarget(args.at(0).c_str());
-    if (!target.IsValid()) throw Exception("invalid target");
-
-    SBBreakpoint breakpoint = target.BreakpointCreateByName("next");
-    if (!breakpoint.IsValid()) throw Exception("invalid breakpoint");
-
-    std::unique_ptr<char> working_dir(get_working_dir());
-
-    SBError error;
-    SBProcess process = target.Launch(g_listener,
-                                      0, 0, 0, 0, 0,
-                                      working_dir.get(),
-                                      0,
-                                      false,
-                                      error);
-    if (!error.Success())
-      throw Exception("Error launching process.");
-
-    /* FIXME: the approach below deadlocks
-    SBProcess process = target.LaunchSimple (0, 0, working_dir.get());
-
-    // get debugger listener (which is attached to process by default)
-    g_listener = dbg.GetListener();
-    */
-
-    // FIXME: because a listener is attached to the process at launch-time,
-    // registering the listener below results in two listeners being attached,
-    // which is not supported by LLDB.
-    // register listener
-    // process.GetBroadcaster().AddListener(g_listener,
-    //                                   SBProcess::eBroadcastBitStateChanged);
-
-    // start listener thread
-    g_listener_thread = thread(listener_func);
-    check_listener(dbg);
-
-  } catch (Exception &e) {
-    shutdown_listener();
-    throw e;
-  }
-  shutdown_listener();
-}

Added: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/lldb-headers.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/lldb-headers.h?rev=285361&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/lldb-headers.h (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/lldb-headers.h Thu Oct 27 18:18:52 2016
@@ -0,0 +1,11 @@
+
+#ifndef LLDB_HEADERS_H
+#define LLDB_HEADERS_H
+
+#ifdef __APPLE__
+#include <LLDB/LLDB.h>
+#else
+#include "lldb/API/LLDB.h"
+#endif
+
+#endif // LLDB_HEADERS_H

Copied: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp (from r285357, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp.template)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp?p2=lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp.template&r1=285357&r2=285361&rev=285361&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp.template (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp Thu Oct 27 18:18:52 2016
@@ -7,7 +7,7 @@
 #include <vector>
 #include <string>
 
-%include_SB_APIs%
+#include "lldb-headers.h"
 
 #include "common.h"
 

Removed: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp.template
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp.template?rev=285360&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp.template (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp.template (removed)
@@ -1,49 +0,0 @@
-
-// LLDB C++ API Test: verify that the function registered with
-// SBBreakpoint.SetCallback() is invoked when a breakpoint is hit.
-
-#include <mutex>
-#include <iostream>
-#include <vector>
-#include <string>
-
-%include_SB_APIs%
-
-#include "common.h"
-
-using namespace std;
-using namespace lldb;
-
-mutex g_mutex;
-condition_variable g_condition;
-int g_breakpoint_hit_count = 0;
-
-bool BPCallback (void *baton,
-                 SBProcess &process,
-                 SBThread &thread,
-                 SBBreakpointLocation &location) {
-  lock_guard<mutex> lock(g_mutex);
-  g_breakpoint_hit_count += 1;
-  g_condition.notify_all();
-  return true;
-}
-
-void test(SBDebugger &dbg, vector<string> args) {
-  dbg.SetAsync(false);  
-  SBTarget target = dbg.CreateTarget(args.at(0).c_str());
-  if (!target.IsValid()) throw Exception("invalid target");
-
-  SBBreakpoint breakpoint = target.BreakpointCreateByName("next");
-  if (!breakpoint.IsValid()) throw Exception("invalid breakpoint");
-  breakpoint.SetCallback(BPCallback, 0);
-
-  std::unique_ptr<char> working_dir(get_working_dir());
-  SBProcess process = target.LaunchSimple (0, 0, working_dir.get());
-
-  {
-    unique_lock<mutex> lock(g_mutex);
-    g_condition.wait_for(lock, chrono::seconds(5));
-    if (g_breakpoint_hit_count != 1)
-      throw Exception("Breakpoint hit count expected to be 1");
-  }
-}

Copied: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp (from r285357, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp.template)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp?p2=lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp.template&r1=285357&r2=285361&rev=285361&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp.template (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp Thu Oct 27 18:18:52 2016
@@ -8,7 +8,7 @@
 #include <string>
 #include <thread>
 
-%include_SB_APIs%
+#include "lldb-headers.h"
 
 #include "common.h"
 

Removed: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp.template
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp.template?rev=285360&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp.template (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp.template (removed)
@@ -1,97 +0,0 @@
-
-// LLDB C++ API Test: verify the event description that is received by an
-// SBListener object registered with a process with a breakpoint.
-
-#include <atomic>
-#include <array>
-#include <iostream>
-#include <string>
-#include <thread>
-
-%include_SB_APIs%
-
-#include "common.h"
-
-using namespace lldb;
-using namespace std;
-
-// listener thread control
-extern atomic<bool> g_done;
-extern SBListener g_listener;
-
-multithreaded_queue<string> g_event_descriptions;
-string g_error_desc;
-
-void listener_func() {
-  while (!g_done) {
-    SBEvent event;
-    bool got_event = g_listener.WaitForEvent(1, event);
-
-    if (got_event) {
-      if (!event.IsValid())
-        throw Exception("event is not valid in listener thread");
-
-      SBStream description;
-      event.GetDescription(description);
-      string str(description.GetData());
-      g_event_descriptions.push(str);
-    }
-  }
-}
-
-bool check_state(string &state, string &desc, bool got_description)
-{
-    g_error_desc.clear();
-
-    if(!got_description)
-    {
-        g_error_desc.append("Did not get expected event description");
-        return false;
-    }
-
-    if (desc.find("state-changed") == desc.npos)
-        g_error_desc.append("Event description incorrect: missing 'state-changed' ");
-
-    if (desc.find("pid = ") == desc.npos)
-        g_error_desc.append("Event description incorrect: missing process pid ");
-
-    string state_search_str = "state = " + state;
-    if (desc.find(state_search_str) == desc.npos)
-    {
-        string errString = ("Event description incorrect: expected state "
-                      + state
-                      + " but desc was "
-                      + desc);
-        g_error_desc.append(errString);
-    }
-
-    if (g_error_desc.length() > 0)
-        return false;
-
-    cout << "check_state: " << state << "  OK\n";
-    return true;
-}
-
-void check_listener(SBDebugger &dbg)
-{
-    bool got_description;
-    string state;
-
-    // check for "launching" state, this may or may not be present
-    string desc = g_event_descriptions.pop(5, got_description);
-    state = "launching";
-    if (check_state(state, desc, got_description))
-    {
-        // found a 'launching' state, pop next one from queue
-        desc = g_event_descriptions.pop(5, got_description);
-    }
-
-    state = "running";
-    if( !check_state(state, desc, got_description) )
-        throw Exception(g_error_desc);
-
-    desc = g_event_descriptions.pop(5, got_description);
-    state = "stopped";
-    if( !check_state(state, desc, got_description) )
-        throw Exception(g_error_desc);
-}

Copied: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp (from r285357, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp.template)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp?p2=lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp.template&r1=285357&r2=285361&rev=285361&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp.template (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp Thu Oct 27 18:18:52 2016
@@ -8,7 +8,7 @@
 #include <string>
 #include <thread>
 
-%include_SB_APIs%
+#include "lldb-headers.h"
 
 #include "common.h"
 

Removed: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp.template
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp.template?rev=285360&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp.template (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp.template (removed)
@@ -1,63 +0,0 @@
-
-// LLDB C++ API Test: verify the event description as obtained by calling
-// SBEvent::GetCStringFromEvent that is received by an
-// SBListener object registered with a process with a breakpoint.
-
-#include <atomic>
-#include <iostream>
-#include <string>
-#include <thread>
-
-%include_SB_APIs%
-
-#include "common.h"
-
-using namespace lldb;
-using namespace std;
-
-// listener thread control
-extern atomic<bool> g_done;
-
-multithreaded_queue<string> g_frame_functions;
-
-extern SBListener g_listener;
-
-void listener_func() {
-  while (!g_done) {
-    SBEvent event;
-    bool got_event = g_listener.WaitForEvent(1, event);
-    if (got_event) {
-      if (!event.IsValid())
-        throw Exception("event is not valid in listener thread");
-        // send process description
-        SBProcess process = SBProcess::GetProcessFromEvent(event);
-        if (!process.IsValid())
-            throw Exception("process is not valid");
-        if (SBProcess::GetStateFromEvent(event) != lldb::eStateStopped || SBProcess::GetRestartedFromEvent(event))
-            continue; // Only interested in "stopped" events.
-
-        SBStream description;
-
-        for (int i = 0; i < process.GetNumThreads(); ++i) {
-            // send each thread description
-            SBThread thread = process.GetThreadAtIndex(i);
-            // send each frame function name
-            uint32_t num_frames = thread.GetNumFrames();
-            for(int j = 0; j < num_frames; ++j) {
-                const char* function_name = thread.GetFrameAtIndex(j).GetSymbol().GetName();
-                if (function_name)
-                    g_frame_functions.push(string(function_name));
-            }
-        }
-    }
-  }
-}
-
-void check_listener(SBDebugger &dbg) {
-  // check thread description
-  bool got_description = false;
-  string func_name = g_frame_functions.pop(5, got_description);
-  
-  if(got_description == false)
-    throw Exception("Expected at least one frame function");
-}

Copied: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp (from r285357, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp.template)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp?p2=lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp.template&r1=285357&r2=285361&rev=285361&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp.template (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp Thu Oct 27 18:18:52 2016
@@ -8,7 +8,7 @@
 #include <string>
 #include <thread>
 
-%include_SB_APIs%
+#include "lldb-headers.h"
 
 #include "common.h"
 

Removed: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp.template
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp.template?rev=285360&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp.template (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp.template (removed)
@@ -1,53 +0,0 @@
-
-// LLDB C++ API Test: verify the event description as obtained by calling
-// SBEvent::GetCStringFromEvent that is received by an
-// SBListener object registered with a process with a breakpoint.
-
-#include <atomic>
-#include <iostream>
-#include <string>
-#include <thread>
-
-%include_SB_APIs%
-
-#include "common.h"
-
-using namespace lldb;
-using namespace std;
-
-// listener thread control
-extern atomic<bool> g_done;
-
-// used by listener thread to communicate a successful process continue command
-// back to the checking thread.
-
-multithreaded_queue<bool> g_process_started;
-
-extern SBListener g_listener;
-
-void listener_func() {
-  while (!g_done) {
-    SBEvent event;
-    bool got_event = g_listener.WaitForEvent(1, event);
-    if (got_event) {
-      if (!event.IsValid())
-        throw Exception("event is not valid in listener thread");
-
-      SBProcess process = SBProcess::GetProcessFromEvent(event);
-      if (process.GetState() == eStateStopped) {
-        SBError error = process.Continue();
-        if (!error.Success())
-          throw Exception(string("Cannot continue process from listener thread: ")
-                          + error.GetCString());
-        g_process_started.push(true);
-      }
-    }
-  }
-}
-
-void check_listener(SBDebugger &dbg) {
-  bool got_message = false;
-  while (!got_message)
-    g_process_started.pop(5, got_message);
-  g_done = true;
-}

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py?rev=285361&r1=285360&r2=285361&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py Thu Oct 27 18:18:52 2016
@@ -18,10 +18,6 @@ class PluginCommandTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    def setUp(self):
-        TestBase.setUp(self)
-        self.generateSource('plugin.cpp')
-
     @skipIfNoSBHeaders
     # Requires a compatible arch and platform to link against the host's built
     # lldb lib.

Copied: lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp (from r285357, lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp?p2=lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template&r1=285357&r2=285361&rev=285361&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp Thu Oct 27 18:18:52 2016
@@ -13,7 +13,15 @@ Compile this into a dylib foo.dylib and
 by typing plugin load foo.dylib at the LLDB command line
 */
 
-%include_SB_APIs%
+#if defined (__APPLE__)
+#include <LLDB/SBCommandInterpreter.h>
+#include <LLDB/SBCommandReturnObject.h>
+#include <LLDB/SBDebugger.h>
+#else
+#include <lldb/API/SBCommandInterpreter.h>
+#include <lldb/API/SBCommandReturnObject.h>
+#include <lldb/API/SBDebugger.h>
+#endif
 
 namespace lldb {
     bool

Removed: lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template?rev=285360&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template (removed)
@@ -1,54 +0,0 @@
-//===-- plugin.cpp -------------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-/*
-An example plugin for LLDB that provides a new foo command with a child subcommand
-Compile this into a dylib foo.dylib and load by placing in appropriate locations on disk or
-by typing plugin load foo.dylib at the LLDB command line
-*/
-
-%include_SB_APIs%
-
-namespace lldb {
-    bool
-    PluginInitialize (lldb::SBDebugger debugger);
-}
-
-class ChildCommand : public lldb::SBCommandPluginInterface
-{
-public:
-    virtual bool
-    DoExecute (lldb::SBDebugger debugger,
-               char** command,
-               lldb::SBCommandReturnObject &result)
-    {
-        if (command)
-        {
-            const char* arg = *command;
-            while (arg)
-            {
-                result.Printf("%s ",arg);
-                arg = *(++command);
-            }
-            result.Printf("\n");
-            return true;
-        }
-        return false;
-    }
-    
-};
-
-bool
-lldb::PluginInitialize (lldb::SBDebugger debugger)
-{
-    lldb::SBCommandInterpreter interpreter = debugger.GetCommandInterpreter();
-    lldb::SBCommand foo = interpreter.AddMultiwordCommand("plugin_loaded_command",NULL);
-    foo.AddCommand("child",new ChildCommand(),"a child of plugin_loaded_command");
-    return true;
-}

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=285361&r1=285360&r2=285361&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Thu Oct 27 18:18:52 2016
@@ -1824,33 +1824,6 @@ class TestBase(Base):
                 folder = os.path.dirname(folder)
                 continue
 
-    def generateSource(self, source):
-        template = source + '.template'
-        temp = os.path.join(os.getcwd(), template)
-        with open(temp, 'r') as f:
-            content = f.read()
-            
-        public_api_dir = os.path.join(
-            os.environ["LLDB_SRC"], "include", "lldb", "API")
-
-        # Look under the include/lldb/API directory and add #include statements
-        # for all the SB API headers.
-        public_headers = os.listdir(public_api_dir)
-        # For different platforms, the include statement can vary.
-        if self.hasDarwinFramework():
-            include_stmt = "'#include <%s>' % os.path.join('LLDB', header)"
-        else:
-            include_stmt = "'#include <%s>' % os.path.join(public_api_dir, header)"
-        list = [eval(include_stmt) for header in public_headers if (
-            header.startswith("SB") and header.endswith(".h"))]
-        includes = '\n'.join(list)
-        new_content = content.replace('%include_SB_APIs%', includes)
-        src = os.path.join(os.getcwd(), source)
-        with open(src, 'w') as f:
-            f.write(new_content)
-
-        self.addTearDownHook(lambda: os.remove(src))
-
     def setUp(self):
         #import traceback
         # traceback.print_stack()




More information about the lldb-commits mailing list