debug-info-remapping
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDebug Info Remapping
调试信息映射
Description
说明
In Lynx, main thread script is encoded to bytecode and uses an external debugging information scheme. Under this scheme, the row and column numbers in the runtime error messages are not the actual row and column numbers. The row and column numbers need to be deciphered from the external file.
debug-info.jsondebug-info.json format is as follows:
json
{
"lepusNG_debug_info": {
"function_info": [
{
"function_id": 1,
"function_name": "App",
"line_col": [
{ "line": 1, "column": 1 },
{ "line": 2, "column": 1 },
{ "line": 3, "column": 1 }
]
}
]
}
}在Lynx中,主线程脚本会被编码为字节码,并采用外部调试信息方案。在该方案下,运行时错误消息中的行号和列号并非实际的源代码行号和列号,需要从外部的文件中解析出真实位置。
debug-info.jsondebug-info.json的格式如下:
json
{
"lepusNG_debug_info": {
"function_info": [
{
"function_id": 1,
"function_name": "App",
"line_col": [
{ "line": 1, "column": 1 },
{ "line": 2, "column": 1 },
{ "line": 3, "column": 1 }
]
}
]
}
}When to Apply
适用场景
This skill is useful when you want to remap the to the original source code position.
function_id:pc_indexWhen the user encounters a runtime error message with function_id:pc_index, along with and in the error message, for example:
main-thread.jsdebug-info.jsonmain-thread.js exception: App render failed at main thread backtrace:
at App (file:///main-thread.js:1356:13)
at doRender (file:///main-thread.js:1002:12)
at call (native)
at render (file:///main-thread.js:466:52)
at _renderToString (file:///main-thread.js:1001:569)
at renderToString (file:///main-thread.js:998:191)
at renderMainThread (file:///main-thread.js:766:45)
at renderPage (file:///main-thread.js:853:69)Where is .
function_id:pc_index1356:13当你需要将映射回原始源代码位置时,该技能会非常有用。
function_id:pc_index当用户遇到包含的运行时错误消息,且错误消息中附带和时,例如:
function_id:pc_indexmain-thread.jsdebug-info.jsonmain-thread.js exception: App render failed at main thread backtrace:
at App (file:///main-thread.js:1356:13)
at doRender (file:///main-thread.js:1002:12)
at call (native)
at render (file:///main-thread.js:466:52)
at _renderToString (file:///main-thread.js:1001:569)
at renderToString (file:///main-thread.js:998:191)
at renderMainThread (file:///main-thread.js:766:45)
at renderPage (file:///main-thread.js:853:69)其中为。
function_id:pc_index1356:13Workflow
操作流程
1. Ask the User for the function_id:pc_index
function_id:pc_index1. 向用户索要function_id:pc_index
function_id:pc_indexUser should provide the in the error message. Or give you the full backtrace.
function_id:pc_indexYou should check if it is a main-thread backtrace. Since background thread backtrace does not need remapping.
用户需要提供错误消息中的,或者完整的调用栈信息。
function_id:pc_index你需要检查该调用栈是否属于主线程,因为后台线程的调用栈不需要进行映射。
2. Find the Corresponding Position in debug-info.json
2. 在debug-info.json中查找对应位置
Ask the user for the path. For example in a rspeedy project with entry it will locate at:
debug-info.jsonmain- :
main-thread.js$PROJECT_DIR/dist/.rspeedy/main/main-thread.js - :
debug-info.json$PROJECT_DIR/dist/.rspeedy/main/debug-info.json
If the user uses and there is no folder, remind them to build the project with .
rspeedy build.rspeedyDEBUG='rspeedy,rsbuild' rspeedy build向用户索要的路径。例如,在以为入口的rspeedy项目中,文件位置如下:
debug-info.jsonmain- :
main-thread.js$PROJECT_DIR/dist/.rspeedy/main/main-thread.js - :
debug-info.json$PROJECT_DIR/dist/.rspeedy/main/debug-info.json
如果用户使用构建后没有生成文件夹,提醒他们使用命令重新构建项目。
rspeedy build.rspeedyDEBUG='rspeedy,rsbuild' rspeedy build3. Run the remapping script
3. 运行映射脚本
For each pair in the stack trace, run the remapping script.
function_id:pc_indexbash
node ${CLAUDE_PLUGIN_ROOT}/skills/debug-info-remapping/scripts/index.mjs $PROJECT_DIR/[dist]/.rspeedy/[main]/debug-info.json $function_id $pc_index针对调用栈中的每一对,运行映射脚本。
function_id:pc_indexbash
node ${CLAUDE_PLUGIN_ROOT}/skills/debug-info-remapping/scripts/index.mjs $PROJECT_DIR/[dist]/.rspeedy/[main]/debug-info.json $function_id $pc_index4. Output the Remapped Position
4. 输出映射后的位置
The remapping script will output the remapped position in the format of .
line:columnYou should output the remapped position for each pair.
function_id:pc_indexReplace the pair in the stack trace with the remapped position and show the remapped stack trace.
function_id:pc_index映射脚本会以的格式输出映射后的位置。
line:column你需要为每一对输出对应的映射位置。
function_id:pc_index将调用栈中的替换为映射后的位置,并展示更新后的调用栈。
function_id:pc_index5. Show the Remapped Stack Trace
5. 展示映射后的调用栈
If you can reach the file, show the remapped stack trace with the remapped positions source code.
main-thread.jsThe final output should be something like this:
log
main-thread.js exception: App render failed at main thread backtrace:
at App (./dist/.rspeedy/main/main-thread.js:9368:56)
at doRender (./dist/.rspeedy/main/main-thread.js:7237:44)
at call (native)
at render (./dist/.rspeedy/main/main-thread.js:3706:72)
at _renderToString (./dist/.rspeedy/main/main-thread.js:7177:78)
at renderToString (./dist/.rspeedy/main/main-thread.js:7067:91)
at renderMainThread (./dist/.rspeedy/main/main-thread.js:5423:113)
at renderPage (./dist/.rspeedy/main/main-thread.js:6199:46)
╭─[5:55]
3 │ export function App() {
4 │ if (__MAIN_THREAD__) {
5 │ throw new Error('App render failed at main thread');
· ─┬
· ╰── main-thread.js exception: App render failed at main thread backtrace
6 │ }
7 │
╰────
... (the same for other callstacks such as doRender, call, render, _renderToString, renderToString, renderMainThread, renderPage here)
Files used:
- Debug Info: ./dist/.rspeedy/main/debug-info.json
- Source File: ./dist/.rspeedy/main/main-thread.jsThe will make sure it is clickable in the editor/terminal.
./dist/.rspeedy/main/main-thread.js:9368:56如果可以访问文件,展示包含映射位置对应源代码的调用栈。
main-thread.js最终输出示例如下:
log
main-thread.js exception: App render failed at main thread backtrace:
at App (./dist/.rspeedy/main/main-thread.js:9368:56)
at doRender (./dist/.rspeedy/main/main-thread.js:7237:44)
at call (native)
at render (./dist/.rspeedy/main/main-thread.js:3706:72)
at _renderToString (./dist/.rspeedy/main/main-thread.js:7177:78)
at renderToString (./dist/.rspeedy/main/main-thread.js:7067:91)
at renderMainThread (./dist/.rspeedy/main/main-thread.js:5423:113)
at renderPage (./dist/.rspeedy/main/main-thread.js:6199:46)
╭─[5:55]
3 │ export function App() {
4 │ if (__MAIN_THREAD__) {
5 │ throw new Error('App render failed at main thread');
· ─┬
· ╰── main-thread.js exception: App render failed at main thread backtrace
6 │ }
7 │
╰────
... (此处可添加其他调用栈如doRender、call、render、_renderToString、renderToString、renderMainThread、renderPage的对应内容)
Files used:
- Debug Info: ./dist/.rspeedy/main/debug-info.json
- Source File: ./dist/.rspeedy/main/main-thread.js./dist/.rspeedy/main/main-thread.js:9368:56