<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>项目介绍 on OS Debug 文档</title><link>https://osdebugger.github.io/async-debug/docs/</link><description>Recent content in 项目介绍 on OS Debug 文档</description><generator>Hugo</generator><language>zh</language><atom:link href="https://osdebugger.github.io/async-debug/docs/index.xml" rel="self" type="application/rss+xml"/><item><title>安装与使用</title><link>https://osdebugger.github.io/async-debug/docs/usage/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://osdebugger.github.io/async-debug/docs/usage/</guid><description>&lt;h1 id="安装与使用">安装与使用&lt;a class="anchor" href="#%e5%ae%89%e8%a3%85%e4%b8%8e%e4%bd%bf%e7%94%a8">#&lt;/a>&lt;/h1>
&lt;h2 id="插件安装">插件安装&lt;a class="anchor" href="#%e6%8f%92%e4%bb%b6%e5%ae%89%e8%a3%85">#&lt;/a>&lt;/h2>
&lt;p>以下操作在 Ubuntu 环境中进行。&lt;/p>
&lt;ol>
&lt;li>
&lt;p>下载 VS Code &lt;a href="https://github.com/chenzhiy2001/code-debug/releases">code-debug 调试插件最新安装包&lt;/a>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>然后启动 VS Code，在扩展视图（Extensions View）中，点击右上角的 &lt;strong>&amp;quot;&amp;hellip;&amp;quot;&lt;/strong> 菜单，选择 &lt;strong>&amp;ldquo;从 VSIX 安装&amp;hellip;&amp;rdquo; (Install from VSIX&amp;hellip;)&lt;/strong>，然后选择第一步下载的 &lt;code>.vsix&lt;/code> 安装包即可，到这一步调试器插件就可以使用了。&lt;/p>
&lt;/li>
&lt;/ol>
&lt;h2 id="使用方法">使用方法&lt;a class="anchor" href="#%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95">#&lt;/a>&lt;/h2>
&lt;h3 id="rcore-tutorial-v3-配置">rCore-Tutorial-v3 配置&lt;a class="anchor" href="#rcore-tutorial-v3-%e9%85%8d%e7%bd%ae">#&lt;/a>&lt;/h3>
&lt;ol>
&lt;li>
&lt;p>请确保 rCore-Tutorial-v3 能成功运行。&lt;/p>
&lt;/li>
&lt;li>
&lt;p>根据该 &lt;a href="https://github.com/chenzhiy2001/rCore-Tutorial-v3/commit/c64ae25ecee708c0257c9acb9da92309d32e1059">commit&lt;/a> 为你本地的 rCore 打好调试补丁。&lt;/p>
&lt;/li>
&lt;li>
&lt;p>打开 VS Code，并打开被调试的 rCore-Tutorial-v3 文件夹，在 &lt;code>.vscode&lt;/code> 文件夹中创建 &lt;code>launch.json&lt;/code> 文件，添加&lt;a href="https://github.com/chenzhiy2001/code-debug/blob/c102c48714221e5a38d28a54289080fff7ca0892/installation%20and%20usage/ebpf_launch.json">该配置文件&lt;/a>中内容。&lt;/p>
&lt;/li>
&lt;li>
&lt;p>为了用 eBPF Panel，需要在 rCore-Tutorial-v3 的根目录下添加一个脚本 &lt;code>qemu-system-riscv64-with-logs.sh&lt;/code>，内容如下：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>tty &amp;gt; ./qemu_tty
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>qemu-system-riscv64 &lt;span style="color:#e6db74">&amp;#34;&lt;/span>$@&lt;span style="color:#e6db74">&amp;#34;&lt;/span> | tee ./code_debug_qemu_output_history.txt&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>保存并添加可执行权限 &lt;code>chmod +x qemu-system-riscv64-with-logs.sh&lt;/code>，然后再编译一遍 rCore。&lt;/p>
&lt;/li>
&lt;li>
&lt;p>启动调试：在 VS Code 的 rCore 窗口下按 &lt;strong>F5&lt;/strong> 启动调试即可。&lt;/p>
&lt;blockquote class='book-hint '>
&lt;p>&lt;strong>NOTE&lt;/strong>：此处是&lt;a href="https://gitlab.eduxiji.net/T202410011992734/project2210132-235708/-/blob/master/installation%20and%20usage/%E6%BC%94%E7%A4%BA%E8%A7%86%E9%A2%91.mp4">演示视频&lt;/a>（该视频是使用仓库代码启动的调试器，如果使用 VS Code code-debug 插件，即可直接按照上面的方法启动调试）&lt;/p></description></item><item><title>功能介绍</title><link>https://osdebugger.github.io/async-debug/docs/features/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://osdebugger.github.io/async-debug/docs/features/</guid><description>&lt;h1 id="功能介绍">功能介绍&lt;a class="anchor" href="#%e5%8a%9f%e8%83%bd%e4%bb%8b%e7%bb%8d">#&lt;/a>&lt;/h1>
&lt;p>OS Debug 是一款 VS Code 调试插件，让你可以&lt;strong>在 VS Code 中像调试普通程序一样调试操作系统内核&lt;/strong>，以下是你安装插件后可以做的事情。&lt;/p>
&lt;hr>
&lt;h2 id="一像调试普通程序一样调试-os-内核">一、像调试普通程序一样调试 OS 内核&lt;a class="anchor" href="#%e4%b8%80%e5%83%8f%e8%b0%83%e8%af%95%e6%99%ae%e9%80%9a%e7%a8%8b%e5%ba%8f%e4%b8%80%e6%a0%b7%e8%b0%83%e8%af%95-os-%e5%86%85%e6%a0%b8">#&lt;/a>&lt;/h2>
&lt;h3 id="1-设置断点">1. 设置断点&lt;a class="anchor" href="#1-%e8%ae%be%e7%bd%ae%e6%96%ad%e7%82%b9">#&lt;/a>&lt;/h3>
&lt;p>在源代码行号旁点击即可设置断点，支持在内核代码和用户程序代码中同时设置断点。除了普通断点外，还支持：&lt;/p>
&lt;ul>
&lt;li>&lt;strong>条件断点&lt;/strong>：右键断点，输入条件表达式（如 &lt;code>i &amp;gt; 10&lt;/code>），只有条件满足时才暂停&lt;/li>
&lt;li>&lt;strong>计数断点&lt;/strong>：设置命中次数，例如&amp;quot;第 5 次经过这里才停下来&amp;quot;&lt;/li>
&lt;li>&lt;strong>日志断点（Log Points）&lt;/strong>：不暂停程序，只在调试控制台输出一条日志消息，适合不想打断程序执行流程时使用&lt;/li>
&lt;/ul>
&lt;h3 id="2-单步调试">2. 单步调试&lt;a class="anchor" href="#2-%e5%8d%95%e6%ad%a5%e8%b0%83%e8%af%95">#&lt;/a>&lt;/h3>
&lt;p>程序暂停后，你可以使用调试工具栏进行：&lt;/p>
&lt;ul>
&lt;li>&lt;strong>继续（Continue）&lt;/strong>：运行到下一个断点&lt;/li>
&lt;li>&lt;strong>单步跳过（Step Over）&lt;/strong>：执行当前行，不进入函数内部&lt;/li>
&lt;li>&lt;strong>单步进入（Step Into）&lt;/strong>：进入函数内部逐行执行&lt;/li>
&lt;li>&lt;strong>单步跳出（Step Out）&lt;/strong>：执行完当前函数，回到调用处&lt;/li>
&lt;li>&lt;strong>逐指令步进&lt;/strong>：按机器指令逐条执行，适合分析汇编级行为&lt;/li>
&lt;/ul>
&lt;h3 id="3-查看变量">3. 查看变量&lt;a class="anchor" href="#3-%e6%9f%a5%e7%9c%8b%e5%8f%98%e9%87%8f">#&lt;/a>&lt;/h3>
&lt;p>程序暂停时，可以在 VS Code 的调试侧边栏中查看：&lt;/p>
&lt;ul>
&lt;li>&lt;strong>局部变量&lt;/strong>：自动展示当前作用域内的所有局部变量及其值&lt;/li>
&lt;li>&lt;strong>结构体/数组展开&lt;/strong>：复杂数据结构（结构体、数组、指针等）可以点击展开，逐层查看内部字段&lt;/li>
&lt;li>&lt;strong>鼠标悬停查看&lt;/strong>：将鼠标悬停在源代码中的变量名上，即可弹出当前值&lt;/li>
&lt;li>&lt;strong>修改变量值&lt;/strong>：在变量面板中双击变量值，可以直接修改，立即生效&lt;/li>
&lt;li>&lt;strong>表达式求值&lt;/strong>：在调试控制台中输入任意表达式（如 &lt;code>a + b * 2&lt;/code>），实时查看计算结果&lt;/li>
&lt;/ul>
&lt;h3 id="4-查看寄存器">4. 查看寄存器&lt;a class="anchor" href="#4-%e6%9f%a5%e7%9c%8b%e5%af%84%e5%ad%98%e5%99%a8">#&lt;/a>&lt;/h3>
&lt;p>在调试侧边栏的 Registers 区域，可以查看 RISC-V 处理器的所有寄存器值（如 &lt;code>ra&lt;/code>、&lt;code>sp&lt;/code>、&lt;code>pc&lt;/code>、&lt;code>a0&lt;/code>-&lt;code>a7&lt;/code>、&lt;code>t0&lt;/code>-&lt;code>t6&lt;/code> 等）。也可以通过配置只显示你关心的寄存器。&lt;/p>
&lt;h3 id="5-查看调用栈">5. 查看调用栈&lt;a class="anchor" href="#5-%e6%9f%a5%e7%9c%8b%e8%b0%83%e7%94%a8%e6%a0%88">#&lt;/a>&lt;/h3>
&lt;p>在调试侧边栏的调用栈区域，可以看到当前的函数调用链，点击任意一层即可跳转到对应的源代码位置，查看该层的局部变量。&lt;/p>
&lt;h3 id="6-查看和编辑内存">6. 查看和编辑内存&lt;a class="anchor" href="#6-%e6%9f%a5%e7%9c%8b%e5%92%8c%e7%bc%96%e8%be%91%e5%86%85%e5%ad%98">#&lt;/a>&lt;/h3>
&lt;p>通过命令面板执行 &amp;ldquo;Examine Memory Location&amp;rdquo; 命令，输入内存地址，即可在 VS Code 的十六进制编辑器中查看和编辑原始内存数据。&lt;/p></description></item><item><title>内核用户态协同调试设计与实现</title><link>https://osdebugger.github.io/async-debug/docs/kernel-user-debugging/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://osdebugger.github.io/async-debug/docs/kernel-user-debugging/</guid><description>&lt;h1 id="内核用户态协同调试设计与实现">内核用户态协同调试设计与实现&lt;a class="anchor" href="#%e5%86%85%e6%a0%b8%e7%94%a8%e6%88%b7%e6%80%81%e5%8d%8f%e5%90%8c%e8%b0%83%e8%af%95%e8%ae%be%e8%ae%a1%e4%b8%8e%e5%ae%9e%e7%8e%b0">#&lt;/a>&lt;/h1>
&lt;h2 id="基本介绍">基本介绍&lt;a class="anchor" href="#%e5%9f%ba%e6%9c%ac%e4%bb%8b%e7%bb%8d">#&lt;/a>&lt;/h2>
&lt;h2 id="调试后端支持">调试后端支持&lt;a class="anchor" href="#%e8%b0%83%e8%af%95%e5%90%8e%e7%ab%af%e6%94%af%e6%8c%81">#&lt;/a>&lt;/h2>
&lt;h2 id="内核用户态协同调试">内核/用户态协同调试&lt;a class="anchor" href="#%e5%86%85%e6%a0%b8%e7%94%a8%e6%88%b7%e6%80%81%e5%8d%8f%e5%90%8c%e8%b0%83%e8%af%95">#&lt;/a>&lt;/h2>
&lt;h3 id="1-状态机">1. 状态机&lt;a class="anchor" href="#1-%e7%8a%b6%e6%80%81%e6%9c%ba">#&lt;/a>&lt;/h3>
&lt;h3 id="2-断点组管理">2. 断点组管理&lt;a class="anchor" href="#2-%e6%96%ad%e7%82%b9%e7%bb%84%e7%ae%a1%e7%90%86">#&lt;/a>&lt;/h3>
&lt;h3 id="3-边界断点">3. 边界断点&lt;a class="anchor" href="#3-%e8%be%b9%e7%95%8c%e6%96%ad%e7%82%b9">#&lt;/a>&lt;/h3>
&lt;h3 id="4-钩子断点">4. 钩子断点&lt;a class="anchor" href="#4-%e9%92%a9%e5%ad%90%e6%96%ad%e7%82%b9">#&lt;/a>&lt;/h3>
&lt;h2 id="vs-code-前端交互">VS Code 前端交互&lt;a class="anchor" href="#vs-code-%e5%89%8d%e7%ab%af%e4%ba%a4%e4%ba%92">#&lt;/a>&lt;/h2>
&lt;h3 id="webview-功能介绍">Webview 功能介绍&lt;a class="anchor" href="#webview-%e5%8a%9f%e8%83%bd%e4%bb%8b%e7%bb%8d">#&lt;/a>&lt;/h3></description></item><item><title>针对 Rust 异步特性调试的设计与实现</title><link>https://osdebugger.github.io/async-debug/docs/rust-async-debugging/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://osdebugger.github.io/async-debug/docs/rust-async-debugging/</guid><description>&lt;h1 id="针对-rust-异步特性调试的设计与实现">针对 Rust 异步特性调试的设计与实现&lt;a class="anchor" href="#%e9%92%88%e5%af%b9-rust-%e5%bc%82%e6%ad%a5%e7%89%b9%e6%80%a7%e8%b0%83%e8%af%95%e7%9a%84%e8%ae%be%e8%ae%a1%e4%b8%8e%e5%ae%9e%e7%8e%b0">#&lt;/a>&lt;/h1>
&lt;h2 id="背景介绍">背景介绍&lt;a class="anchor" href="#%e8%83%8c%e6%99%af%e4%bb%8b%e7%bb%8d">#&lt;/a>&lt;/h2></description></item><item><title>项目阶段工作</title><link>https://osdebugger.github.io/async-debug/docs/roadmap/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://osdebugger.github.io/async-debug/docs/roadmap/</guid><description>&lt;h1 id="项目阶段工作">项目阶段工作&lt;a class="anchor" href="#%e9%a1%b9%e7%9b%ae%e9%98%b6%e6%ae%b5%e5%b7%a5%e4%bd%9c">#&lt;/a>&lt;/h1>
&lt;hr>
&lt;h2 id="第一阶段2022-2023">第一阶段：2022-2023&lt;a class="anchor" href="#%e7%ac%ac%e4%b8%80%e9%98%b6%e6%ae%b52022-2023">#&lt;/a>&lt;/h2>
&lt;blockquote class='book-hint '>
&lt;p>核心目标：从零构建操作系统源代码级调试工具，打通内核/用户态联合调试的基本链路。&lt;/p>&lt;/blockquote>&lt;h3 id="基础框架搭建">基础框架搭建&lt;a class="anchor" href="#%e5%9f%ba%e7%a1%80%e6%a1%86%e6%9e%b6%e6%90%ad%e5%bb%ba">#&lt;/a>&lt;/h3>
&lt;ul>
&lt;li>基于 &lt;a href="https://github.com/WebFreak001/code-debug">WebFreak001/code-debug&lt;/a>（一个开源的 GDB/LLDB 调试前端）进行 fork，在其基础上扩展操作系统调试能力&lt;/li>
&lt;li>实现 VS Code 扩展的基本架构：通过 DAP 协议与 VS Code 调试界面交互，通过 GDB/MI 接口控制 GDB&lt;/li>
&lt;li>支持 QEMU 虚拟机环境下的远程调试&lt;/li>
&lt;/ul>
&lt;h3 id="内核态用户态联合断点调试">内核态/用户态联合断点调试&lt;a class="anchor" href="#%e5%86%85%e6%a0%b8%e6%80%81%e7%94%a8%e6%88%b7%e6%80%81%e8%81%94%e5%90%88%e6%96%ad%e7%82%b9%e8%b0%83%e8%af%95">#&lt;/a>&lt;/h3>
&lt;ul>
&lt;li>提出并实现&lt;strong>断点组&lt;/strong>的核心概念：将用户设置的 GDB 断点按所在的地址空间分组，在任意时刻下只有当前地址空间对应的断点组生效&lt;/li>
&lt;li>实现断点组切换时的符号表动态加载/卸载：切换地址空间时自动卸载旧符号表、加载新符号表&lt;/li>
&lt;li>实现内核态 ↔ 用户态的边界检测与自动切换&lt;/li>
&lt;li>以 rCore-Tutorial 作为首个适配目标，验证联合调试的可行性&lt;/li>
&lt;/ul>
&lt;h3 id="ebpf-动态跟踪调试">eBPF 动态跟踪调试&lt;a class="anchor" href="#ebpf-%e5%8a%a8%e6%80%81%e8%b7%9f%e8%b8%aa%e8%b0%83%e8%af%95">#&lt;/a>&lt;/h3>
&lt;ul>
&lt;li>实现 eBPF 调试面板（WebView）&lt;/li>
&lt;li>实现基于 eBPF 的内核态、用户态代码动态跟踪，与 GDB 静态断点调试形成互补&lt;/li>
&lt;/ul>
&lt;h3 id="调试界面与交互">调试界面与交互&lt;a class="anchor" href="#%e8%b0%83%e8%af%95%e7%95%8c%e9%9d%a2%e4%b8%8e%e4%ba%a4%e4%ba%92">#&lt;/a>&lt;/h3>
&lt;ul>
&lt;li>实现 WebView 面板，提供 eBPF 调试的可视化操作界面&lt;/li>
&lt;li>实现内存读写功能，寄存器查看功能（RISC-V 寄存器），在侧边栏 TreeView 中展示&lt;/li>
&lt;li>实现断点表的可视化展示&lt;/li>
&lt;/ul>
&lt;h3 id="本阶段遗留的问题">本阶段遗留的问题&lt;a class="anchor" href="#%e6%9c%ac%e9%98%b6%e6%ae%b5%e9%81%97%e7%95%99%e7%9a%84%e9%97%ae%e9%a2%98">#&lt;/a>&lt;/h3>
&lt;p>在完成核心功能验证的同时，也暴露出了很多问题：&lt;/p>
&lt;ul>
&lt;li>调试器自动设置的断点不会在 VS Code 中显示出来&lt;/li>
&lt;li>边界断点的实现逻辑不具有普适性（与内核符号表耦合）&lt;/li>
&lt;li>代码实现复杂，不易维护和扩展&lt;/li>
&lt;li>没有实现单步步进功能，Continue 按钮不能适用于所有情况&lt;/li>
&lt;li>控制台输出杂乱且不完整&lt;/li>
&lt;li>编译后的插件包体积过大&lt;/li>
&lt;li>配置文件中存在大量硬编码&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="第二阶段2023-2024">第二阶段：2023-2024&lt;a class="anchor" href="#%e7%ac%ac%e4%ba%8c%e9%98%b6%e6%ae%b52023-2024">#&lt;/a>&lt;/h2>
&lt;blockquote class='book-hint '>
&lt;p>核心目标：全面完善调试器的可用性和通用性，扩展对不同语言（C 语言）和不同运行环境（真实硬件）的支持。&lt;/p></description></item></channel></rss>