1"use strict";(self.rspackChunkrspack_website=self.rspackChunkrspack_website||[]).push([["hd"],{Ob(s,e,r){r.r(e);var n=r("i"),a=r("fj"),i=r("V");function c(s){let e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",li:"li",ol:"ol",p:"p",pre:"pre",span:"span",...(0,a.R)(),...s.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(e.h1,{id:"debugging",children:[(0,n.jsx)(e.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#debugging",children:"#"}),"Debugging"]}),"\n",(0,n.jsxs)(e.h2,{id:"éè¿-vs-code-è°è¯",children:[(0,n.jsx)(e.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#éè¿-vs-code-è°è¯",children:"#"}),"éè¿ VS Code è°è¯"]}),"\n",(0,n.jsxs)(e.ol,{children:["\n",(0,n.jsxs)(e.li,{children:["å®è£
",(0,n.jsx)(e.code,{children:"go install github.com/go-delve/delve/cmd/dlv@latest"})]}),"\n",(0,n.jsxs)(e.li,{children:["å®è£
VS Code æ©å± ",(0,n.jsx)(e.a,{href:"https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer",rel:"noopener noreferrer",target:"_blank",children:"rust-analyzer"})," å ",(0,n.jsx)(e.a,{href:"https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb",rel:"noopener noreferrer",target:"_blank",children:"CodeLLDB"})]}),"\n",(0,n.jsxs)(e.li,{children:["éè¿æ§è¡ ",(0,n.jsx)(e.code,{children:"pnpm install && pnpm -w build:cli:dev"})," æå»º ",(0,n.jsx)(e.code,{children:"@rspack/cli"})," å napi binding"]}),"\n",(0,n.jsxs)(e.li,{children:["å¨ VS Code ç ",(0,n.jsx)(e.code,{children:"Run and Debug"})," æ ä¸, éæ© ",(0,n.jsx)(e.code,{children:"Debug Rspack"})," å¼å§è°è¯ ",(0,n.jsx)(e.code,{children:"@rspack/cli"})," çå¯å¨è¿ç¨ã 该任å¡å¯ä»¥å¨ ",(0,n.jsx)(e.code,{children:".vscode/launch.json"})," ä¸é
ç½®ï¼ä¼åæ¶å¯å¨ Node å Rust çè°è¯å¨ã"]}),"\n"]}),"\n",(0,n.jsx)(i.Pq,{type:"note",title:"Note",children:(0,n.jsx)(e.p,{children:"\nå
¶ä»å·¥å
·éæçä¸è¬æ¯ Rspack ç release çæ¬ï¼å
¶ä¸å¹¶ä¸å
å«è°è¯ä¿¡æ¯ï¼è¿æ¶åéè¦ä½¿ç¨å¯¹åºç嫿debug ççæ¬è¿è¡overrideæ¿æ¢ï¼æ¹å¯è°è¯ã"})}),"\n",(0,n.jsxs)(e.h2,{id:"使ç¨-rspack-debugcore",children:[(0,n.jsx)(e.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#使ç¨-rspack-debugcore",children:"#"}),"ä½¿ç¨ ",(0,n.jsx)(e.code,{children:"@rspack-debug/core"})]}),"\n",(0,n.jsxs)(e.p,{children:["éæ Rspack çæ¡æ¶æå·¥å
·é常ä¾èµ release çæ¬ç ",(0,n.jsx)(e.code,{children:"@rspack/core"}),"ãrelease å
é忣叏æå»ºï¼ä½ä¸å
å«é¨åä»
ç¨äºè°è¯çè½åãå½ä½ éè¦å¨æ¬å°ææ¥é®é¢æ¶ï¼å¯ä»¥å¨å®é
æ§è¡æå»ºç项ç®ä¸éè¿ package manager override å° ",(0,n.jsx)(e.code,{children:"@rspack/core"})," æ¿æ¢ä¸º ",(0,n.jsx)(e.code,{children:"@rspack-debug/core"}),"ã"]}),"\n",(0,n.jsx)(e.p,{children:"以 pnpm 为ä¾ï¼"}),"\n",(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(e.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",title:"package.json",lang:"json",children:(0,n.jsxs)(e.code,{children:[(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{style:{color:"var(--shiki-foreground)"},children:"{"})}),"\n",(0,n.jsxs)(e.span,{className:"line",children:[(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:' "pnpm"'}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-foreground)"},children:" {"})]}),"\n",(0,n.jsxs)(e.span,{className:"line",children:[(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:' "overrides"'}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-foreground)"},children:" {"})]}),"\n",(0,n.jsxs)(e.span,{className:"line",children:[(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:' "@rspack/core"'}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:' "npm:@rspack-debug/core@latest"'})]}),"\n",(0,n.jsxs)(e.span,{className:"line",children:[(0,n.jsx)(e.span,{style:{color:"var(--shiki-foreground)"},children:" }"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,n.jsxs)(e.span,{className:"line",children:[(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"}
1,children:' "peerDependencyRules"'}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-foreground)"},children:" {"})]}),"\n",(0,n.jsxs)(e.span,{className:"line",children:[(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:' "allowAny"'}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-punctuation)"},children:":"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-foreground)"},children:" ["}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string-expression)"},children:'"@rspack/*"'}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-foreground)"},children:"]"})]}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{style:{color:"var(--shiki-foreground)"},children:" }"})}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{style:{color:"var(--shiki-foreground)"},children:" }"})}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{style:{color:"var(--shiki-foreground)"},children:"}"})})]})})}),"\n",(0,n.jsx)(e.p,{children:"ç¶åéæ°å®è£
ä¾èµï¼å¹¶ç»§ç»è¿è¡åæ¥çæå»ºå½ä»¤ãä¾å¦é¡¹ç®éè¿ Rsbuild æå»ºæ¶ï¼"}),"\n",(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(e.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",lang:"bash",children:(0,n.jsxs)(e.code,{children:[(0,n.jsxs)(e.span,{className:"line",children:[(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"pnpm"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:" install"})]}),"\n",(0,n.jsxs)(e.span,{className:"line",children:[(0,n.jsx)(e.span,{style:{color:"var(--shiki-foreground)"},children:"RSPACK_PROFILE"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"OVERVIEW"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-foreground)"},children:" RSPACK_TRACE_LAYER"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:"perfetto"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:" rsbuild"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:" build"})]})]})})}),"\n",(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.code,{children:"@rspack-debug/core"})," ä»
建议ç¨äºæ¬å°è°è¯åé®é¢è¯æã妿æ£å¨ææ¥ç¹å®çæ¬çé®é¢ï¼å»ºè®®å°å®åºå®å°ä¸å ",(0,n.jsx)(e.code,{children:"@rspack/core"})," ç¸åççæ¬ï¼ææ¥ç»æååºç§»é¤ overrideã"]}),"\n",(0,n.jsxs)(e.h3,{id:"常è§è°è¯åºæ¯æå",children:[(0,n.jsx)(e.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#常è§è°è¯åºæ¯æå",children:"#"}),"常è§è°è¯åºæ¯æå"]}),"\n",(0,n.jsxs)(e.h4,{id:"è°è¯-rust",children:[(0,n.jsx)(e.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#è°è¯-rust",children:"#"}),"è°è¯ Rust"]}),"\n",(0,n.jsxs)(e.p,{children:["åªé卿å®ç Rust 代ç å¤è®¾ç½®æç¹åå¯å¨ ",(0,n.jsx)(e.code,{children:"Debug Rspack"})," å³å¯è¿è¡è°è¯ã"]}),"\n",(0,n.jsxs)(e.h4,{id:"è°è¯-javascript",children:[(0,n.jsx)(e.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#è°è¯-javascript",children:"#"}),"è°è¯ JavaScript"]}),"\n",(0,n.jsxs)(e.p,{children:["å¯å¨ ",(0,n.jsx)(e.code,{children:"Debug Rspack"})," æ¶ï¼éæ© ",(0,n.jsx)(e.code,{children:"--inspect"})," æ ",(0,n.jsx)(e.code,{children:"--inspect-brk"})," é项ï¼ç¶åå¯å¨ ",(0,n.jsx)(e.code,{children:"Attach JavaScript"})," å¹¶éæ©ç¸åºè¿ç¨ç PID å³å¯ã"]}),"\n",(0,n.jsxs)(e.h4,{id:"è°è¯å·²å¯å¨ç-rspack-è¿ç¨",children:[(0,n.jsx)(e.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#è°è¯å·²å¯å¨ç-rspack-è¿ç¨",children:"#"}),"è°è¯å·²å¯å¨ç Rspack è¿ç¨"]}),"\n",(0,n.jsxs)(e.p,{children:["å½ Rspack 被éæå°å
¶ä»æ¡æ¶æå·¥å
·ï¼å¦ Nxï¼ä¸æ¶ï¼å¯è½é¾ä»¥ç¬ç«ä½¿ç¨ Launch 模å¼å¯å¨ Rspackãæ¤æ¶ï¼å¯ä»¥éè¿ attach 模å¼è°è¯ä»£ç ãå¯å¨ ",(0,n.jsx)(e.code,{children:"Attach Rust"})," å¹¶éæ© Rspack æå±è¿ç¨ç PID å³å¯,å¯å¨ ",(0,n.jsx)(e.code,{children:"Attach JavaScript"})," å³å¯è°è¯ JavaScriptã"]}),"\n",(0,n.jsxs)(e.h4,{id:"è°è¯åçæ»éç-rspack-è¿ç¨",children:[(0,n.jsx)(e.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#è°è¯åçæ»éç-rspack-è¿ç¨",children:"#"}),"è°è¯åçæ»éç Rspack è¿ç¨"]}),"\n",(0,n.jsxs)(e.p,{children:["å½ä½¿ç¨ ",(0,n.jsx)(e.code,{children:"Attach Rust"})," å°è°è¯å¨ attach å° Rspack æå±è¿ç¨åï¼ç¹å» Debugger ç Pause æé®å³å¯å¨æ»éç°åºè®¾ç½®æç¹ã"]}),"\n",(0,n.jsxs)(e.h2,{id:"rust-lldb",children:[(0,n.jsx)(e.a,{className:"rp-header-anchor","aria-hidden":"true",href:"#rust-lldb",children:"#"}),"rust-lldb"]}),"\n",(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.code,{children:"rust-lldb"})," å¯ç¨äºä» debug çæ¬ä¸è·å panic ä¿¡æ¯"]}),"\n",(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(e.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",lang:"bash",children:(0,n.jsx)(e.code,{children:(0,n.jsxs)(e.span,{className:"line",children:[(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"rust-lldb"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:" --"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:" node"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:" /path/to/rspack"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:" build"})]})})})}),"\n",(0,n.jsxs)(e.p,{children:["å¯å¨åï¼æä½ ",(0,n.jsx)(e.code,{children:"r"})," æ¥æ§è¡ç¨åºã"]}),"\n",(0,n.jsxs)(e.p,{children:["ä¾å¦ï¼",(0,n.jsx)(e.code,{children:"examples/arco-pro"})," è¿è¡å´©æºäºå¹¶ä¸æ²¡æä»»ä½ä¿¡æ¯å¨",(0,n.jsx)(e.a,{href:"https://github.com/web-infra-dev/rspack/pull/3195/files",rel:"noopener noreferrer",target:"_blank",children:"è¿ä¸ªä¿®å¤"})," ä¹å:"]}),"\n",(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(e.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",lang:"txt",children:(0,n.jsxs)(e.code,{children:[(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{children:"rspack/examples/arco-pro ⯠node ../../packages/rspack-cli/bin/rspack build"})}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{children:"Rspack ââââââââââââââââââââââââââââââââââââââââ 56% building ./pages/welcome"})}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{children:"zsh: bus error node ../../packages/rspack-cli/bin/rspack build"})})]})})}),"\n",(0,n.jsxs)(e.p,{children:["ä½¿ç¨ ",(0,n.jsx)(e.code,{children:"rust-lldb"})]}),"\n",(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(e.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",lang:"bash",children:(0,n.jsx)(e.code,{children:(0,n.jsxs)(e.span,{className:"line",children:[(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-function)"},children:"rspack/examples/arco-pro"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:" â¯"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:" rust-lldb"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:" --"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:" node"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:" ../../packages/rspack-cli/bin/rspack"}),(0,n.jsx)(e.span,{style:{color:"var(--shiki-token-string)"},children:" build"})]})})})}),"\n",(0,n.jsxs)(e.p,{children:["æä¸ ",(0,n.jsx)(e.code,{children:"r"})," ç¶å伿å°:"]}),"\n",(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(e.pre,{className:"shiki css-variables",style:{backgroundColor:"var(--shiki-background)",color:"var(--shiki-foreground)"},tabIndex:"0",lang:"txt",children:(0,n.jsxs)(e.code,{children:[(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{children:"Process 23110 stopped"})}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{children:"* thread #10, name = 'tokio-runtime-worker', stop reason = EXC_BAD_ACCESS (code=2, address=0x70000cc66560)"})}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{children:" frame #0: 0x0000000140d0db4b rspack.darwin-x64.node`swc_ecma_parser::parser::expr::ops::_$LT$impl$u20$swc_ecma_parser..parser..Parser$LT$I$GT$$GT$::parse_unary_expr::h29f49330a806839c(self=0x0000000000000000) at ops.rs:244"})}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{children:" 241 /// Parse unary expression and update expression."})}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{children:" 242 ///"})}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{children:" 243 /// spec: 'UnaryExpression'"})}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{children:"-> 244 pub(in crate::parser) fn parse_unary_expr(&mut self) -> PResult<Box<Expr>> {"})}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{children:" 245 trace_cur!(self, parse_unary_expr);"})}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{children:" 246 let start = cur_pos!(self);"})}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{children:" 247"})}),"\n",(0,n.jsx)(e.span,{className:"line",children:(0,n.jsx)(e.span,{children:"Target 0: (node) stopped."})})]})})})]})}function l(){let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:e}={...(0,a.R)(),...s.components};return e?(0,n.jsx)(e,{...s,children:(0,n.jsx)(c,{...s})}):c(s)}l.__RSPRESS_PAGE_META={},l.__RSPRESS_PAGE_META["zh%2Fcontribute%2Fdevelopment%2Fdebugging.mdx"]={toc:[{id:"éè¿-vs-code
1-è°è¯",text:"éè¿ VS Code è°è¯",depth:2},{id:"使ç¨-rspack-debugcore",text:"ä½¿ç¨ `@rspack-debug/core`",depth:2},{id:"常è§è°è¯åºæ¯æå",text:"常è§è°è¯åºæ¯æå",depth:3},{id:"è°è¯-rust",text:"è°è¯ Rust",depth:4},{id:"è°è¯-javascript",text:"è°è¯ JavaScript",depth:4},{id:"è°è¯å·²å¯å¨ç-rspack-è¿ç¨",text:"è°è¯å·²å¯å¨ç Rspack è¿ç¨",depth:4},{id:"è°è¯åçæ»éç-rspack-è¿ç¨",text:"è°è¯åçæ»éç Rspack è¿ç¨",depth:4},{id:"rust-lldb",text:"rust-lldb",depth:2}],title:"Debugging",headingTitle:"Debugging",frontmatter:{description:"å
¶ä»å·¥å
·éæçä¸è¬æ¯ Rspack ç release çæ¬ï¼å
¶ä¸å¹¶ä¸å
å«è°è¯ä¿¡æ¯ï¼è¿æ¶åéè¦ä½¿ç¨å¯¹åºç嫿debug ççæ¬è¿è¡overrideæ¿æ¢ï¼æ¹å¯è°è¯ã"}},r.d(e,{default:()=>l})}}]);
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.