summaryrefslogtreecommitdiff
path: root/libbacktrace/backtrace_test.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove libprocinfo, libbacktrace, libunwindstackBaligh Uddin2020-10-161-1893/+0
| | | | | | | | | | | These projects have moved to a different location. platform/system/core [libprocinfo] -> platform/system/libprocinfo platform/system/core [libbacktrace] -> platform/system/unwinding [libbacktrace] platform/system/core [libunwindstack] -> platform/system/unwinding [libunwindstack] BUG: 163786882 Test: Local build + TH Change-Id: Id6d278d917236df0ffd40b5c32593856e112cb5b
* Cleanup for #inclusivefixit.Christopher Ferris2020-07-281-1/+1
| | | | | | | Bug: 161896447 Test: NA Change-Id: I8bc5b4be29f91b1884017aa3b4f28d91d9cac419
* Load libbacktrace_test.so explicitly.Christopher Ferris2018-10-031-94/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | This guarantees that the shared library is loaded separately. It allows this test to be run without depending on the shared library being somewhere in the system path since the library is now treated as a file to be dlopen'd. This also fixes some bugs in the deleted shared library test code. The previous test was passing when it was really failing. This new test no longer passes incorrectly. Specifically, the original testlib library only had a debug_frame on 32 bit host, which is not mapped into memory. Adding the exceptions option causes a full eh_frame to be generated. Due to the new dlopen code, also, switching to the new isolated test runner. Also, changing the memory leak checker to use mallinfo since the new unwinder allocates everything using the normal allocator. The use of the isolated runner causes the PSS checker to fail because processes come and go which changes the PSS distribution to the process doing the PSS check. Bug: 109876814 Test: All unit tests pass. Change-Id: I1b77a783979a8beaae0c0b12823267f363e07977
* Move libbacktrace off cutils.Elliott Hughes2018-07-111-8/+8
| | | | | | | | | | | There's still <cutils/atomic.h> in a test, but I don't understand why that isn't just std::atomic. Also add a shared tgkill wrapper to libbase. Bug: N/A Test: ran tests Change-Id: Idd4baa1e1670a84b3a8f35803cc5ffe5aae008a6
* Change tests to use a temporary dir for files.Christopher Ferris2018-05-241-42/+45
| | | | | | | | | | | Avoid using hard-coded paths for generated files. This can cause problems if the tests are run in parallel. Also fix a potential race condition in the unwind_through_unreadable_elf_remote test. Test: Ran tests in parallel and normally. Change-Id: Ib42522de49499766a29bda5bfffe737b56715e3f
* Method to avoid skipping frames for local unwinds.Christopher Ferris2018-03-231-3/+39
| | | | | | | | | | | | | In cases where there might be a crash in the unwind library itself, we need a method to avoid skipping these frames or we won't be able to see the actual crash. Added unit test for this behavior. Bug: 74121887 Test: Ran unit tests on host and target. Change-Id: I45825020c174016af39dd8ffdc67acb72a24ad4d
* Use new unwinder for offline in libbacktrace.Christopher Ferris2018-01-291-35/+49
| | | | | | | | | | | | | libbbacktrace changes: - Completely rewrite the BacktraceOffline class to use the new unwinder. - Modify the test data to save ucontext_t data instead of unw_context data. - Convert the previous tests from unw_context data to ucontext_t data. Bug: 65682279 Test: New unit tests pass in libunwindstack. Test: All offline tests continue to pass. Change-Id: I540345c304b20199d46deeb0349a0638a0f3ab2f
* Change all uintptr_t to uint64_t in API.Christopher Ferris2018-01-181-57/+58
| | | | | | | | | | | | | | | | | In order to support the offline unwinding properly, get rid of the usage of non-fixed type uintptr_t from all API calls. In addition, completely remove the old local and remote unwinding code that used libunwind. The next step will be to move the offline unwinding to the new unwinder. Bug: 65682279 Test: Ran unit tests for libbacktrace/debuggerd. Test: Ran debuggerd -b on a few arm and arm64 processes. Test: Ran crasher and crasher64 and verified tombstones look correct. Change-Id: Ib0c6cee3ad6785a102b74908a3d8e5e93e5c6b33
* libbacktrace: export offline unwinding failures.Yabin Cui2017-12-151-24/+24
| | | | | | | | This is to help debugging different offline unwiding failures. Bug: http://b/69383534 Test: run backtrace_test. Change-Id: I5ed4837027a9f17d032925e97e9f5927161444b3
* Demand read load bias for a map.Christopher Ferris2017-12-051-6/+42
| | | | | | | | | | | | | | | | | | | Add a static GetLoadBias method to the Elf object that only reads just enough to get the load bias. Add a method to MapInfo that gets the load bias. First attempt to get it if the elf object already exists. If no elf object was created, use the new static method to get the load bias. In BacktraceMap, add a custom iterator so that when code dereferences a map element, that's when the load bias will be retrieved if it hasn't already been set. Bug: 69871050 Test: New unit tests, verify tombstones have non-zero load bias values for Test: libraries with a non-zero load bias. Change-Id: I125f4abc827589957fce2f0df24b0f25d037d732
* Allow multiple threads sharing a map to unwind.Christopher Ferris2017-11-281-43/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | Add a mutex in MapInfo, and a mutex in Elf. Lock the creation of an Elf file using the MapInfo mutex, and lock when calling Step, GetFunctionName, or GetSoname since they can modify information in the object. It might be beneficial to use a fine grained lock in the future. Change the Maps object to contain a vector of MapInfo pointers rather than the total objects. This avoids copying this data around. Add a test to libbacktrace to verify that sharing a map while doing unwinds in different threads works. Add concurrency tests in libunwindstack to verify the locking works. Add always inline to the RegsGetLocal arm and aarch64 functions. I had a case where clang did not inline the code, so make sure this is specified. Bug: 68813077 Test: New unit tests to cover the case. Passes all unit tests. Test: Ran a monkey test while dumping bugreports and verified that Test: no crashes in libunwind. Test: Remove the locking and verified that all of the concurrenty tests fail. Change-Id: I769e728c676f6bdae9e64ce4cdc03b6749beae03
* Switch libbacktrace new unwinder.Christopher Ferris2017-10-301-99/+6
| | | | | | | | | | | | | Update the backtrace leak tests to share a map since this is the most common way it will be used, and it runs much faster. Remove the CreateNew functions, and references to them. Remove benchmarks of CreateNew functions. Test: Builds, ran new unit tests, ran art tests. Change-Id: I4a25a412f1a74c6d43aebbebbf32ead20ead8f94
* libbacktrace: correctly number frames when skipping.Josh Gao2017-10-261-0/+16
| | | | | | | | Correct for the number of skipped frames when unwinding with libunwindstack. Test: backtrace_test32 --gtest_filter="unwind_frame_skip_*" Change-Id: I9528977104fde3c4ec792a6db1ada24ed571b867
* Add a new unwind method on error.Christopher Ferris2017-09-221-22/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If a function crashes by jumping into unexecutable code, the old method could not unwind through that. Add a fallback method to set the pc from the default return address location. In addition, add a new finished check for steps. This will provide a method to indicate that this step is the last step. This prevents cases where the fallback method might be triggered incorrectly. Update the libbacktrace code to unwind using the new methodology. Update the unwind tool to use the new unwind methodology. Add a new option to crasher that calls through a null function. Create a new object, Unwinder, that encapsulates the a basic unwind. For now, libbacktrace will still use the custom code. Added new unit tests to cover the new cases. Also add a test that crashes calling a nullptr as a function, and then has call frames in the signal stack. Bug: 65842173 Test: Pass all unit tests, verify crasher dumps properly. Change-Id: Ia18430ab107e9f7bdf0e14a9b74710b1280bd7f4
* Update the tests.Christopher Ferris2017-08-281-25/+108
| | | | | | | | | | | | | - Change all load_base to load_bias in the test files. - Add the test files to the backtrace_test. - Add a function to get the path to the test libraries. - Change aarch64 to arm64 for offline test code. - Modify the offline tests so that they can be easily updated when unwinding on any arch for any other arch is possible. - Add tests of CreateNew for remote debugging. Test: Ran unit tests on host and angler. Change-Id: Id6c5afe73aeb2ac22463dd81f061799fcb1c178b
* Cleanup the libbacktrace interface a bit.Christopher Ferris2017-07-191-6/+14
| | | | | | | | | | | | - Change the field name load_base to load_bias (which is what it really is). - Add a rel_pc field so that callers do not need to compute it themselves. - Remove the BacktraceMap::GetRelativePc() since nobody should need to compute this themselves. Bug: 23762183 Test: Compiles and unit tests pass (debuggerd, libbacktrace). Change-Id: I2cb579767120adf08c407a58f3c487ee3f2b45fc
* Test unwinding through a signal handler.Christopher Ferris2017-03-231-7/+146
| | | | | | | | | Also make backtrace_testlib.c C++. Bug: 34468756 Test: Ran new unit test on host x86, host x86_64, angler (32 bit, 64 bit), Test: fugu. Change-Id: Ia810f596c2df56cd56e8ab17e6c19be0c48d737f
* Do not access device maps.Christopher Ferris2017-03-221-0/+166
| | | | | | | | | | | | | It's possible that a device map has memory controlled by a single entry device driver. Thus, you can deadlock if a process is touching that device memory and we try to unwind it and also touch that device memory. Simply skip any attempts to step through, or get function names from device memory maps. Bug: 36130325 Test: Ran new unit tests, ran bionic unit tests, ran art ThreadStress. Change-Id: Ibc62d7ec8106c619ee08968f05e04aea55d7cbfa
* Allow calling GetFunctionName before unwinding.Christopher Ferris2017-03-211-84/+88
| | | | | | | | | | | | | | | Some extra initialization needs to occur before calling the local/remote GetFunctioneName. Also, cleanup the test code a bit: - Make all local functions static. - Create a common function to create and finish remote processes. - Remove unused function. - Fix the formatting a bit by making it match clang format. Test: Ran the unit tests. Change-Id: I998bed1378d582df59fdf9263df6f208db5d795a
* Fix race condition updating local map data.Christopher Ferris2016-06-161-0/+1
| | | | | | | | | | | | If the underlying local map changes, it's possible for multiple threads to try and modify the map data associated with the UnwindLocalMap object. Add a lock when generating the local map to avoid this problem. In addition, add a read lock whenever any caller gets the maps iterator. Updated all iterator callers to make this lock. Bug: 29387050 Change-Id: Ie34822c3d8fd3bdb3dd126aeeb399969c36508c1
* Fix misc-macro-parentheses warnings in adb, debuggerd, libbacktrace.Chih-Hung Hsieh2016-05-181-1/+1
| | | | | Bug: 28705665 Change-Id: I469b2a882f6d1f399bfc22c75a26da245991fc33
* Add error reporting mechanism for failing Unwind.Christopher Ferris2016-03-101-0/+32
| | | | | | | | | Remove the logging of an error if a thread disappears before the unwind can begin. This can happen, so allow the caller to determine if this is really a problem worth logging. Bug: 27449879 Change-Id: Ie81718d53fb0e519fa0a7db9fd5f314b72bfa431
* Don't fail if the new pss is less than stable.Christopher Ferris2016-03-071-3/+3
| | | | | | | Sometimes, the new pss is significantly less than the stable pss. Do not fail if this case occurs. Change-Id: Ic7da87275a821818e375d05cac10e84c62710c5e
* system/core: Cleanup direct calls to opendir by containing in aJames Hawkins2016-02-181-3/+2
| | | | | | | std::unique_ptr. Bug: 26643633 Change-Id: Ia3491fdbff086558da694ae949cf08e4c89d0307
* Modify tests to use executable memory.Christopher Ferris2016-01-151-2/+2
| | | | | | | | | The check_unreadble_elf_* tests only create a readable map. I changed libunwind to disallow unwinding through non-executable maps, so make the maps executable too. Bug: 26589772 Change-Id: Idbe6426ac4d3243779b819c8f1aebdcdacb0669f
* Track rename of base/ to android-base/.Elliott Hughes2015-12-041-2/+1
| | | | Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
* Change the way some maps are printed.Christopher Ferris2015-11-301-4/+17
| | | | | | | | | | | | | Before, an anonymous map wound up printing the pc as relative. Unfortunately, this meant that it was impossible to tell the actual pc. The new code prints the map name as <anonymous:map_start> and still prints the pc as relative. In addition, add the start of the map for map names that begin with a '[' character. Bug: 25844836 Change-Id: Ie0b6149dde258fe13f0e5a3e5739d85374512f4b
* am e0ab2322: Display the map offset for each frame.Christopher Ferris2015-08-201-0/+9
|\ | | | | | | | | * commit 'e0ab23223a1c3110c9550136b8a119b4c30ec066': Display the map offset for each frame.
| * Display the map offset for each frame.Christopher Ferris2015-08-201-0/+9
| | | | | | | | | | | | | | | | | | | | | | The dlopen of a shared library in an apk results in large map offsets. Unfortunately, the current way that the frame data is printed, it's impossible to tell what the relative pc is relative to. With the addition of the offset, it's possible to figure out what the relative pc actually references. Bug: 23348999 Change-Id: Ia51b669ea3f810158cfd0d71d9ae89bf9a3170d3
| * Add tests for elf unwinding in memory.Christopher Ferris2015-05-131-0/+298
| | | | | | | | | | | | | | Bug: 19517541 (cherry picked from commit 67aba6881d8857d3017e11695207eb2ade45a274) Change-Id: I914636ccd814e041475b6b2d81119cac1745a9ff
| * Remove libbacktrace definition of gettid.Dan Albert2015-05-131-8/+9
| | | | | | | | | | | | | | | | | | | | | | Also simplifies the Darwin implementation of gettid, because apparently libbacktrace had a better way of doing it. Bug: 19517541 (cherry picked from commit 23f750b068ddf5b20fb5d153a798b22562368992) Change-Id: I2f888e8ed7a2f5719973786cbcbb399a81867ee9
| * Fix small ptrace reads.Christopher Ferris2015-05-061-9/+29
| | | | | | | | | | | | | | | | | | | | | | The BacktracePtrace::Read function crashes if the number of bytes to read is less than the number of bytes needed to align the read to a word_t boundary. Fix this and add a test for this case. Change-Id: I50808849ece44928f65dba1d25309e3885c829a2 (cherry picked from commit 944f417ccb86441060ffb670b4bdc2975fda08fc)
| * Add load base to map for relocation packing.Christopher Ferris2015-05-011-0/+11
| | | | | | | | | | | | | | | | | | | | The new linker relocation packing support uses non-zero load bases, so we better handle them properly. Also print out the load base for a map if it's non-zero. Bug: 20687795 Change-Id: Iec2d1db2051e7b4a278c1dfa57d745128a7f2974
* | Use delete[] to de-allocate pointers from new[]Pirama Arumuga Nainar2015-07-091-2/+2
| | | | | | | | | | | | | | | | | | Upstream clang has a new diagnostic, '-Wmismatched-new-delete' to generate a warning (that becomes an error with -Werror) when delete is used to deallocate pointers created with 'new[]'. This patch fixes 'delete's that trigger this warning/error. Change-Id: I7551e856b4b13bfae4cb78b5664d8652322683cf
* | Add tests for elf unwinding in memory.Christopher Ferris2015-05-121-0/+298
| | | | | | | | | | Bug: 19517541 Change-Id: Ib42360a82934ff7103e2ccb64c1105c59aa3fdea
* | Fix small ptrace reads.Christopher Ferris2015-05-061-9/+29
| | | | | | | | | | | | | | | | | | | | The BacktracePtrace::Read function crashes if the number of bytes to read is less than the number of bytes needed to align the read to a word_t boundary. Fix this and add a test for this case. Change-Id: I50808849ece44928f65dba1d25309e3885c829a2
* | Add load base to map for relocation packing.Christopher Ferris2015-05-011-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | The new linker relocation packing support uses non-zero load bases, so we better handle them properly. Also print out the load base for a map if it's non-zero. Bug: 20687795 (cherry picked from commit 329ed7dae49eba09bdf865dd999d1a7e73bb9687) Change-Id: Ibc37d8c8bb032820dca4e7531184349ba6d402d2
* | Remove libbacktrace definition of gettid.Dan Albert2015-04-301-8/+9
|/ | | | | | | Also simplifies the Darwin implementation of gettid, because apparently libbacktrace had a better way of doing it. Change-Id: I9e14f9176b167405a5aaa5b8a0db0327c7126271
* Update the test for better output on error.Christopher Ferris2015-04-021-14/+31
| | | | Change-Id: Id3b0b96a33441ce5d908aac38e639ac3598a7a89
* Discards frames for code within library.Christopher Ferris2015-04-011-0/+18
| | | | | | | | When doing a local unwind, do not include the frames that come from either libunwind or libbacktrace. Bug: 11518609 Change-Id: I0ec8d823aebbfa0903e61b16b7e5663f3fd65e78
* Refactor the code.Christopher Ferris2015-03-311-9/+22
| | | | | | | | The object hierarchy was confusing and convoluted. This removes a lot of unnecessary code, and consolidates the BacktraceCurrent and BacktraceThread code into BacktraceCurrent. Change-Id: I01c8407d493712a48169df49dd3ff46db4a7c3ae
* Add variable length read to Backtrace.Christopher Ferris2015-03-171-77/+238
| | | | | | | | | | Included tests for this new feature. Changed the NULLs to nullptr in backtrace_test. Changed UniquePtr to std::unique_ptr in backtrace_test. Change-Id: I92375465b8f8ba84589834cc162db5915bf1be81
* Move map data into backtrace data proper.Christopher Ferris2015-02-061-10/+24
| | | | | | | | | | | The backtrace structure used to include a pointer to a backtrace_map_t that represented the map data for a particular pc. This introduced a race condition where the pointer could be discarded, but the backtrace structure still contained a pointer to garbage memory. Now all of the map information is right in the structure. Bug: 19028453 Change-Id: If7088a73f3c6bf1f3bc8cdd2bb4b62e7cab831c0
* Convert futex to cond wait.Christopher Ferris2014-11-141-5/+12
| | | | | | | | | | | | | Switch to the better supported pthread_cond to handle the Wait/Wake functions. Also, increase the number of simultaneous threads in the thread tests. Bug: 18381207 (cherry picked from commit db44538387b08f367fc2419653639866f4c2fbd6) Change-Id: Id326a7a7b92cb61573def3f761597c40f3ef2f4b
* Rewrite unwind thread handling.Christopher Ferris2014-05-081-0/+43
| | | | | | | | | | | | | | | | | | This new version doesn't require any specialized thread implementation, it uses the Current implementation to do its job. In addition, it runs much faster when multiple threads are trying to unwind at the same time since the global signal lock is held for only a small amount of time. Even running through the threads one at a time should be faster since it no longer requires two passes through the unwound stacks. The new code now allows multiple simultaneous unwinds of the same thread. Finally, add the ability to unwind from a ucontext_t passed in. This functionality doesn't work for remote unwinds yet. Change-Id: I4d181d7ca5ffd2acfd1686e668e6d21e36b425cb
* Use real time signal for threads instead of SIGURG.Christopher Ferris2014-04-301-2/+11
| | | | | | | This guarantees that any application is not also using this signal for some other purpose. Change-Id: I7c9bbb0ec8bb4e13322ecda951bcd43c6bf6ee1a
* Create an UnwindMapLocal object.Christopher Ferris2014-04-031-6/+141
| | | | | | | | | | | | | The way libunwind handles local unwinds is different from remote unwinds, so create a new map object to handle the differences. Add new test to verify the map data is being generated correctly. Add new tests to check for leaks. Refactor the BACK_LOGW code into a single header file. Change-Id: I01f3cbfc4b927646174ea1b614fa25d23b9b3427
* Re-enable libunwind for arm.Christopher Ferris2014-01-281-6/+47
| | | | | | | | | | Update to handle the new optimized way that libunwind works. In addition, a small refactor of the BacktraceMap code. A few new tests of for good measure. Change-Id: I2f9b4f5ad5a0dfe907b31febee76e4b9b94fb76f
* Rewrite libbacktrace to be all C++.Christopher Ferris2014-01-161-38/+57
| | | | | | | | | | | | | This includes removing the map_info.c source and replacing it with the BacktraceMap class to handle all map related code. Change all callers of libbacktrace map functionality. Also modify the corkscrew thread code so that it doesn't need to build the map twice (once in the corkscrew format and once in the libbacktrace format). Change-Id: I32865a39f83a3dd6f958fc03c2759ba47d12382e
* Next phase of the move, reformat use C++ features.Christopher Ferris2014-01-131-179/+147
| | | | | | | | | | | | | | | | | Use the libbacktrace C++ interface instead of the C interface in debuggerd. Reformat the debuggerd code to be closer to Google C++ style. Fix all debuggerd casts to be C++ casts. Add a frame number to the frame data structure for ease of formatting and add another FormatFrameData function. Change the format_test to use the new FormatFrameData function. Modify all of the backtrace_test to use the C++ interface. Change-Id: I10e1610861acf7f4a3ad53276b74971cfbfda464