# Debugging

## Installation

Sodium comes with

* A native 64bit Windows Debugger application, **SodiumDebugger.exe (SD).**
* VS Code Debug Adaptor Protocol implementation, **Sodium-debug-0.37.0.vsix.**

&#x20;If you are a Sodium developer and want to debug your Sodium application, follow the steps below:

* Download and Install Visul Studio Code from [https://code.visualstudio.com/download](https://code.visualstudio.com/download)
* Run Visual Studio Code as administrator
* Find and click "Run \ Install Additional Debugger" menu item

![](https://1666013677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2ds-WBcneenLnDVHbz%2F-M53lgTF3JLNZ1Kph6mI%2F-M53tFCaX52_EcfylB3F%2Fstep-1.png?alt=media\&token=81ef292f-3678-4b4e-9436-2fae6282e875)

* Click "..." button to open pull-down menu and click "Install from VSIX..." menu item

![](https://1666013677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2ds-WBcneenLnDVHbz%2F-M53lgTF3JLNZ1Kph6mI%2F-M53tdwP0ohYQ7czc8O4%2Fstep-2.png?alt=media\&token=30374f2c-8744-4172-a706-1e08655cc3e1)

* Find and click "sodium-debug-x.x.x.vsix" file and click "Install" button

![](https://1666013677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2ds-WBcneenLnDVHbz%2F-M53lgTF3JLNZ1Kph6mI%2F-M53uClPNWNQtWx89DMI%2Fstep-3.png?alt=media\&token=57ac1b00-a147-45a0-bf80-05da04d4cf6f)

* After installation completes, you will see the screen below;

![](https://1666013677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2ds-WBcneenLnDVHbz%2F-M53uEgzdAzTZhkjss_H%2F-M53ugf4-TOpPZoKx6wb%2Fstep-4.png?alt=media\&token=a71c25a0-1fcc-40aa-becb-1ba64b5e4440)

## How To Debug

Now, Sodium applications can be debugged using Visual Stuido Code editor. Follow the steps below;

* Run **StartSodiumServer.bat** file as administrator.
* Wait for internet browser to open and then find the "Session Id: XXXXX" section at the bottom of the page and copy the session id.

![](https://1666013677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2ds-WBcneenLnDVHbz%2F-M53uEgzdAzTZhkjss_H%2F-M53vgQYXkPXTXA4sxiP%2Fstep-5.png?alt=media\&token=e26abcc3-130e-474c-ac84-3b35581eada7)

* Switch to Visual Stuido Code and then click "File \ Open Workspace" menu item
* Find "Sodium-Site" folder in Sodium installation folder and choose "Sodium.code-workspace" file and click "Open" button.

![](https://1666013677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2ds-WBcneenLnDVHbz%2F-M53vj-RR-zIK1bfauRS%2F-M53wrEQbLrYeFO3p5z3%2Fstep-6.png?alt=media\&token=53cb23d7-be54-439e-ad07-33c9fad142f4)

* Find and open "launch.json" file. Replace "Session Id" value with the correct value.
* "sdPath" value must be the full path of the "SodiumDebugger.exe". (Put double \ character between folder names)

![](https://1666013677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2ds-WBcneenLnDVHbz%2F-M5cRfrtiQKPGroCJ4sp%2F-M5cTMtmdU1zpfZ_h4DH%2Fimage.png?alt=media\&token=ba1ce6c5-1540-4145-b25e-8d462f19e0d8)

* Find and open the "welcome.sqlx" file in VS Code

![](https://1666013677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2ds-WBcneenLnDVHbz%2F-M53wvw3XhuorJ4b9AEw%2F-M53xMOrKKBCVBDwUfMj%2Fstep-7.png?alt=media\&token=257cbf67-6f50-4393-b191-c8da5351d6d9)

* Press F5 button. SodiumDebugger will be activated and VS Code will show debug view.&#x20;

![](https://1666013677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2ds-WBcneenLnDVHbz%2F-M53wvw3XhuorJ4b9AEw%2F-M53yq6F6RJd0R5_fn0h%2Fstep-9.png?alt=media\&token=529510f0-a3cc-4474-9537-1b96c9ecd475)

* Find `cb_oracle.logon2oracle()` function in the `welcome.sqlx` file and put a breakpoint on any line in that function.
* Reload web page. A new line will be appeared at the bottom of the page as shown below;

![](https://1666013677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2ds-WBcneenLnDVHbz%2F-M541MXzD7kt9CsG-wWe%2F-M547NfUCBNsynBMrNSv%2Fstep-10.png?alt=media\&token=140fbd5f-14c9-4118-9b2e-075cb5d46c67)

Click "Login to Oracle" button (you do not need to have Oracle Database at this stage). Execution of the "welcome.sqlx" file will be stopped and VS Code will point the line where the execution stopped. Also, VS Code will show "Watch", "Variables" and "Call Stacks" panels.

![](https://1666013677-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2ds-WBcneenLnDVHbz%2F-M541MXzD7kt9CsG-wWe%2F-M548prfOZFQuPGIH1jQ%2Fstep-11.png?alt=media\&token=4d100863-5aa1-498b-bf6e-8f756d81efc2)

* Now, you can use following buttons to send debug commands to the debugger
  * F10 for Step-Over
  * F11 for Step-In
  * Shift-F11 for Step-Out
  * F5 for Continue

## Video Guide

{% embed url="https://www.youtube.com/watch?v=is5o-LWgx0o" %}
Sodium Debugging
{% endembed %}



