Skip to content

Commit

Permalink
Simplify updating libbacktrace
Browse files Browse the repository at this point in the history
Previously our `regenerate_libbacktrace.sh` script could only clone the
repo and re-apply our existing patches. Give it the ability to also
update to a different commit and rebase our patches.

If the rebasing fails, have it leave the `.git` directory around so that
a developer can manually rebase and finish the job.

Signed-off-by: Matt Wozniski <[email protected]>
  • Loading branch information
godlygeek committed Jul 26, 2024
1 parent fc06d9d commit 4b0ed4f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
From d99c0a30bacfe6cae604a85250f12587d0fee932 Mon Sep 17 00:00:00 2001
From: Matt Wozniski <[email protected]>
Date: Thu, 25 Jul 2024 18:59:09 -0400
Subject: [PATCH] Expose some internal functions of libbacktrace

Memray uses these for more control than the public entry points give.
---
Makefile.am | 2 +-
Makefile.in | 2 +-
elf.c | 10 +++++-----
internal.h | 39 +++++++++++++++++++++++++++++++++++++++
macho.c | 31 +++++++++++++++++++------------
5 files changed, 65 insertions(+), 19 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 4d509a2..f80a9e6 100644
--- a/Makefile.am
Expand Down Expand Up @@ -224,3 +238,6 @@ index fc4c959..527c5ac 100644
break;
default:
error_callback (data, "executable file is not an executable", 0);
--
2.42.3

Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
From b052eda140ac673de19a3060523fb250d898ffb6 Mon Sep 17 00:00:00 2001
From: Matt Wozniski <[email protected]>
Date: Thu, 25 Jul 2024 18:59:10 -0400
Subject: [PATCH] Add debuginfod support to libbacktrace

Allow fetching debug info from a debuginfod server when unwinding.
---
Makefile.am | 5 +-
Makefile.in | 5 +-
debuginfod_support.h | 115 +++++++++++++++++++++++++++++++++++++++++++
elf.c | 64 ++++++++++++++++++++++++
4 files changed, 185 insertions(+), 4 deletions(-)
create mode 100644 debuginfod_support.h

diff --git a/Makefile.am b/Makefile.am
index f80a9e6..15e87c7 100644
--- a/Makefile.am
Expand Down Expand Up @@ -283,3 +297,6 @@ index 80482a4..61f08af 100644

if (!state->threaded)
{
--
2.42.3

40 changes: 28 additions & 12 deletions src/vendor/regenerate_libbacktrace.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
#!/usr/bin/env bash
set -Eeuo pipefail

SNAPSHOT_COMMIT=7e2b7da3d6568d2e4e78658f22e701746a48d7e1
LIBBACKTRACE_DIR="libbacktrace"
if [[ $# -ne 0 ]] && [[ $# -ne 1 ]]; then
echo "Usage: $0 [new-commit]"
exit 1
fi

echo "checking" $(ls)
old_snapshot=7e2b7da3d6568d2e4e78658f22e701746a48d7e1
new_snapshot=${1:-}

echo ">>> Cloning libbacktrace"
rm -rf "$LIBBACKTRACE_DIR"
git clone https://github.com/ianlancetaylor/libbacktrace.git "$LIBBACKTRACE_DIR"
rm -rf libbacktrace
git clone https://github.com/ianlancetaylor/libbacktrace.git libbacktrace

echo ">>> Checking out commit ${SNAPSHOT_COMMIT}"
cd "$LIBBACKTRACE_DIR"
git checkout $SNAPSHOT_COMMIT 1>/dev/null
echo "Applying patches"
cd libbacktrace
git checkout "$old_snapshot"
git am ../libbacktrace-patches/*

if [[ -n "$new_snapshot" ]]; then
echo "Rebasing on $new_snapshot"
if git rebase "$new_snapshot"; then
echo "Rebased successfully. Updating patches."
(cd ../libbacktrace-patches && git rm -f 0*)
git format-patch "$new_snapshot" --no-numbered --output-directory=../libbacktrace-patches
(cd ../libbacktrace-patches && git add 0*)
else
echo "Failed to apply patches. You must finish rebasing manually."
echo "When you are satisfied, update the patches by running:"
echo " git format-patch $new_snapshot --no-numbered --output-directory=../libbacktrace-patches"
echo "Be sure to remove the old patches first if the file names will change."
exit 1
fi
fi

echo ">>> Applying main patch for commit ${SNAPSHOT_COMMIT}"
git apply ../libbacktrace_${SNAPSHOT_COMMIT}_patch.diff
echo ">>> Applying debuginfod patch for commit ${SNAPSHOT_COMMIT}"
git apply ../libbacktrace_${SNAPSHOT_COMMIT}_debuginfod_patch.diff
rm -rf .git

echo "Regenerated vendored libbacktrace"

0 comments on commit 4b0ed4f

Please sign in to comment.