From 827664c1da4f4c5d8977145cab31b2990d7e6aad Mon Sep 17 00:00:00 2001 From: Vinnie Magro Date: Wed, 26 Jun 2024 11:14:11 -0700 Subject: [PATCH] [antlir2][debuginfo] attempt to add debugging information when objcopy fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: This seems to sometimes fail on very large binaries and we don't really have any details to go on since a retry almost always works. Test Plan: ``` ❯ buck2 test fbcode//mode/opt fbcode//antlir/antlir2/features/install/... Buck UI: https://www.internalfb.com/buck2/6f13a5c7-ce51-4516-bfe6-911bb224aa3f Test UI: https://www.internalfb.com/intern/testinfra/testrun/11258999107872474 Network: Up: 0B Down: 0B (reSessionID-5f98e59a-6be6-489b-a71f-37c9e63cbc2b) Jobs completed: 431. Time elapsed: 5.2s. Cache hits: 0%. Commands: 3 (cached: 0, remote: 0, local: 3) Tests finished: Pass 37. Fail 0. Fatal 0. Skip 0. Build failure 0 ``` Reviewed By: naveedgol Differential Revision: D59062594 fbshipit-source-id: c7644f7adea129449d79649ada46a0477bc82b40 --- antlir/antlir2/bzl/debuginfo.bzl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/antlir/antlir2/bzl/debuginfo.bzl b/antlir/antlir2/bzl/debuginfo.bzl index b5e05ab6d2..cda56d1e78 100644 --- a/antlir/antlir2/bzl/debuginfo.bzl +++ b/antlir/antlir2/bzl/debuginfo.bzl @@ -103,7 +103,7 @@ subprocess.run( # Find the BuildID of the binary. This determines where it should go for gdb to # look it up under /usr/lib/debug # https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html -buildid = subprocess.run( +buildid_proc = subprocess.run( [ args.objcopy, "--dump-section", @@ -112,9 +112,14 @@ buildid = subprocess.run( args.objcopy_tmp, ], capture_output=True, - check=True, -).stdout - +) +if buildid_proc.returncode != 0: + raise RuntimeError("Failed to get build-id for {}:\\n{}\\n{}".format( + args.binary, + buildid_proc.stdout.decode("utf-8", errors = "surrogateescape"), + buildid_proc.stderr.decode("utf-8", errors = "surrogateescape"), + )) +buildid = buildid_proc.stdout # Prefer to install the debug info by BuildID since it does not require another # objcopy invocation and is more standard