Re: [PATCH 2/2][PR GDB/32956] gdb: query inferior's filesystem for build-id debug files

Fabian Kilger
2025-05-24T19:55:15Z

[-- Attachment #1.1.1: Type: text/plain, Size: 2697 bytes --]

Thanks for approving, I'll add the link to the commit message.

If I merge this ahead of #1, can I leave it out in the v2 patch
submission, or should it be included for completeness' sake - not sure
what is desired.

Best,
Fabian

On 5/23/25 20:20, Andrew Burgess wrote:
> Fabian Kilger <kilger@sec.in.tum.de> writes:
>
>> This fixes a bug related to build-id files with linux namespaces.
>> Specifically, we expect the debug files to be present inside the container,
>> thus the container filesystem should be queried if the program is running
>> inside one.
>
> You should add a bug link to the end of this commit message, like:
>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32956
>
> With that added, for this patch:
>
> Approved-By: Andrew Burgess <aburgess@redhat.com>
>
> You are welcome to merge this ahead of patch #1 if you want, as they are
> related, but don't depend on each other.
>
> Thanks,
> Andrew
>
>
>
>>
>> ---
>> gdb/build-id.c | 6 ++++--
>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/gdb/build-id.c b/gdb/build-id.c
>> index 43a80dd3978..abbd65a7c12 100644
>> --- a/gdb/build-id.c
>> +++ b/gdb/build-id.c
>> @@ -29,6 +29,7 @@
>> #include "gdbsupport/scoped_fd.h"
>> #include "debuginfod-support.h"
>> #include "extension.h"
>> +#include "inferior.h"
>>
>> /* See build-id.h. */
>>
>> @@ -128,7 +129,8 @@ build_id_to_debug_bfd_1 (const std::string &original_link,
>> if (supports_target_stat != TRIBOOL_FALSE)
>> {
>> struct stat sb;
>> - int res = target_fileio_stat (nullptr, link_on_target, &sb,
>> + int res = target_fileio_stat (current_inferior (),
>> + link_on_target, &sb,
>> &target_errno);
>>
>> if (res != 0 && target_errno != FILEIO_ENOSYS)
>> @@ -157,7 +159,7 @@ build_id_to_debug_bfd_1 (const std::string &original_link,
>> the path doesn't exist, but we just assume that anything
>> other than EINVAL indicates the path doesn't exist. */
>> std::optional<std::string> link_target
>> - = target_fileio_readlink (nullptr, link_on_target,
>> + = target_fileio_readlink (current_inferior (), link_on_target,
>> &target_errno);
>> if (link_target.has_value ()
>> || target_errno == FILEIO_EINVAL)
>> --
>> 2.49.0
>

--
Fabian Kilger, M.Sc.
Wissenschaftlicher Mitarbeiter

Technische Universität München
TUM School of Computation, Information and Technology
Chair of IT Security

Boltzmannstraße 3
85748 Garching (bei München)

Tel. +49 (0)89 289-18587
Fax +49 (0)89 289-18579

kilger@sec.in.tum.de
www.sec.in.tum.de

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 653 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]