-
-
Notifications
You must be signed in to change notification settings - Fork 169
feat(ptrace): 初步实现ptrace系统调用(1/2),并完善信号处理机制 #1663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
oeasy1412
wants to merge
16
commits into
DragonOS-Community:master
Choose a base branch
from
oeasy1412:feat/ptrace
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+3,394
−444
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
strace & RawPid Signed-off-by: aLinChe <1129332011@qq.com>
Signed-off-by: aLinChe <1129332011@qq.com>
Signed-off-by: aLinChe <1129332011@qq.com>
Signed-off-by: aLinChe <1129332011@qq.com>
主要改进: - 重构信号权限检查,统一使用check_kill_permission函数 - 修复wait系统调用对ptrace子进程的支持,包括TracedStopped状态处理 - 完善ptrace_signal函数,修复潜在的use-after-free问题 - 改进exit_signal时序,确保waitid后进程资源立即释放 - 修复ProcessState::Stopped状态存储实际停止信号号 - 增强错误处理,避免panic风险
Signed-off-by: aLinChe <1129332011@qq.com>
Collaborator
|
2 months ago... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat(ptrace): 初步实现ptrace系统调用并完善信号处理机制
概述
本PR实现了Linux兼容的ptrace系统调用,包括进程跟踪、信号拦截、系统调用监控等核心功能。实现严格遵循Linux 6.6.21源码语义,为DragonOS提供初步的调试器支持(如gdb、strace)的能力。
主要功能
1. PTRACE_TRACEME 完整实现
2. PTRACE_ATTACH / PTRACE_DETACH 完整实现
3. PTRACE_SYSCALL 部分实现
4. PTRACE_PEEKDATA / PTRACE_POKEDATA 部分实现
5. PTRACE_GETREGS 部分实现
核心实现
新增文件
kernel/src/process/ptrace.rs- ptrace核心逻辑kernel/src/process/syscall/sys_ptrace.rs- ptrace系统调用入口user/apps/c_unitest/test_ptrace.c- ptrace功能测试用例修改文件
kernel/src/process/mod.rs- 添加ptrace相关进程状态管理kernel/src/process/exit.rs- 处理被跟踪进程的退出通知kernel/src/arch/x86_64/syscall/mod.rs- 系统调用拦截支持kernel/src/ipc/signal.rs- 信号处理与ptrace集成kernel/src/ipc/signal_types.rs- 添加ptrace相关的siginfo类型定义测试验证
测试用例输出(与Linux 6.6.21行为一致)
后续工作