summaryrefslogtreecommitdiff
path: root/runtime/thread.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/thread.cc')
-rw-r--r--runtime/thread.cc49
1 files changed, 25 insertions, 24 deletions
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 94d10590c7..e8e93555ac 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -1138,8 +1138,6 @@ void Thread::Shutdown() {
Thread::Thread(bool daemon) : tls32_(daemon), wait_monitor_(nullptr), interrupted_(false) {
wait_mutex_ = new Mutex("a thread wait mutex");
wait_cond_ = new ConditionVariable("a thread wait condition variable", *wait_mutex_);
- tlsPtr_.debug_invoke_req = new DebugInvokeReq;
- tlsPtr_.single_step_control = nullptr;
tlsPtr_.instrumentation_stack = new std::deque<instrumentation::InstrumentationStackFrame>;
tlsPtr_.name = new std::string(kThreadNameDuringStartup);
tlsPtr_.nested_signal_state = static_cast<jmp_buf*>(malloc(sizeof(jmp_buf)));
@@ -1291,7 +1289,6 @@ Thread::~Thread() {
CleanupCpu();
}
- delete tlsPtr_.debug_invoke_req;
if (tlsPtr_.single_step_control != nullptr) {
delete tlsPtr_.single_step_control;
}
@@ -1705,29 +1702,25 @@ jobjectArray Thread::InternalStackTraceToStackTraceElementArray(
return result;
}
-void Thread::ThrowNewExceptionF(const ThrowLocation& throw_location,
- const char* exception_class_descriptor, const char* fmt, ...) {
+void Thread::ThrowNewExceptionF(const char* exception_class_descriptor, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
- ThrowNewExceptionV(throw_location, exception_class_descriptor,
- fmt, args);
+ ThrowNewExceptionV(exception_class_descriptor, fmt, args);
va_end(args);
}
-void Thread::ThrowNewExceptionV(const ThrowLocation& throw_location,
- const char* exception_class_descriptor,
+void Thread::ThrowNewExceptionV(const char* exception_class_descriptor,
const char* fmt, va_list ap) {
std::string msg;
StringAppendV(&msg, fmt, ap);
- ThrowNewException(throw_location, exception_class_descriptor, msg.c_str());
+ ThrowNewException(exception_class_descriptor, msg.c_str());
}
-void Thread::ThrowNewException(const ThrowLocation& throw_location,
- const char* exception_class_descriptor,
+void Thread::ThrowNewException(const char* exception_class_descriptor,
const char* msg) {
// Callers should either clear or call ThrowNewWrappedException.
AssertNoPendingExceptionForNewException(msg);
- ThrowNewWrappedException(throw_location, exception_class_descriptor, msg);
+ ThrowNewWrappedException(exception_class_descriptor, msg);
}
static mirror::ClassLoader* GetCurrentClassLoader(Thread* self)
@@ -1738,8 +1731,7 @@ static mirror::ClassLoader* GetCurrentClassLoader(Thread* self)
: nullptr;
}
-void Thread::ThrowNewWrappedException(const ThrowLocation& throw_location ATTRIBUTE_UNUSED,
- const char* exception_class_descriptor,
+void Thread::ThrowNewWrappedException(const char* exception_class_descriptor,
const char* msg) {
DCHECK_EQ(this, Thread::Current());
ScopedObjectAccessUnchecked soa(this);
@@ -1843,7 +1835,7 @@ void Thread::ThrowOutOfMemoryError(const char* msg) {
msg, (tls32_.throwing_OutOfMemoryError ? " (recursive case)" : ""));
if (!tls32_.throwing_OutOfMemoryError) {
tls32_.throwing_OutOfMemoryError = true;
- ThrowNewException(GetCurrentLocationForThrow(), "Ljava/lang/OutOfMemoryError;", msg);
+ ThrowNewException("Ljava/lang/OutOfMemoryError;", msg);
tls32_.throwing_OutOfMemoryError = false;
} else {
Dump(LOG(WARNING)); // The pre-allocated OOME has no stack, so help out and log one.
@@ -2074,14 +2066,6 @@ mirror::ArtMethod* Thread::GetCurrentMethod(uint32_t* dex_pc, bool abort_on_erro
return visitor.method_;
}
-ThrowLocation Thread::GetCurrentLocationForThrow() {
- Context* context = GetLongJumpContext();
- CurrentMethodVisitor visitor(this, context, true);
- visitor.WalkStack(false);
- ReleaseLongJumpContext(context);
- return ThrowLocation(visitor.this_object_, visitor.method_, visitor.dex_pc_);
-}
-
bool Thread::HoldsLock(mirror::Object* object) const {
if (object == nullptr) {
return false;
@@ -2416,4 +2400,21 @@ void Thread::DeactivateSingleStepControl() {
delete ssc;
}
+void Thread::SetDebugInvokeReq(DebugInvokeReq* req) {
+ CHECK(Dbg::IsDebuggerActive());
+ CHECK(GetInvokeReq() == nullptr) << "Debug invoke req already active in thread " << *this;
+ CHECK(Thread::Current() != this) << "Debug invoke can't be dispatched by the thread itself";
+ CHECK(req != nullptr);
+ tlsPtr_.debug_invoke_req = req;
+}
+
+void Thread::ClearDebugInvokeReq() {
+ CHECK(Dbg::IsDebuggerActive());
+ CHECK(GetInvokeReq() != nullptr) << "Debug invoke req not active in thread " << *this;
+ CHECK(Thread::Current() == this) << "Debug invoke must be finished by the thread itself";
+ // We do not own the DebugInvokeReq* so we must not delete it, it is the responsibility of
+ // the owner (the JDWP thread).
+ tlsPtr_.debug_invoke_req = nullptr;
+}
+
} // namespace art