Skip to content

Commit

Permalink
Make gnu_debuglink_test compatible with aarch64
Browse files Browse the repository at this point in the history
Summary:
It turns out that __builtin_trap doesn't produce the right kind of crash on aarch64, eliding the stack trace.

Use abort(3) to crash, which reliably generates a crash that the symbolizer can output.

Reviewed By: Gownta

Differential Revision: D50733603

fbshipit-source-id: 3f244a97ce6d0cbdfe2a4fc9c6f6f9b4cadbe4d4
  • Loading branch information
Michael van der Westhuizen authored and facebook-github-bot committed Oct 30, 2023
1 parent 82ce15a commit a339306
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion folly/experimental/symbolizer/test/Crash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

#include <cstdlib>
#include <folly/experimental/symbolizer/SignalHandler.h>

int main() {
folly::symbolizer::installFatalSignalHandler();
__builtin_trap();
std::abort();
}
4 changes: 2 additions & 2 deletions folly/experimental/symbolizer/test/gnu_debuglink_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ uuid=$(cat /proc/sys/kernel/random/uuid)
for sig in 1 2 3 13 15; do eval "trap 'exit $((sig + 128))' $sig"; done
trap 'rm -f "$crash.debuginfo.$uuid" "$crash.strip.$uuid"' 0

${OBJCOPY} --only-keep-debug "$crash" "$crash.debuginfo.$uuid"
${OBJCOPY} --strip-debug --add-gnu-debuglink="$crash.debuginfo.$uuid" "$crash" "$crash.strip.$uuid"
objcopy --only-keep-debug "$crash" "$crash.debuginfo.$uuid"
objcopy --strip-debug --add-gnu-debuglink="$crash.debuginfo.$uuid" "$crash" "$crash.strip.$uuid"

echo '{"op":"start","test":"gnu_debuglink_test"}';
start=$(date +%s)
Expand Down

0 comments on commit a339306

Please sign in to comment.