Merge "Add support for logging package name." into pi-dev
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index a1f0211..40cf6c3 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -190,6 +190,19 @@
static unique_fd g_tombstoned_socket;
static unique_fd g_output_fd;
+static void DefuseSignalHandlers() {
+ // Don't try to dump ourselves.
+ struct sigaction action = {};
+ action.sa_handler = SIG_DFL;
+ debuggerd_register_handlers(&action);
+
+ sigset_t mask;
+ sigemptyset(&mask);
+ if (sigprocmask(SIG_SETMASK, &mask, nullptr) != 0) {
+ PLOG(FATAL) << "failed to set signal mask";
+ }
+}
+
static void Initialize(char** argv) {
android::base::InitLogging(argv);
android::base::SetAborter([](const char* abort_msg) {
@@ -213,17 +226,6 @@
_exit(1);
});
-
- // Don't try to dump ourselves.
- struct sigaction action = {};
- action.sa_handler = SIG_DFL;
- debuggerd_register_handlers(&action);
-
- sigset_t mask;
- sigemptyset(&mask);
- if (sigprocmask(SIG_SETMASK, &mask, nullptr) != 0) {
- PLOG(FATAL) << "failed to set signal mask";
- }
}
static void ParseArgs(int argc, char** argv, pid_t* pseudothread_tid, DebuggerdDumpType* dump_type) {
@@ -321,6 +323,8 @@
}
int main(int argc, char** argv) {
+ DefuseSignalHandlers();
+
atrace_begin(ATRACE_TAG, "before reparent");
pid_t target_process = getppid();
diff --git a/debuggerd/libdebuggerd/tombstone.cpp b/debuggerd/libdebuggerd/tombstone.cpp
index 140ef6d..933a597 100644
--- a/debuggerd/libdebuggerd/tombstone.cpp
+++ b/debuggerd/libdebuggerd/tombstone.cpp
@@ -418,8 +418,10 @@
dump_registers(log, thread_info.registers.get());
+ // Unwind will mutate the registers, so make a copy first.
+ std::unique_ptr<Regs> regs_copy(thread_info.registers->Clone());
std::vector<backtrace_frame_data_t> frames;
- if (!Backtrace::Unwind(thread_info.registers.get(), map, &frames, 0, nullptr)) {
+ if (!Backtrace::Unwind(regs_copy.get(), map, &frames, 0, nullptr)) {
_LOG(log, logtype::THREAD, "Failed to unwind");
return false;
}
diff --git a/init/init_first_stage.cpp b/init/init_first_stage.cpp
index 0f4cc68..45d3d44 100644
--- a/init/init_first_stage.cpp
+++ b/init/init_first_stage.cpp
@@ -119,10 +119,7 @@
FirstStageMount::FirstStageMount()
: need_dm_verity_(false), device_tree_fstab_(fs_mgr_read_fstab_dt(), fs_mgr_free_fstab) {
if (!device_tree_fstab_) {
- // The client of FirstStageMount should check the existence of fstab in device-tree
- // in advance, without parsing it. Reaching here means there is a FATAL error when
- // parsing the fstab. So stop here to expose the failure.
- LOG(FATAL) << "Failed to read fstab from device tree";
+ LOG(INFO) << "Failed to read fstab from device tree";
return;
}
// Stores device_tree_fstab_->recs[] into mount_fstab_recs_ (vector<fstab_rec*>)
diff --git a/libunwindstack/RegsArm.cpp b/libunwindstack/RegsArm.cpp
index 27cab43..de22bde 100644
--- a/libunwindstack/RegsArm.cpp
+++ b/libunwindstack/RegsArm.cpp
@@ -197,4 +197,8 @@
return true;
}
+Regs* RegsArm::Clone() {
+ return new RegsArm(*this);
+}
+
} // namespace unwindstack
diff --git a/libunwindstack/RegsArm64.cpp b/libunwindstack/RegsArm64.cpp
index 4a2a6c4..a68f6e0 100644
--- a/libunwindstack/RegsArm64.cpp
+++ b/libunwindstack/RegsArm64.cpp
@@ -148,4 +148,8 @@
return true;
}
+Regs* RegsArm64::Clone() {
+ return new RegsArm64(*this);
+}
+
} // namespace unwindstack
diff --git a/libunwindstack/RegsMips.cpp b/libunwindstack/RegsMips.cpp
index c87e69b..2e6908c 100644
--- a/libunwindstack/RegsMips.cpp
+++ b/libunwindstack/RegsMips.cpp
@@ -173,4 +173,8 @@
return true;
}
+Regs* RegsMips::Clone() {
+ return new RegsMips(*this);
+}
+
} // namespace unwindstack
diff --git a/libunwindstack/RegsMips64.cpp b/libunwindstack/RegsMips64.cpp
index 236a922..0b835a1 100644
--- a/libunwindstack/RegsMips64.cpp
+++ b/libunwindstack/RegsMips64.cpp
@@ -160,4 +160,8 @@
return true;
}
+Regs* RegsMips64::Clone() {
+ return new RegsMips64(*this);
+}
+
} // namespace unwindstack
diff --git a/libunwindstack/RegsX86.cpp b/libunwindstack/RegsX86.cpp
index f7e0614..9bb39d1 100644
--- a/libunwindstack/RegsX86.cpp
+++ b/libunwindstack/RegsX86.cpp
@@ -179,4 +179,8 @@
return false;
}
+Regs* RegsX86::Clone() {
+ return new RegsX86(*this);
+}
+
} // namespace unwindstack
diff --git a/libunwindstack/RegsX86_64.cpp b/libunwindstack/RegsX86_64.cpp
index 7d6ad86..ebad3f4 100644
--- a/libunwindstack/RegsX86_64.cpp
+++ b/libunwindstack/RegsX86_64.cpp
@@ -168,4 +168,8 @@
return true;
}
+Regs* RegsX86_64::Clone() {
+ return new RegsX86_64(*this);
+}
+
} // namespace unwindstack
diff --git a/libunwindstack/include/unwindstack/Regs.h b/libunwindstack/include/unwindstack/Regs.h
index 4bac473..878ced3 100644
--- a/libunwindstack/include/unwindstack/Regs.h
+++ b/libunwindstack/include/unwindstack/Regs.h
@@ -73,6 +73,8 @@
uint16_t total_regs() { return total_regs_; }
+ virtual Regs* Clone() = 0;
+
static ArchEnum CurrentArch();
static Regs* RemoteGet(pid_t pid);
static Regs* CreateFromUcontext(ArchEnum arch, void* ucontext);
diff --git a/libunwindstack/include/unwindstack/RegsArm.h b/libunwindstack/include/unwindstack/RegsArm.h
index 31e6797..44f6744 100644
--- a/libunwindstack/include/unwindstack/RegsArm.h
+++ b/libunwindstack/include/unwindstack/RegsArm.h
@@ -50,6 +50,8 @@
void set_pc(uint64_t pc) override;
void set_sp(uint64_t sp) override;
+ Regs* Clone() override final;
+
static Regs* Read(void* data);
static Regs* CreateFromUcontext(void* ucontext);
diff --git a/libunwindstack/include/unwindstack/RegsArm64.h b/libunwindstack/include/unwindstack/RegsArm64.h
index 0c45eba..a72f91f 100644
--- a/libunwindstack/include/unwindstack/RegsArm64.h
+++ b/libunwindstack/include/unwindstack/RegsArm64.h
@@ -50,6 +50,8 @@
void set_pc(uint64_t pc) override;
void set_sp(uint64_t sp) override;
+ Regs* Clone() override final;
+
static Regs* Read(void* data);
static Regs* CreateFromUcontext(void* ucontext);
diff --git a/libunwindstack/include/unwindstack/RegsMips.h b/libunwindstack/include/unwindstack/RegsMips.h
index 709f9e2..c9dd202 100644
--- a/libunwindstack/include/unwindstack/RegsMips.h
+++ b/libunwindstack/include/unwindstack/RegsMips.h
@@ -50,6 +50,8 @@
void set_pc(uint64_t pc) override;
void set_sp(uint64_t sp) override;
+ Regs* Clone() override final;
+
static Regs* Read(void* data);
static Regs* CreateFromUcontext(void* ucontext);
diff --git a/libunwindstack/include/unwindstack/RegsMips64.h b/libunwindstack/include/unwindstack/RegsMips64.h
index 1de83ea..7c42812 100644
--- a/libunwindstack/include/unwindstack/RegsMips64.h
+++ b/libunwindstack/include/unwindstack/RegsMips64.h
@@ -50,6 +50,8 @@
void set_pc(uint64_t pc) override;
void set_sp(uint64_t sp) override;
+ Regs* Clone() override final;
+
static Regs* Read(void* data);
static Regs* CreateFromUcontext(void* ucontext);
diff --git a/libunwindstack/include/unwindstack/RegsX86.h b/libunwindstack/include/unwindstack/RegsX86.h
index 586c9d8..d19e449 100644
--- a/libunwindstack/include/unwindstack/RegsX86.h
+++ b/libunwindstack/include/unwindstack/RegsX86.h
@@ -53,6 +53,8 @@
void set_pc(uint64_t pc) override;
void set_sp(uint64_t sp) override;
+ Regs* Clone() override final;
+
static Regs* Read(void* data);
static Regs* CreateFromUcontext(void* ucontext);
diff --git a/libunwindstack/include/unwindstack/RegsX86_64.h b/libunwindstack/include/unwindstack/RegsX86_64.h
index 061f479..dc9a220 100644
--- a/libunwindstack/include/unwindstack/RegsX86_64.h
+++ b/libunwindstack/include/unwindstack/RegsX86_64.h
@@ -53,6 +53,8 @@
void set_pc(uint64_t pc) override;
void set_sp(uint64_t sp) override;
+ Regs* Clone() override final;
+
static Regs* Read(void* data);
static Regs* CreateFromUcontext(void* ucontext);
diff --git a/libunwindstack/tests/RegsFake.h b/libunwindstack/tests/RegsFake.h
index ede16b3..d6ca9b7 100644
--- a/libunwindstack/tests/RegsFake.h
+++ b/libunwindstack/tests/RegsFake.h
@@ -58,6 +58,8 @@
void FakeSetReturnAddress(uint64_t return_address) { fake_return_address_ = return_address; }
void FakeSetReturnAddressValid(bool valid) { fake_return_address_valid_ = valid; }
+ Regs* Clone() override { return nullptr; }
+
private:
ArchEnum fake_arch_ = ARCH_UNKNOWN;
uint64_t fake_pc_ = 0;
@@ -83,6 +85,8 @@
bool SetPcFromReturnAddress(Memory*) override { return false; }
bool StepIfSignalHandler(uint64_t, Elf*, Memory*) override { return false; }
+ Regs* Clone() override { return nullptr; }
+
private:
uint64_t fake_pc_ = 0;
uint64_t fake_sp_ = 0;
diff --git a/libunwindstack/tests/RegsTest.cpp b/libunwindstack/tests/RegsTest.cpp
index d15823e..90c3fe6 100644
--- a/libunwindstack/tests/RegsTest.cpp
+++ b/libunwindstack/tests/RegsTest.cpp
@@ -286,4 +286,39 @@
EXPECT_EQ(ARCH_MIPS64, mips64_regs.Arch());
}
+template <typename RegisterType>
+void clone_test(Regs* regs) {
+ RegisterType* register_values = reinterpret_cast<RegisterType*>(regs->RawData());
+ int num_regs = regs->total_regs();
+ for (int i = 0; i < num_regs; ++i) {
+ register_values[i] = i;
+ }
+
+ std::unique_ptr<Regs> clone(regs->Clone());
+ ASSERT_EQ(regs->total_regs(), clone->total_regs());
+ RegisterType* clone_values = reinterpret_cast<RegisterType*>(clone->RawData());
+ for (int i = 0; i < num_regs; ++i) {
+ EXPECT_EQ(register_values[i], clone_values[i]);
+ EXPECT_NE(®ister_values[i], &clone_values[i]);
+ }
+}
+
+TEST_F(RegsTest, clone) {
+ std::vector<std::unique_ptr<Regs>> regs;
+ regs.emplace_back(new RegsArm());
+ regs.emplace_back(new RegsArm64());
+ regs.emplace_back(new RegsX86());
+ regs.emplace_back(new RegsX86_64());
+ regs.emplace_back(new RegsMips());
+ regs.emplace_back(new RegsMips64());
+
+ for (auto& r : regs) {
+ if (r->Is32Bit()) {
+ clone_test<uint32_t>(r.get());
+ } else {
+ clone_test<uint64_t>(r.get());
+ }
+ }
+}
+
} // namespace unwindstack