Skip to content
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

MIRAI 使用记录 #6

Open
zjp-CN opened this issue Sep 12, 2024 · 2 comments
Open

MIRAI 使用记录 #6

zjp-CN opened this issue Sep 12, 2024 · 2 comments

Comments

@zjp-CN
Copy link
Member

zjp-CN commented Sep 12, 2024

图片

808eb78db63b557fe1b9075e7b18b95

61404eae6bb17ca372493d456b4afaa

MIRAI 有些做的好的地方:

  • 复用了 Rust 编译器的诊断方式:支持相同的打印样式和 JSON 输出
    • 不过这也带来缺点:当编译器也发出诊断,那么无法区分诊断来自编译器还是 MIRAI
  • 错误报告做了细节上的优化,比如 "possible Invalid page size!",其中的 page size 来自函数调用的参数名
warning: possible Invalid page size!
   --> src/cap/mod.rs:230:41
    |
230 |                 let topA = botA + MASK!(pageBitsForSize(cap1.get_frame_size()));
    |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pub fn pageBitsForSize(page_size: usize) -> usize {
    match page_size {
        RISCV_4K_Page => RISCVPageBits,
        RISCV_Mega_Page => RISCVMegaPageBits,
        RISCV_Giga_Page => RISCVGigaPageBits,
        _ => panic!("Invalid page size!"),
    }
}
@zjp-CN
Copy link
Member Author

zjp-CN commented Sep 12, 2024

测试 kern-crates/rtc 时,MIRAI 无法处理的函数会在除 --diag=default 之外的诊断上报告:

warning: the called function did not resolve to an implementation with a MIR body
  --> src/goldfish.rs:32:24
   |
32 |         let time_low = self.region.read_at(RTC_TIME_LOW);
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

我认为 os-checker 应该使用 --diag=default 参数,展示少的误报结果。

(p.s. MIRAI 虽然将误报视为自己的错误,但也存在误报)

@zjp-CN
Copy link
Member Author

zjp-CN commented Sep 14, 2024

cargo mirai 会遵照 .cargo/config.toml 的 target;并且也支持识别 --target 参数

os-checker/dockerfiles@11de250

zjp-CN pushed a commit that referenced this issue Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant