Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt 5.x embedded debugging - deploy stripped binary?

I believe (correct me if I'm wrong) that when remote debugging with gdb and gdbserver, the binary running on the target under gdbserver doesn't need the debug information in the binary, but the host, running gdb, does.

Our application binary with debugging symbols is about 112 megs (!). If I run strip, the binary is only 6.7 megs, which would be much faster to deploy to our target.

Is it possible to have Qt Creator strip the binary before deploying it? Will we still be able to debug?

like image 403
Steve Avatar asked Feb 17 '16 21:02

Steve


1 Answers

To strip symbols, you can have Qt Creator run a final build step after qmake and make, which calls the 'strip' command on the binary in your app bundle. For example: -

strip -u -r ./MyApplication/Contents/MacOS/MyApplication

In order to debug, you'd need a separate .dsym file to be generated during the build, which contains the symbols. If this resides on the host, the debugger should automatically pick this up; it does with lldb, though with gdb, you may need to manually load the symbol file.

how to enable that extra build step

Select projects from the right-side tool bar

Menu bar

Ensure you're on the Build and Run tab (GraphicsScene is just the name of the project)

tabs

Under Build Steps, you'll see two steps, qMake and Make. Select add build step for a custom process step

Build Steps

Fill in the relevant fields you may need to correct for the paths, rather than just copy these:

Enter details

When the build has finished, the strip command will run. If you've any errors, it's likely a problem with the path to either the strip command or the path to your app bundle's executable.

Note that if you need the full path to strip, it resides in /usr/bin/strip.

As for the symbol file, I believe you can use the addsymbolfilecommand with the argument to the path to the dsym file. However, gdb has since been deprecated and you should really be using lldb now, which automatically finds the dsym file, once it has been indexed by Spotlight.

like image 82
TheDarkKnight Avatar answered Nov 16 '22 02:11

TheDarkKnight