summaryrefslogtreecommitdiffstats
path: root/runtime/debugger.cc
Commit message (Collapse)AuthorAgeFilesLines
* JDWP: fix deadlock with GCSebastien Hertz2015-01-131-2/+7
| | | | | | | | | | | | | | | | | | | | This CL fixes a deadlock where JDWP thread and running GC thread are waiting for each other. Here is the sequence of the deadlock: 1. GC thread disables access to weak global references, then releases mutator lock. 2. JDWP thread takes mutator lock exclusively after suspending all threads. 3. GC thread waits for shared mutator lock which is held by JDWP thread. 4. JDWP thread clears weak global references but need to wait for GC thread to re-enable access to them. To avoid that situation, we ensure the JDWP thread does not attempt to delete weak global references while holding the mutator exclusively so GC thread is not blocked. Bug: 18995321 Change-Id: Ia7e82f463c27ffdcfd730c3117337a6a33d111e7
* Change hprof to use streamingMathieu Chartier2015-01-091-0/+4
| | | | | | | | | | | | | | | Previously, we compute the whole hprof dump in memory resulting in > 50MB of memory usage for some apps (such as maps). This could cause the app to get killed by the low memory killer. The solution works by doing the dump in 2 passes. The first pass calculates the size of the dump. The second pass starts by sending the DDMS header with the correct size, then does the rest of the hprof dump by streaming and sending data one HprofRecord at a time. Bug: 18921793 Change-Id: I7dd9f5cfe49799ba268095c994a8c2eb1fe493df
* Don't allow suspension from FindLocksAtDexPcMathieu Chartier2015-01-061-1/+1
| | | | | | | | | | | | | | | | Transitioning to suspended from runnable sometimes runs dump checkpoints in ThreadStress which can cause deadlocks. This happens since FindLocksAtDexPC runs the verifier which calls AllowThreadSuspension. This results in a blocked thread which holds the monitor lock, and if another thread tries to do a monitor enter, it deadlocks while holding the mutator lock (assuming the GC is suspending all). The fix for avoiding this deadlock is not calling AllowThreadSuspension from FindLocksAtDexPc. Bug: 18576985 Change-Id: I7e5faaf3bbbd5b5f680de95d53c33b5106705b0c
* Merge "Cleanup JDWP event matching"Sebastien Hertz2014-12-181-4/+2
|\
| * Cleanup JDWP event matchingSebastien Hertz2014-12-171-4/+2
| | | | | | | | | | | | | | | | * Use std::vector for the event match list. * Make event reporting methods void since result is never used. * Use nullptr keyword instead of NULL. Change-Id: Icd6f47e46cefc2cc63325df00037cd4b6a475259
* | JDWP: fix setting multiple breakpoints in the same methodSebastien Hertz2014-12-171-7/+23
|/ | | | | | | | | | | | | | | | When setting multiple breakpoints in the same method, we were incorrectly setting the deoptimization kind of all the breakpoints set after a first breakpoint. This resulted in incorrect deoptimization/undeoptimization and even an abort. This was caught by running the debugger with sanity checks enabled with libartd.so. We now set next breakpoints with the deoptimization kind of the first existing breakpoint (if any) so we trigger right [un]deoptimization when adding or removing a breakpoint. Bug: 18782753 Bug: 18651686 Change-Id: Idf36ede73302fba83a154052bef701bedc8bc726
* Clean up debuggerMathieu Chartier2014-12-151-94/+87
| | | | | | | | | Separated logic for native vs java heap, cleaned up lock annotations. Added missing end of space marker for bump pointer spaces. Bug: 18730149 Change-Id: I5bc21f0cee83b9cfa357e8a59658885c12cae09c
* ART: Fix DDM client hang transmitting native heap dump with MALLOC_IMPL=dlmallocPavel Vyssotski2014-12-081-0/+8
| | | | | | | | | | | VM acting as a DDM client hangs transmitting native heap segment data when dlmalloc is used instead of default jemalloc. dlmalloc_inspect_all disallow any memory allocation inside heap callback. So cannot send any data walking the heap, the same for logging. Callback function also needs to acquire the heap bitmap lock. Finally, need to indicate end of a space to flush data. Change-Id: I9541962268dd58c2a4237fe1550c9e153252ab4a Signed-off-by: Pavel Vyssotski <pavel.n.vyssotski@intel.com>
* Merge "JDWP: fix breakpoint for method in the image"Sebastien Hertz2014-12-041-2/+10
|\
| * JDWP: fix breakpoint for method in the imageSebastien Hertz2014-12-041-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we set a breakpoint in a compiled method, we deoptimize it by changing its entrypoint so it is executed with the interpreter. However, methods in the image can be called with their direct code pointer, ignoring the updated entrypoint. In that case, the method is not executed with the interpreter and we miss the breakpoint. This CL avoids that situation by forcing a full deoptimization so everything runs with the interpreter. However, if the image has been compiled in PIC mode, we keep using selective deoptimization because direct code pointer is not used in this mode. Bug: 17965285 Change-Id: Icaf8cbb7fe9ad01d36f7378c59d50d9ce42ae57f
* | Move GetClassFromTypeIdx to ArtMethod.Ian Rogers2014-12-021-5/+3
| | | | | | | | | | | | | | Move GetClassFromTypeIdx out of MethodHelper into ArtMethod in preparation for the removal of MethodHelper. Change-Id: I9c03dd8c821944c606ea08cdf92afc80c4275247
* | Remove FieldHelper.Ian Rogers2014-12-021-2/+1
|/ | | | Change-Id: I2d74e2d5b3c35a691c95339de0db9361847fca11
* ART: Fix inline dependencyAndreas Gampe2014-11-241-1/+1
| | | | | | GetClassFromTypeIdx is defined in the -inl file. Change-Id: Ib5dbcea08dccee43ff70cac2e45cdbf210cb490c
* JDWP: only deoptimize when it is requiredSebastien Hertz2014-11-191-43/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | We don't need to deoptimize anything when we forced the use of the interpreter (-Xint). In this case, no compiled code is executed (except native methods which are not concerned by deoptimization). Therefore we even don't need to enable/disable deoptimization support in instrumentation. We also don't need to deoptimize a method that hasn't been compiled. Since it will run with interpreter, there is no point deoptimizing it. However this method may be inlined in a compiled caller method so we still need to deoptimize everything in this case. This CL updates breakpoint support by storing the required kind of deoptimization for a particular method. There are 3 cases: - kNothing: the method does not require deoptimization. - kSelectiveDeoptimization: the method needs to be deoptimized. - kFullDeoptimization: we must deoptimize everythinig. When uninstalling a breakpoint, we need to do the reverse operation. Also fixes the SanityCheckExistingBreakpoints function to control breakpoints related to the given method only and adds extra verbose logs when choosing the appropriate deoptimization kind. Bug: 18407046 Change-Id: I5212c1fd2f72e06c79e7871db15696824d37dc0b
* Modify the behavior of thread suspend shootouts.Ian Rogers2014-11-121-10/+4
| | | | | | | | | | The thread doing the suspension doesn't attempt to suspend the other thread unless it knows another thread isn't trying to suspend it. Use the suspend count, and its lock, for this purpose. Re-enable ThreadStress test. Bug: 15446488 Change-Id: Idd34410c7b89d8abd6973e5699a15ca699472c78
* ART: More warningsAndreas Gampe2014-11-041-15/+15
| | | | | | | Enable -Wno-conversion-null, -Wredundant-decls and -Wshadow in general, and -Wunused-but-set-parameter for GCC builds. Change-Id: I81bbdd762213444673c65d85edae594a523836e5
* Remove -Wno-unused-parameter and -Wno-sign-promo from base cflags.Ian Rogers2014-11-031-4/+7
| | | | | | | | | | | Fix associated errors about unused paramenters and implict sign conversions. For sign conversion this was largely in the area of enums, so add ostream operators for the effected enums and fix tools/generate-operator-out.py. Tidy arena allocation code and arena allocated data types, rather than fixing new and delete operators. Remove dead code. Change-Id: I5b433e722d2f75baacfacae4d32aef4a828bfe1b
* Tidy and reduce ART library dependencies on the host.Ian Rogers2014-10-301-1/+1
| | | | | | | Move to shared rather than static libraries. Avoids capture of all static libraries library dependencies. Change-Id: I2be96e92dad4ed1842d76b044745f2a2e15372eb
* Merge "Fix JDWP Virtualmachine.Resume command"Sebastien Hertz2014-10-241-1/+1
|\
| * Fix JDWP Virtualmachine.Resume commandSebastien Hertz2014-10-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We used to call ThreadList::UndoDebuggerSuspensions but this is not correct. Indeed Virtualmachine.Resume command should be performed as many times as all threads have been suspended (either by the Virtualmachine.Suspend command or the application of suspend policy ALL for event). This CL fixes this issue by adding ThreadList::ResumeAllForDebugger. It decrements suspend count and debug suspend count by 1 (globally and for each thread). It also handles the case where Virtualmachine.Resume is called while threads have not been suspended (global debug suspend count is 0). In this case we just print a warning and do nothing. Bug: 17974047 Change-Id: I25af22b1936760292d2a8c286e0867f2ae864108
* | Merge "More use of WellKnownClasses for debugger"Sebastien Hertz2014-10-241-9/+14
|\ \
| * | More use of WellKnownClasses for debuggerSebastien Hertz2014-10-231-9/+14
| |/ | | | | | | | | | | | | | | | | Uses WellKnownClasses cached fields for ThreadGroupReference-related JDWP commands. Adds fields of java.lang.ThreadGroup and java.util.ArrayList used by the debugger. Change-Id: I54f7ef7e44cb61bec95657a69177bba1fbb7dc75
* | C++11 related clean-up of DISALLOW_..Ian Rogers2014-10-221-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move DISALLOW_COPY_AND_ASSIGN to delete functions. By no having declarations with no definitions this prompts better warning messages so deal with these by correcting the code. Add a DISALLOW_ALLOCATION and use for ValueObject and mirror::Object. Make X86 assembly operand types ValueObjects to fix compilation errors. Tidy the use of iostream and ostream. Avoid making cutils a dependency via mutex-inl.h for tests that link against libart. Push tracing dependencies into appropriate files and mutex.cc. x86 32-bit host symbols size is increased for libarttest, avoid copying this in run-test 115 by using symlinks and remove this test's higher than normal ulimit. Fix the RunningOnValgrind test in RosAllocSpace to not use GetHeap as it returns NULL when the heap is under construction by Runtime. Change-Id: Ia246f7ac0c11f73072b30d70566a196e9b78472b
* | Make ART compile with GCC -O0 again.Ian Rogers2014-10-161-1/+1
|/ | | | | | | | | | | | | Tidy up InstructionSetFeatures so that it has a type hierarchy dependent on architecture. Add to instruction_set_test to warn when InstructionSetFeatures don't agree with ones from system properties, AT_HWCAP and /proc/cpuinfo. Clean-up class linker entry point logic to not return entry points but to test whether the passed code is the particular entrypoint. This works around image trampolines that replicate entrypoints. Bug: 17993736 Change-Id: I5f4b49e88c3b02a79f9bee04f83395146ed7be23
* Merge "Hold mutator lock in DdmSendHeapSegments for all spaces"Mathieu Chartier2014-10-101-11/+14
|\
| * Hold mutator lock in DdmSendHeapSegments for all spacesMathieu Chartier2014-10-101-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | Previously we were releasing the mutator lock in DdmSendHeapSegments and only reacquiring it for RosAlloc spaces. This was causing problems since the HeapChunkCallback access object fields through mirror. Bug: 17950534 (cherry picked from commit d6527cf8e824d9057f32755f2ff4bdcf46c7095b) Change-Id: Idb307fd4c01450a07e3c9621e04d2aabf2c6a0b9
* | Enable -Wimplicit-fallthrough.Ian Rogers2014-10-091-0/+1
|/ | | | | | | | Falling through switch cases on a clang build must now annotate the fallthrough with the FALLTHROUGH_INTENDED macro. Bug: 17731372 Change-Id: I836451cd5f96b01d1ababdbf9eef677fe8fa8324
* Fix broken runtime SetStatsEnabled logicMathieu Chartier2014-09-261-2/+2
| | | | | | | | | | | | | | | Previously, Runtime::SetStatsEnabled wouldn't take stats_enabled_ into account when deciding whether or not to increment / decrement teh stats enabled counter. This resulted in counter underflows and other errors which caused some CTS tests to fail. Also added some locking to prevent race conditions. Bug: 17360878 (cherry picked from commit a98ffd745bbecb2e84a492194950c0b94966546b) Change-Id: I21d241a58d35bd6a607aa2305c6da81720bd0886
* Some optimizations for the array alloc path.Hiroshi Yamauchi2014-09-251-1/+1
| | | | | | | | | | | | | | | | | - Force Array::Alloc() to be inlined. - Simplify the array size overflow check. - Turn fill_usable into a template parameter. - Remove a branch in Array::DataOffset() and avoid Primitive::ComponentSize(), which has a switch, in the array alloc path. - Strength reductions in the array size computation by using component size shifts instead of component sizes. Store component size shift in the upper 16 bits of primitive_type field. - Speedup: ~4% (3435->3284) in MemAllocTest on N4. Bug: 9986565 Change-Id: I4b142ffac4ab8b5b915836f1660a949d6442344c
* Merge "Add ScopedAssertNoThreadSuspension"Mathieu Chartier2014-09-221-12/+11
|\
| * Add ScopedAssertNoThreadSuspensionMathieu Chartier2014-09-191-12/+11
| | | | | | | | | | | | | | | | Added a new class, ScopedAssertNoThreadSuspension. Deleted some unnecessary ScopedAssertNoThreadSuspension since VisitObjects already has a ScopedAssertNoThreadSuspension. Change-Id: I29ec0006120c39a27184d30e2d1d0c179e203776
* | Merge "Optimize JDWP stack local values access"Sebastien Hertz2014-09-221-274/+303
|\ \
| * | Optimize JDWP stack local values accessSebastien Hertz2014-09-221-274/+303
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | The StackFrame.GetValues and StackFrame.SetValues JDWP commands can refer to multiple variables at the same time in a given frame. However we used to walk the stack until getting to the requested frame for each variable. Now, we walk the stack only once until getting to the frame so the context is initialized. Then we read/write value for each variable from this context. Bug: 17343501 Bug: 15680615 Change-Id: I2a4128f29a3c5856b994e280037c0a09eb48c5c8
* | Merge "Do not hold breakpoint lock when running the verifier"Sebastien Hertz2014-09-221-21/+34
|\ \
| * | Do not hold breakpoint lock when running the verifierSebastien Hertz2014-09-221-21/+34
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | When setting a breakpoint, we need to know whether the method may be inlined. We run the method verifier but that may cause thread suspension. Therefore we must not hold any lock at this time. The issue is we do hold the breakpoint lock so we fails a check in debug mode. This CL ensures we don't hold the breakpoint lock when running the method verifier to detect inlining. Bug: 17562442 Change-Id: Ia6b128fc8917ce00025b68ae4ac62fb2a1f154e6
* | Fix JDWP crash when reporting exceptionSebastien Hertz2014-09-221-3/+15
|/ | | | | | | | | | The exception's throw location may be null so we need to handle that case. Also fixes a memset issue. Bug: 17571297 (cherry picked from commit bbb63897d7f2d99219cb50721fe530521e08ddff) Change-Id: Iedebb58f9460c5f04913c269200e51161bda1ba9
* Update JDWP event filtering to avoid useless idsSebastien Hertz2014-09-181-81/+93
| | | | | | | | | | | | | | | To reduce the number of JDWP ids in the debugger, we update the event filtering support to work with runtime objects (Thread, Class, Object, ...) instead of JDWP ids (ThreadId, RefTypeId, ObjectId, ...). We used to create useless JDWP ids for events even if they were not reported because of event filtering (thread only, class only, instance only, ...). Now we only create JDWP ids when we know we're going to report an event. Bug: 17343664 (cherry picked from commit d539167b7f11136fe570a77aff2ee4935842007a) Change-Id: I8619e219733fc2fa3569f473b7bd8d9af4181f2b
* Avoid suspending for alloc trace enabling when already suspended.Jeff Hao2014-09-171-2/+2
| | | | | | | | Bug: 17499772 (cherry picked from commit 1d6ee090fddd4bfd35c304d6ceb929d5c529dfcc) Change-Id: Id09809c476c685f0a197ee75bb08638931364efd
* Avoid crash in StringReference.Value JDWP commandSebastien Hertz2014-09-171-4/+18
| | | | | | | | | | | | Checks for null or invalid object id. Also checks whether the corresponding object is a java.lang.String. Bug: 17492221 Bug: 15005460 (cherry picked from commit 29259fa6b0514866d2d4bf57d58c1557b26abbb7) Change-Id: I52673bdef6912a4cccf5a6eeecb6e1e817b9dd6b
* Merge "Check for errors in ThreadGroupReference JDWP commands"Sebastien Hertz2014-09-171-46/+97
|\
| * Check for errors in ThreadGroupReference JDWP commandsSebastien Hertz2014-09-161-46/+97
| | | | | | | | | | | | | | | | | | | | Returns INVALID_OBJECT error for null or invalid object. Also returns INVALID_THREAD_GROUP error when the object is not a java.lang.ThreadGroup. Removes unused Dbg::GetMainThreadGroupId method. Bug: 17503230 Change-Id: Ifae39b0280633836655b22fc212018cb06b65c6c
* | ART: Rename Handle hierarchyAndreas Gampe2014-09-151-1/+1
|/ | | | | | | Bring the names in line with normal OO principles: ConstHandle becomes Handle, and Handle becomes MutableHandle. Change-Id: I0f018eb7ba28bc422e3a23dd73a6cbe6fc2d2044
* Pass current thread as argument to alloc instrumentation.Ian Rogers2014-09-121-4/+1
| | | | | | | Avoids recomputation in the hot allocation path when instrumentation is enabled. Change-Id: Ic6e7d7d0744f4756787f75d21fddd3c50280b588
* Compile time performance improvements focusing on interpret-only.Ian Rogers2014-09-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reduce virtual method dispatch in the method verifier and make more code inline-able. Add a StringPiece with const char* equality operator to avoid redundant StringPieces and strlens. Remove back link from register line to verifier and pass as argument to reduce size of RegisterLine. Remove instruction length from instruction flags and compute from the instruction, again to reduce size. Add suspend checks to resolve and verify to allow for more easy monitor inflation and reduce contention on Locks::thread_list_suspend_thread_lock_. Change ThrowEarlierClassFailure to throw pre-allocated exception. Avoid calls to Thread::Current() by passing self. Template specialize IsValidClassName. Make ANR reporting with SIGQUIT run using checkpoints rather than suspending all threads. This makes the stack/lock analysis less lock error prone. Extra Barrier assertions and condition variable time out is now returned as a boolean both from Barrier and ConditionVariable::Wait. 2 threaded host x86-64 interpret-only numbers from 341 samples: Before change: Avg 176.137ms 99% CI 3.468ms to 1060.770ms After change: Avg 139.163% 99% CI 3.027ms to 838.257ms Reduction in average compile time after change is 20.9%. Slow-down without change is 26.5%. Bug: 17471626 - Fix bug where RegTypeCache::JavaLangObject/String/Class/Throwable could return unresolved type when class loading is disabled. Bug: 17398101 Change-Id: Id59ce3cc520701c6ecf612f7152498107bc40684
* Fix deadlock in VirtualMachine.AllThreadsSebastien Hertz2014-09-111-57/+42
| | | | | | | | | | | | We cannot add any object in the JDWP object registry while holding the Locks::thread_list_lock. Indeed we may need to suspend a thread and take it, causing a deadlock by waiting for ourself on this lock. Bug: 17343664 (cherry picked from commit d35776413901a6a9d478e06dc354ea4f7d962e04) Change-Id: I07d150b95a6d2b62c913bf2ca2ac217911b2f19d
* Don't hold any lock when visiting classes from JDWPSebastien Hertz2014-09-111-1/+2
| | | | | | | | | | | | | | | | Computes reference type ids of all loaded classes without holding the class linker lock. Because computing the JDWP reference type id can cause thread suspension, we can't hold any lock. This is detected in debug build (using libartd.so) and causes an abort. Also adds missing thread safety annotations related to ObjectRegistry::lock_. Bug: 17305632 Bug: 16720689 (cherry picked from commit 95795e286145a4aece5c4a095fa2e7e88ee2115a) Change-Id: If4fb069790a0a3358ad49da8f75c62a54c0f0b56
* Fix numerous issues with DdmVmInternal allocation trackingBrian Carlstrom2014-09-051-45/+60
| | | | | | | | | | | | | | | | | Issues addressed: - Using without JDWP attached caused native crash. - When buffer is full (64k entries), number of entries reported was 0. - Disabling tracking after disabling tracking caused native crash. - Asking for allocations after disabled caused native crash. - Lock ordering issues between mutator lock and alloc tracker lock. Adding 098-ddmc test to cover these cases. Bug: 17392248 (cherry picked from commit a5815065ac0877add9c0db3605d27b4d6c426e61) Change-Id: Ib0bc18dfcdafcc050ab9dceed3d167dd878d1d7a
* Merge "Remove abuse of mirror::Object* to reference special values."Ian Rogers2014-09-041-355/+382
|\
| * Remove abuse of mirror::Object* to reference special values.Ian Rogers2014-09-031-355/+382
| | | | | | | | | | | | | | | | | | | | | | | | | | Remove kInvalidIndirectRefObject, kClearedJniWeakGlobal and ObjectRegistry::kInvalidObject. Handle error conditions by passing in or returning an error value. GetObjectRefType is simplified to be faster and not return invalid references that are not expected according to the spec. Adjust check JNI and jni_internal_test appropriately. Fix cases in the debugger/JDWP of out arguments being passed by reference. Bug: 17376993 Change-Id: I3ce8a28c01827e163f4dc288449959464da788b1
* | Reduce lock contention when debuggingSebastien Hertz2014-09-021-7/+7
|/ | | | | | | | | | | | | | | Uses a ReaderWriterMutex for the breakpoint lock to reduce contention during debugging session. Also adds missing thread safety annotations on fields and methods related to instrumentation and debugging. Bug: 16814665 Bug: 11667502 (cherry picked from commit 59d9d668d4f4286813afe2b4e7c6db839222ce96) Change-Id: I5f1156da8c6cc8316d6db16e6cfb2470fe289ad3