Hello lindi,
lindi wrote: ↑2023-11-04 18:50
How do I find the Debian binary package containing a C function ?
For example, the source package named "samba" [1] generates the binary code for the C function named "remote_password_change" with the following prototype:
Code: Select all
NTSTATUS remote_password_change(const char *remote_machine,
const char *domain, const char *user_name,
const char *old_passwd, const char *new_passwd,
char **err_str);
Fetch -dbgsym packages for all of the binary packages generated from the source package. Then use "nm" to list symbols in those binaries? This still won't help if the function got inlined though.
I followed your hint:
1) I configured /etc/apt/sources.list to add debian-debug repositories:
Code: Select all
deb http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm main non-free-firmware
deb http://deb.debian.org/debian bookworm-updates main non-free-firmware
deb-src http://deb.debian.org/debian bookworm-updates main non-free-firmware
deb http://deb.debian.org/debian-security/ bookworm-security main non-free-firmware
deb-src http://deb.debian.org/debian-security/ bookworm-security main non-free-firmware
# Debug Symbols
deb http://deb.debian.org/debian-debug/ bookworm-debug main contrib non-free non-free-firmware
deb http://deb.debian.org/debian-debug/ bookworm-proposed-updates-debug main
2) Using the Debian site at
https://packages.debian.org , I searched for the Debian source package of the samba binary package:
I obtained the following output:
Source Package samba
bookworm (net): 2:4.17.12+dfsg-0+deb12u1 [security]
Binary packages: [hide 26 binary packages] ctdb, ldb-tools, libldb-dev, libldb2, libnss-winbind, libpam-winbind, libsmbclient, libsmbclient-dev, libwbclient-dev, libwbclient0, python3-ldb, python3-ldb-dev, python3-samba, registry-tools, samba, samba-ad-dc, samba-ad-provision, samba-common, samba-common-bin, samba-dev, samba-dsdb-modules, samba-libs, samba-testsuite, samba-vfs-modules, smbclient, winbind
3) I copied, pasted and manually edited all the names of the binary packages built from the source package named "samba".
Then, I assembled the following command (a simulated install) replacing the ',' character from previous output with "-dbgsym" (all symbols packages created by Debian project use the "-dbgsym" suffix):
Code: Select all
# apt -s install ctdb-dbgsym ldb-tools-dbgsym libldb-dev-dbgsym libldb2-dbgsym libnss-winbind-dbgsym libpam-winbind-dbgsym libsmbclient-dbgsym libsmbclient-dev-dbgsym libwbclient-dev-dbgsym libwbclient0-dbgsym python3-ldb-dbgsym python3-ldb-dev-dbgsym python3-samba-dbgsym registry-tools-dbgsym samba-dbgsym samba-ad-dc-dbgsym samba-ad-provision-dbgsym samba-common-dbgsym samba-common-bin-dbgsym samba-dev-dbgsym samba-dsdb-modules-dbgsym samba-libs-dbgsym samba-testsuite-dbgsym samba-vfs-modules-dbgsym smbclient-dbgsym winbind
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package libldb-dev-dbgsym
E: Unable to locate package libsmbclient-dev-dbgsym
E: Unable to locate package libwbclient-dev-dbgsym
E: Unable to locate package python3-ldb-dev-dbgsym
E: Unable to locate package samba-ad-dc-dbgsym
E: Unable to locate package samba-ad-provision-dbgsym
E: Unable to locate package samba-common-dbgsym
E: Unable to locate package samba-dev-dbgsym
As you can see, some binary packages have no debug symbol packages. They are "-dev" packages, while the others packages I suppose don't contain libraries or executable code, therefore I suppose they could not supply debug symbols.
4) I modified the previous simulated command, removing references to not existing "-dbgsym" packages:
Code: Select all
# apt install ctdb-dbgsym ldb-tools-dbgsym \
libldb2-dbgsym libnss-winbind-dbgsym libpam-winbind-dbgsym \
libsmbclient-dbgsym libwbclient0-dbgsym python3-ldb-dbgsym \
python3-samba-dbgsym registry-tools-dbgsym samba-dbgsym \
samba-common-bin-dbgsym samba-dsdb-modules-dbgsym \
samba-libs-dbgsym samba-testsuite-dbgsym samba-vfs-modules-dbgsym \
smbclient-dbgsym winbind
5) I searched for the name of the C function named "
remote_password_change" (using the nm package you advised to me) in debug symbols (note: "-dbgsym" packages store their "*.debug" files in the directory named /usr/lib/debug/ )
Code: Select all
# find /usr/lib/debug -name "*.debug" -exec nm --print-file-name --line-numbers {} 2>&1 \; | grep "remote_password_change"
It took about 6 minutes; the output was:
Code: Select all
# find /usr/lib/debug -name "*.debug" -exec nm --print-file-name --line-numbers {} 2>&1 \; | grep "remote_password_change"
/usr/lib/debug/.build-id/db/feab433239b8e04dcce44968d70346ac03571a.debug:0000000000005830 T remote_password_change ./bin/default/../../source3/libsmb/passchange.c:37
Now I missing the last step: how can I tell which Debian binary package and binary executable (program) the following file refers to?
Code: Select all
/usr/lib/debug/.build-id/db/feab433239b8e04dcce44968d70346ac03571a.debug
Is there a smarter way to do all this?