Update and apply patches to compile libunwindstack

This CL adds new patches required to make the latest libunwindstack
compile and applies all the patches on top of latest libunwindstack pull
in parent change.

Bug: 1140633
Change-Id: Ia94fb408c1827663295242b8483fad1bd5a78172
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/third_party/libunwindstack/+/3879628
Reviewed-by: Mike Wittman <wittman@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 6ae7816..f9a897d 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -25,13 +25,13 @@
   ]
   include_dirs = [
     "//third_party/libunwindstack/src/android-base/include",
-    "//third_party/libunwindstack/src/demangle/include",
-    "//third_party/libunwindstack/src/liblog/include",
     "//third_party/libunwindstack/src/libprocinfo/include",
     "//third_party/libunwindstack/src/libunwindstack/include",
   ]
 
   public = [
+    "src/libunwindstack/include/GlobalDebugInterface.h",
+    "src/libunwindstack/include/unwindstack/Arch.h",
     "src/libunwindstack/include/unwindstack/DexFiles.h",
     "src/libunwindstack/include/unwindstack/DwarfError.h",
     "src/libunwindstack/include/unwindstack/DwarfLocation.h",
@@ -43,7 +43,6 @@
     "src/libunwindstack/include/unwindstack/Error.h",
     "src/libunwindstack/include/unwindstack/Global.h",
     "src/libunwindstack/include/unwindstack/JitDebug.h",
-    "src/libunwindstack/include/unwindstack/LocalUnwinder.h",
     "src/libunwindstack/include/unwindstack/Log.h",
     "src/libunwindstack/include/unwindstack/MachineArm64.h",
     "src/libunwindstack/include/unwindstack/MachineArm.h",
@@ -56,12 +55,12 @@
     "src/libunwindstack/include/unwindstack/Memory.h",
     "src/libunwindstack/include/unwindstack/RegsArm64.h",
     "src/libunwindstack/include/unwindstack/RegsArm.h",
-    "src/libunwindstack/include/unwindstack/RegsGetLocal.h",
     "src/libunwindstack/include/unwindstack/Regs.h",
     "src/libunwindstack/include/unwindstack/RegsMips64.h",
     "src/libunwindstack/include/unwindstack/RegsMips.h",
     "src/libunwindstack/include/unwindstack/RegsX86_64.h",
     "src/libunwindstack/include/unwindstack/RegsX86.h",
+    "src/libunwindstack/include/unwindstack/SharedString.h",
     "src/libunwindstack/include/unwindstack/UcontextArm64.h",
     "src/libunwindstack/include/unwindstack/UcontextArm.h",
     "src/libunwindstack/include/unwindstack/UcontextMips64.h",
@@ -89,15 +88,6 @@
     "src/android-base/stringprintf.cpp",
     "src/android-base/strings.cpp",
     "src/android-base/threads.cpp",
-    "src/liblog/include/android/log.h",
-    "src/liblog/include/log/log.h",
-    "src/liblog/include/log/log_id.h",
-    "src/liblog/include/log/log_main.h",
-    "src/liblog/include/log/log_radio.h",
-    "src/liblog/include/log/log_read.h",
-    "src/liblog/include/log/log_safetynet.h",
-    "src/liblog/include/log/log_system.h",
-    "src/liblog/include/log/log_time.h",
     "src/libprocinfo/include/procinfo/process_map.h",
     "src/libunwindstack/ArmExidx.cpp",
     "src/libunwindstack/ArmExidx.h",
@@ -118,9 +108,9 @@
     "src/libunwindstack/ElfInterfaceArm.h",
     "src/libunwindstack/ElfInterface.cpp",
     "src/libunwindstack/Global.cpp",
+    "src/libunwindstack/GlobalDebugImpl.h",
     "src/libunwindstack/JitDebug.cpp",
-    "src/libunwindstack/LocalUnwinder.cpp",
-    "src/libunwindstack/Log.cpp",
+    "src/libunwindstack/LogAndroid.cpp",
     "src/libunwindstack/MapInfo.cpp",
     "src/libunwindstack/Maps.cpp",
     "src/libunwindstack/MemoryBuffer.h",
@@ -128,10 +118,13 @@
     "src/libunwindstack/Memory.cpp",
     "src/libunwindstack/MemoryFileAtOffset.h",
     "src/libunwindstack/MemoryLocal.h",
+    "src/libunwindstack/MemoryMte.cpp",
     "src/libunwindstack/MemoryOfflineBuffer.h",
     "src/libunwindstack/MemoryOffline.h",
     "src/libunwindstack/MemoryRange.h",
     "src/libunwindstack/MemoryRemote.h",
+    "src/libunwindstack/MemoryXz.cpp",
+    "src/libunwindstack/MemoryXz.h",
     "src/libunwindstack/RegsArm64.cpp",
     "src/libunwindstack/RegsArm.cpp",
     "src/libunwindstack/Regs.cpp",
diff --git a/README.chromium b/README.chromium
index f5c3927..dc6adc8 100644
--- a/README.chromium
+++ b/README.chromium
@@ -35,10 +35,16 @@
 
 1. Update the contents to the upstream revision.
 
-   git checkout master && git pull -q
-   git checkout -b update && git cl upstream master
    rm -rf src
-   tools/copy_libunwindstack_sources.py <upstream_git_tag>
+   mkdir temp src
+   git clone https://android.googlesource.com/platform/system/libprocinfo -b master src/libprocinfo
+   git clone https://android.googlesource.com/platform/system/libbase -b master src/android-base
+   git clone https://android.googlesource.com/platform/system/unwinding -b master temp/unwinding
+   cp -pr temp/unwinding/libunwindstack src/libunwindstack
+   # ... get revisions of repositories
+   head {src,temp}/*/.git/refs/heads/master
+   rm -rf src/*/.git temp
+   find src/* -name .clang-format -exec rm \{\} \;
    # ... manually update the revision info in README.chromium ...
    git add --all
    git commit -m 'step 1'
@@ -113,3 +119,19 @@
 
   Removes all usages of std::iterator, which is deprecated in C++17.
 
+- 0005-dont-include-bionic-headers.patch
+
+  Some bionic headers are not part of NDK even though build flag __BIONIC__ is
+  defined when buliding with NDK. Adds extra check of !defined(__ANDROID_NDK__)
+  to not include those headers.
+
+- 0006-include-algorithm-header.patch
+
+  libunwindstack/DwarfSection.cpp uses std::upper_bound which is declared in
+  <algorithm> header, include header to compile it.
+
+- 0007-stub-out-logging-libunwindstack.patch
+
+  Stub out libunwindstack log methods. It helps to suppress log statements and
+  avoid liblog dependency which the upstream libunwindstack depends on.
+
diff --git a/patches/0005-dont-include-bionic-headers.patch b/patches/0005-dont-include-bionic-headers.patch
new file mode 100644
index 0000000..0a406f7
--- /dev/null
+++ b/patches/0005-dont-include-bionic-headers.patch
@@ -0,0 +1,57 @@
+diff --git a/src/libunwindstack/LogAndroid.cpp b/src/libunwindstack/LogAndroid.cpp
+index a2bfc39..bb8fdaf 100644
+--- a/src/libunwindstack/LogAndroid.cpp
++++ b/src/libunwindstack/LogAndroid.cpp
+@@ -23,7 +23,7 @@
+ #define LOG_TAG "unwind"
+ #include <log/log.h>
+ 
+-#if defined(__BIONIC__)
++#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
+ #include <async_safe/log.h>
+ #endif
+ #include <android-base/stringprintf.h>
+@@ -66,7 +66,7 @@ void Error(const char* format, ...) {
+   va_end(args);
+ }
+ 
+-#if defined(__BIONIC__)
++#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
+ void AsyncSafe(const char* format, ...) {
+   va_list args;
+   va_start(args, format);
+diff --git a/src/libunwindstack/MemoryMte.cpp b/src/libunwindstack/MemoryMte.cpp
+index 3841744..681aea6 100644
+--- a/src/libunwindstack/MemoryMte.cpp
++++ b/src/libunwindstack/MemoryMte.cpp
+@@ -17,7 +17,7 @@
+ #include <sys/ptrace.h>
+ #include <sys/uio.h>
+ 
+-#if defined(__BIONIC__)
++#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
+ #include <bionic/mte.h>
+ #else
+ #define mte_supported() false
+diff --git a/src/libunwindstack/RegsArm64.cpp b/src/libunwindstack/RegsArm64.cpp
+index 99eddb0..05a1809 100644
+--- a/src/libunwindstack/RegsArm64.cpp
++++ b/src/libunwindstack/RegsArm64.cpp
+@@ -19,7 +19,7 @@
+ 
+ #include <functional>
+ 
+-#if defined(__BIONIC__)
++#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
+ #include <bionic/pac.h>
+ #endif
+ 
+@@ -60,7 +60,7 @@ static uint64_t strip_pac(uint64_t pc, uint64_t mask) {
+   if (mask) {
+     pc &= ~mask;
+   } else {
+-#if defined(__BIONIC__)
++#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
+     pc = __bionic_clear_pac_bits(pc);
+ #endif
+   }
diff --git a/patches/0006-include-algorithm-header.patch b/patches/0006-include-algorithm-header.patch
new file mode 100644
index 0000000..d7a34e2
--- /dev/null
+++ b/patches/0006-include-algorithm-header.patch
@@ -0,0 +1,13 @@
+diff --git a/src/libunwindstack/DwarfSection.cpp b/src/libunwindstack/DwarfSection.cpp
+index 34d37b0..7174866 100644
+--- a/src/libunwindstack/DwarfSection.cpp
++++ b/src/libunwindstack/DwarfSection.cpp
+@@ -16,6 +16,8 @@
+ 
+ #include <stdint.h>
+ 
++#include <algorithm>
++
+ #include <unwindstack/DwarfError.h>
+ #include <unwindstack/DwarfLocation.h>
+ #include <unwindstack/DwarfMemory.h>
diff --git a/patches/0007-stub-out-logging-libunwindstack.patch b/patches/0007-stub-out-logging-libunwindstack.patch
new file mode 100644
index 0000000..e510c3e
--- /dev/null
+++ b/patches/0007-stub-out-logging-libunwindstack.patch
@@ -0,0 +1,56 @@
+diff --git a/src/libunwindstack/LogAndroid.cpp b/src/libunwindstack/LogAndroid.cpp
+index bb8fdaf..248cf2b 100644
+--- a/src/libunwindstack/LogAndroid.cpp
++++ b/src/libunwindstack/LogAndroid.cpp
+@@ -21,7 +21,9 @@
+ #include <string>
+ 
+ #define LOG_TAG "unwind"
++#if 0
+ #include <log/log.h>
++#endif
+ 
+ #if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
+ #include <async_safe/log.h>
+@@ -34,6 +36,7 @@ namespace unwindstack {
+ 
+ namespace Log {
+ 
++#if 0
+ // Send the data to the log.
+ static void LogWithPriority(int priority, uint8_t indent, const char* format, va_list args) {
+   std::string real_format;
+@@ -44,26 +47,33 @@ static void LogWithPriority(int priority, uint8_t indent, const char* format, va
+   }
+   LOG_PRI_VA(priority, LOG_TAG, real_format.c_str(), args);
+ }
++#endif
+ 
+ void Info(const char* format, ...) {
++#if 0
+   va_list args;
+   va_start(args, format);
+   LogWithPriority(ANDROID_LOG_INFO, 0, format, args);
+   va_end(args);
++#endif
+ }
+ 
+ void Info(uint8_t indent, const char* format, ...) {
++#if 0
+   va_list args;
+   va_start(args, format);
+   LogWithPriority(ANDROID_LOG_INFO, indent, format, args);
+   va_end(args);
++#endif
+ }
+ 
+ void Error(const char* format, ...) {
++#if 0
+   va_list args;
+   va_start(args, format);
+   LogWithPriority(ANDROID_LOG_ERROR, 0, format, args);
+   va_end(args);
++#endif
+ }
+ 
+ #if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
diff --git a/src/android-base/file.cpp b/src/android-base/file.cpp
index d0cec7d..a3eddfe 100644
--- a/src/android-base/file.cpp
+++ b/src/android-base/file.cpp
@@ -45,11 +45,17 @@
 #define OS_PATH_SEPARATOR '/'
 #endif
 
-#include "android-base/logging.h"  // and must be after windows.h for ERROR
 #include "android-base/macros.h"   // For TEMP_FAILURE_RETRY on Darwin.
 #include "android-base/unique_fd.h"
 #include "android-base/utf8.h"
 
+class FakeLog {
+ public:
+  FakeLog operator<<(const char*) { return *this; }
+  operator bool() { return false; }
+};
+#define PLOG(x) false && FakeLog()
+
 namespace {
 
 #ifdef _WIN32
diff --git a/src/android-base/include/android-base/unique_fd.h b/src/android-base/include/android-base/unique_fd.h
index 1ffe02f..110712c 100644
--- a/src/android-base/include/android-base/unique_fd.h
+++ b/src/android-base/include/android-base/unique_fd.h
@@ -29,7 +29,11 @@
 // Including other headers from libbase frequently results in inclusion of
 // android-base/macros.h, which causes macro collisions.
 
-#if defined(__BIONIC__)
+#if defined(__BIONIC__) && defined(__ANDROID_API__) && __ANDROID_API__ >= 29
+  #define FDSAN_AVAILABLE 1
+#endif
+
+#if defined(FDSAN_AVAILABLE)
 #include <android/fdsan.h>
 #endif
 #if !defined(_WIN32) && !defined(__TRUSTY__)
@@ -151,7 +155,7 @@
 // The actual details of closing are factored out to support unusual cases.
 // Almost everyone will want this DefaultCloser, which handles fdsan on bionic.
 struct DefaultCloser {
-#if defined(__BIONIC__)
+#if defined(FDSAN_AVAILABLE)
   static void Tag(int fd, void* old_addr, void* new_addr) {
     if (android_fdsan_exchange_owner_tag) {
       uint64_t old_tag = android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_UNIQUE_FD,
diff --git a/src/libunwindstack/DwarfSection.cpp b/src/libunwindstack/DwarfSection.cpp
index 34d37b0..7174866 100644
--- a/src/libunwindstack/DwarfSection.cpp
+++ b/src/libunwindstack/DwarfSection.cpp
@@ -16,6 +16,8 @@
 
 #include <stdint.h>
 
+#include <algorithm>
+
 #include <unwindstack/DwarfError.h>
 #include <unwindstack/DwarfLocation.h>
 #include <unwindstack/DwarfMemory.h>
diff --git a/src/libunwindstack/ElfInterfaceArm.h b/src/libunwindstack/ElfInterfaceArm.h
index 6ee6dc9..a2435f2 100644
--- a/src/libunwindstack/ElfInterfaceArm.h
+++ b/src/libunwindstack/ElfInterfaceArm.h
@@ -32,8 +32,14 @@
   ElfInterfaceArm(Memory* memory) : ElfInterface32(memory) {}
   virtual ~ElfInterfaceArm() = default;
 
-  class iterator : public std::iterator<std::bidirectional_iterator_tag, uint32_t> {
+  class iterator {
    public:
+    using iterator_category = std::bidirectional_iterator_tag;
+    using value_type = uint32_t;
+    using difference_type = std::ptrdiff_t;
+    using pointer = uint32_t*;
+    using reference = uint32_t&;
+
     iterator(ElfInterfaceArm* interface, size_t index) : interface_(interface), index_(index) { }
 
     iterator& operator++() { index_++; return *this; }
diff --git a/src/libunwindstack/LogAndroid.cpp b/src/libunwindstack/LogAndroid.cpp
index a2bfc39..248cf2b 100644
--- a/src/libunwindstack/LogAndroid.cpp
+++ b/src/libunwindstack/LogAndroid.cpp
@@ -21,9 +21,11 @@
 #include <string>
 
 #define LOG_TAG "unwind"
+#if 0
 #include <log/log.h>
+#endif
 
-#if defined(__BIONIC__)
+#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
 #include <async_safe/log.h>
 #endif
 #include <android-base/stringprintf.h>
@@ -34,6 +36,7 @@
 
 namespace Log {
 
+#if 0
 // Send the data to the log.
 static void LogWithPriority(int priority, uint8_t indent, const char* format, va_list args) {
   std::string real_format;
@@ -44,29 +47,36 @@
   }
   LOG_PRI_VA(priority, LOG_TAG, real_format.c_str(), args);
 }
+#endif
 
 void Info(const char* format, ...) {
+#if 0
   va_list args;
   va_start(args, format);
   LogWithPriority(ANDROID_LOG_INFO, 0, format, args);
   va_end(args);
+#endif
 }
 
 void Info(uint8_t indent, const char* format, ...) {
+#if 0
   va_list args;
   va_start(args, format);
   LogWithPriority(ANDROID_LOG_INFO, indent, format, args);
   va_end(args);
+#endif
 }
 
 void Error(const char* format, ...) {
+#if 0
   va_list args;
   va_start(args, format);
   LogWithPriority(ANDROID_LOG_ERROR, 0, format, args);
   va_end(args);
+#endif
 }
 
-#if defined(__BIONIC__)
+#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
 void AsyncSafe(const char* format, ...) {
   va_list args;
   va_start(args, format);
diff --git a/src/libunwindstack/Memory.cpp b/src/libunwindstack/Memory.cpp
index 5cfe2f0..f5f37ee 100644
--- a/src/libunwindstack/Memory.cpp
+++ b/src/libunwindstack/Memory.cpp
@@ -201,6 +201,10 @@
   return nullptr;
 }
 
+std::unique_ptr<Memory> Memory::CreateLocalProcessMemory() {
+  return std::unique_ptr<Memory>(new MemoryLocal());
+}
+
 std::shared_ptr<Memory> Memory::CreateProcessMemory(pid_t pid) {
   if (pid == getpid()) {
     return std::shared_ptr<Memory>(new MemoryLocal());
diff --git a/src/libunwindstack/MemoryMte.cpp b/src/libunwindstack/MemoryMte.cpp
index 3841744..681aea6 100644
--- a/src/libunwindstack/MemoryMte.cpp
+++ b/src/libunwindstack/MemoryMte.cpp
@@ -17,7 +17,7 @@
 #include <sys/ptrace.h>
 #include <sys/uio.h>
 
-#if defined(__BIONIC__)
+#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
 #include <bionic/mte.h>
 #else
 #define mte_supported() false
diff --git a/src/libunwindstack/RegsArm64.cpp b/src/libunwindstack/RegsArm64.cpp
index 99eddb0..05a1809 100644
--- a/src/libunwindstack/RegsArm64.cpp
+++ b/src/libunwindstack/RegsArm64.cpp
@@ -19,7 +19,7 @@
 
 #include <functional>
 
-#if defined(__BIONIC__)
+#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
 #include <bionic/pac.h>
 #endif
 
@@ -60,7 +60,7 @@
   if (mask) {
     pc &= ~mask;
   } else {
-#if defined(__BIONIC__)
+#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
     pc = __bionic_clear_pac_bits(pc);
 #endif
   }
diff --git a/src/libunwindstack/include/unwindstack/DwarfSection.h b/src/libunwindstack/include/unwindstack/DwarfSection.h
index 33435b2..c5f2015 100644
--- a/src/libunwindstack/include/unwindstack/DwarfSection.h
+++ b/src/libunwindstack/include/unwindstack/DwarfSection.h
@@ -42,8 +42,14 @@
   DwarfSection(Memory* memory);
   virtual ~DwarfSection() = default;
 
-  class iterator : public std::iterator<std::bidirectional_iterator_tag, DwarfFde*> {
+  class iterator {
    public:
+    using iterator_category = std::bidirectional_iterator_tag;
+    using value_type = DwarfFde*;
+    using difference_type = std::ptrdiff_t;
+    using pointer = DwarfFde**;
+    using reference = DwarfFde*&;
+
     iterator(DwarfSection* section, size_t index) : index_(index) {
       section->GetFdes(&fdes_);
       if (index_ == static_cast<size_t>(-1)) {
diff --git a/src/libunwindstack/include/unwindstack/Memory.h b/src/libunwindstack/include/unwindstack/Memory.h
index d6ca29e..5ec9787 100644
--- a/src/libunwindstack/include/unwindstack/Memory.h
+++ b/src/libunwindstack/include/unwindstack/Memory.h
@@ -32,6 +32,7 @@
   Memory() = default;
   virtual ~Memory() = default;
 
+  static std::unique_ptr<Memory> CreateLocalProcessMemory();
   static std::shared_ptr<Memory> CreateProcessMemory(pid_t pid);
   static std::shared_ptr<Memory> CreateProcessMemoryCached(pid_t pid);
   static std::shared_ptr<Memory> CreateProcessMemoryThreadCached(pid_t pid);
diff --git a/tools/copy_libunwindstack_sources.py b/tools/copy_libunwindstack_sources.py
deleted file mode 100755
index c5e7262..0000000
--- a/tools/copy_libunwindstack_sources.py
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/env vpython3
-# Copyright 2019 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-'''Copies the source code required to compile libunwindstack into the
-libunwindstack/src directory.'''
-
-import argparse
-import os
-import re
-import shutil
-import subprocess
-import sys
-
-_LIBUNWINDSTACK_ROOT = os.path.abspath(
-    os.path.join(os.path.dirname(__file__), os.pardir))
-_LIBUNWINDSTACK_SRC_ROOT = os.path.join(_LIBUNWINDSTACK_ROOT, 'src')
-_DIRS_TO_COPY = [
-    'base',
-    'liblog',
-    'libprocinfo',
-    'libunwindstack',
-]
-_ALTERNATE_PATH_DICT = {'base': 'android-base'}
-
-
-def GitFetchTag(git_tag):
-  'Fetches the specified upstream git tag.'
-  # Upstream is a direct mirror of Android's platform/system/core. That git
-  # repo's ref/heads/* and refs/tags/* are mirrored to origin's
-  # refs/upstream/heads/* and refs/upstream/tags/*, respectively. By default,
-  # only refs/heads/* and refs/tags/* are fetched, so we need to explicitly
-  # fetch the tag we care about.
-  subprocess.check_call([
-      'git', 'fetch', 'origin',
-      'refs/upstream/tags/{0}'.format(git_tag)
-  ])
-
-def GitFetchRevision(revision):
-  'Fetches the specified upstream git revision.'
-  subprocess.check_call(['git', 'fetch', 'origin', revision])
-
-
-def CopyDirsFromUpstream(git_rev):
-  '''Checks out the required directories from the upstream Android repo and puts
-  them into the src/ directory.'''
-  os.mkdir(_LIBUNWINDSTACK_SRC_ROOT)
-  for path in _DIRS_TO_COPY:
-    dir_root_path = os.path.join(_LIBUNWINDSTACK_ROOT, path)
-    if os.path.exists(dir_root_path):
-      raise IOError('{} should not exist before running this script.'.format(
-          dir_root_path))
-
-    subprocess.check_call(
-        ['git', 'checkout', git_rev, '--', path])
-
-    # Some directories need to be renamed in order for C++ #includes to work
-    # correctly.
-    dir_src_path = os.path.join(_LIBUNWINDSTACK_SRC_ROOT,
-                                _ALTERNATE_PATH_DICT.get(path, path))
-    # The source file directories live in upstream's root directory, so are
-    # copied there when we use `git checkout`. In this repo, we move them to
-    # the src/ directory.
-    shutil.move(dir_root_path, dir_src_path)
-
-
-def Main():
-  parser = argparse.ArgumentParser(description='''Copies the source code
-      required to compile libunwindstack into the libunwindstack/src/
-      directory.''')
-  parser.add_argument(
-      'git_rev',
-      help='''The git revision or tag for the Android platform/system/core
-      commit that you want to copy the source code from.''')
-  args = parser.parse_args()
-
-  if os.path.exists(_LIBUNWINDSTACK_SRC_ROOT):
-    raise IOError('{} should not exist before running this script.'.format(
-        _LIBUNWINDSTACK_SRC_ROOT))
-
-  if re.search(r'^[0-9a-f]+$', args.git_rev):
-    GitFetchRevision(args.git_rev)
-  else:
-    GitFetchTag(args.git_rev)
-  CopyDirsFromUpstream('FETCH_HEAD')
-  return 0
-
-
-if __name__ == '__main__':
-  sys.exit(Main())
diff --git a/tools/get_required_sources.sh b/tools/get_required_sources.sh
index 0f19ca2..509df9b 100755
--- a/tools/get_required_sources.sh
+++ b/tools/get_required_sources.sh
@@ -20,7 +20,7 @@
 # `clean` can return a non-zero exit code if targets write files to the output
 # directory that ninja doesn't know about.
 autoninja -C $out_dir -t clean >&2 || true
-autoninja -C $out_dir -d keepdepfile libstack_unwinder.cr.so >&2
+autoninja -C $out_dir -d keepdepfile libunwindstack >&2
 
 # Restore the default deps file behavior.
 gn gen $out_dir >&2