Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab9cf8b4 authored by Christopher Ferris's avatar Christopher Ferris
Browse files

Only call one unwinder.

Nobody is looking at the mismatches, and it can cause problems
with tombstone parsers.

Also, fix the dump_header_info test and remove unused properties_fake.cpp.

Test: Ran unit tests, verified tombstones still work.
Change-Id: I4261646016b4e84b26a5aee72f3227f1ce48ec9a
parent 7de02203
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -193,7 +193,6 @@ cc_test {
        "libdebuggerd/test/elf_fake.cpp",
        "libdebuggerd/test/log_fake.cpp",
        "libdebuggerd/test/open_files_list_test.cpp",
        "libdebuggerd/test/property_fake.cpp",
        "libdebuggerd/test/ptrace_fake.cpp",
        "libdebuggerd/test/tombstone_test.cpp",
    ],
+2 −8
Original line number Diff line number Diff line
@@ -348,11 +348,6 @@ int main(int argc, char** argv) {
      LOG(FATAL) << "failed to create backtrace map";
    }
  }
  std::unique_ptr<BacktraceMap> backtrace_map_new;
  backtrace_map_new.reset(BacktraceMap::CreateNew(main_tid));
  if (!backtrace_map_new) {
    LOG(FATAL) << "failed to create backtrace map new";
  }

  // Collect the list of open files.
  OpenFilesList open_files;
@@ -432,9 +427,8 @@ int main(int argc, char** argv) {
    dump_backtrace(output_fd.get(), backtrace_map.get(), target, main_tid, process_name, threads, 0);
  } else {
    ATRACE_NAME("engrave_tombstone");
    engrave_tombstone(output_fd.get(), backtrace_map.get(), backtrace_map_new.get(), &open_files,
                      target, main_tid, process_name, threads, abort_address,
                      fatal_signal ? &amfd_data : nullptr);
    engrave_tombstone(output_fd.get(), backtrace_map.get(), &open_files, target, main_tid,
                      process_name, threads, abort_address, fatal_signal ? &amfd_data : nullptr);
  }

  // We don't actually need to PTRACE_DETACH, as long as our tracees aren't in
+4 −4
Original line number Diff line number Diff line
@@ -35,10 +35,10 @@ class BacktraceMap;
int open_tombstone(std::string* path);

/* Creates a tombstone file and writes the crash dump to it. */
void engrave_tombstone(int tombstone_fd, BacktraceMap* map, BacktraceMap* map_new,
                       const OpenFilesList* open_files, pid_t pid, pid_t tid,
                       const std::string& process_name, const std::map<pid_t, std::string>& threads,
                       uintptr_t abort_msg_address, std::string* amfd_data);
void engrave_tombstone(int tombstone_fd, BacktraceMap* map, const OpenFilesList* open_files,
                       pid_t pid, pid_t tid, const std::string& process_name,
                       const std::map<pid_t, std::string>& threads, uintptr_t abort_msg_address,
                       std::string* amfd_data);

void engrave_tombstone_ucontext(int tombstone_fd, uintptr_t abort_msg_address, siginfo_t* siginfo,
                                ucontext_t* ucontext);
+0 −45
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 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 <string.h>

#include <string>
#include <unordered_map>

#include <sys/system_properties.h>

std::unordered_map<std::string, std::string> g_properties;

extern "C" int property_set(const char* name, const char* value) {
  if (g_properties.count(name) != 0) {
    g_properties.erase(name);
  }
  g_properties[name] = value;
  return 0;
}

extern "C" int property_get(const char* key, char* value, const char* default_value) {
  if (g_properties.count(key) == 0) {
    if (default_value == nullptr) {
      return 0;
    }
    strncpy(value, default_value, PROP_VALUE_MAX-1);
  } else {
    strncpy(value, g_properties[key].c_str(), PROP_VALUE_MAX-1);
  }
  value[PROP_VALUE_MAX-1] = '\0';
  return strlen(value);
}
+6 −2
Original line number Diff line number Diff line
@@ -19,8 +19,9 @@
#include <memory>
#include <string>

#include <gtest/gtest.h>
#include <android-base/file.h>
#include <android-base/properties.h>
#include <gtest/gtest.h>

#include "libdebuggerd/utility.h"

@@ -639,7 +640,10 @@ TEST_F(TombstoneTest, dump_log_file_error) {
TEST_F(TombstoneTest, dump_header_info) {
  dump_header_info(&log_);

  std::string expected = "Build fingerprint: 'unknown'\nRevision: 'unknown'\n";
  std::string expected = android::base::StringPrintf(
      "Build fingerprint: '%s'\nRevision: '%s'\n",
      android::base::GetProperty("ro.build.fingerprint", "unknown").c_str(),
      android::base::GetProperty("ro.revision", "unknown").c_str());
  expected += android::base::StringPrintf("ABI: '%s'\n", ABI_STRING);
  ASSERT_STREQ(expected.c_str(), amfd_data_.c_str());
}
Loading