platform_system_core/libbacktrace/BacktracePtrace.h
Christopher Ferris e328673a30 Add method to detect remote read function to use.
The process_vm_read function is much faster than ptrace, but sometimes
that will not work on a remote process. Modify the libunwindstack
MemoryRemote object to figure out which one it can use.

Wrote new unit test to verify this checking behavior.

Modify libbacktrace so that the read from libunwind is used instead of
using the default ptrace calls.

Add some benchmarks to libbacktrace to compare the two different methods.

Test: Ran unit tests libbacktrace/libunwindstack/debuggerd.
Test: Ran debuggerd -b <SYSTEM_SERVER_PID>
Test: Ran debuggerd -b <MEDIACODEC PID>
Test: Ran debuggerd -b <RANDOM_PID>
Test: Used crasher to create tombstones and verified stack data is
Test: dumped properly.
Change-Id: If75ca238289532dd8e1de430d569cabb2523380a
2017-12-07 19:00:00 -08:00

37 lines
1.1 KiB
C++

/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBBACKTRACE_BACKTRACE_PTRACE_H
#define _LIBBACKTRACE_BACKTRACE_PTRACE_H
#include <stdint.h>
#include <sys/types.h>
#include <backtrace/Backtrace.h>
class BacktraceMap;
class BacktracePtrace : public Backtrace {
public:
BacktracePtrace(pid_t pid, pid_t tid, BacktraceMap* map) : Backtrace(pid, tid, map) {}
virtual ~BacktracePtrace() {}
size_t Read(uintptr_t addr, uint8_t* buffer, size_t bytes) override;
bool ReadWord(uintptr_t ptr, word_t* out_value) override;
};
#endif // _LIBBACKTRACE_BACKTRACE_PTRACE_H