summaryrefslogtreecommitdiff
path: root/libunwindstack/tests/MapInfoCreateMemoryTest.cpp
AgeCommit message (Collapse)Author
2020-10-16Remove libprocinfo, libbacktrace, libunwindstackBaligh Uddin
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
2020-01-22Properly handle empty map after read-only map.Christopher Ferris
Recently, the maps for an elf in memory might show up looking like: f0000-f1000 0 r-- /system/lib/libc.so f1000-f2000 0 --- f2000-f3000 1000 r-x /system/lib/libc.so f3000-f4000 2000 rw- /system/lib/libc.so The problem is that there is logic in the code that assumed that the map before the execute map must be the read-only map. In the case above, this is not true. Add a new prev_real_map that will point to the previous map that is not one of these empty maps. This will fix the backtraces that look like this: #00 pc 0000000000050d58 /apex/com.android.runtime/lib64/bionic/libc.so!libc.so (offset 0x50000) (syscall+24) (BuildId: 5252408bf30e395d49ee270b54c77ca4) To get rid of the !libc.so and the offset value, which is not correct. Added new unit tests to verify this. Added new offline test which an empty map between read-only and execute map. Before this change, the backtraces had lines like libc.so!libc.so (offset XXX) would be present. Bug: 148075852 Test: Ran unit tests. Change-Id: Ie04bfc96b8f91ed885cb1e655cf1e346efe48a45
2019-07-17Move to isolated testing.Christopher Ferris
Modify the MapInfoCreateMemoryTest to work in the isolated mode. Test: Ran unit tests on host/target. Change-Id: I84e01d96e852acd813e0f203b4a207cfaf8ca556
2019-06-20Switch case to suite to follow new gtest naming.Christopher Ferris
Bug: 135528735 Test: All unit tests pass. Change-Id: I1f3dc6fe381ec557b6b7bc5cb1c58d210efa63da
2019-04-18Add indicator that an elf is memory backed.Christopher Ferris
Modify the unwinder library to indicate that at least one of the stack frames contains an elf file that is unreadable. Modify debuggerd to display a note about the unreadable frame and a possible way to fix it. Bug: 129769339 Test: New unit tests pass. Test: Ran an app that crashes and has an unreadable file and verified the Test: message is displayed. Then setenforce 0 and verify the message is Test: not displayed. Change-Id: Ibc4fe1d117e9b5840290454e90914ddc698d3cc2
2019-03-12Fix missing offset for apk.Christopher Ferris
The elf_start_offset field in a map_info was not set in one path. Added new offline test for this, and update a few unit tests. Bug: 128442792 Test: New unit tests pass. Change-Id: I2c6ac1b5271a99aa0e8c4b6342a5970199185112
2018-12-18Fix offsets when shared lib split across maps.Christopher Ferris
The linker was modified so that a shared library has a read-only map, then a read-execute map to represent the whole shared library. When backtraces are created, then the offsets are set incorrectly for backtraces. For example, all backtraces wind up with an offset now, and a shared library loaded out of an apk shows the wrong offset. Changes: - Fix the FormatFrame function which was putting the offset before the map name. - Refactor the Maps and MapInfo classes to keep track of the previous map instead of all maps. This was the only map that was ever needed. - Modify the unwind_for_offline tool to capture both the read-only and read-execute map when using the read-only segment option. Bug: 120981155 Test: Updated unit tests pass. Test: Unwinds on device don't show the offsets everywhere any more. Change-Id: I75b3727221be9c20316dfdcd7a1c6d242d7ce948
2018-12-11Fix handling of ro segments for embedded libs.Christopher Ferris
When a shared library is loaded directly from an apk, the new way the linker splits a shared library into a read-only and execute segment broke unwinding. Modify the code to handle this case. Other changes: - Modify the algorithm for finding read-only map entries. Before, the code would search the entire map for the closest offset. Now it simply looks at the previous map. I did this because the old code was too lenient and might still work even if the linker changes. I want this to break if the linker behavior changes so that I can analyze the change. - Update the tools to use PTRACE_SEIZE instead of PTRACE_ATTACH since PTRACE_ATTACH doesn't work in all cases. - Small refactor of the GetFileMemory function. - Add new unit test cases and new offline unwind test cases. Bug: 120618231 Test: Ran new unit tests, ran original failing test. Change-Id: I4bade55cf33220d52f1d5e9b0cbbbcc8419669d4
2018-11-14switch to using android-base/file.h instead of android-base/test_utils.hMark Salyzyn
Test: compile Bug: 119313545 Change-Id: I4f7ad84743e974b4b4d1d7256088f6c8b749a237
2018-10-03Implement support for linker rosegment option.Christopher Ferris
The rosegment linker option results in two maps containing the elf data existing. One is an execute map where the code lives, and the other is the read-only segment which contains the elf header information. If the file backing a shared library in memory is not readable, then the new code will attempt to find the read-only map that has the same name as the current execute segment, and that is at offest zero in the file. Add new unit tests for this functionality. Add the missing MapInfoCreateMemoryTest.cpp to the list of tests. Bug: 109657296 Test: Pass new unit tests. Test: All unit libbacktrace/libunwindstack tests pass with rosegment enabled. Change-Id: If8f69e4a067d77b3f2a7c31e2e5cd989a0702a8c
2017-12-02Merge changes I53c2c560,I7d845ac5,I8b11d923Treehugger Robot
* changes: unwindstack: rename Memory::ReadPartially to Read. unwindstack: rename Memory::Read to ReadFully. unwindstack: add Memory::ReadPartially.
2017-11-28Allow multiple threads sharing a map to unwind.Christopher Ferris
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
2017-11-15unwindstack: rename Memory::Read to ReadFully.Josh Gao
Rename Memory::Read to ReadFully to match its semantics with that of android::base. ReadPartially will be renamed to Read in a follow up commit, kept intentionally separate so that there aren't any callers accidentally switched from ReadFully to Read. Test: treehugger Change-Id: I7d845ac5244c3025d92c8512e960e5d0d1da05af
2017-09-05Add a method to share the process memory object.Christopher Ferris
New function to create the process memory object. This allows for a future where different remote process memory objects could be created depending on the way remote memory can be created. Even different local memory objects that access memory without doing any checks. It also allows MemoryRange objects to share one single process memory object and could help if the process memory object caches data. Small changes to MapInfo::CreateMemory to when some errors are detected. - Always check if the map is a device map, instead of only if the name is not empty. - Check if a memory map is readable before creating the memory from process memory. Bug: 23762183 Test: Ran unit tests, unwound on device using the new code. Change-Id: I12a93c2dc19639689a528ec41c67bfac74d431b3
2017-08-30Add proper support for embedded elf files.Christopher Ferris
- Add a method to get the max size of an elf file by reading the section header offset + size. This will properly map an elf file embedded into an apk, instead of just mapping in what is done by the dynamic linker. It does assume that the section headers are at the end of the elf file. - Add new tests for the above functionality. - Update the unwind_symbols tool to take an address for finding a function instead of dumping the entire symbol table. Bug: 23762183 Test: Unit tests pass, unwind through the camera process and verify Test: the GoogleCamera.apk shows some function names. Change-Id: I00c021680fe1d43b60d652bf91bbf6667d9617be
2017-07-14Make the library usable as a library.Christopher Ferris
- Add namespace unwindstack everywhere so that it's easier for other code to use the library. - Move some of the header files into include/unwindstack so that they can be exposed. - Modify the headers so that only a limited number need to be exposed. - Update the tools to use the new headers. - Add a GetLoadBias() call on the Elf object. This prevents the need to get the interface object out of the Elf object. - Move the GetRelPc() call out of the Reg class, to the Elf class. It's not always the case that a Reg object will be around when you want to get a relative pc. The tests for this moved to ElfTest.cpp. Bug: 23762183 Test: Unit tests pass. Change-Id: Iac609dac1dd90ed83d1a1e24ff2579c96c023bc3
2017-07-11Add full support for initing registers.Christopher Ferris
- Fixes a few bugs in untested functionality. - Add tests for the way the register handling code is used. - Fix a few tests that were not reaping child processes. Bug: 23762183 Test: Ran unit tests on host (32 bit and 64 bit). Test: Ran unit tests on angler (32 bit and 64 bit). Change-Id: I573d6617b4f1561f6e8494d7213c52086d112d97
2017-06-30Init .gnu_debugdata in GetElf().Christopher Ferris
- Modify the tests to share some code for the generation of the elf data. - Move the gnu_debugdata files into a separate directory. - Add tests for GetElf(). - Move the CreateMemory() tests and the GetElf() tests into separate files. Bug: 23762183 Test: New unit tests pass. Change-Id: Ie3380296bb49753c2ac8801cfa11f93d6ff7121d