PageSourceSearch

https://noir-lang.org/docs/assets/js/59ef7082.b870db4d.js

js noir-lang.org collected 2026-10-03 22:50:37 UTC 10,168 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkdocs=globalThis.webpackChunkdocs||[]).push([[739],{96837(e,n,t){t.d(n,{Ay:()=>r});var i=t(74848),s=t(28453);function o(e){const n={a:"a",admonition:"admonition",p:"p",strong:"strong",...(0,s.R)(),...e.components};return(0,i.jsxs)(n.admonition,{title:"Experimental Feature",type:"caution",children:[(0,i.jsx)(n.p,{children:"This feature is experimental. The documentation may be incomplete or out of date, which means it could change in future versions, potentially causing unexpected behavior or not working as expected."}),(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Contributions Welcome:"})," If you notice any inaccuracies or potential improvements, please consider contributing. Visit our GitHub repository to make your contributions: ",(0,i.jsx)(n.a,{href:"https://github.com/noir-lang/noir",children:"Contribute Here"}),"."]})]})}function r(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(o,{...e})}):o(e)}t.d(n,["RM",0,[]])},54330(e,n,t){t.r(n),t.d(n,{assets:()=>a,contentTitle:()=>d,default:()=>g,frontMatter:()=>c,metadata:()=>i,toc:()=>h});const i=JSON.parse('{"id":"guides/debugging/debugging_with_vs_code","title":"Using the VS Code Debugger","description":"Step-by-step guide on how to debug your Noir circuits with the VS Code Debugger configuration and features.","source":"@site/versioned_docs/version-v1.0.0-rc.0/guides/debugging/debugging_with_vs_code.mdx","sourceDirName":"guides/
1debugging","slug":"/guides/debugging/debugging_with_vs_code","permalink":"/docs/v1.0.0-rc.0/guides/debugging/debugging_with_vs_code","draft":false,"unlisted":false,"editUrl":"https://github.com/noir-lang/noir/edit/master/docs/versioned_docs/version-v1.0.0-rc.0/guides/debugging/debugging_with_vs_code.mdx","tags":[],"version":"v1.0.0-rc.0","frontMatter":{"title":"Using the VS Code Debugger","description":"Step-by-step guide on how to debug your Noir circuits with the VS Code Debugger configuration and features.","keywords":["Nargo","Noir CLI","Noir Debugger","VS Code","IDE"]},"sidebar":"sidebar","previous":{"title":"How to use Oracles","permalink":"/docs/v1.0.0-rc.0/guides/how_to_use_oracles"},"next":{"title":"Using the REPL Debugger","permalink":"/docs/v1.0.0-rc.0/guides/debugging/debugging_with_the_repl"}}');var s=t(74848),o=t(28453),r=t(96837);const c={title:"Using the VS Code Debugger",description:"Step-by-step guide on how to debug your Noir circuits with the VS Code Debugger configuration and features.",keywords:["Nargo","Noir CLI","Noir Debugger","VS Code","IDE"]},d=void 0,a={},h=[...r.RM,{value:"Pre-requisites",id:"pre-requisites",level:4},{value:"Running the debugger",id:"running-the-debugger",level:2}];function l(e){const n={a:"a",code:"code",em:"em",h2:"h2",h4:"h4",img:"img",li:"li",ol:"ol",p:"p",strong:"strong",ul:"ul",...(0,o.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.Ay,{}),"\n",(0,s.jsx)(n.p,{children:"This guide will show you how to use VS Code with the vscode-noir extension to debug a Noir project."}),"\n",(0,s.jsx)(n.h4,{id:"pre-requisites",children:"Pre-requisites"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"Nargo"}),"\n",(0,s.jsx)(n.li,{children:"vscode-noir"}),"\n",(0,s.jsxs)(n.li,{children:["A Noir project with a ",(0,s.jsx)(n.code,{children:"Nargo.toml"}),", ",(0,s.jsx)(n.code,{children:"Prover.toml"})," and at least one Noir (",(0,s.jsx)(n.code,{children:".nr"}),") containing an entry point function (typically ",(0,s.jsx)(n.code,{children:"main"}),")."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"running-the-debugger",children:"Running the debugger"}),"\n",(0,s.jsxs)(n.p,{children:["The easiest way to start debugging is to open the file you want to debug, and click on ",(0,s.jsx)(n.code,{children:"Debug"})," codelens over main functions or ",(0,s.jsx)(n.code,{children:"Debug test"})," over ",(0,s.jsx)(n.code,{children:"#[test]"})," functions"]}),"\n",(0,s.jsxs)(n.p,{children:["If you don't see the codelens options ",(0,s.jsx)(n.code,{children:"Compile|Info|..|Debug"})," over the ",(0,s.jsx)(n.code,{children:"main"})," function or ",(0,s.jsx)(n.code,{children:"Run test| Debug test"})," over a test function then you probably have the codelens feature disabled. To enable it open the extension configuration page and check the ",(0,s.jsx)(n.code,{children:"Enable Code Lens"})," setting."]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"Debugger codelens",src:t(5160).A+"",width:"898",height:"648"})}),"\n",(0,s.jsxs)(n.p,{children:["Another way of starting the debugger is to press ",(0,s.jsx)(n.code,{children:"F5"})," on the file you want to debug. This will cause the debugger to launch, using your ",(0,s.jsx)(n.code,{children:"Prover.toml"})," file as input."]}),"\n",(0,s.jsx)(n.p,{children:"Once the debugger has started you should see something like this:"}),"\n",(0,s.jsx)(n.p,{children:"You should see something like this:"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"Debugger launched",src:t(10776).A+"",width:"3092",height:"2236"})}),"\n",(0,s.jsxs)(n.p,{children:["Let's inspect the state of the program. For that, we open VS Code's ",(0,s.jsx)(n.em,{children:"Debug pane"}),". Look for this icon:"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"Debug pane icon",src:t(95121).A+"",width:"328",height:"174"})}),"\n",(0,s.jsx)(n.p,{children:"You will now see two categories of variables: Locals and Witness Map."}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"Debug pane expanded",src:t(64473).A+"",width:"1050",height:"1014"})}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"Locals"}),": variables of your program. At this point in execution this section is empty, but as we step through the code it will get populated by ",(0,s.jsx)(n.code,{children:"x"}),", ",(0,s.jsx)(n.code,{children:"result"}),", ",(0,s.jsx)(n.code,{children:"digest"}),", etc."]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"Witness map"}),": these are initially populated from your project's ",(0,s.jsx)(n.code,{children:"Prover.toml"})," file. In this example, they will be used to populate ",(0,s.jsx)(n.code,{children:"x"})," and ",(0,s.jsx)(n.code,{children:"result"})," at the beginning of the ",(0,s.jsx)(n.code,{children:"main"})," function."]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"Most of the time you will probably be focusing mostly on locals, as they represent the high level state of your program."}),"\n",(0,s.jsx)(n.p,{children:"You might be interested in inspecting the witness map in case you are trying to solve a really low level issue in the compiler or runtime itself, so this concerns mostly advanced or niche users."}),"\n",(0,s.jsx)(n.p,{children:"Let's step through the program, by using the debugger buttons or their corresponding keyboard shortcuts."}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"Debugger buttons",src:t(90789).A+"",width:"526",height:"102"})}),"\n",(0,s.jsxs)(n.p,{children:["Now we can see in the variables pane that there's values for ",(0,s.jsx)(n.code,{children:"digest"}),", ",(0,s.jsx)(n.code,{children:"result"})," and ",(0,s.jsx)(n.code,{children:"x"}),"."]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"Inspecting locals",src:t(82621).A+"",width:"3084",height:"1374"})}),"\n",(0,s.jsx)(n.p,{children:"We can also inspect the values of variables by directly hovering on them on the code."}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"Hover locals",src:t(46386).A+"",width:"3074",he
1ight:"799"})}),"\n",(0,s.jsxs)(n.p,{children:["Let's set a break point at the ",(0,s.jsx)(n.code,{children:"keccak256"})," function, so we can continue execution up to the point when it's first invoked without having to go one step at a time."]}),"\n",(0,s.jsxs)(n.p,{children:["We just need to click to the right of the line number 18. Once the breakpoint appears, we can click the ",(0,s.jsx)(n.code,{children:"continue"})," button or use its corresponding keyboard shortcut (",(0,s.jsx)(n.code,{children:"F5"})," by default)."]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"Breakpoint",src:t(67284).A+"",width:"3086",height:"1888"})}),"\n",(0,s.jsxs)(n.p,{children:["Now we are debugging the ",(0,s.jsx)(n.code,{children:"keccak256"})," function, notice the ",(0,s.jsx)(n.em,{children:"Call Stack pane"})," at the lower right. This lets us inspect the current call stack of our process."]}),"\n",(0,s.jsxs)(n.p,{children:["That covers most of the current debugger functionalities. Check out ",(0,s.jsx)(n.a,{href:"/docs/v1.0.0-rc.0/tooling/debugger/debugger_vscode",children:"the reference"})," for more details on how to configure the debugger."]})]})}function g(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(l,{...e})}):l(e)}},10776(e,n,t){const i=t.p+"assets/images/1-started-065fd6d2514cb30176af1321362017fb.png";t.d(n,["A",0,i])},95121(e,n,t){const i=t.p+"assets/images/2-icon-fdadb8da0ed2fb590e04bbda4a70ce83.png";t.d(n,["A",0,i])},64473(e,n,t){const i=t.p+"assets/images/3-debug-pane-7e181445e9308d2aeb1bdec231bba2d5.png";t.d(n,["A",0,i])},90789(e,n,t){const i=t.p+"assets/images/4-debugger-buttons-4fb081d6d7a6a616cb8841f527ffb0a9.png";t.d(n,["A",0,i])},82621(e,n,t){const i=t.p+"assets/images/5-assert-629b315a69ca2901037412a4b691488c.png";t.d(n,["A",0,i])},46386(e,n,t){const i=t.p+"assets/images/6-hover-57ea821fa09dcc402a9fcff41e3da6d4.png";t.d(n,["A",0,i])},67284(e,n,t){const i=t.p+"assets/images/7-break-634214d816d82dbd5d8ff66636767f51.png";t.d(n,["A",0,i])},5160(e,n,t){const i=t.p+"assets/images/debugger-codelens-4611f534ed2fa482c20ac6bda39ad926.png";t.d(n,["A",0,i])},28453(e,n,t){t.d(n,{R:()=>r,x:()=>c});var i=t(96540);const s={},o=i.createContext(s);function r(e){const n=i.useContext(o);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),i.createElement(o.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.