Webinar Recording: Debugging C/C++ applications on Linux in CLion, from basics to reverse debug
The recording of our December 6th webinar with Phil Nash, Isa Smith and Greg Law, Debugging C/C++ applications on Linux in CLion, from basics to reverse debug, is now available on JetBrainsTV YouTube channel.
In this webinar we look at how CLion makes debugging easier out of the box – then see how Undo’s award-winning reversible debugging technology allows developers to step backwards as well as forwards inside their program to find the root cause of a failure.
Phil’s demo project: Catch framework on GitHub
The video includes the time stamps following the agenda announced:
0:44 – Fundamental CLion debugging topics
1:24 – Getting orientated with debugging in CLion
4:20 – Stepping, viewing and watching variables and expressions
8:21 – Breakpoints, conditions, dependent breakpoints and logging
14:57 – Reversible Debugging in CLion with Undo, intro from Greg Law
21:50 – Undo demo
33:35 – Advanced CLion debugging topics: attach to local process
36:16 – Advanced CLion debugging topics: remote GDB debug
Below are some questions from our webinar answered by Phil, Isa and Anastasia.
Questions on CLion
Q: Can you define a custom way of printing variables in the locals window? As a C developer I often want to correlate a pointer with a counter for listing a dynamic array.
Anastasia: You can use custom pretty printers via .gdbinit/.lldbinit.
Q: Any chance that the setup workflow for remote debug will be automated in a future version? Something like the Docker workflow in PyCharm?
Anastasia: Thanks for the idea. We’ll consider for the future. However use cases are rather different, so suggestions are welcome in the tracker.
Questions on Undo
Q: Is it possible to jump to a specific stack frame?
Isa: You can move up and down the stack one frame using ‘Step Out’ and ‘Reverse Step Out’.
You can view the state of a particular frame by clicking on it as normal, but this doesn’t properly move the state. You can move the state by setting a breakpoint in code having clicked the stack frame and using ‘Reverse Resume’ to run back to it.
Moving the program state to a particular stack frame without using breakpoints is an extra feature we could consider.
Q: Is the recorder always enabled during a debugging session?
Isa: You can delay, or ‘defer’ recording until some time into your program, for example if you have an IO heavy startup which is slow to record, and you don’t want to debug it. This isn’t yet supported directly from CLion: you will need to add
--undodb-defer-recording to the undodb-gdb invocation and then urecord in the gdb pane to start recording.
Q: Does it freeze one thread or the whole state?
Isa: The whole state.
Q: Does it also support cross-compile?
Isa: Yes, Undo technology supports ARM and x86, and you can debug a remote ARM process from an x86 machine.
Q: Does it require extra memory to run Undo?
Isa: The memory requirements depend on your application. Applications that are heavy on IO, shared memory usage, signals… these will use more memory than CPU-bound applications. We are always working to improve performance and memory usage.
Q: I didn’t see support for amd64 on the Undo webpage – is this supported?
Q: What if the issue is reproduced only once a day. Can we still record our session with undo?
Isa: Yes — this is what Undo is best for. If your program needs to run for a day, then it will take longer to run in Undo. However you only need to capture the problem happening once. Once you have captured it, you can save the state to a recording and share it with colleagues, and reproduce on any machine. To learn more about recording, and our Live Recorder products, please have a look at our website or contact us.
For long sessions we recommend setting a circular event log. This will keep the memory usage to a specified amount, at the cost of losing history from the start of your program.
Q: What about program that runs for many hours? Is there a limit to how much you can record?
Isa: By default we will record everything and keep growing our event log up to 256MB. You can increase (or reduce) the size of the event log, and for very long runs we suggest that you use a circular event log. This will overwrite old history with new history, so you should still have enough context to debug your problem, without having large demands on memory.
Q: What is cost of this plugin?
Isa: Please contact us for pricing and we can give you a quote depending on whether you want node-locked, floating or Live Recorder licenses (firstname.lastname@example.org).
Thanks to all the attendees for the questions!
About the presenters:
Phil Nash is a Developer Advocate for C++, Objective-C and Swift tools at JetBrains. Prior to that he worked in as diverse fields as finance, agile coaching and iOS development. A long time C++ developer he also has his feet in C#, F#, Objective-C and Swift – as well as dabbling in other languages. He is the author of several open source projects – most notably Catch: a C++-native test framework.
Isa Smith is a Software Engineer at Undo. Her technical interests revolve around creating great development tools. Her favourite programming language is C, for its closeness to the machine. She likes to tackle problems from the bottom up, and has an extensive knowledge of the ARM (and ARM 64-bit) architectures and a good knowledge of the x86-64 instruction set.
At Undo she is responsible (among other things) for performance and optimisation of the Undo tools. She holds a BSc in Computer Science and Mathematics from the University of York.
Greg Law is the co-founder and CEO of Undo. He is a coder at heart, but likes to bridge the gap between the business and software worlds. Greg has 20 years’ experience in the software industry and has held development and management roles at companies including the pioneering British computer firm Acorn, as well as fast-growing start ups, NexWave and Solarflare. It was at Acorn that Greg met his co-founder, Julian Smith, and on evenings and weekends, they invented the core technology that eventually became UndoDB. Greg left Solarflare in 2012 to lead Undo as CEO and has overseen the company as it transitioned from the shed in his back garden to a scalable award-winning business.
The CLion Team