Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "debugger.h" |
| 18 | |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 19 | #include <sys/uio.h> |
| 20 | |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame^] | 21 | #include "thread_list.h" |
| 22 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 23 | namespace art { |
| 24 | |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame^] | 25 | class ObjectRegistry { |
| 26 | public: |
| 27 | ObjectRegistry() : lock_("ObjectRegistry lock") { |
| 28 | } |
| 29 | |
| 30 | JDWP::ObjectId Add(Object* o) { |
| 31 | if (o == NULL) { |
| 32 | return 0; |
| 33 | } |
| 34 | JDWP::ObjectId id = static_cast<JDWP::ObjectId>(reinterpret_cast<uintptr_t>(o)); |
| 35 | MutexLock mu(lock_); |
| 36 | map_[id] = o; |
| 37 | return id; |
| 38 | } |
| 39 | |
| 40 | bool Contains(JDWP::ObjectId id) { |
| 41 | MutexLock mu(lock_); |
| 42 | return map_.find(id) != map_.end(); |
| 43 | } |
| 44 | |
| 45 | private: |
| 46 | Mutex lock_; |
| 47 | std::map<JDWP::ObjectId, Object*> map_; |
| 48 | }; |
| 49 | |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 50 | // JDWP is allowed unless the Zygote forbids it. |
| 51 | static bool gJdwpAllowed = true; |
| 52 | |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 53 | // Was there a -Xrunjdwp or -agent argument on the command-line? |
| 54 | static bool gJdwpConfigured = false; |
| 55 | |
| 56 | // Broken-down JDWP options. (Only valid if gJdwpConfigured is true.) |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 57 | static JDWP::JdwpOptions gJdwpOptions; |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 58 | |
| 59 | // Runtime JDWP state. |
| 60 | static JDWP::JdwpState* gJdwpState = NULL; |
| 61 | static bool gDebuggerConnected; // debugger or DDMS is connected. |
| 62 | static bool gDebuggerActive; // debugger is making requests. |
| 63 | |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame^] | 64 | static ObjectRegistry* gRegistry = NULL; |
| 65 | |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 66 | /* |
| 67 | * Handle one of the JDWP name/value pairs. |
| 68 | * |
| 69 | * JDWP options are: |
| 70 | * help: if specified, show help message and bail |
| 71 | * transport: may be dt_socket or dt_shmem |
| 72 | * address: for dt_socket, "host:port", or just "port" when listening |
| 73 | * server: if "y", wait for debugger to attach; if "n", attach to debugger |
| 74 | * timeout: how long to wait for debugger to connect / listen |
| 75 | * |
| 76 | * Useful with server=n (these aren't supported yet): |
| 77 | * onthrow=<exception-name>: connect to debugger when exception thrown |
| 78 | * onuncaught=y|n: connect to debugger when uncaught exception thrown |
| 79 | * launch=<command-line>: launch the debugger itself |
| 80 | * |
| 81 | * The "transport" option is required, as is "address" if server=n. |
| 82 | */ |
| 83 | static bool ParseJdwpOption(const std::string& name, const std::string& value) { |
| 84 | if (name == "transport") { |
| 85 | if (value == "dt_socket") { |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 86 | gJdwpOptions.transport = JDWP::kJdwpTransportSocket; |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 87 | } else if (value == "dt_android_adb") { |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 88 | gJdwpOptions.transport = JDWP::kJdwpTransportAndroidAdb; |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 89 | } else { |
| 90 | LOG(ERROR) << "JDWP transport not supported: " << value; |
| 91 | return false; |
| 92 | } |
| 93 | } else if (name == "server") { |
| 94 | if (value == "n") { |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 95 | gJdwpOptions.server = false; |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 96 | } else if (value == "y") { |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 97 | gJdwpOptions.server = true; |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 98 | } else { |
| 99 | LOG(ERROR) << "JDWP option 'server' must be 'y' or 'n'"; |
| 100 | return false; |
| 101 | } |
| 102 | } else if (name == "suspend") { |
| 103 | if (value == "n") { |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 104 | gJdwpOptions.suspend = false; |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 105 | } else if (value == "y") { |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 106 | gJdwpOptions.suspend = true; |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 107 | } else { |
| 108 | LOG(ERROR) << "JDWP option 'suspend' must be 'y' or 'n'"; |
| 109 | return false; |
| 110 | } |
| 111 | } else if (name == "address") { |
| 112 | /* this is either <port> or <host>:<port> */ |
| 113 | std::string port_string; |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 114 | gJdwpOptions.host.clear(); |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 115 | std::string::size_type colon = value.find(':'); |
| 116 | if (colon != std::string::npos) { |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 117 | gJdwpOptions.host = value.substr(0, colon); |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 118 | port_string = value.substr(colon + 1); |
| 119 | } else { |
| 120 | port_string = value; |
| 121 | } |
| 122 | if (port_string.empty()) { |
| 123 | LOG(ERROR) << "JDWP address missing port: " << value; |
| 124 | return false; |
| 125 | } |
| 126 | char* end; |
| 127 | long port = strtol(port_string.c_str(), &end, 10); |
| 128 | if (*end != '\0') { |
| 129 | LOG(ERROR) << "JDWP address has junk in port field: " << value; |
| 130 | return false; |
| 131 | } |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 132 | gJdwpOptions.port = port; |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 133 | } else if (name == "launch" || name == "onthrow" || name == "oncaught" || name == "timeout") { |
| 134 | /* valid but unsupported */ |
| 135 | LOG(INFO) << "Ignoring JDWP option '" << name << "'='" << value << "'"; |
| 136 | } else { |
| 137 | LOG(INFO) << "Ignoring unrecognized JDWP option '" << name << "'='" << value << "'"; |
| 138 | } |
| 139 | |
| 140 | return true; |
| 141 | } |
| 142 | |
| 143 | /* |
| 144 | * Parse the latter half of a -Xrunjdwp/-agentlib:jdwp= string, e.g.: |
| 145 | * "transport=dt_socket,address=8000,server=y,suspend=n" |
| 146 | */ |
| 147 | bool Dbg::ParseJdwpOptions(const std::string& options) { |
| 148 | std::vector<std::string> pairs; |
| 149 | Split(options, ',', pairs); |
| 150 | |
| 151 | for (size_t i = 0; i < pairs.size(); ++i) { |
| 152 | std::string::size_type equals = pairs[i].find('='); |
| 153 | if (equals == std::string::npos) { |
| 154 | LOG(ERROR) << "Can't parse JDWP option '" << pairs[i] << "' in '" << options << "'"; |
| 155 | return false; |
| 156 | } |
| 157 | ParseJdwpOption(pairs[i].substr(0, equals), pairs[i].substr(equals + 1)); |
| 158 | } |
| 159 | |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 160 | if (gJdwpOptions.transport == JDWP::kJdwpTransportUnknown) { |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 161 | LOG(ERROR) << "Must specify JDWP transport: " << options; |
| 162 | } |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 163 | if (!gJdwpOptions.server && (gJdwpOptions.host.empty() || gJdwpOptions.port == 0)) { |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 164 | LOG(ERROR) << "Must specify JDWP host and port when server=n: " << options; |
| 165 | return false; |
| 166 | } |
| 167 | |
| 168 | gJdwpConfigured = true; |
| 169 | return true; |
| 170 | } |
| 171 | |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 172 | void Dbg::StartJdwp() { |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 173 | if (!gJdwpAllowed || !gJdwpConfigured) { |
| 174 | // No JDWP for you! |
| 175 | return; |
| 176 | } |
| 177 | |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame^] | 178 | CHECK(gRegistry == NULL); |
| 179 | gRegistry = new ObjectRegistry; |
| 180 | |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 181 | // Init JDWP if the debugger is enabled. This may connect out to a |
| 182 | // debugger, passively listen for a debugger, or block waiting for a |
| 183 | // debugger. |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 184 | gJdwpState = JDWP::JdwpState::Create(&gJdwpOptions); |
| 185 | if (gJdwpState == NULL) { |
| 186 | LOG(WARNING) << "debugger thread failed to initialize"; |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame^] | 187 | return; |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | // If a debugger has already attached, send the "welcome" message. |
| 191 | // This may cause us to suspend all threads. |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 192 | if (gJdwpState->IsActive()) { |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 193 | //ScopedThreadStateChange(Thread::Current(), Thread::kRunnable); |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 194 | if (!gJdwpState->PostVMStart()) { |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 195 | LOG(WARNING) << "failed to post 'start' message to debugger"; |
| 196 | } |
| 197 | } |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 198 | } |
| 199 | |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 200 | void Dbg::StopJdwp() { |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 201 | delete gJdwpState; |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame^] | 202 | delete gRegistry; |
| 203 | gRegistry = NULL; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 204 | } |
| 205 | |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 206 | void Dbg::SetJdwpAllowed(bool allowed) { |
| 207 | gJdwpAllowed = allowed; |
| 208 | } |
| 209 | |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 210 | DebugInvokeReq* Dbg::GetInvokeReq() { |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame^] | 211 | return Thread::Current()->GetInvokeReq(); |
| 212 | } |
| 213 | |
| 214 | Thread* Dbg::GetDebugThread() { |
| 215 | return (gJdwpState != NULL) ? gJdwpState->GetDebugThread() : NULL; |
| 216 | } |
| 217 | |
| 218 | void Dbg::ClearWaitForEventThread() { |
| 219 | gJdwpState->ClearWaitForEventThread(); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | void Dbg::Connected() { |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 223 | CHECK(!gDebuggerConnected); |
| 224 | LOG(VERBOSE) << "JDWP has attached"; |
| 225 | gDebuggerConnected = true; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | void Dbg::Active() { |
| 229 | UNIMPLEMENTED(FATAL); |
| 230 | } |
| 231 | |
| 232 | void Dbg::Disconnected() { |
| 233 | UNIMPLEMENTED(FATAL); |
| 234 | } |
| 235 | |
| 236 | bool Dbg::IsDebuggerConnected() { |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 237 | return gDebuggerActive; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | bool Dbg::IsDebuggingEnabled() { |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 241 | return gJdwpConfigured; |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | int64_t Dbg::LastDebuggerActivity() { |
| 245 | UNIMPLEMENTED(WARNING); |
| 246 | return -1; |
| 247 | } |
| 248 | |
| 249 | int Dbg::ThreadRunning() { |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 250 | return static_cast<int>(Thread::Current()->SetState(Thread::kRunnable)); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | int Dbg::ThreadWaiting() { |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 254 | return static_cast<int>(Thread::Current()->SetState(Thread::kVmWait)); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 255 | } |
| 256 | |
Elliott Hughes | 6ba581a | 2011-10-25 11:45:35 -0700 | [diff] [blame] | 257 | int Dbg::ThreadContinuing(int new_state) { |
| 258 | return static_cast<int>(Thread::Current()->SetState(static_cast<Thread::State>(new_state))); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | void Dbg::UndoDebuggerSuspensions() { |
| 262 | UNIMPLEMENTED(FATAL); |
| 263 | } |
| 264 | |
| 265 | void Dbg::Exit(int status) { |
| 266 | UNIMPLEMENTED(FATAL); |
| 267 | } |
| 268 | |
| 269 | const char* Dbg::GetClassDescriptor(JDWP::RefTypeId id) { |
| 270 | UNIMPLEMENTED(FATAL); |
| 271 | return NULL; |
| 272 | } |
| 273 | |
| 274 | JDWP::ObjectId Dbg::GetClassObject(JDWP::RefTypeId id) { |
| 275 | UNIMPLEMENTED(FATAL); |
| 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | JDWP::RefTypeId Dbg::GetSuperclass(JDWP::RefTypeId id) { |
| 280 | UNIMPLEMENTED(FATAL); |
| 281 | return 0; |
| 282 | } |
| 283 | |
| 284 | JDWP::ObjectId Dbg::GetClassLoader(JDWP::RefTypeId id) { |
| 285 | UNIMPLEMENTED(FATAL); |
| 286 | return 0; |
| 287 | } |
| 288 | |
| 289 | uint32_t Dbg::GetAccessFlags(JDWP::RefTypeId id) { |
| 290 | UNIMPLEMENTED(FATAL); |
| 291 | return 0; |
| 292 | } |
| 293 | |
| 294 | bool Dbg::IsInterface(JDWP::RefTypeId id) { |
| 295 | UNIMPLEMENTED(FATAL); |
| 296 | return false; |
| 297 | } |
| 298 | |
| 299 | void Dbg::GetClassList(uint32_t* pNumClasses, JDWP::RefTypeId** pClassRefBuf) { |
| 300 | UNIMPLEMENTED(FATAL); |
| 301 | } |
| 302 | |
| 303 | void Dbg::GetVisibleClassList(JDWP::ObjectId classLoaderId, uint32_t* pNumClasses, JDWP::RefTypeId** pClassRefBuf) { |
| 304 | UNIMPLEMENTED(FATAL); |
| 305 | } |
| 306 | |
| 307 | void Dbg::GetClassInfo(JDWP::RefTypeId classId, uint8_t* pTypeTag, uint32_t* pStatus, const char** pSignature) { |
| 308 | UNIMPLEMENTED(FATAL); |
| 309 | } |
| 310 | |
| 311 | bool Dbg::FindLoadedClassBySignature(const char* classDescriptor, JDWP::RefTypeId* pRefTypeId) { |
| 312 | UNIMPLEMENTED(FATAL); |
| 313 | return false; |
| 314 | } |
| 315 | |
| 316 | void Dbg::GetObjectType(JDWP::ObjectId objectId, uint8_t* pRefTypeTag, JDWP::RefTypeId* pRefTypeId) { |
| 317 | UNIMPLEMENTED(FATAL); |
| 318 | } |
| 319 | |
| 320 | uint8_t Dbg::GetClassObjectType(JDWP::RefTypeId refTypeId) { |
| 321 | UNIMPLEMENTED(FATAL); |
| 322 | return 0; |
| 323 | } |
| 324 | |
| 325 | const char* Dbg::GetSignature(JDWP::RefTypeId refTypeId) { |
| 326 | UNIMPLEMENTED(FATAL); |
| 327 | return NULL; |
| 328 | } |
| 329 | |
| 330 | const char* Dbg::GetSourceFile(JDWP::RefTypeId refTypeId) { |
| 331 | UNIMPLEMENTED(FATAL); |
| 332 | return NULL; |
| 333 | } |
| 334 | |
| 335 | const char* Dbg::GetObjectTypeName(JDWP::ObjectId objectId) { |
| 336 | UNIMPLEMENTED(FATAL); |
| 337 | return NULL; |
| 338 | } |
| 339 | |
| 340 | uint8_t Dbg::GetObjectTag(JDWP::ObjectId objectId) { |
| 341 | UNIMPLEMENTED(FATAL); |
| 342 | return 0; |
| 343 | } |
| 344 | |
| 345 | int Dbg::GetTagWidth(int tag) { |
| 346 | UNIMPLEMENTED(FATAL); |
| 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | int Dbg::GetArrayLength(JDWP::ObjectId arrayId) { |
| 351 | UNIMPLEMENTED(FATAL); |
| 352 | return 0; |
| 353 | } |
| 354 | |
| 355 | uint8_t Dbg::GetArrayElementTag(JDWP::ObjectId arrayId) { |
| 356 | UNIMPLEMENTED(FATAL); |
| 357 | return 0; |
| 358 | } |
| 359 | |
| 360 | bool Dbg::OutputArray(JDWP::ObjectId arrayId, int firstIndex, int count, JDWP::ExpandBuf* pReply) { |
| 361 | UNIMPLEMENTED(FATAL); |
| 362 | return false; |
| 363 | } |
| 364 | |
| 365 | bool Dbg::SetArrayElements(JDWP::ObjectId arrayId, int firstIndex, int count, const uint8_t* buf) { |
| 366 | UNIMPLEMENTED(FATAL); |
| 367 | return false; |
| 368 | } |
| 369 | |
| 370 | JDWP::ObjectId Dbg::CreateString(const char* str) { |
| 371 | UNIMPLEMENTED(FATAL); |
| 372 | return 0; |
| 373 | } |
| 374 | |
| 375 | JDWP::ObjectId Dbg::CreateObject(JDWP::RefTypeId classId) { |
| 376 | UNIMPLEMENTED(FATAL); |
| 377 | return 0; |
| 378 | } |
| 379 | |
| 380 | JDWP::ObjectId Dbg::CreateArrayObject(JDWP::RefTypeId arrayTypeId, uint32_t length) { |
| 381 | UNIMPLEMENTED(FATAL); |
| 382 | return 0; |
| 383 | } |
| 384 | |
| 385 | bool Dbg::MatchType(JDWP::RefTypeId instClassId, JDWP::RefTypeId classId) { |
| 386 | UNIMPLEMENTED(FATAL); |
| 387 | return false; |
| 388 | } |
| 389 | |
| 390 | const char* Dbg::GetMethodName(JDWP::RefTypeId refTypeId, JDWP::MethodId id) { |
| 391 | UNIMPLEMENTED(FATAL); |
| 392 | return NULL; |
| 393 | } |
| 394 | |
| 395 | void Dbg::OutputAllFields(JDWP::RefTypeId refTypeId, bool withGeneric, JDWP::ExpandBuf* pReply) { |
| 396 | UNIMPLEMENTED(FATAL); |
| 397 | } |
| 398 | |
| 399 | void Dbg::OutputAllMethods(JDWP::RefTypeId refTypeId, bool withGeneric, JDWP::ExpandBuf* pReply) { |
| 400 | UNIMPLEMENTED(FATAL); |
| 401 | } |
| 402 | |
| 403 | void Dbg::OutputAllInterfaces(JDWP::RefTypeId refTypeId, JDWP::ExpandBuf* pReply) { |
| 404 | UNIMPLEMENTED(FATAL); |
| 405 | } |
| 406 | |
| 407 | void Dbg::OutputLineTable(JDWP::RefTypeId refTypeId, JDWP::MethodId methodId, JDWP::ExpandBuf* pReply) { |
| 408 | UNIMPLEMENTED(FATAL); |
| 409 | } |
| 410 | |
| 411 | void Dbg::OutputVariableTable(JDWP::RefTypeId refTypeId, JDWP::MethodId id, bool withGeneric, JDWP::ExpandBuf* pReply) { |
| 412 | UNIMPLEMENTED(FATAL); |
| 413 | } |
| 414 | |
| 415 | uint8_t Dbg::GetFieldBasicTag(JDWP::ObjectId objId, JDWP::FieldId fieldId) { |
| 416 | UNIMPLEMENTED(FATAL); |
| 417 | return 0; |
| 418 | } |
| 419 | |
| 420 | uint8_t Dbg::GetStaticFieldBasicTag(JDWP::RefTypeId refTypeId, JDWP::FieldId fieldId) { |
| 421 | UNIMPLEMENTED(FATAL); |
| 422 | return 0; |
| 423 | } |
| 424 | |
| 425 | void Dbg::GetFieldValue(JDWP::ObjectId objectId, JDWP::FieldId fieldId, JDWP::ExpandBuf* pReply) { |
| 426 | UNIMPLEMENTED(FATAL); |
| 427 | } |
| 428 | |
| 429 | void Dbg::SetFieldValue(JDWP::ObjectId objectId, JDWP::FieldId fieldId, uint64_t value, int width) { |
| 430 | UNIMPLEMENTED(FATAL); |
| 431 | } |
| 432 | |
| 433 | void Dbg::GetStaticFieldValue(JDWP::RefTypeId refTypeId, JDWP::FieldId fieldId, JDWP::ExpandBuf* pReply) { |
| 434 | UNIMPLEMENTED(FATAL); |
| 435 | } |
| 436 | |
| 437 | void Dbg::SetStaticFieldValue(JDWP::RefTypeId refTypeId, JDWP::FieldId fieldId, uint64_t rawValue, int width) { |
| 438 | UNIMPLEMENTED(FATAL); |
| 439 | } |
| 440 | |
| 441 | char* Dbg::StringToUtf8(JDWP::ObjectId strId) { |
| 442 | UNIMPLEMENTED(FATAL); |
| 443 | return NULL; |
| 444 | } |
| 445 | |
| 446 | char* Dbg::GetThreadName(JDWP::ObjectId threadId) { |
| 447 | UNIMPLEMENTED(FATAL); |
| 448 | return NULL; |
| 449 | } |
| 450 | |
| 451 | JDWP::ObjectId Dbg::GetThreadGroup(JDWP::ObjectId threadId) { |
| 452 | UNIMPLEMENTED(FATAL); |
| 453 | return 0; |
| 454 | } |
| 455 | |
| 456 | char* Dbg::GetThreadGroupName(JDWP::ObjectId threadGroupId) { |
| 457 | UNIMPLEMENTED(FATAL); |
| 458 | return NULL; |
| 459 | } |
| 460 | |
| 461 | JDWP::ObjectId Dbg::GetThreadGroupParent(JDWP::ObjectId threadGroupId) { |
| 462 | UNIMPLEMENTED(FATAL); |
| 463 | return 0; |
| 464 | } |
| 465 | |
| 466 | JDWP::ObjectId Dbg::GetSystemThreadGroupId() { |
| 467 | UNIMPLEMENTED(FATAL); |
| 468 | return 0; |
| 469 | } |
| 470 | |
| 471 | JDWP::ObjectId Dbg::GetMainThreadGroupId() { |
| 472 | UNIMPLEMENTED(FATAL); |
| 473 | return 0; |
| 474 | } |
| 475 | |
| 476 | bool Dbg::GetThreadStatus(JDWP::ObjectId threadId, uint32_t* threadStatus, uint32_t* suspendStatus) { |
| 477 | UNIMPLEMENTED(FATAL); |
| 478 | return false; |
| 479 | } |
| 480 | |
| 481 | uint32_t Dbg::GetThreadSuspendCount(JDWP::ObjectId threadId) { |
| 482 | UNIMPLEMENTED(FATAL); |
| 483 | return 0; |
| 484 | } |
| 485 | |
| 486 | bool Dbg::ThreadExists(JDWP::ObjectId threadId) { |
| 487 | UNIMPLEMENTED(FATAL); |
| 488 | return false; |
| 489 | } |
| 490 | |
| 491 | bool Dbg::IsSuspended(JDWP::ObjectId threadId) { |
| 492 | UNIMPLEMENTED(FATAL); |
| 493 | return false; |
| 494 | } |
| 495 | |
| 496 | //void Dbg::WaitForSuspend(JDWP::ObjectId threadId); |
| 497 | |
| 498 | void Dbg::GetThreadGroupThreads(JDWP::ObjectId threadGroupId, JDWP::ObjectId** ppThreadIds, uint32_t* pThreadCount) { |
| 499 | UNIMPLEMENTED(FATAL); |
| 500 | } |
| 501 | |
| 502 | void Dbg::GetAllThreads(JDWP::ObjectId** ppThreadIds, uint32_t* pThreadCount) { |
| 503 | UNIMPLEMENTED(FATAL); |
| 504 | } |
| 505 | |
| 506 | int Dbg::GetThreadFrameCount(JDWP::ObjectId threadId) { |
| 507 | UNIMPLEMENTED(FATAL); |
| 508 | return 0; |
| 509 | } |
| 510 | |
| 511 | bool Dbg::GetThreadFrame(JDWP::ObjectId threadId, int num, JDWP::FrameId* pFrameId, JDWP::JdwpLocation* pLoc) { |
| 512 | UNIMPLEMENTED(FATAL); |
| 513 | return false; |
| 514 | } |
| 515 | |
| 516 | JDWP::ObjectId Dbg::GetThreadSelfId() { |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame^] | 517 | return gRegistry->Add(Thread::Current()->GetPeer()); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 518 | } |
| 519 | |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame^] | 520 | void Dbg::SuspendVM() { |
| 521 | Runtime::Current()->GetThreadList()->SuspendAll(true); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | void Dbg::ResumeVM() { |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame^] | 525 | Runtime::Current()->GetThreadList()->ResumeAll(true); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | void Dbg::SuspendThread(JDWP::ObjectId threadId) { |
| 529 | UNIMPLEMENTED(FATAL); |
| 530 | } |
| 531 | |
| 532 | void Dbg::ResumeThread(JDWP::ObjectId threadId) { |
| 533 | UNIMPLEMENTED(FATAL); |
| 534 | } |
| 535 | |
| 536 | void Dbg::SuspendSelf() { |
Elliott Hughes | 475fc23 | 2011-10-25 15:00:35 -0700 | [diff] [blame^] | 537 | Runtime::Current()->GetThreadList()->SuspendSelfForDebugger(); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 538 | } |
| 539 | |
| 540 | bool Dbg::GetThisObject(JDWP::ObjectId threadId, JDWP::FrameId frameId, JDWP::ObjectId* pThisId) { |
| 541 | UNIMPLEMENTED(FATAL); |
| 542 | return false; |
| 543 | } |
| 544 | |
| 545 | void Dbg::GetLocalValue(JDWP::ObjectId threadId, JDWP::FrameId frameId, int slot, uint8_t tag, uint8_t* buf, int expectedLen) { |
| 546 | UNIMPLEMENTED(FATAL); |
| 547 | } |
| 548 | |
| 549 | void Dbg::SetLocalValue(JDWP::ObjectId threadId, JDWP::FrameId frameId, int slot, uint8_t tag, uint64_t value, int width) { |
| 550 | UNIMPLEMENTED(FATAL); |
| 551 | } |
| 552 | |
| 553 | void Dbg::PostLocationEvent(const Method* method, int pcOffset, Object* thisPtr, int eventFlags) { |
| 554 | UNIMPLEMENTED(FATAL); |
| 555 | } |
| 556 | |
| 557 | void Dbg::PostException(void* throwFp, int throwRelPc, void* catchFp, int catchRelPc, Object* exception) { |
| 558 | UNIMPLEMENTED(FATAL); |
| 559 | } |
| 560 | |
| 561 | void Dbg::PostThreadStart(Thread* t) { |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 562 | if (!gDebuggerConnected) { |
| 563 | return; |
| 564 | } |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 565 | UNIMPLEMENTED(WARNING); |
| 566 | } |
| 567 | |
| 568 | void Dbg::PostThreadDeath(Thread* t) { |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 569 | if (!gDebuggerConnected) { |
| 570 | return; |
| 571 | } |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 572 | UNIMPLEMENTED(WARNING); |
| 573 | } |
| 574 | |
| 575 | void Dbg::PostClassPrepare(Class* c) { |
| 576 | UNIMPLEMENTED(FATAL); |
| 577 | } |
| 578 | |
| 579 | bool Dbg::WatchLocation(const JDWP::JdwpLocation* pLoc) { |
| 580 | UNIMPLEMENTED(FATAL); |
| 581 | return false; |
| 582 | } |
| 583 | |
| 584 | void Dbg::UnwatchLocation(const JDWP::JdwpLocation* pLoc) { |
| 585 | UNIMPLEMENTED(FATAL); |
| 586 | } |
| 587 | |
| 588 | bool Dbg::ConfigureStep(JDWP::ObjectId threadId, JDWP::JdwpStepSize size, JDWP::JdwpStepDepth depth) { |
| 589 | UNIMPLEMENTED(FATAL); |
| 590 | return false; |
| 591 | } |
| 592 | |
| 593 | void Dbg::UnconfigureStep(JDWP::ObjectId threadId) { |
| 594 | UNIMPLEMENTED(FATAL); |
| 595 | } |
| 596 | |
| 597 | JDWP::JdwpError Dbg::InvokeMethod(JDWP::ObjectId threadId, JDWP::ObjectId objectId, JDWP::RefTypeId classId, JDWP::MethodId methodId, uint32_t numArgs, uint64_t* argArray, uint32_t options, uint8_t* pResultTag, uint64_t* pResultValue, JDWP::ObjectId* pExceptObj) { |
| 598 | UNIMPLEMENTED(FATAL); |
| 599 | return JDWP::ERR_NONE; |
| 600 | } |
| 601 | |
| 602 | void Dbg::ExecuteMethod(DebugInvokeReq* pReq) { |
| 603 | UNIMPLEMENTED(FATAL); |
| 604 | } |
| 605 | |
| 606 | void Dbg::RegisterObjectId(JDWP::ObjectId id) { |
| 607 | UNIMPLEMENTED(FATAL); |
| 608 | } |
| 609 | |
| 610 | bool Dbg::DdmHandlePacket(const uint8_t* buf, int dataLen, uint8_t** pReplyBuf, int* pReplyLen) { |
| 611 | UNIMPLEMENTED(FATAL); |
| 612 | return false; |
| 613 | } |
| 614 | |
| 615 | void Dbg::DdmConnected() { |
| 616 | UNIMPLEMENTED(FATAL); |
| 617 | } |
| 618 | |
| 619 | void Dbg::DdmDisconnected() { |
| 620 | UNIMPLEMENTED(FATAL); |
| 621 | } |
| 622 | |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 623 | void Dbg::DdmSendChunk(int type, size_t byte_count, const uint8_t* buf) { |
| 624 | CHECK(buf != NULL); |
| 625 | iovec vec[1]; |
| 626 | vec[0].iov_base = reinterpret_cast<void*>(const_cast<uint8_t*>(buf)); |
| 627 | vec[0].iov_len = byte_count; |
| 628 | Dbg::DdmSendChunkV(type, vec, 1); |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | void Dbg::DdmSendChunkV(int type, const struct iovec* iov, int iovcnt) { |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 632 | if (gJdwpState == NULL) { |
| 633 | LOG(VERBOSE) << "Debugger thread not active, ignoring DDM send: " << type; |
| 634 | } else { |
Elliott Hughes | 376a7a0 | 2011-10-24 18:35:55 -0700 | [diff] [blame] | 635 | gJdwpState->DdmSendChunkV(type, iov, iovcnt); |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 636 | } |
Elliott Hughes | 872d4ec | 2011-10-21 17:07:15 -0700 | [diff] [blame] | 637 | } |
| 638 | |
| 639 | } // namespace art |