Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lldb/Plugins] Add support of multiple ScriptedThreads in a ScriptedP…
…rocess This patch adds support of multiple Scripted Threads in a ScriptedProcess. This is done by fetching the Scripted Threads info dictionary at every ScriptedProcess::DoUpdateThreadList and iterate over each element to create a new ScriptedThread using the object instance, if it was not already available. This patch also adds the ability to pass a pointer of a script interpreter object instance to initialize a ScriptedInterface instead of having to call the script object initializer in the ScriptedInterface constructor. This is used to instantiate the ScriptedThreadInterface from the ScriptedThread constructor, to be able to perform call on that script interpreter object instance. Finally, the patch also updates the scripted process test to check for multiple threads. rdar://84507704 Differential Revision: https://reviews.llvm.org/D117071 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
- Loading branch information
1 parent
1b86344
commit d3e0f7e
Showing
16 changed files
with
176 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
C_SOURCES := main.c | ||
|
||
CXX_SOURCES := main.cpp | ||
ENABLE_THREADS := YES | ||
include Makefile.rules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <iostream> | ||
#include <mutex> | ||
#include <thread> | ||
|
||
int bar(int i) { | ||
int j = i * i; | ||
return j; // break here | ||
} | ||
|
||
int foo(int i) { return bar(i); } | ||
|
||
void call_and_wait(int &n) { | ||
std::cout << "waiting for computation!" << std::endl; | ||
while (n != 42 * 42) | ||
; | ||
std::cout << "finished computation!" << std::endl; | ||
} | ||
|
||
void compute_pow(int &n) { n = foo(n); } | ||
|
||
int main() { | ||
int n = 42; | ||
std::mutex mutex; | ||
std::unique_lock<std::mutex> lock(mutex); | ||
|
||
std::thread thread_1(call_and_wait, std::ref(n)); | ||
std::thread thread_2(compute_pow, std::ref(n)); | ||
lock.unlock(); | ||
|
||
thread_1.join(); | ||
thread_2.join(); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.