Suppose there is a project folder /home/srcdbg/project/module_prj in the WSL ubuntu18 whose host name is localhost. The following steps explain how to use offline debugging for code analysis.
1. Select File > New > Solution... > Wizard... and then click the OK button.
2. Enter the name of the project and click Next button.
3. Enter the correct Remote host, Port, Username, Password, Initial path and click Next button.
4. Click Next button.
5. Click Next button.
6. Click Finish button.
7. Enter the solution File name and click Save button.
8. Enter the project File name and click Save button.
9. Right click the srcdbg_test project and select Add > Add Existing Remote File to add the project files.
10. Select the needed folders and files and click Open button.
11. Select Build > Synchronize Files... to synchronize files and build the project symbols.
12. Right click the srcdbg_test project and select Properties.
Change Attach to program as "-i=mi ./test.ko".
Configure Entry function as "hello_init".
13. Select Debug > Start Debugging to debug the project.
14. In the find box you can enter the following types of content and press Ctrl+J to jump to the corresponding source code:
Symbol name: hello_init
Symbol + offset:
hello_init+0x24
Symbo address: 0x5c
15. It will automatically navigate to the corresponding location of the source code as below.
16. The toolbar button(shortcut F6) is used to jump to the source location of the symbol. For example, placing the mouse on a symbol(e.g. hello_init) and pressing F6 will jump to the place where the symbol is defined. If there is no corresponding symbol for the mouse position, then offline debugging will start from that line.
17. The toolbar button(shortcut F7) is used to jump to next source location of the symbol. In most cases you need firstly press F6 to jump to a certain position, and then use F7 to jump to the next position. This can be used to determine if the code is conditionally compiled or not.
If CRASH_TEST is defined, press F7 it will run to position 1-4 as shown below.
If CRASH_TEST is not defined, press F7 it will run to position 1-2 as shown below.