Build digikam with debug symbols?

I’m trying to track down a problem with digikam, but haven’t been able to build it with debug symbols. Nothing I’ve found here, in the manual, or elsewhere has been successful. Any advice would be greatly appreciated!

Have you tried what is written in the wiki to disable stripping of the debug symbols that is enabled by default? Doing dontStrip = true; is needed to disable the optimization. You also need to enable the debug symbols during compilation: doing:

nix-build -E 'with import <nixpkgs> {}; enableDebugging digikam'

Should automatically disable stripping and add compilation options -Og -ggdb. But I can’t test without a computer.

I haven’t been able to get that to work. I’ve checked out the repo locally, and am running
nix-build -E '(import <nixpkgs> { config = { cudaSupport = false; }; }).libsForQt5.callPackage ./default.nix { }'

I’ve addedseparateDebugInfo = true; to default.nix (and have tried mucking with compiler flags as well), but gdb insists it can’t find any debug symbols.

Hum… you might additionally need to enable the debug mode in cmake with cmakeBuildType = "Debug";? Sorry I still can’t test now.

For separateDebugInfo to work, you need to tell gdb where to find the separate debug symbols:

  • either with this environment variable NIX_DEBUG_INFO_DIRS
  • or with additional tooling like nixseparatedebuginfod

See Debug Symbols - NixOS Wiki for more details.

I’m making progress. The debugger now finds symbols, but not the source code. I’m getting messages like
/build/digikam-8.1.0/core/libs/dngwriter/extra/dng_sdk/dng_validate.cpp: No such file or directory.

Any ideas?

OK, I downloaded the source, applied the path, and copied it to /build, then told gdb where to find it. Now I can tell it is stuck in KApplicationTrader::queryByMimeType(firstMimeType); (which I haven’t build with debug symbols).

1 Like

So is your problem solved? (If you also want to build one dependency with debug symbols I guess you can use overlays) If so you can maybe summarize the solution? I’m just surprised that you need to copy stuff in /build, that seems fairly weird, but I know very little about debugging.

Apparently, dgb has a directory command to specify where to look for sources if you do not use GitHub - symphorien/nixseparatedebuginfod: Downloads and provides debug symbols and source code for nix derivations to gdb and other debuginfod-capable debuggers as needed.

Thanks for following up. I’ve been able to get the debugger to recognize the source code. If I remember correctly, the steps were:

  1. Clone the repo locally

  2. Edit the digikam default.nix, adding:

     enableDebugging = true;
     separateDebugInfo = true;

    to the derivation, and "-DCMAKE_BUILD_TYPE=Debug" to the cmakeFlags.

    (I’m not sure if all of this is required)

  3. In the digikam directory, run:
    nix-build -I /home/mike/src/nixpkgs/ -E '(import <nixpkgs> { config = { cudaSupport = false; }; }).libsForQt5.callPackage ./default.nix { }'. This put the results in /nix/store/d9w4hzwb4sb42sfzg5d297j237xivl15-digikam-8.1.0.

  4. Find the debug symbols by running: nix show-derivation /nix/store/d9w4hzwb4sb42sfzg5d297j237xivl15-digikam-8.1.0| grep debug. They are in /nix/store/1c8npncnaxg9jm98bs27f1n2vl1vp5r9-digikam-8.1.0-debug`.

  5. Download the source, and apply the patch. Store the source in /build/digikam-8.1.0.

  6. At some point, I added set auto-load safe-path / to ~/.config/gdb/gdbinit to allow gdb to load the debug symbols.

  7. digikam sets up a bunch of environment variables, then runs digikam-wrapped. Capture the set-up to `~/tmp.bash~ with

head --lines=-1 /nix/store/d9w4hzwb4sb42sfzg5d297j237xivl15-digikam-8.1.0/bin/digikam > ~/tmp.bash
  1. Start a new shell and set up the environment for digikam:
    . ~/tmp.bash
7.  Start the program, telling `gdb` where to find the symbols:

NIX_DEBUG_INFO_DIRS=/nix/store/1c8npncnaxg9jm98bs27f1n2vl1vp5r9-digikam-8.1.0-debug/lib/debug gdb /nix/store/d9w4hzwb4sb42sfzg5d297j237xivl15-digikam-8.1.0/bin/.digikam-wrapped

8. Get the program to lock up by right-clicking in the album view, then interrupt it in the debugger and dump the backtrace:
#0  0x00007ffff3ef4c89 in ?? () from /nix/store/im7q5f5j9q8x5whs4d2hz9m8il47iidp-qtbase-5.15.3/lib/
#1  0x00007ffff3ef981a in QString::fromLatin1_helper(char const*, int) () from /nix/store/im7q5f5j9q8x5whs4d2hz9m8il47iidp-qtbase-5.15.3/lib/
#2  0x00007ffff4133a71 in ?? () from /nix/store/im7q5f5j9q8x5whs4d2hz9m8il47iidp-qtbase-5.15.3/lib/
#3  0x00007ffff4125f77 in ?? () from /nix/store/im7q5f5j9q8x5whs4d2hz9m8il47iidp-qtbase-5.15.3/lib/
#4  0x00007ffff412646b in ?? () from /nix/store/im7q5f5j9q8x5whs4d2hz9m8il47iidp-qtbase-5.15.3/lib/
#5  0x00007ffff4126b62 in ?? () from /nix/store/im7q5f5j9q8x5whs4d2hz9m8il47iidp-qtbase-5.15.3/lib/
#6  0x00007ffff584bf27 in KBuildServiceFactory::populateServiceTypes() () from /nix/store/ysablxbzzb7jys1i48cph38n7dnd1zb1-kservice-5.93.0/lib/
#7  0x00007ffff58535e4 in KBuildSycoca::save(QDataStream*) () from /nix/store/ysablxbzzb7jys1i48cph38n7dnd1zb1-kservice-5.93.0/lib/
#8  0x00007ffff5856ddd in KBuildSycoca::recreate(bool) () from /nix/store/ysablxbzzb7jys1i48cph38n7dnd1zb1-kservice-5.93.0/lib/
#9  0x00007ffff5836d30 in KSycocaPrivate::buildSycoca() () from /nix/store/ysablxbzzb7jys1i48cph38n7dnd1zb1-kservice-5.93.0/lib/
#10 0x00007ffff5837ca0 in KSycoca::ensureCacheValid() () from /nix/store/ysablxbzzb7jys1i48cph38n7dnd1zb1-kservice-5.93.0/lib/
#11 0x00007ffff57fa552 in KApplicationTrader::queryByMimeType(QString const&, std::function<bool (QExplicitlySharedDataPointer<KService> const&)>) ()
   from /nix/store/ysablxbzzb7jys1i48cph38n7dnd1zb1-kservice-5.93.0/lib/
#12 0x00007ffff662a929 in Digikam::DServiceMenu::servicesForOpenWith (urls=...) at /build/digikam-8.1.0/core/libs/threadimageio/engine/dservicemenu_linux.cpp:247

`digikam` makes a call to `KApplicationTrader::queryByMimeType`, which never returns. 

So, I've gotten past the problem raised here--thanks for your help!

I guess I need to dig deeper to solve the original problem, though. I suppose I'll need to build some of the libraries for debugging as well.
1 Like