Tuesday, April 23, 2024

Re: Debugging Existing C++ Blocks with VS Code & GDB

Hi Matt, 

I'm not sure if this is an apples-to-apples situation, but your issue sounds exactly like something I've run into while abusing Python snippets. 
It was easy to avoid after understanding order-of-events for block creation.

I suspect this is language-independent, and you can quickly create a python flowgraph / review the code - it will illustrate the principles:

1. Create a python flowgraph 'FOO.grc' with minimal blocks (e.g. [signal source] --> [throttle2] --> [null sink]).  

2. Add four [Python Snippet] blocks - one for each type of [Section of Flowgraph] param: 'Init - Before Blocks', 'Main - After Start', etc.

3. For each Python Snippet block, add a one-line snippet distinct to the [Section of Flowgraph], for example: 

print("Hello IAMA Init - Before Blocks")    
# NOTE: it's important to have a least one line of code or nothing will be generated for the snippet!

4. Set the Title param of the [Options] block (top block) to "FOO".

5. Press [F5] to generate the flowgraph code, which will be called FOO.py (in same directory as FOO.grc).

6. Examine the resulting FOO.py script in VSCode - in particular, where each of the snippets are invoked.

The most obvious example is that in 'Init - Before Block' it's possible to reference a block or variable self.X before self.X has been instantiated.

More subtle cases are possible, depending on how clever one tries to be when using this mechanism.

- W 

Attached: screencap of example error (take my word that the block 'radio' exists).  I can send a shot of the flowgraph, but it probably wouldn't shed further light.



On Apr 23, 2024, at 13:46, Matt Clemons <mattclems11@gmail.com> wrote:

Hello,

I've walked through tutorials and successfully set breakpoints and debugged OOT modules in Gnu Radio using the DCMAKE_BUILD_TYPE=Debug option. However, I'm trying to debug local changes I've made to existing gnuradio/dtv/ files and not having success.

I've followed the steps in a similar question/email chain here: https://lists.gnu.org/archive/html/discuss-gnuradio/2021-08/msg00008.html (I wasn't sure if replying to this old chain with a question or referencing it was better, let me know if there is a preference for future scenerios).

I also tried recompiling all of the gnu radio source code on my machine with the  DCMAKE_BUILD_TYPE=Debug option and still can not get VScode to stop on my set breakpoint within the dtv/dvbt_demod_reference_signals_impl.cc file. The flowchart runs, and completes but when I hover over the break point it just says "Module containing this breakpoint has not yet loaded or the address could not be obtained".

Any suggestions? I don't like the option of copying this into an OOT module just to debug. I'm not sure I understand the difference either.

Thanks,

Matt

No comments:

Post a Comment