Make pbtombstone a host tool.
This is preparation for the next patch, which adds host-side symbolization capabilities to pbtombstone. Bug: 328531087 Change-Id: Id5813ae6b121af784643b1ed76084e49fdca118b
This commit is contained in:
parent
d7f4fbf778
commit
39a1730a82
15 changed files with 186 additions and 49 deletions
|
|
@ -200,22 +200,18 @@ cc_library {
|
|||
ramdisk_available: true,
|
||||
recovery_available: true,
|
||||
vendor_ramdisk_available: true,
|
||||
host_supported: true,
|
||||
|
||||
local_include_dirs: ["libdebuggerd/include"],
|
||||
export_include_dirs: ["libdebuggerd/include"],
|
||||
|
||||
srcs: [
|
||||
"libdebuggerd/tombstone_proto_to_text.cpp",
|
||||
],
|
||||
|
||||
header_libs: [
|
||||
"bionic_libc_platform_headers",
|
||||
"libdebuggerd/utility_host.cpp",
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
"libbase",
|
||||
"liblog_for_runtime_apex",
|
||||
"libunwindstack",
|
||||
],
|
||||
|
||||
whole_static_libs: [
|
||||
|
|
@ -223,6 +219,10 @@ cc_library {
|
|||
"libprotobuf-cpp-lite",
|
||||
],
|
||||
|
||||
shared_libs: [
|
||||
"liblog",
|
||||
],
|
||||
|
||||
apex_available: [
|
||||
"//apex_available:platform",
|
||||
"com.android.runtime",
|
||||
|
|
@ -331,15 +331,15 @@ cc_library_static {
|
|||
|
||||
cc_binary {
|
||||
name: "pbtombstone",
|
||||
host_supported: true,
|
||||
defaults: ["debuggerd_defaults"],
|
||||
srcs: ["pbtombstone.cpp"],
|
||||
static_libs: [
|
||||
"libbase",
|
||||
"libdebuggerd",
|
||||
"libdebuggerd_tombstone_proto_to_text",
|
||||
"liblog",
|
||||
"libprotobuf-cpp-lite",
|
||||
"libtombstone_proto",
|
||||
"libunwindstack",
|
||||
],
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@
|
|||
#include "crash_test.h"
|
||||
#include "debuggerd/handler.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "libdebuggerd/utility_host.h"
|
||||
#include "protocol.h"
|
||||
#include "tombstoned/tombstoned.h"
|
||||
#include "util.h"
|
||||
|
|
@ -741,8 +742,6 @@ TEST_F(CrasherTest, mte_multiple_causes) {
|
|||
}
|
||||
|
||||
#if defined(__aarch64__)
|
||||
constexpr size_t kTagGranuleSize = 16;
|
||||
|
||||
static uintptr_t CreateTagMapping() {
|
||||
// Some of the MTE tag dump tests assert that there is an inaccessible page to the left and right
|
||||
// of the PROT_MTE page, so map three pages and set the two guard pages to PROT_NONE.
|
||||
|
|
|
|||
|
|
@ -67,10 +67,6 @@ void engrave_tombstone_proto(Tombstone* tombstone, unwindstack::AndroidUnwinder*
|
|||
const Architecture* guest_arch,
|
||||
unwindstack::AndroidUnwinder* guest_unwinder);
|
||||
|
||||
bool tombstone_proto_to_text(
|
||||
const Tombstone& tombstone,
|
||||
std::function<void(const std::string& line, bool should_log)> callback);
|
||||
|
||||
void fill_in_backtrace_frame(BacktraceFrame* f, const unwindstack::FrameData& frame);
|
||||
void set_human_readable_cause(Cause* cause, uint64_t fault_addr);
|
||||
#if defined(__aarch64__)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (C) 2024 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
class Tombstone;
|
||||
|
||||
bool tombstone_proto_to_text(
|
||||
const Tombstone& tombstone,
|
||||
std::function<void(const std::string& line, bool should_log)> callback);
|
||||
|
|
@ -91,10 +91,3 @@ bool signal_has_si_addr(const siginfo_t*);
|
|||
void get_signal_sender(char* buf, size_t n, const siginfo_t*);
|
||||
const char* get_signame(const siginfo_t*);
|
||||
const char* get_sigcode(const siginfo_t*);
|
||||
|
||||
// Number of bytes per MTE granule.
|
||||
constexpr size_t kTagGranuleSize = 16;
|
||||
|
||||
// Number of rows and columns to display in an MTE tag dump.
|
||||
constexpr size_t kNumTagColumns = 16;
|
||||
constexpr size_t kNumTagRows = 16;
|
||||
|
|
|
|||
31
debuggerd/libdebuggerd/include/libdebuggerd/utility_host.h
Normal file
31
debuggerd/libdebuggerd/include/libdebuggerd/utility_host.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright 2024, 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
std::string describe_tagged_addr_ctrl(long ctrl);
|
||||
std::string describe_pac_enabled_keys(long keys);
|
||||
|
||||
// Number of bytes per MTE granule.
|
||||
constexpr size_t kTagGranuleSize = 16;
|
||||
|
||||
// Number of rows and columns to display in an MTE tag dump.
|
||||
constexpr size_t kNumTagColumns = 16;
|
||||
constexpr size_t kNumTagRows = 16;
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "libdebuggerd/scudo.h"
|
||||
#include "libdebuggerd/tombstone.h"
|
||||
#include "libdebuggerd/utility_host.h"
|
||||
|
||||
#include "unwindstack/AndroidUnwinder.h"
|
||||
#include "unwindstack/Memory.h"
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <android-base/test_utils.h>
|
||||
|
||||
#include "libdebuggerd/tombstone.h"
|
||||
#include "libdebuggerd/tombstone_proto_to_text.h"
|
||||
#include "tombstone.pb.h"
|
||||
|
||||
using CallbackType = std::function<void(const std::string& line, bool should_log)>;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#define LOG_TAG "DEBUG"
|
||||
|
||||
#include "libdebuggerd/tombstone.h"
|
||||
#include "libdebuggerd/tombstone_proto_to_text.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@
|
|||
|
||||
#include "libdebuggerd/open_files_list.h"
|
||||
#include "libdebuggerd/utility.h"
|
||||
#include "libdebuggerd/utility_host.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "tombstone.pb.h"
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <libdebuggerd/tombstone.h>
|
||||
#include <libdebuggerd/tombstone_proto_to_text.h>
|
||||
#include <libdebuggerd/utility_host.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
|
|
@ -30,8 +31,6 @@
|
|||
#include <android-base/stringprintf.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <android-base/unique_fd.h>
|
||||
#include <bionic/macros.h>
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include "tombstone.pb.h"
|
||||
|
||||
|
|
@ -57,28 +56,6 @@ static std::string describe_end(long value, std::string& desc) {
|
|||
return desc.empty() ? "" : " (" + desc.substr(2) + ")";
|
||||
}
|
||||
|
||||
static std::string describe_tagged_addr_ctrl(long value) {
|
||||
std::string desc;
|
||||
DESCRIBE_FLAG(PR_TAGGED_ADDR_ENABLE);
|
||||
DESCRIBE_FLAG(PR_MTE_TCF_SYNC);
|
||||
DESCRIBE_FLAG(PR_MTE_TCF_ASYNC);
|
||||
if (value & PR_MTE_TAG_MASK) {
|
||||
desc += StringPrintf(", mask 0x%04lx", (value & PR_MTE_TAG_MASK) >> PR_MTE_TAG_SHIFT);
|
||||
value &= ~PR_MTE_TAG_MASK;
|
||||
}
|
||||
return describe_end(value, desc);
|
||||
}
|
||||
|
||||
static std::string describe_pac_enabled_keys(long value) {
|
||||
std::string desc;
|
||||
DESCRIBE_FLAG(PR_PAC_APIAKEY);
|
||||
DESCRIBE_FLAG(PR_PAC_APIBKEY);
|
||||
DESCRIBE_FLAG(PR_PAC_APDAKEY);
|
||||
DESCRIBE_FLAG(PR_PAC_APDBKEY);
|
||||
DESCRIBE_FLAG(PR_PAC_APGAKEY);
|
||||
return describe_end(value, desc);
|
||||
}
|
||||
|
||||
static const char* abi_string(const Architecture& arch) {
|
||||
switch (arch) {
|
||||
case Architecture::ARM32:
|
||||
|
|
@ -113,6 +90,13 @@ static int pointer_width(const Tombstone& tombstone) {
|
|||
}
|
||||
}
|
||||
|
||||
static uint64_t untag_address(Architecture arch, uint64_t addr) {
|
||||
if (arch == Architecture::ARM64) {
|
||||
return addr & ((1ULL << 56) - 1);
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
||||
static void print_thread_header(CallbackType callback, const Tombstone& tombstone,
|
||||
const Thread& thread, bool should_log) {
|
||||
const char* process_name = "<unknown>";
|
||||
|
|
@ -321,7 +305,8 @@ static void print_tag_dump(CallbackType callback, const Tombstone& tombstone) {
|
|||
|
||||
size_t tag_index = 0;
|
||||
size_t num_tags = tags.length();
|
||||
uintptr_t fault_granule = untag_address(signal.fault_address()) & ~(kTagGranuleSize - 1);
|
||||
uintptr_t fault_granule =
|
||||
untag_address(tombstone.arch(), signal.fault_address()) & ~(kTagGranuleSize - 1);
|
||||
for (size_t row = 0; tag_index < num_tags; ++row) {
|
||||
uintptr_t row_addr =
|
||||
(memory_dump.begin_address() + row * kNumTagColumns * kTagGranuleSize) & kRowStartMask;
|
||||
|
|
@ -369,7 +354,7 @@ static void print_memory_maps(CallbackType callback, const Tombstone& tombstone)
|
|||
|
||||
const Signal& signal_info = tombstone.signal_info();
|
||||
bool has_fault_address = signal_info.has_fault_address();
|
||||
uint64_t fault_address = untag_address(signal_info.fault_address());
|
||||
uint64_t fault_address = untag_address(tombstone.arch(), signal_info.fault_address());
|
||||
bool preamble_printed = false;
|
||||
bool printed_fault_address_marker = false;
|
||||
for (const auto& map : tombstone.memory_mappings()) {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#define LOG_TAG "DEBUG"
|
||||
|
||||
#include "libdebuggerd/utility.h"
|
||||
#include "libdebuggerd/utility_host.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
|
|
|||
101
debuggerd/libdebuggerd/utility_host.cpp
Normal file
101
debuggerd/libdebuggerd/utility_host.cpp
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright 2024, 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.
|
||||
*/
|
||||
|
||||
#include "libdebuggerd/utility_host.h"
|
||||
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <android-base/stringprintf.h>
|
||||
|
||||
using android::base::StringPrintf;
|
||||
|
||||
#ifndef PR_MTE_TAG_SHIFT
|
||||
#define PR_MTE_TAG_SHIFT 3
|
||||
#endif
|
||||
|
||||
#ifndef PR_MTE_TAG_MASK
|
||||
#define PR_MTE_TAG_MASK (0xffffUL << PR_MTE_TAG_SHIFT)
|
||||
#endif
|
||||
|
||||
#ifndef PR_MTE_TCF_ASYNC
|
||||
#define PR_MTE_TCF_ASYNC (1UL << 2)
|
||||
#endif
|
||||
|
||||
#ifndef PR_MTE_TCF_SYNC
|
||||
#define PR_MTE_TCF_SYNC (1UL << 1)
|
||||
#endif
|
||||
|
||||
#ifndef PR_PAC_APIAKEY
|
||||
#define PR_PAC_APIAKEY (1UL << 0)
|
||||
#endif
|
||||
|
||||
#ifndef PR_PAC_APIBKEY
|
||||
#define PR_PAC_APIBKEY (1UL << 1)
|
||||
#endif
|
||||
|
||||
#ifndef PR_PAC_APDAKEY
|
||||
#define PR_PAC_APDAKEY (1UL << 2)
|
||||
#endif
|
||||
|
||||
#ifndef PR_PAC_APDBKEY
|
||||
#define PR_PAC_APDBKEY (1UL << 3)
|
||||
#endif
|
||||
|
||||
#ifndef PR_PAC_APGAKEY
|
||||
#define PR_PAC_APGAKEY (1UL << 4)
|
||||
#endif
|
||||
|
||||
#ifndef PR_TAGGED_ADDR_ENABLE
|
||||
#define PR_TAGGED_ADDR_ENABLE (1UL << 0)
|
||||
#endif
|
||||
|
||||
#define DESCRIBE_FLAG(flag) \
|
||||
if (value & flag) { \
|
||||
desc += ", "; \
|
||||
desc += #flag; \
|
||||
value &= ~flag; \
|
||||
}
|
||||
|
||||
static std::string describe_end(long value, std::string& desc) {
|
||||
if (value) {
|
||||
desc += StringPrintf(", unknown 0x%lx", value);
|
||||
}
|
||||
return desc.empty() ? "" : " (" + desc.substr(2) + ")";
|
||||
}
|
||||
|
||||
std::string describe_tagged_addr_ctrl(long value) {
|
||||
std::string desc;
|
||||
DESCRIBE_FLAG(PR_TAGGED_ADDR_ENABLE);
|
||||
DESCRIBE_FLAG(PR_MTE_TCF_SYNC);
|
||||
DESCRIBE_FLAG(PR_MTE_TCF_ASYNC);
|
||||
if (value & PR_MTE_TAG_MASK) {
|
||||
desc += StringPrintf(", mask 0x%04lx", (value & PR_MTE_TAG_MASK) >> PR_MTE_TAG_SHIFT);
|
||||
value &= ~PR_MTE_TAG_MASK;
|
||||
}
|
||||
return describe_end(value, desc);
|
||||
}
|
||||
|
||||
std::string describe_pac_enabled_keys(long value) {
|
||||
std::string desc;
|
||||
DESCRIBE_FLAG(PR_PAC_APIAKEY);
|
||||
DESCRIBE_FLAG(PR_PAC_APIBKEY);
|
||||
DESCRIBE_FLAG(PR_PAC_APDAKEY);
|
||||
DESCRIBE_FLAG(PR_PAC_APDBKEY);
|
||||
DESCRIBE_FLAG(PR_PAC_APGAKEY);
|
||||
return describe_end(value, desc);
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <android-base/unique_fd.h>
|
||||
#include <libdebuggerd/tombstone.h>
|
||||
#include <libdebuggerd/tombstone_proto_to_text.h>
|
||||
|
||||
#include "tombstone.pb.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ cc_library_static {
|
|||
ramdisk_available: true,
|
||||
recovery_available: true,
|
||||
vendor_ramdisk_available: true,
|
||||
host_supported: true,
|
||||
}
|
||||
|
||||
java_library_static {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue