Skip to content

Add the get_umf_debug_info.sh script to print saved strings #993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,25 @@ $ strings libumf.so | grep "@(#)"
@(#) Intel(R) UMF CMake variables: "CMAKE_BUILD_TYPE:Debug,...
```

or using the dedicated `scripts/get_umf_debug_info.sh` script with any user binary:

```bash
$ scripts/get_umf_debug_info.sh ./build/test/umf_test-base
./build/test/umf_test-base is not linked with the UMF library.

$ scripts/get_umf_debug_info.sh ./build/test/umf_test-ipc
./build/test/umf_test-ipc is statically linked with the UMF library.
Strings:
@(#) Intel(R) UMF version: 0.10.0-git4.gbf701ee8
@(#) Intel(R) UMF CMake variables: "CMAKE_BUILD_TYPE:Debug,UMF_BUILD_BENCHMARKS:OFF, ..."

$ scripts/get_umf_debug_info.sh ./build/test/umf_test-c_api_disjoint_pool
./build/test/umf_test-c_api_disjoint_pool is dynamically linked with the UMF library.
Strings:
@(#) Intel(R) UMF version: 0.10.0-git4.gbf701ee8
@(#) Intel(R) UMF CMake variables: "CMAKE_BUILD_TYPE:Debug,UMF_BUILD_BENCHMARKS:OFF, ..."
```

#### Requirements

- binutils package (Linux)
44 changes: 44 additions & 0 deletions scripts/get_umf_debug_info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
# Copyright (C) 2024 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

BINARY=$1

if [ "$BINARY" = "" ]; then
echo "Usage: $(basename $0) <binary_name>"
exit 1
fi

if ! which strings >/dev/null; then
echo "strings command not found. Please install the binutils package."
exit 1
fi

# check if the binary is statically linked with libumf
# or if it is the UMF library itself
if [ $(strings $BINARY | grep -c -e "@(#) Intel(R) UMF") -gt 0 ]; then
BIN_NO_LINK=$(readlink -f "$BINARY")
FILE_INFO=$(file $BIN_NO_LINK)
if [[ "$FILE_INFO" == *"libumf.so"*"ELF 64-bit LSB shared object"*"dynamically linked"* ]]; then
echo "$BINARY is the UMF library ($BIN_NO_LINK)."
else
echo "$BINARY is statically linked with the UMF library."
fi

echo "Strings in $BIN_NO_LINK:"
strings $BIN_NO_LINK | grep "@(#) Intel(R) UMF"
exit 0
fi

# check if the binary is dynamically linked with libumf
if [ $(ldd $BINARY | grep -c -e "libumf.so") -gt 0 ]; then
UMF_LIB=$(ldd $BINARY | grep libumf.so | awk '{ print $3 }')
UMF_LIB=$(readlink -f "$UMF_LIB")
echo "$BINARY is dynamically linked with the UMF library ($UMF_LIB)."
echo "Strings in $UMF_LIB:"
strings $UMF_LIB | grep "@(#) Intel(R) UMF"
exit 0
fi

echo "$BINARY does not contain magic strings of the UMF library."
Loading