Skip to content

Commit 9717f3b

Browse files
committed
Add get_umf_debug_info.sh to print saved strings
Add the `get_umf_debug_info.sh` script to print saved strings. It can be used with any user binary: $ scripts/get_umf_debug_info.sh ./build/test/umf_test-base ./test/umf_test-base does not contain magic strings of the UMF library. $ scripts/get_umf_debug_info.sh ./build/test/umf_test-ipc ./test/umf_test-ipc is statically linked with the UMF library. Strings in /mnt/wsl/files/repos/unified-memory-framework/build/test/umf_test-ipc: @(#) Intel(R) UMF version: 0.10.0-git4.gbf701ee8 @(#) Intel(R) UMF CMake variables: "CMAKE_BUILD_TYPE:Debug, ..." $ scripts/get_umf_debug_info.sh ./build/test/umf_test-c_api_disjoint_pool ./test/umf_test-c_api_disjoint_pool is dynamically linked with the UMF library \ (/mnt/wsl/files/repos/unified-memory-framework/build/lib/libumf.so.0.10.0). Strings in /mnt/wsl/files/repos/unified-memory-framework/build/lib/libumf.so.0.10.0: @(#) Intel(R) UMF version: 0.10.0-git4.gbf701ee8 @(#) Intel(R) UMF CMake variables: "CMAKE_BUILD_TYPE:Debug, ..." $ ../scripts/get_umf_debug_info.sh ./lib/libumf.so ./lib/libumf.so is the UMF library (/mnt/wsl/files/repos/unified-memory-framework/build/lib/libumf.so.0.10.0). Strings in /mnt/wsl/files/repos/unified-memory-framework/build/lib/libumf.so.0.10.0: @(#) Intel(R) UMF version: 0.10.0-git4.g806ce00c @(#) Intel(R) UMF CMake variables: "CMAKE_BUILD_TYPE:Debug, ..." Signed-off-by: Lukasz Dorau <[email protected]>
1 parent ac9094d commit 9717f3b

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

CONTRIBUTING.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,25 @@ $ strings libumf.so | grep "@(#)"
239239
@(#) Intel(R) UMF CMake variables: "CMAKE_BUILD_TYPE:Debug,...
240240
```
241241
242+
or using the dedicated `scripts/get_umf_debug_info.sh` script with any user binary:
243+
244+
```bash
245+
$ scripts/get_umf_debug_info.sh ./build/test/umf_test-base
246+
./build/test/umf_test-base is not linked with the UMF library.
247+
248+
$ scripts/get_umf_debug_info.sh ./build/test/umf_test-ipc
249+
./build/test/umf_test-ipc is statically linked with the UMF library.
250+
Strings:
251+
@(#) Intel(R) UMF version: 0.10.0-git4.gbf701ee8
252+
@(#) Intel(R) UMF CMake variables: "CMAKE_BUILD_TYPE:Debug,UMF_BUILD_BENCHMARKS:OFF, ..."
253+
254+
$ scripts/get_umf_debug_info.sh ./build/test/umf_test-c_api_disjoint_pool
255+
./build/test/umf_test-c_api_disjoint_pool is dynamically linked with the UMF library.
256+
Strings:
257+
@(#) Intel(R) UMF version: 0.10.0-git4.gbf701ee8
258+
@(#) Intel(R) UMF CMake variables: "CMAKE_BUILD_TYPE:Debug,UMF_BUILD_BENCHMARKS:OFF, ..."
259+
```
260+
242261
#### Requirements
243262
244263
- binutils package (Linux)

scripts/get_umf_debug_info.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
# Copyright (C) 2024 Intel Corporation
3+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
BINARY=$1
7+
8+
if [ "$BINARY" = "" ]; then
9+
echo "Usage: $(basename $0) <binary_name>"
10+
exit 1
11+
fi
12+
13+
if ! which strings >/dev/null; then
14+
echo "strings command not found. Please install the binutils package."
15+
exit 1
16+
fi
17+
18+
# check if the binary is statically linked with libumf
19+
# or if it is the UMF library itself
20+
if [ $(strings $BINARY | grep -c -e "@(#) Intel(R) UMF") -gt 0 ]; then
21+
BIN_NO_LINK=$(readlink -f "$BINARY")
22+
FILE_INFO=$(file $BIN_NO_LINK)
23+
if [[ "$FILE_INFO" == *"libumf.so"*"ELF 64-bit LSB shared object"*"dynamically linked"* ]]; then
24+
echo "$BINARY is the UMF library ($BIN_NO_LINK)."
25+
else
26+
echo "$BINARY is statically linked with the UMF library."
27+
fi
28+
29+
echo "Strings in $BIN_NO_LINK:"
30+
strings $BIN_NO_LINK | grep "@(#) Intel(R) UMF"
31+
exit 0
32+
fi
33+
34+
# check if the binary is dynamically linked with libumf
35+
if [ $(ldd $BINARY | grep -c -e "libumf.so") -gt 0 ]; then
36+
UMF_LIB=$(ldd $BINARY | grep libumf.so | awk '{ print $3 }')
37+
UMF_LIB=$(readlink -f "$UMF_LIB")
38+
echo "$BINARY is dynamically linked with the UMF library ($UMF_LIB)."
39+
echo "Strings in $UMF_LIB:"
40+
strings $UMF_LIB | grep "@(#) Intel(R) UMF"
41+
exit 0
42+
fi
43+
44+
echo "$BINARY does not contain magic strings of the UMF library."

0 commit comments

Comments
 (0)