简介
本书是一份学习Rust
笔记,用于记录技安
在学习Rust
的过程中遇到的问题、解决思路和方法、学习感悟等。
作者简介
姓名:李扬
网名:技安
,由技术
和安全
这两个词结合而来。
有着15
年互联网软件开发经验和5
年Rust
开发经验,同时也是一名创业者,从事软件开发相关的业务。在2018
年开始接触Rust
语言开始学习和使用它,现在工作中主要以Rust
语言为主。核心工作是数字图像算法
,数字图像处理
,AI人工智能
,数字孪生
等。
目前主要发展方向是基于Rust
语言的组件化操作系统
和机器人操作系统
方向。
于2014
年成立自己的软件公司苏州幻果软件有限公司
https://www.huanguosoft.com。
公司业务包含Web
系统应用,移动端应用,桌面客户端应用,物联网应用,图像算法应用,AI
人工智能应用,游戏,各种小程序,数字孪生等方向。
2024年2月-4月
参加了由国家智能网联汽车创新中心
和清华大学操作系统实验室
联合举办的首期自动驾驶OS开发中阶训练营
。 实战项目是移植FastDDS
到组件化操作系统AcreOS
宏内核系统上。 获得了优秀队长
和优秀学员
证书。
2024年5月
应邀我来到了北京, 参与清华大学ArceOS
操作系统和Rust
基金会下的Dora
机器人系统的项目, 主要工作是移植Dora
到清华大学组件化操作系统ArceOS
和开放原子基金会开源鸿蒙系统OpenHarmony
中。项目预计在2024年10月
完成。
2024年5月28日
在清华大学操作系统实验室
主办的2024 春夏季开源操作系统训练营
上讲课。主讲的课程是:让Dora在ArceOS上闪耀 —— RISC-V64架构
。
感谢开源运动和开源软件赋予我们能够进一步的创造和改变世界的能力。
热爱开源,喜欢分享。可以加我微信一起交流。
前言
Rust
是一门赋予每个人构建可靠且高效软件能力的语言。 —— 引用官网
官网列出了三个选择Rust
的理由:
-
高性能
Rust
速度惊人且内存利用率极高。由于没有运行时和垃圾回收,它能够胜任对性能要求特别高的服务,可以在嵌入式设备上运行,还能轻松和其他语言集成。 -
可靠性
Rust
丰富的类型系统和所有权模型保证了内存安全和线程安全,让您在编译期就能够消除各种各样的错误。 -
生产力
Rust
拥有出色的文档、友好的编译器和清晰的错误提示信息, 还集成了一流的工具——包管理器和构建工具, 智能地自动补全和类型检验的多编辑器支持, 以及自动格式化代码等等。
技安
也是被Rust
的这几个特点吸引了,才下定决心学习Rust
。怎奈Rust
的学习曲线实在是太高了,技安
在学习的过程中也遇到了很多的问题,踩过很多的坑。希望通过笔记的形式记录并分享出来,大家一起学习Rust
,共同进步。
本书的时间线以技安
学习Rust
语言的时间线为准,记录下来一个从零开始学习Rust
到熟练使用Rust
做出生产级别的项目的一个学习过程。书中也会整理分享出一些实际开发中遇到的比较有代表性的案例。
本书假设你使用Rust 1.68.2
(2023-03-28 发布) 或者更高的版本。
Rust
入门
在开始学习 Rust
之前,还有很多的前置内容需要学习。在本章中,我们会讨论:
- 分别在
Linux
、macOS
和Windows
上安装Rust
- 选择一个合适的编辑器或者
IDE
- 在终端打印
Hello, World!
- 学习并掌握
Rust
强大的包管理工具cargo
- 配置并使用国内镜像解决网络问题
安装Rust
学习 Rust
的第一步就是安装 Rust
。我们会通过两种方式来安装 Rust
:自动安装
和 手动安装
。
Rust
的安装其实很简单,可能是因为网络的原因,导致部分小伙伴们卡在了安装 Rust
这一步。我将会在下面三节中分别介绍 自动安装
和 手动安装
的方法,并且详细的说明安装过程中的每一步。
约定
在本书中,所有在终端使用的命令,都是以
$
开头。你不需要输入$
字符,不以$
字符开始的行通常是一条命令的输出。本书中的所有的系统登录账号为
echo
Linux
用户主目录为/home/echo
macOS
用户主目录为/Users/echo
windows
用户主目录为C:\Users\Echo
Linux系统安装
Ubuntu 系统安装 Rust
安装依赖
$ sudo apt-get update -y
$ sudo apt install -y curl wget vim build-essential
自动安装
安装 Rust
的主要方式是通过 Rustup
这一工具,它既是一个 Rust
安装器又是一个版本管理工具。
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
手动安装
下载 rust-1.68.2-x86_64-unknown-linux-gnu
将文件 rust-1.68.2-x86_64-unknown-linux-gnu.tar.gz
下载到 ~/Downloads
文件夹下.
$ cd ~/Downloads
$ wget -c https://static.rust-lang.org/dist/rust-1.68.2-x86_64-unknown-linux-gnu.tar.gz
$ tar -zxvf rust-1.68.2-x86_64-unknown-linux-gnu.tar.gz
$ cd rust-1.68.2-x86_64-unknown-linux-gnu
$ ./install.sh --help
Usage: ./install.sh [options]
Options:
--uninstall only uninstall from the installation prefix
--destdir=[<none>] set installation root
--prefix=[/usr/local] set installation prefix
--without=[<none>] comma-separated list of components to not install
--components=[<none>] comma-separated list of components to install
--list-components list available components
--sysconfdir=[/etc] install system configuration files
--bindir=[/bin] install binaries
--libdir=[/lib] install libraries
--datadir=[/share] install data
--mandir=[/share/man] install man pages in PATH
--docdir=[\<default\>] install documentation in PATH
--disable-ldconfig don't run ldconfig after installation (Linux only)
--disable-verify don't obsolete
--verbose run with verbose output
安装参数解释说明
--uninstall 仅从安装的prefix卸载
--destdir=[<none>] 设置安装根目录
--prefix=[/usr/local] 设置安装前缀目录
--without=[<none>] 逗号分隔的不安装组件列表
--components=[<none>] 以逗号分隔的要安装的组件列表
--list-components 列出所有的组件
--sysconfdir=[/etc] 安装配置文件路径, 以prefix为前缀
--bindir=[/bin] 安装二进制文件路径, 以prefix为前缀
--libdir=[/lib] 安装库文件路径, 以prefix为前缀
--datadir=[/share] 安装数据文件路径, 以prefix为前缀
--mandir=[/share/man] 安装手册文件路径, 以prefix为前缀
--docdir=[\<default\>] 安装文档文件路径, 默认为/usr/local/share/doc
--disable-ldconfig 安装后不允许ldconfig(仅限Linux)
--disable-verify 禁用验证
--verbose 输出详细运行信息
将安装在目录 ~/rustlang
中
$ mkdir ~/rustlang
$ ./install.sh --destdir=~/rustlang
$ vim ~/.bashrc
# 在最后一行添加环境变量
export PATH="$PATH:/home/echo/rustlang/usr/local/bin"
$ source ~/.bashrc
$ cargo -V
cargo 1.68.2 (6feb7c9cf 2023-03-26)
$ rustc -V
rustc 1.68.2 (9eb3afe9e 2023-03-27)
所有可用组件列表
$ ./install.sh --list-components
# Available components
* rustc
* rust-std-x86_64-unknown-linux-gnu
* rust-docs
* rust-demangler-preview
* cargo
* rustfmt-preview
* rls-preview
* rust-analyzer-preview
* llvm-tools-preview
* clippy-preview
* rust-analysis-x86_64-unknown-linux-gnu
问题
1、出现 error: linker 'cc' not found
错误信息
这是缺少 compiler toolchain
, 通过命令安装sudo apt install build-essential
即可解决.
2、出现 run pkg_config fail: Could not run PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags openssl The pkg-config command could not be found.
错误信息
需要安装sudo apt install pkg-config
3、 出现 Could not find directory of OpenSSL installation, and this -sys crate cannot proceed without this knowledge. If OpenSSL is installed and this crate had trouble finding it, you can set the OPENSSL_DIR environment variable for the
错误信息
需要安装 sudo apt install libssl-dev
Fedora
安装 sudo apt install libssl-devel
MAC系统安装 Rust
可以通过运行以下命令获得 C
语言编译器:
$ xcode-select --install
MAC
系统安装 Rust
和 Linux
差不多
自动安装
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
手动安装
由于 MAC
电脑存在 intel
和 M
系列的芯片, 手动安装需要根据电脑的架构下载对应的安装文件.
M
芯片下载 rust-1.68.2-aarch64-apple-darwin.pkg
intel
芯片下载 rust-1.68.2-x86_64-apple-darwin.pkg
以 intel
芯片为例. 将rust-1.68.2-x86_64-apple-darwin.pkg
下载到 ~/Downloads
文件夹下.
$ wget -c https://static.rust-lang.org/dist/rust-1.68.2-x86_64-apple-darwin.pkg
$ open rust-1.68.2-x86_64-apple-darwin.pkg
随后会打开 Rust
的安装向导, 根据向导提示一步一步的安装完成即可.
Windows系统安装
MSVC
安装 MSVC
构建工具
2、安装 Visual Studio 2022 生成工具,分为两种安装方式,一种是图形化安装,另一种是命令式安装。
图形化安装
双击 vs_BuildTools.exe
打开。选中如下图所示的选项:
- 使用
C++
的桌面开发 Windows 10 (或 11) SDK
- 语言包中选中
英语
,以及其他你需要的语言包
命令式安装
vs_BuildTools.exe
存放在 C:\Echo
目录下
PS C:\Echo> .\vs_BuildTools.exe --installPath "C:\VS" --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --await --passive --norestart
安装程序会自动的下载并安装所需的组件,整个过程自动化处理,安装完成后自动退出,整个过程无需人工干预。
命令参数详见
自动安装 Rust
下载 rustup-init.exe 到 C:\Echo
目录下。
PS C:\Echo> .\rustup-init.exe
Welcome to Rust!
This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.
Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:
C:\Users\Echo\.rustup
This can be modified with the RUSTUP_HOME environment variable.
The Cargo home directory is located at:
C:\Users\Echo\.cargo
This can be modified with the CARGO_HOME environment variable.
The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:
C:\Users\Echo\.cargo\bin
This path will then be added to your PATH environment variable by
modifying the HKEY_CURRENT_USER/Environment/PATH registry key.
You can uninstall at any time with rustup self uninstall and
these changes will be reverted.
Current installation options:
default host triple: x86_64-pc-windows-msvc
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
> 1 # 输入1表示使用程序默认的安装方式自动安装当前最新版本以及对应的工具链
安装完成后按 Enter
键退出安装程序。
查看安装版本:
PS C:\Echo> cargo -V
cargo 1.68.2 (6feb7c9cf 2023-03-26)
PS C:\Echo> rustc -V
rustc 1.68.2 (9eb3afe9e 2023-03-27)
手动安装
下载 rust-1.68.2-x86_64-pc-windows-msvc.msi 到 C:\Echo
目录下。
进入 C:\Echo
, 打开下载的 rust-1.68.2-x86_64-pc-windows-msvc.msi
文件,根据向导提示一步步安装即可。
Rust更新与卸载
更新,只需要在命令行中运行更新脚本即可:
$ rustup update
卸载
若要卸载 Rust
和 rustup
,请在命令行中运行如下卸载脚本:
$ rustup self uninstall
Rust编辑器
Rust
编辑器主要有:
Visual Studio Code
免费IntelliJ IDEA Community Edition
免费Clion
收费- Zed 编辑器 https://zed.dev/ (
Zed
是一款高性能、多人代码编辑器,由Atom
和Tree-sitter
的创建者开发。采用Rust
开发, 使用GPU
渲染UI
)
Visual Studio Code
开发环境设置:
- 安装
rust-analyzer
插件。该插件现在由Rust
官方在维护。 (可选) 安装crates
插件。该插件可以帮助你在使用Cargo.toml
时管理依赖项。- (可选) 安装
dependi
,crates
的升级版本。Dependi 是一个全面的依赖关系管理扩展,通过有效管理项目依赖关系,帮助开发人员更快、更智能地编写代码。以前称为Crates
,是Rust
最受欢迎和使用的依赖管理扩展。Dependi
现在支持多种语言,包括Rust
、Go``、JavaScript
和Python
。 - (可选) 安装
Rust Flash Snippets
插件。该插件提供了Rust
的代码片段,加快开发速度。 - (可选) 安装
Error Lens
插件。该插件可以更好的显示错误信息,方便快速修改程序。
Clion
和 IntelliJ IDEA Community Edition
主要是通过安装 IntelliJ
官方的 Rust
的插件提供 Rust
支持。
2024年更新
IntelliJ
官方专门为Rust
提供了一款独立工具RustRover
,目前已经正式发布, 对个人非商业用途免费,具体可以参考官网。
Hello, World!
我们现在开始编写第一个 Rust
程序.
创建项目目录
本书将在用户目录中创建 rust-projects
目录, 并将所有的项目存放在这里.
对于 Linux、macOS 和 Windows PowerShell,输入:
$ mkdir ~/rust-projects
$ cd ~/rust-projects
$ mkdir hello_world
$ cd hello_world
接下来使用 VS Code
打开当前文件夹
$ code .
编写并运行 Rust
程序
在 VS Code
中新建一个源文件, 命名为 main.rs
. Rust
源文件总是以 .rs
扩展名结尾.
打开刚才新建的 main.rs
文件, 输入下面代码.
文件名: main.rs
fn main() { println!("Hello, world!"); }
保存文件, 在终端中进入当前目录. 在 Linux
和 macOS
系统上, 输入如下命令, 编译并运行文件:
$ cd ~/rust-projects/hello_world
$ rustc main.rs
$ ./main
Hello, world!
在 Windows
系统上, 输入命令 .\main.exe
.
> cd C:\Users\Echo\rust-projects/hello_world
> rustc main.rs
> .\main.exe
Hello, world!
如果没有出错误,终端应该可以打印字符串 Hello, world!
。如果没有,需要检查一下 Rust
是否已安装正确。
如果 Hello, world!
出现了,恭喜你!你已经正式编写了一个 Rust
程序。现在你成为一名 Rustacean
了,欢迎加入!
学习和使用 cargo
Rust
是一门现代化语言,也为系统编程带来了现代化的开发工具。Cargo
便是 Rust
内置的依赖管理器和构建工具,它能轻松的增加、编译和管理依赖,并使依赖在 Rust
生态体系中保持一致的开发体验。
使用 Cargo
创建和运行项目
使用 cargo
创建上一节的 hello_world
项目。在终端中运行以下命令:
$ cargo new new_hello_world
Created binary (application) `new_hello_world` package
$ cd new_hello_world
先查看一下 cargo
生成的项目的结构:
$ tree -a
.
├── .git
│ ├── HEAD
│ ├── config
│ ├── description
│ ├── hooks
│ │ └── README.sample
│ ├── info
│ │ └── exclude
│ ├── objects
│ │ ├── info
│ │ └── pack
│ └── refs
│ ├── heads
│ └── tags
├── .gitignore
├── Cargo.toml
└── src
└── main.rs
11 directories, 8 files
可以看到项目创建了一个 Cargo.toml
文件、一个 src
目录、一个 .gitignore
文件和 git
仓库。我们主要关注 Cargo.toml
文件和 src
目录。
查看 Cargo.toml
文件,它看起来如示例 1-1 所示:
文件名 Cargo.toml
[package]
name = "new_hello_world"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
这个文件使用的是 TOML 文件格式。
[package]
片段主要配置当前项目的基本信息:项目名字、项目版本和 Rust
的版本 edition
(许多人推荐使用 版次
来表述)。
[dependencies]
是我们添加依赖的地方。在 Rust
中,依赖包称为 crates
。
现在查看 src/main.rs
文件
文件名 src/main.rs
fn main() { println!("Hello, world!"); }
运行当前项目
$ cargo run
Compiling new_hello_world v0.1.0 (/Users/echo/new_hello_world)
Finished dev [unoptimized + debuginfo] target(s) in 1.01s
Running `target/debug/new_hello_world`
Hello, world!
该命令会创建一个可执行文件 target/debug/new_hello_world
(Windows
系统上为 target\debug\new_hello_world.exe
),并且执行当前的可执行文件。
最终在终端上会打印出 Hello, world!
默认 cargo run
执行的是 debug
模式的构建。如果想要编译发布模式构建可以使用如下命令:
$ cargo build --release
Compiling new_hello_world v0.1.0 (/Users/echo/new_hello_world)
Finished release [optimized] target(s) in 0.23s
该命令会生成 target/release/new_hello_world
发布模式的可执行文件。cargo build --release
会启用一些优化来编译项目,可以使得编译后的可执行文件运行的更快,因此编译的时间会比较长。
在开发过程中,如果只是想快速检查代码是否通过编译,而不需要实际编译可执行文件,可以使用下面这个命令:
$ cargo check
Checking new_hello_world v0.1.0 (/Users/echo/new_hello_world)
Finished dev [unoptimized + debuginfo] target(s) in 0.11s
该命令只会检查当前的代码能否通过编译,省略了生成可执行文件的步骤,因此速度很快。在实际开发过程中,可以经常使用 cargo check
命令来检查代码是否编写正确。
常用的 cargo
命令:
- 使用
cargo new
创建项目 - 使用
cargo run
构建并运行项目 - 使用
cargo check
快速检查代码是否可以通过编译 - 使用
cargo build
构建项目
从现在起,使用 cargo
管理我们的项目吧。
Cargo
命令简介
终端中输入 cargo
命令查看
$ cargo
Rust's package manager
Usage: cargo [+toolchain] [OPTIONS] [COMMAND]
Options:
-V, --version Print version info and exit
--list List installed commands
--explain <CODE> Run `rustc --explain CODE`
-v, --verbose... Use verbose output (-vv very verbose/build.rs output)
-q, --quiet Do not print cargo log messages
--color <WHEN> Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
--offline Run without accessing the network
--config <KEY=VALUE> Override a configuration value
-Z <FLAG> Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
-h, --help Print help
Some common cargo commands are (see all commands with --list):
build, b Compile the current package
check, c Analyze the current package and report errors, but don't build object files
clean Remove the target directory
doc, d Build this package's and its dependencies' documentation
new Create a new cargo package
init Create a new cargo package in an existing directory
add Add dependencies to a manifest file
remove Remove dependencies from a manifest file
run, r Run a binary or example of the local package
test, t Run the tests
bench Run the benchmarks
update Update dependencies listed in Cargo.lock
search Search registry for crates
publish Package and upload this package to the registry
install Install a Rust binary. Default location is $HOME/.cargo/bin
uninstall Uninstall a Rust binary
See 'cargo help <command>' for more information on a specific command.
主要命令详解
build, b 构建当前包
check, c 分析当前包并报告错误,但不构建目标文件
clean 删除构建的目录
doc, d 构建当前包及其依赖项目的文档(会创建 `target/doc` 目录,使用浏览器打开可以查看详细的文档)
new 创建一个新的包
init 在现有目录中创建一个新的包
add 添加依赖项到当前项目中
remove 从当前项目中删除依赖项
run, r 构建并运行项目
test, t 运行测试
bench 运行基准测试
update 更新在 Cargo.lock 注册的依赖项版本
search 搜索 crates
publish 打包并上传当前包 (crates.io)
install 安装 Rust 二进制文件,默认目录在 $HOME/.cargo/bin
uninstall 卸载 Rust 二进制文件
配置国内镜像服务
在安装 Rust
的语言或者拉取依赖包的时候,经常会因为网络原因导致安装失败或者无法正常编译程序。这个时候可以使用国内镜像加速。
Rustup
镜像
RUSTUP_DIST_SERVER
(默认:https://static.rust-lang.org
) 设置下载与Rust
相关的静态资源的根URL
。RUSTUP_UPDATE_ROOT
(默认:https://static.rust-lang.org/rustup
) 设置下载自我更新的URL
。
设置终端的环境变量为国内镜像站点,可以加速安装 Rust
和更新。
# 设置为字节镜像地址
$ export RUSTUP_DIST_SERVER="https://rsproxy.cn"
$ export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
重启终端或者执行source ****
之类的命令即可生效。
# 执行Rust在线安装方式就可以使用了
$ curl --proto '=https' --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh
# 其他镜像地址
# 清华大学
export RUSTUP_DIST_SERVER="https://mirrors.tuna.tsinghua.edu.cn/rustup"
export RUSTUP_UPDATE_ROOT="https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup"
# 中国科学技术大学
export RUSTUP_DIST_SERVER="https://mirrors.ustc.edu.cn/rust-static"
export RUSTUP_UPDATE_ROOT="https://mirrors.ustc.edu.cn/rust-static/rustup"
# 上海交通大学
export RUSTUP_DIST_SERVER="https://mirror.sjtu.edu.cn/rust-static"
export RUSTUP_UPDATE_ROOT="https://mirror.sjtu.edu.cn/rust-static/rustup"
crates.io
镜像
文件名 ~/.cargo/config
, 如果不存在可以新建这个文件.
windows
在C
盘当前用户目录下面的.cargo
目录下. 例如:C:\Users\echo\.cargo\config
.
- 字节跳动
crates.io
源
# Rust >= 1.68 版本建议使用 sparse-index,速度更快。
# 把下面第二行的 replace-with = 'rsproxy' 改成 replace-with = 'rsproxy-sparse'
[source.crates-io]
replace-with = 'rsproxy-sparse'
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true
其他镜像地址
- 清华大学
[source.crates-io]
replace-with = 'mirror'
[source.mirror]
registry = "sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/"
- 中国科学技术大学
[source.crates-io]
replace-with = 'ustc'
[source.ustc]
registry = "sparse+https://mirrors.ustc.edu.cn/crates.io-index/"
- 上海交通大学
[source.crates-io]
replace-with = 'mirror'
[source.mirror]
registry = "sparse+https://mirrors.sjtug.sjtu.edu.cn/crates.io-index/"
宏(Macro)
Rust宏是什么?
宏(Macro)指的是Rust
中的一系列的功能: 使用macro_rules!
的声明宏
和三种过程宏
.
声明宏
分类符
item
只匹配Rust
的item
的定义, 不会匹配指向item
的标识符.block
匹配blok
表达式.stmt
匹配语句. 除非item
语句要求结尾有分号, 否则不会匹配语句最后的分号.pat_param
允许|
跟在后面,2021 editing
开始.pat
匹配任何形式的模式.expr
匹配任何形式的表达式.ty
匹配任何形式的类型表达式.ident
匹配任何形式的标识符或者关键字.path
匹配类型中的路径tt
匹配标记树TokenTree
.meta
匹配属性. 准确的说是属性里面的内容.lifetime
匹配生命周期注解或者标签. 和ident
很像, 但是lifetime
会匹配到前缀'
.vis
匹配可能为空的内容.literal
匹配字面表达式.
item
item
分类器只匹配Rust
的item
的定义, 不匹配指向item
的标识符.
macro_rules! items { ($($item: item)*) => {}; } items!{ struct Foo; enum Bar { Baz } impl Foo {} } fn main() {}
item
是在编译器完全确定的, 通常在程序执行期间保持固定, 并且可以驻留在支付存储器中.
modules
extern crate
use
function
type
struce
enum
union
constant
static
trait
impl
extern
block
block
匹配bolck表达式
块(block)由{
开始, 接着是一些语句, 最后以}
结束. 块的类型要么是最后的值表达式类型, 要么是单元元组()
类型.
macro_rules! blocks { ($($block: block)*) => {}; } blocks! { {} { let abc; } {8} } fn main() {}
stmt
stmt
匹配语句. 除非item
语句要求结尾有分号, 否则不会匹配语句最后的分号.
item
语句要求结尾有分号: 例如 单元结构体是一个例子, 定义中必须要带上结尾的分号.
macro_rules! statements { ($($stmt: stmt)*) => {$($stmt)*}; } fn main() { statements!{ struct Foo; fn foo() {} let bar = 8 let bar = 8 ; 8; ; if true {} else {} {} () } }
pat_param
从 2021 edition 起,or-patterns
模式开始应用,这让pat
分类符不再允许跟随|
。
为了避免这个问题或者说恢复旧的 pat 分类符行为,你可以使用 pat_param
片段,它允许 |
跟在它后面,因为 pat_param
不允许 top level
或 or-patterns
。
macro_rules! patterns { (pat: $pat: pat) => { println!("pat: {}", stringify!($pat)); }; (pat_param: $($pat: pat_param)|*) => { $( println!("pat_param: {}", stringify!($pat)); )+ }; } fn main() { patterns!{ pat: 0 | 1 | 2 | 3 } patterns!{ pat_param: 0 | 1 | 2 | 3 } }
macro_rules! patterns { ($($($pat: pat_param)|+)*) => {}; } patterns!{ 0 | 1 | 2 | 3 } fn main() { }
pat
pat
分类符用于匹配任何形式的模式 (pattern
),包括 2021 edition
开始的 or-patterns
。
macro_rules! patterns { ($($pat:pat)*) => (); } patterns! { "literal" _ 0..5 ref mut PatternsAreNice 0 | 1 | 2 | 3 } fn main() {}
expr
expr
匹配任何形式的表达式.
macro_rules! experssions { ($($expr: expr)*) => {}; } experssions! { "abc" func() func.await break 'foo } fn main() {}
ty
ty
匹配任何形式的类型表达式, 类型表达式是在Rust
中表示类型的语法.
macro_rules! types { ($($type: ty)*) => {}; } types! { foo::bar bool [u8] impl IntoIterator<Item = u32> } fn main() {}
ident
ident
匹配任何形式的标识符或者关键字.
macro_rules! idents { ($($ident: ident)*) => {}; } idents! { // foo async o_____o ___o___ } fn main() {}
path
path
匹配类型中的路径.
macro_rules! paths { ($($path: path)*) => {}; } paths! { APath ::A::B::C::D E::<fff>::G FnMut(u32) -> () } fn main() {}
tt
tt
分类符用于匹配标记树 (TokenTree
)。tt
分类符是最有作用的分类符之一,因为它能匹配几乎所有东西, 而且能够让你在使用宏之后检查 (inspect) 匹配的内容。
meta
meta
匹配属性, 准确的说是属性里面的内容. 通常会在#[$meta: meta]
或 #![$meta: meta]
模式匹配中看到这个.
macro_rules! metas { ($($meta: meta)*) => {}; } metas! { ASimplePath super::man path = "home" foo(bar) } fn main() {}
lifetime
lifetime
匹配生命周期注解或者标签. 和ident
很像, 但是lifetime
会匹配到前缀'
.
macro_rules! lifetimes { ($($lifetime: lifetime)*) => { $( println!("lifetime: {}", stringify!($lifetime)); )*}; } fn main() { lifetimes! { 'static 'a '_ } }
vis
vis
匹配可能为空的内容. 实际上支持例子里的几种方式,因为这里的 visibility
指的是可见性,与私有性相对。而涉及这方面的内容只有与 pub
的关键字。所以,vis
在关心匹配输入的内容是公有还是私有时有用。
macro_rules! visibilities { ($($vis: vis,)*) => {}; } visibilities! ( pub, , ); fn main() {}
literal
literal
匹配字面表达式
macro_rules! literals { ($($literal: literal)*) => {}; } literals! { -1 "hello world" 2.3 b'b' 'c' true } fn main() {}
Rust生态系统非官方指南(翻译)
本文是Blessed - An unofficial guide to the Rust ecosystem的翻译。
blessed.rs
设什么?
Rust
的标准库要比 Python
或 Go
小得多。这些语言对 HTTP(S)
、JSON
、时区
、随机数
和异步 IO
等都提供了 "内置"支持。另一方面,Rust
可以从 crates.io
生态系统和 Cargo
软件包管理器中获得这些支持。但是,由于有近 10
万个 crates
可供选择,Rust
新开发者经常抱怨不知道从何入手,不知道应该使用哪些 crates
,不知道应该信任哪些 crates
。本列表试图回答这些问题。
另请参阅 lib.rs
,它采用了一种更为自动化的方法(根据下载数量对板条箱进行排序),同时还具有出色的搜索功能。
工具
用于处理 Rust
项目的开发人员工具。
应用场景 | 推荐的 crate |
---|---|
工具链管理 | rustup 安装、管理和升级 rustc 、cargo 、clippy 、rustfmt 等版本。 |
代码检查 | clippy 官方 Rust linter 。 cargo-semver-checks 检查您的 crate 版本是否存在语义版本控制违规。 |
代码格式化 | rustfmt 官方 Rust 代码格式化程序。 |
交叉编译 | cross 使用 Docker 容器进行无缝交叉编译。 cargo-zigbuild 使用 Zig 作为链接器,可轻松进行交叉编译。 |
依赖管理 | cargo-edit cargo 命令添加了 cargo upgrade 和 cargo set-version 。 cargo-outdated 查找有可用更新的依赖项。 cargo-audit 检查依赖项是否存在已报告的安全漏洞。 cargo-license 列出所有依赖项的许可证。 cargo-deny 对代码和依赖关系执行策略。 |
测试 | cargo-nextest 更快、更好的测试运行器。 insta 支持内联快照的快照测试。 |
基准测试 | criterion 用于基准测试库的统计准确的基准测试工具。 divan 简单而强大的基准测试库,具有分配分析功能。 hyperfine 用于对编译后的二进制文件进行基准测试的工具(类似于 unix time 命令,但效果更好)。 |
性能 | cargo-flamegraph 生成执行火焰图。 dhat 堆内存分析。 cargo-show-asm 用于显示为 Rust 源代码生成的 Assembly 、LLVM-IR 、MIR 和 WASM 。 |
调试宏 | Rust Analyzer Rust Analyzer 还允许你在编辑器中直接扩展宏。 cargo-expand 允许您检查宏扩展到的代码。 |
发布自动化 | cargo-release 发布 cargo 新版本的助手。 Release-plz 通过 CI 发布Rust crates 的Release PR 。 |
持续集成 | rust-toolchain (github action) 使用 Github Action 通过rustup 安装Rust 组件。 rust-cache (github action) 使用 Github Action 生成编译缓存,并加速运行。install-action (github action) 使用 Github Action 安装开发工具(主要来自Github 发行版)。 |
常用的
每个人都应该知道的常用crate
用于处理 Rust
项目的开发人员工具。
应用场景 | 推荐的 crate |
---|---|
随机数 | rand 从标准库中分离出来的事实上的随机数生成库 |
时间和日期 | 遗憾的是,在time 和chrono 之间,并没有哪个比另一个更好。请自行评估这两个库。不过,这两个库都是值得信赖的并且维护的都很好。time 一个很小,很简单的库。如果能够满足你的需求,那么它将是你的首选,但是它提供的功能非常的有限。 chrono 一个非常完整的时间库,它提供了很多功能,同时也包含了很多不必要的功能,因此也更为复杂。 |
序列化(JSON、YAML等) | serde 事实上的标准序列化库。请与 serde_json 等子库结合使用,以满足您使用的特定格式。 |
正则表达式 | regex 事实上的标准 regex 库。速度非常快,但不支持回溯等更高级的功能。fancy-regex 如果需要回溯等 regex 不支持的功能,请使用该库。 |
UUID | uuid 实现生成和解析 UUID 以及一系列实用功能。 |
临时文件 | tempfile 同时支持临时文件和临时目录。 |
(解)压缩 | flate2 默认使用存 Rust 实现,通过使用 feature 可使用系统 zlib 。 |
有序插入Map | indexmap 单独跟踪插入顺序的 HashMap ,可让您按照该顺序有效地遍历其元素。 |
栈分配的数组 | arrayvec 只采用固定容量栈分配的数组。 smallvec 栈分配的数组,如果超过固定栈容量,则使用堆分配。 tinyvec 使用100%的安全 Rust 进行栈分配的数组,但是要求实现Default trait 。 |
HTTP 请求 | reqwest 全功能 HTTP 客户端,支持在同步和异步两种方式,需要tokio 运行时。ureq 最小化的同步 HTTP 客户端,注重简单和最小化依赖。 |
RustOS
这是参加RustOS
训练营的过程记录.
文件属性 stat,lstat,fstat系统调用
x86_64
系统调用分析
系统调用号
stat
: 4fstat
: 5lstat
: 6
st_mode
文件类型及权限
st_mode
字段所含各位的布局情况如下图:
st_mode
字段的低12位定义了文件权限, 其中最低的9位分别用来表示文件宿主, 组群和其他用户的读,写,执行权限.
针对stat
结构中的st_mode
来检查文件类型的宏
常量 | 测试宏 | 文件类型 |
---|---|---|
S_IFREG | S_ISREG() | 常规文件 |
S_IFDIR | S_ISDIR() | 目录 |
S_IFCHR | S_ISCHR() | 字符设备 |
S_IFBLK | S_ISBLK() | 块设备 |
S_IFIFO | S_ISFIFO() | FIFO 或管道 |
S_IFSOCK | S_ISSOCK() | 套接字 |
S_IFLNK | S_ISLNK() | 符号链接 |
// TODO 其它参数的介绍
Ubuntu源码编译QEMU
$ sudo apt update -y
$ sudo apt install -y ninja-build pkg-config libglib2.0-dev libpixman-1-dev flex bison
报错:ERROR: glib-2.56 gthread-2.0 is required to compile QEMU
需要安装 libglib2.0-dev
报错:ERROR: Dependency "pixman-1" not found, tried pkgconfig
需要安装 libpixman-1-dev
报错:ERROR: Program 'flex' not found or not executable
需要安装 flex
报错:ERROR: Program 'bison' not found or not executable
需要安装 bison
$ ./configure
$ make -j$(nproc)
$ sudo make install
configure
过程
Using './build' as the directory for build output
The Meson build system
Version: 0.61.5
Source dir: /home/echo/Software/qemu-8.0.5
Build dir: /home/echo/Software/qemu-8.0.5/build
Build type: native build
Project name: qemu
Project version: 8.0.5
C compiler for the host machine: cc -m64 -mcx16 (gcc 11.4.0 "cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0")
C linker for the host machine: cc -m64 -mcx16 ld.bfd 2.38
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program scripts/symlink-install-tree.py found: YES (/usr/bin/python3 /home/echo/Software/qemu-8.0.5/scripts/symlink-install-tree.py)
Program sh found: YES (/usr/bin/sh)
C++ compiler for the host machine: c++ -m64 -mcx16 (gcc 11.4.0 "c++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0")
C++ linker for the host machine: c++ -m64 -mcx16 ld.bfd 2.38
Program python3 found: YES (/usr/bin/python3)
Program bzip2 found: YES (/usr/bin/bzip2)
Program iasl found: NO
Compiler for C supports link arguments -Wl,-z,relro: YES
Compiler for C supports link arguments -Wl,-z,now: YES
Compiler for C++ supports link arguments -Wl,--warn-common: YES
Program cgcc found: NO
Library m found: YES
Run-time dependency threads found: YES
Library util found: YES
Run-time dependency appleframeworks found: NO (tried framework)
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Run-time dependency gio-2.0 found: YES 2.72.4
Program /usr/bin/gdbus-codegen found: YES (/usr/bin/gdbus-codegen)
Run-time dependency gio-unix-2.0 found: YES 2.72.4
Run-time dependency pixman-1 found: YES 0.40.0
Run-time dependency zlib found: YES 1.2.11
Has header "libaio.h" : NO
Run-time dependency liburing found: NO (tried pkgconfig)
Run-time dependency libnfs found: NO (tried pkgconfig)
Run-time dependency appleframeworks found: NO (tried framework)
Run-time dependency appleframeworks found: NO (tried framework)
Run-time dependency libseccomp found: NO (tried pkgconfig)
Has header "cap-ng.h" : NO
Run-time dependency xkbcommon found: NO (tried pkgconfig)
Run-time dependency slirp found: NO (tried pkgconfig)
Has header "libvdeplug.h" : NO
Run-time dependency libpulse found: NO (tried pkgconfig)
Run-time dependency alsa found: NO (tried pkgconfig)
Run-time dependency jack found: NO (tried pkgconfig)
Run-time dependency sndio found: NO (tried pkgconfig)
Run-time dependency spice-protocol found: NO (tried pkgconfig)
Run-time dependency spice-server found: NO (tried pkgconfig)
Library rt found: YES
Run-time dependency libiscsi found: NO (tried pkgconfig)
Run-time dependency libzstd found: NO (tried pkgconfig)
Run-time dependency virglrenderer found: NO (tried pkgconfig)
Run-time dependency blkio found: NO (tried pkgconfig)
Run-time dependency libcurl found: NO (tried pkgconfig)
Run-time dependency libudev found: NO (tried pkgconfig)
Library mpathpersist found: NO
Run-time dependency ncursesw found: NO (tried pkgconfig)
Has header "curses.h" : NO
Message: Trying with /usr/include/ncursesw
Has header "curses.h" : NO
Has header "brlapi.h" : NO
sdl2-config found: NO
Run-time dependency sdl2 found: NO (tried pkgconfig and config-tool)
Library rados found: NO
Has header "rbd/librbd.h" : NO
Run-time dependency glusterfs-api found: NO (tried pkgconfig)
Run-time dependency libssh found: NO (tried pkgconfig)
Has header "bzlib.h" : NO
Has header "lzfse.h" : NO
Has header "sys/soundcard.h" : YES
Run-time dependency epoxy found: NO (tried pkgconfig)
Has header "epoxy/egl.h" with dependency epoxy: NO
Run-time dependency gnutls found: NO (tried pkgconfig)
Run-time dependency gnutls found: NO (tried pkgconfig)
libgcrypt-config found: NO need ['>=1.8']
Run-time dependency libgcrypt found: NO (tried config-tool)
Run-time dependency nettle found: NO (tried pkgconfig)
Run-time dependency gmp found: NO (tried pkgconfig)
Run-time dependency gtk+-3.0 found: NO (tried pkgconfig)
Run-time dependency libpng found: NO (tried pkgconfig)
Run-time dependency libjpeg found: NO (tried pkgconfig)
Has header "sasl/sasl.h" : NO
Has header "security/pam_appl.h" : NO
Has header "snappy-c.h" : NO
Has header "lzo/lzo1x.h" : NO
Has header "numa.h" : NO
Library ibumad found: NO
Has header "rdma/rdma_cma.h" : NO
Library ibverbs found: NO
Run-time dependency xencontrol found: NO (tried pkgconfig)
Library xenstore found: NO
Library xenctrl found: NO
Library xendevicemodel found: NO
Library xenforeignmemory found: NO
Library xengnttab found: NO
Library xenevtchn found: NO
Library xentoolcore found: NO
Run-time dependency libcacard found: NO (tried pkgconfig)
Run-time dependency u2f-emu found: NO (tried pkgconfig)
Run-time dependency canokey-qemu found: NO (tried pkgconfig)
Run-time dependency libusbredirparser-0.5 found: NO (tried pkgconfig)
Run-time dependency libusb-1.0 found: NO (tried pkgconfig)
Run-time dependency libpmem found: NO (tried pkgconfig)
Run-time dependency libdaxctl found: NO (tried pkgconfig)
Run-time dependency libkeyutils found: NO (tried pkgconfig)
Checking for function "gettid" : YES
Run-time dependency libselinux found: YES 3.3
Run-time dependency fuse3 found: NO (tried pkgconfig)
Run-time dependency libbpf found: NO (tried pkgconfig)
Run-time dependency libdw found: NO (tried pkgconfig)
Has header "sys/epoll.h" : YES
Has header "linux/magic.h" : YES
Has header "valgrind/valgrind.h" : NO
Has header "linux/btrfs.h" : YES
Has header "libdrm/drm.h" : NO
Has header "pty.h" : YES
Has header "sys/disk.h" : NO
Has header "sys/ioccom.h" : NO
Has header "sys/kcov.h" : NO
Checking for function "close_range" : YES
Checking for function "accept4" : YES
Checking for function "clock_adjtime" : YES
Checking for function "dup3" : YES
Checking for function "fallocate" : YES
Checking for function "posix_fallocate" : YES
Checking for function "posix_memalign" : YES
Checking for function "_aligned_malloc" : NO
Checking for function "valloc" : YES
Checking for function "memalign" : YES
Checking for function "ppoll" : YES
Checking for function "preadv" : YES
Checking for function "pthread_fchdir_np" : NO
Checking for function "sendfile" : YES
Checking for function "setns" : YES
Checking for function "unshare" : YES
Checking for function "syncfs" : YES
Checking for function "sync_file_range" : YES
Checking for function "timerfd_create" : YES
Checking for function "copy_file_range" : YES
Checking for function "getifaddrs" : YES
Checking for function "openpty" with dependency -lutil: YES
Checking for function "strchrnul" : YES
Checking for function "system" : YES
Header <sys/epoll.h> has symbol "epoll_create1" : YES
Header <linux/falloc.h> has symbol "FALLOC_FL_PUNCH_HOLE" : YES
Header <linux/falloc.h> has symbol "FALLOC_FL_KEEP_SIZE" : YES
Header <linux/falloc.h> has symbol "FALLOC_FL_ZERO_RANGE" : YES
Has header "linux/fiemap.h" : YES
Header <linux/fs.h> has symbol "FS_IOC_FIEMAP" : YES
Checking for function "getrandom" : YES
Header <sys/random.h> has symbol "GRND_NONBLOCK" : YES
Header <sys/inotify.h> has symbol "inotify_init" : YES
Header <sys/inotify.h> has symbol "inotify_init1" : YES
Header <sys/prctl.h> has symbol "PR_SET_TIMERSLACK" : YES
Header <linux/rtnetlink.h> has symbol "IFLA_PROTO_DOWN" : YES
Header <sys/sysmacros.h> has symbol "makedev" : YES
Header <getopt.h> has symbol "optreset" : NO
Header <netinet/in.h> has symbol "IPPROTO_MPTCP" : YES
Checking whether type "struct sigevent" has member "sigev_notify_thread_id" : NO
Checking whether type "struct stat" has member "st_atim" : YES
Checking for type "struct iovec" : YES
Checking for type "struct utmpx" : YES
Checking for type "struct mmsghdr" : YES
Header <linux/vm_sockets.h> has symbol "AF_VSOCK" : YES
Program scripts/minikconf.py found: YES (/usr/bin/python3 /home/echo/Software/qemu-8.0.5/scripts/minikconf.py)
Configuring aarch64-softmmu-config-target.h using configuration
Configuring aarch64-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/aarch64-softmmu-config-devices.mak.d
Configuring aarch64-softmmu-config-devices.h using configuration
Configuring alpha-softmmu-config-target.h using configuration
Configuring alpha-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/alpha-softmmu-config-devices.mak.d
Configuring alpha-softmmu-config-devices.h using configuration
Configuring arm-softmmu-config-target.h using configuration
Configuring arm-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/arm-softmmu-config-devices.mak.d
Configuring arm-softmmu-config-devices.h using configuration
Configuring avr-softmmu-config-target.h using configuration
Configuring avr-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/avr-softmmu-config-devices.mak.d
Configuring avr-softmmu-config-devices.h using configuration
Configuring cris-softmmu-config-target.h using configuration
Configuring cris-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/cris-softmmu-config-devices.mak.d
Configuring cris-softmmu-config-devices.h using configuration
Configuring hppa-softmmu-config-target.h using configuration
Configuring hppa-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/hppa-softmmu-config-devices.mak.d
Configuring hppa-softmmu-config-devices.h using configuration
Configuring i386-softmmu-config-target.h using configuration
Configuring i386-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/i386-softmmu-config-devices.mak.d
Configuring i386-softmmu-config-devices.h using configuration
Configuring loongarch64-softmmu-config-target.h using configuration
Configuring loongarch64-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/loongarch64-softmmu-config-devices.mak.d
Configuring loongarch64-softmmu-config-devices.h using configuration
Configuring m68k-softmmu-config-target.h using configuration
Configuring m68k-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/m68k-softmmu-config-devices.mak.d
Configuring m68k-softmmu-config-devices.h using configuration
Configuring microblaze-softmmu-config-target.h using configuration
Configuring microblaze-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/microblaze-softmmu-config-devices.mak.d
Configuring microblaze-softmmu-config-devices.h using configuration
Configuring microblazeel-softmmu-config-target.h using configuration
Configuring microblazeel-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/microblazeel-softmmu-config-devices.mak.d
Configuring microblazeel-softmmu-config-devices.h using configuration
Configuring mips-softmmu-config-target.h using configuration
Configuring mips-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/mips-softmmu-config-devices.mak.d
Configuring mips-softmmu-config-devices.h using configuration
Configuring mips64-softmmu-config-target.h using configuration
Configuring mips64-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/mips64-softmmu-config-devices.mak.d
Configuring mips64-softmmu-config-devices.h using configuration
Configuring mips64el-softmmu-config-target.h using configuration
Configuring mips64el-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/mips64el-softmmu-config-devices.mak.d
Configuring mips64el-softmmu-config-devices.h using configuration
Configuring mipsel-softmmu-config-target.h using configuration
Configuring mipsel-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/mipsel-softmmu-config-devices.mak.d
Configuring mipsel-softmmu-config-devices.h using configuration
Configuring nios2-softmmu-config-target.h using configuration
Configuring nios2-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/nios2-softmmu-config-devices.mak.d
Configuring nios2-softmmu-config-devices.h using configuration
Configuring or1k-softmmu-config-target.h using configuration
Configuring or1k-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/or1k-softmmu-config-devices.mak.d
Configuring or1k-softmmu-config-devices.h using configuration
Configuring ppc-softmmu-config-target.h using configuration
Configuring ppc-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/ppc-softmmu-config-devices.mak.d
Configuring ppc-softmmu-config-devices.h using configuration
Configuring ppc64-softmmu-config-target.h using configuration
Configuring ppc64-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/ppc64-softmmu-config-devices.mak.d
Configuring ppc64-softmmu-config-devices.h using configuration
Configuring riscv32-softmmu-config-target.h using configuration
Configuring riscv32-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/riscv32-softmmu-config-devices.mak.d
Configuring riscv32-softmmu-config-devices.h using configuration
Configuring riscv64-softmmu-config-target.h using configuration
Configuring riscv64-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/riscv64-softmmu-config-devices.mak.d
Configuring riscv64-softmmu-config-devices.h using configuration
Configuring rx-softmmu-config-target.h using configuration
Configuring rx-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/rx-softmmu-config-devices.mak.d
Configuring rx-softmmu-config-devices.h using configuration
Configuring s390x-softmmu-config-target.h using configuration
Configuring s390x-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/s390x-softmmu-config-devices.mak.d
Configuring s390x-softmmu-config-devices.h using configuration
Configuring sh4-softmmu-config-target.h using configuration
Configuring sh4-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/sh4-softmmu-config-devices.mak.d
Configuring sh4-softmmu-config-devices.h using configuration
Configuring sh4eb-softmmu-config-target.h using configuration
Configuring sh4eb-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/sh4eb-softmmu-config-devices.mak.d
Configuring sh4eb-softmmu-config-devices.h using configuration
Configuring sparc-softmmu-config-target.h using configuration
Configuring sparc-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/sparc-softmmu-config-devices.mak.d
Configuring sparc-softmmu-config-devices.h using configuration
Configuring sparc64-softmmu-config-target.h using configuration
Configuring sparc64-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/sparc64-softmmu-config-devices.mak.d
Configuring sparc64-softmmu-config-devices.h using configuration
Configuring tricore-softmmu-config-target.h using configuration
Configuring tricore-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/tricore-softmmu-config-devices.mak.d
Configuring tricore-softmmu-config-devices.h using configuration
Configuring x86_64-softmmu-config-target.h using configuration
Configuring x86_64-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/x86_64-softmmu-config-devices.mak.d
Configuring x86_64-softmmu-config-devices.h using configuration
Configuring xtensa-softmmu-config-target.h using configuration
Configuring xtensa-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/xtensa-softmmu-config-devices.mak.d
Configuring xtensa-softmmu-config-devices.h using configuration
Configuring xtensaeb-softmmu-config-target.h using configuration
Configuring xtensaeb-softmmu-config-devices.mak with command
Reading depfile: /home/echo/Software/qemu-8.0.5/build/meson-private/xtensaeb-softmmu-config-devices.mak.d
Configuring xtensaeb-softmmu-config-devices.h using configuration
Configuring aarch64-linux-user-config-target.h using configuration
Configuring aarch64_be-linux-user-config-target.h using configuration
Configuring alpha-linux-user-config-target.h using configuration
Configuring arm-linux-user-config-target.h using configuration
Configuring armeb-linux-user-config-target.h using configuration
Configuring cris-linux-user-config-target.h using configuration
Configuring hexagon-linux-user-config-target.h using configuration
Configuring hppa-linux-user-config-target.h using configuration
Configuring i386-linux-user-config-target.h using configuration
Configuring loongarch64-linux-user-config-target.h using configuration
Configuring m68k-linux-user-config-target.h using configuration
Configuring microblaze-linux-user-config-target.h using configuration
Configuring microblazeel-linux-user-config-target.h using configuration
Configuring mips-linux-user-config-target.h using configuration
Configuring mips64-linux-user-config-target.h using configuration
Configuring mips64el-linux-user-config-target.h using configuration
Configuring mipsel-linux-user-config-target.h using configuration
Configuring mipsn32-linux-user-config-target.h using configuration
Configuring mipsn32el-linux-user-config-target.h using configuration
Configuring nios2-linux-user-config-target.h using configuration
Configuring or1k-linux-user-config-target.h using configuration
Configuring ppc-linux-user-config-target.h using configuration
Configuring ppc64-linux-user-config-target.h using configuration
Configuring ppc64le-linux-user-config-target.h using configuration
Configuring riscv32-linux-user-config-target.h using configuration
Configuring riscv64-linux-user-config-target.h using configuration
Configuring s390x-linux-user-config-target.h using configuration
Configuring sh4-linux-user-config-target.h using configuration
Configuring sh4eb-linux-user-config-target.h using configuration
Configuring sparc-linux-user-config-target.h using configuration
Configuring sparc32plus-linux-user-config-target.h using configuration
Configuring sparc64-linux-user-config-target.h using configuration
Configuring x86_64-linux-user-config-target.h using configuration
Configuring xtensa-linux-user-config-target.h using configuration
Configuring xtensaeb-linux-user-config-target.h using configuration
Program scripts/make-config-poison.sh found: YES (/home/echo/Software/qemu-8.0.5/scripts/make-config-poison.sh)
Run-time dependency capstone found: NO (tried pkgconfig)
Library fdt found: NO
Configuring config-host.h using configuration
Program scripts/hxtool found: YES (/home/echo/Software/qemu-8.0.5/scripts/hxtool)
Program scripts/shaderinclude.py found: YES (/usr/bin/python3 /home/echo/Software/qemu-8.0.5/scripts/shaderinclude.py)
Program scripts/qapi-gen.py found: YES (/usr/bin/python3 /home/echo/Software/qemu-8.0.5/scripts/qapi-gen.py)
Program scripts/qemu-version.sh found: YES (/home/echo/Software/qemu-8.0.5/scripts/qemu-version.sh)
Executing subproject libvhost-user
libvhost-user| Project name: libvhost-user
libvhost-user| Project version: undefined
libvhost-user| C compiler for the host machine: cc -m64 -mcx16 (gcc 11.4.0 "cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0")
libvhost-user| C linker for the host machine: cc -m64 -mcx16 ld.bfd 2.38
libvhost-user| Compiler for C supports arguments -Wsign-compare: YES
libvhost-user| Compiler for C supports arguments -Wdeclaration-after-statement: YES
libvhost-user| Compiler for C supports arguments -Wstrict-aliasing: YES
libvhost-user| Dependency threads found: YES unknown (cached)
libvhost-user| Dependency glib-2.0 found: YES 2.72.4 (overridden)
libvhost-user| Build targets in project: 10
libvhost-user| Subproject libvhost-user finished.
Executing subproject libvduse
libvduse| Project name: libvduse
libvduse| Project version: undefined
libvduse| C compiler for the host machine: cc -m64 -mcx16 (gcc 11.4.0 "cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0")
libvduse| C linker for the host machine: cc -m64 -mcx16 ld.bfd 2.38
libvduse| Compiler for C supports arguments -Wsign-compare: YES (cached)
libvduse| Compiler for C supports arguments -Wdeclaration-after-statement: YES (cached)
libvduse| Compiler for C supports arguments -Wstrict-aliasing: YES (cached)
libvduse| Build targets in project: 11
libvduse| Subproject libvduse finished.
Program scripts/decodetree.py found: YES (/usr/bin/python3 /home/echo/Software/qemu-8.0.5/scripts/decodetree.py)
Program flex found: YES (/usr/bin/flex)
Program bison found: YES 3.8.2 (/usr/bin/bison)
Dependency glib-2.0 found: YES 2.72.4 (overridden)
Program indent found: NO
Program ../scripts/modules/module_block.py found: YES (/usr/bin/python3 /home/echo/Software/qemu-8.0.5/block/../scripts/modules/module_block.py)
Program ../scripts/block-coroutine-wrapper.py found: YES (/usr/bin/python3 /home/echo/Software/qemu-8.0.5/block/../scripts/block-coroutine-wrapper.py)
Program scripts/modinfo-collect.py found: YES (/home/echo/Software/qemu-8.0.5/scripts/modinfo-collect.py)
Program scripts/modinfo-generate.py found: YES (/home/echo/Software/qemu-8.0.5/scripts/modinfo-generate.py)
Program nm found: YES
Program scripts/undefsym.py found: YES (/usr/bin/python3 /home/echo/Software/qemu-8.0.5/scripts/undefsym.py)
Program scripts/feature_to_c.sh found: YES (/bin/sh /home/echo/Software/qemu-8.0.5/scripts/feature_to_c.sh)
Configuring 50-edk2-i386-secure.json using configuration
Configuring 50-edk2-x86_64-secure.json using configuration
Configuring 60-edk2-aarch64.json using configuration
Configuring 60-edk2-arm.json using configuration
Configuring 60-edk2-i386.json using configuration
Configuring 60-edk2-x86_64.json using configuration
Program qemu-keymap found: NO
Program sphinx-build found: NO
Program bash found: YES 5.1.16 (/usr/bin/bash)
Program diff found: YES (/usr/bin/diff)
Program dbus-daemon found: YES (/usr/bin/dbus-daemon)
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency gvnc-1.0 found: NO (tried pkgconfig and cmake)
Run-time dependency sysprof-capture-4 found: NO (tried pkgconfig and cmake)
Program initrd-stress.sh found: YES (/home/echo/Software/qemu-8.0.5/tests/migration/initrd-stress.sh)
Build targets in project: 731
qemu 8.0.5
Directories
Install prefix : /usr/local
BIOS directory : share/qemu
firmware path : share/qemu-firmware
binary directory : /usr/local/bin
library directory : /usr/local/lib/x86_64-linux-gnu
module directory : lib/x86_64-linux-gnu/qemu
libexec directory : /usr/local/libexec
include directory : /usr/local/include
config directory : /usr/local/etc
local state directory : /var/local
Manual directory : /usr/local/share/man
Doc directory : /usr/local/share/doc
Build directory : /home/echo/Software/qemu-8.0.5/build
Source path : /home/echo/Software/qemu-8.0.5
GIT submodules : ui/keycodemapdb tests/fp/berkeley-testfloat-3 tests/fp/berkeley-softfloat-3 dtc
Host binaries
git : git
make : make
python : /usr/bin/python3 (version: 3.10)
sphinx-build : NO
gdb : /usr/bin/gdb
iasl : NO
genisoimage : /usr/bin/genisoimage
Configurable features
Documentation : NO
system-mode emulation : YES
user-mode emulation : YES
block layer : YES
Install blobs : YES
module support : NO
fuzzing support : NO
Audio drivers : oss
Trace backends : log
D-Bus display : YES
QOM debugging : NO
vhost-kernel support : YES
vhost-net support : YES
vhost-user support : YES
vhost-user-crypto support : YES
vhost-user-blk server support: YES
vhost-vdpa support : YES
build guest agent : YES
Compilation
host CPU : x86_64
host endianness : little
C compiler : cc -m64 -mcx16
Host C compiler : cc -m64 -mcx16
C++ compiler : c++ -m64 -mcx16
CFLAGS : -g -O2
CXXFLAGS : -g -O2
QEMU_CFLAGS : -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wmissing-format-attribute -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong
QEMU_CXXFLAGS : -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -Wundef -Wwrite-strings -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wmissing-format-attribute -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -fstack-protector-strong
QEMU_LDFLAGS : -fstack-protector-strong -Wl,-z,relro -Wl,-z,now -Wl,--warn-common
profiler : NO
link-time optimization (LTO) : NO
PIE : YES
static build : NO
malloc trim support : YES
membarrier : NO
debug graph lock : NO
debug stack usage : NO
mutex debugging : NO
memory allocator : system
avx2 optimization : YES
avx512bw optimization : YES
avx512f optimization : NO
gprof : NO
gcov : NO
thread sanitizer : NO
CFI support : NO
strip binaries : NO
sparse : NO
mingw32 support : NO
Cross compilers
aarch64 : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc aarch64-linux-gnu-gcc-10 -i qemu/debian-arm64-cross -s /home/echo/Software/qemu-8.0.5 --
alpha : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc alpha-linux-gnu-gcc -i qemu/debian-alpha-cross -s /home/echo/Software/qemu-8.0.5 --
arm : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc arm-linux-gnueabihf-gcc -i qemu/debian-armhf-cross -s /home/echo/Software/qemu-8.0.5 --
i386 : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc gcc -i qemu/fedora-i386-cross -s /home/echo/Software/qemu-8.0.5 --
loongarch64 : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc loongarch64-unknown-linux-gnu-gcc -i qemu/debian-loongarch-cross -s /home/echo/Software/qemu-8.0.5 --
nios2 : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc nios2-linux-gnu-gcc -i qemu/debian-nios2-cross -s /home/echo/Software/qemu-8.0.5 --
riscv64 : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc riscv64-linux-gnu-gcc -i qemu/debian-riscv64-test-cross -s /home/echo/Software/qemu-8.0.5 --
s390x : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc s390x-linux-gnu-gcc -i qemu/debian-s390x-cross -s /home/echo/Software/qemu-8.0.5 --
x86_64 : cc
xtensa : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc /opt/2020.07/xtensa-dc232b-elf/bin/xtensa-dc232b-elf-gcc -i qemu/debian-xtensa-cross -s /home/echo/Software/qemu-8.0.5 --
xtensaeb : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc /opt/2020.07/xtensa-dc232b-elf/bin/xtensa-dc232b-elf-gcc -i qemu/debian-xtensa-cross -s /home/echo/Software/qemu-8.0.5 --
cris : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc cris-linux-gnu-gcc -i qemu/fedora-cris-cross -s /home/echo/Software/qemu-8.0.5 --
hexagon : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc hexagon-unknown-linux-musl-clang -i qemu/debian-hexagon-cross -s /home/echo/Software/qemu-8.0.5 --
hppa : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc hppa-linux-gnu-gcc -i qemu/debian-hppa-cross -s /home/echo/Software/qemu-8.0.5 --
m68k : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc m68k-linux-gnu-gcc -i qemu/debian-m68k-cross -s /home/echo/Software/qemu-8.0.5 --
microblaze : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc microblaze-linux-musl-gcc -i qemu/debian-microblaze-cross -s /home/echo/Software/qemu-8.0.5 --
mips : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc mips-linux-gnu-gcc -i qemu/debian-mips-cross -s /home/echo/Software/qemu-8.0.5 --
mips64 : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc mips64-linux-gnuabi64-gcc -i qemu/debian-mips64-cross -s /home/echo/Software/qemu-8.0.5 --
mips64el : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc mips64el-linux-gnuabi64-gcc -i qemu/debian-mips64el-cross -s /home/echo/Software/qemu-8.0.5 --
mipsel : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc mipsel-linux-gnu-gcc -i qemu/debian-mipsel-cross -s /home/echo/Software/qemu-8.0.5 --
ppc : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc powerpc-linux-gnu-gcc-10 -i qemu/debian-powerpc-test-cross -s /home/echo/Software/qemu-8.0.5 --
ppc64 : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc powerpc64-linux-gnu-gcc-10 -i qemu/debian-powerpc-test-cross -s /home/echo/Software/qemu-8.0.5 --
ppc64le : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc powerpc64le-linux-gnu-gcc-10 -i qemu/debian-powerpc-test-cross -s /home/echo/Software/qemu-8.0.5 --
sh4 : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc sh4-linux-gnu-gcc -i qemu/debian-sh4-cross -s /home/echo/Software/qemu-8.0.5 --
sparc64 : /usr/bin/python3 -B /home/echo/Software/qemu-8.0.5/tests/docker/docker.py --engine podman cc --cc sparc64-linux-gnu-gcc -i qemu/debian-sparc64-cross -s /home/echo/Software/qemu-8.0.5 --
Targets and accelerators
KVM support : YES
HAX support : NO
HVF support : NO
WHPX support : NO
NVMM support : NO
Xen support : NO
Xen emulation : YES
TCG support : YES
TCG backend : native (x86_64)
TCG plugins : YES
TCG debug enabled : NO
target list : aarch64-softmmu alpha-softmmu arm-softmmu avr-softmmu cris-softmmu hppa-softmmu i386-softmmu loongarch64-softmmu m68k-softmmu microblaze-softmmu microblazeel-softmmu mips-softmmu mips64-softmmu mips64el-softmmu mipsel-softmmu nios2-softmmu or1k-softmmu ppc-softmmu ppc64-softmmu riscv32-softmmu riscv64-softmmu rx-softmmu s390x-softmmu sh4-softmmu sh4eb-softmmu sparc-softmmu sparc64-softmmu tricore-softmmu x86_64-softmmu xtensa-softmmu xtensaeb-softmmu aarch64-linux-user aarch64_be-linux-user alpha-linux-user arm-linux-user armeb-linux-user cris-linux-user hexagon-linux-user hppa-linux-user i386-linux-user loongarch64-linux-user m68k-linux-user microblaze-linux-user microblazeel-linux-user mips-linux-user mips64-linux-user mips64el-linux-user mipsel-linux-user mipsn32-linux-user mipsn32el-linux-user nios2-linux-user or1k-linux-user ppc-linux-user ppc64-linux-user ppc64le-linux-user riscv32-linux-user riscv64-linux-user s390x-linux-user sh4-linux-user sh4eb-linux-user sparc-linux-user sparc32plus-linux-user sparc64-linux-user x86_64-linux-user xtensa-linux-user xtensaeb-linux-user
default devices : YES
out of process emulation : YES
vfio-user server : NO
Block layer support
coroutine backend : ucontext
coroutine pool : YES
Block whitelist (rw) :
Block whitelist (ro) :
Use block whitelist in tools : NO
VirtFS support : NO
Live block migration : YES
replication support : YES
bochs support : YES
cloop support : YES
dmg support : YES
qcow v1 support : YES
vdi support : YES
vvfat support : YES
qed support : YES
parallels support : YES
FUSE exports : NO
VDUSE block exports : YES
Crypto
TLS priority : NORMAL
GNUTLS support : NO
libgcrypt : NO
nettle : NO
AF_ALG support : NO
rng-none : NO
Linux keyring : YES
Dependencies
SDL support : NO
SDL image support : NO
GTK support : NO
pixman : YES 0.40.0
VTE support : NO
slirp support : NO
libtasn1 : NO
PAM : NO
iconv support : YES
curses support : NO
virgl support : NO
blkio support : NO
curl support : NO
Multipath support : NO
PNG support : NO
VNC support : YES
VNC SASL support : NO
VNC JPEG support : NO
OSS support : YES
sndio support : NO
ALSA support : NO
PulseAudio support : NO
JACK support : NO
brlapi support : NO
vde support : NO
netmap support : NO
l2tpv3 support : YES
Linux AIO support : NO
Linux io_uring support : NO
ATTR/XATTR support : YES
RDMA support : NO
PVRDMA support : NO
fdt support : internal
libcap-ng support : NO
bpf support : NO
spice protocol support : NO
rbd support : NO
smartcard support : NO
U2F support : NO
libusb : NO
usb net redir : NO
OpenGL support (epoxy) : NO
GBM : NO
libiscsi support : NO
libnfs support : NO
seccomp support : NO
GlusterFS support : NO
TPM support : YES
libssh support : NO
lzo support : NO
snappy support : NO
bzip2 support : NO
lzfse support : NO
zstd support : NO
NUMA host support : NO
capstone : NO
libpmem support : NO
libdaxctl support : NO
libudev : NO
FUSE lseek : NO
selinux : YES 3.3
libdw : NO
Subprojects
libvduse : YES
libvhost-user : YES
User defined options
Native files : config-meson.cross
prefix : /usr/local
vfio_user_server : disabled
Found ninja-1.10.1 at /usr/bin/ninja
Running postconf script '/usr/bin/python3 /home/echo/Software/qemu-8.0.5/scripts/symlink-install-tree.py'
ArceOS系统调用 - FastDDS移植
什么是FastDDS
?
eProsima Fast DDS
是DDS
(数据分发服务)规范的 C++
实现 ,该规范是由对象管理组 (OMG)定义的协议。eProsima Fast DDS
库提供了应用程序编程接口 (API) 和通信协议,用于部署以数据为中心的发布者-订阅者 (DCPS)
模型,目的是在实时系统之间建立高效可靠的信息分发。eProsima Fast DDS
在资源处理方面具有可预测、可扩展、灵活和高效的特点。为了满足这些要求,它利用类型化接口并依赖于多对多分布式网络范例,从而巧妙地分离了通信的发布者和订阅者端 。eProsima Fast DDS
包括:
DDS API
实现。Fast DDS-Gen
,一种用于连接类型接口和中间件实现的生成工具。- 底层
RTPS
有线协议实现。
鉴于以上所有情况,eProsima Fast DDS
已被选为 机器人操作系统 2 (ROS 2)
在每个长期 (LTS) 版本和大多数非 LTS 版本中支持的默认中间件。
分析FastDDS
的在Linux
中的系统调用
# 发布者
./DDSHelloWorldExample publisher
Starting
Publisher running 10 samples.
Publisher matched.
Message: HelloWorld with index: 1 SENT
Message: HelloWorld with index: 2 SENT
Message: HelloWorld with index: 3 SENT
Message: HelloWorld with index: 4 SENT
Message: HelloWorld with index: 5 SENT
Message: HelloWorld with index: 6 SENT
Message: HelloWorld with index: 7 SENT
Message: HelloWorld with index: 8 SENT
Message: HelloWorld with index: 9 SENT
Message: HelloWorld with index: 10 SENT
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
68.00 0.008722 396 22 futex
13.44 0.001724 123 14 sendto
3.91 0.000502 41 12 munmap
2.54 0.000326 40 8 clone3
1.96 0.000251 13 19 8 setsockopt
1.93 0.000247 3 63 mmap
1.58 0.000203 5 39 close
1.43 0.000183 7 23 mprotect
0.76 0.000097 1 79 55 openat
0.54 0.000069 69 1 clock_nanosleep
0.51 0.000066 4 14 socket
0.38 0.000049 6 8 1 unlink
0.37 0.000048 16 3 3 shutdown
0.32 0.000041 2 15 brk
0.30 0.000038 4 9 epoll_ctl
0.27 0.000035 2 17 rt_sigprocmask
0.23 0.000030 0 33 10 newfstatat
0.20 0.000026 2 9 bind
0.20 0.000026 2 10 flock
0.20 0.000026 8 3 fallocate
0.19 0.000024 6 4 write
0.13 0.000017 0 18 recvmsg
0.06 0.000008 0 16 read
0.06 0.000008 1 6 getsockname
0.06 0.000008 8 1 link
0.06 0.000008 8 1 eventfd2
0.05 0.000006 1 5 ioctl
0.05 0.000006 3 2 getsockopt
0.04 0.000005 2 2 getrandom
0.03 0.000004 1 3 fchmod
0.03 0.000004 4 1 set_tid_address
0.03 0.000004 4 1 timerfd_create
0.03 0.000004 4 1 epoll_create1
0.02 0.000003 1 2 1 arch_prctl
0.02 0.000003 3 1 set_robust_list
0.02 0.000003 3 1 rseq
0.02 0.000002 0 5 getpid
0.01 0.000001 0 2 lseek
0.00 0.000000 0 1 rt_sigaction
0.00 0.000000 0 4 pread64
0.00 0.000000 0 1 1 access
0.00 0.000000 0 2 2 connect
0.00 0.000000 0 1 execve
0.00 0.000000 0 1 uname
0.00 0.000000 0 1 geteuid
0.00 0.000000 0 1 prlimit64
------ ----------- ----------- --------- --------- ----------------
100.00 0.012827 26 485 81 total
# 订阅者
/DDSHelloWorldExample subscriber
Starting
Subscriber running. Please press enter to stop the Subscriber
Subscriber matched.
Message HelloWorld 1 RECEIVED
Message HelloWorld 2 RECEIVED
Message HelloWorld 3 RECEIVED
Message HelloWorld 4 RECEIVED
Message HelloWorld 5 RECEIVED
Message HelloWorld 6 RECEIVED
Message HelloWorld 7 RECEIVED
Message HelloWorld 8 RECEIVED
Message HelloWorld 9 RECEIVED
Message HelloWorld 10 RECEIVED
Subscriber unmatched.
^Cstrace: Process 157950 detached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
17.85 0.002071 26 79 55 openat
10.09 0.001171 18 62 mmap
7.91 0.000918 65 14 3 setsockopt
6.89 0.000800 28 28 futex
6.46 0.000750 22 34 10 newfstatat
6.32 0.000733 81 9 sendto
5.66 0.000657 43 15 rt_sigprocmask
4.33 0.000502 22 22 mprotect
4.05 0.000470 16 28 close
3.83 0.000445 24 18 recvmsg
3.58 0.000415 59 7 clone3
3.12 0.000362 25 14 socket
2.22 0.000258 16 16 read
2.12 0.000246 15 16 brk
2.05 0.000238 79 3 fallocate
1.67 0.000194 21 9 epoll_ctl
1.39 0.000161 17 9 bind
1.22 0.000142 17 8 flock
1.12 0.000130 26 5 1 unlink
1.10 0.000128 32 4 write
0.90 0.000105 17 6 getsockname
0.83 0.000096 32 3 fchmod
0.73 0.000085 21 4 pread64
0.67 0.000078 15 5 ioctl
0.65 0.000076 15 5 getpid
0.50 0.000058 19 3 munmap
0.33 0.000038 19 2 getsockopt
0.32 0.000037 18 2 2 connect
0.29 0.000034 34 1 1 access
0.28 0.000033 16 2 lseek
0.26 0.000030 15 2 1 arch_prctl
0.22 0.000026 26 1 link
0.20 0.000023 23 1 timerfd_create
0.18 0.000021 21 1 eventfd2
0.17 0.000020 20 1 epoll_create1
0.16 0.000018 18 1 rt_sigaction
0.14 0.000016 8 2 getrandom
0.09 0.000010 10 1 uname
0.09 0.000010 10 1 geteuid
0.00 0.000000 0 1 execve
0.00 0.000000 0 1 set_tid_address
0.00 0.000000 0 1 set_robust_list
0.00 0.000000 0 1 prlimit64
0.00 0.000000 0 1 rseq
------ ----------- ----------- --------- --------- ----------------
100.00 0.011605 25 449 73 total
64位Linux
系统调用整理
返回值放在%rax
中
ArceOS系统调用 - FastDDS在ArceOS中的系统调用
发布者
/bin/DDSHelloWorldExample publisher
Starting
terminate called after throwing an instance of 'std::runtime_error'
what(): random_device::random_device(const std::string&)
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ------------------
31.70 0.004095 102 40 mmap
16.70 0.002157 308 7 writev
13.78 0.001781 222 8 munmap
12.31 0.001591 198 8 recvfrom
9.54 0.001233 308 4 sendto
4.45 0.000575 287 2 close
2.83 0.000366 366 1 set_tid_address
2.63 0.000340 113 3 3 openat
1.91 0.000247 123 2 socket
1.29 0.000167 83 2 brk
0.98 0.000127 63 2 rt_sigprocmask
0.53 0.000069 69 1 tkill
0.52 0.000067 67 1 ioctl
0.48 0.000062 62 1 sched_getaffinity
0.33 0.000043 43 1 getpid
0.00 0.000000 0 1 execve
------ ----------- ----------- --------- --------- ------------------
100.00 0.012920 153 84 3 total
Aborted
订阅者
/bin/DDSHelloWorldExample subscriber
Starting
terminate called after throwing an instance of 'std::runtime_error'
what(): random_device::random_device(const std::string&)
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ------------------
23.69 0.004032 100 40 mmap
18.03 0.003069 3069 1 execve
14.94 0.002543 363 7 writev
14.09 0.002399 599 4 sendto
10.78 0.001835 229 8 recvfrom
8.58 0.001461 182 8 munmap
1.84 0.000314 314 1 set_tid_address
1.79 0.000305 152 2 close
1.54 0.000263 87 3 3 openat
1.47 0.000251 250 1 tkill
0.83 0.000141 70 2 brk
0.72 0.000122 61 2 rt_sigprocmask
0.70 0.000119 59 2 socket
0.39 0.000067 67 1 ioctl
0.33 0.000057 57 1 sched_getaffinity
0.26 0.000045 45 1 getpid
------ ----------- ----------- --------- --------- ------------------
100.00 0.017023 202 84 3 total
Aborted
ArceOS
在 RISC-V
架构下的系统调用整理
# | syscall | prototype |
---|---|---|
222 | mmap | asmlinkage long sys_old_mmap(struct mmap_arg_struct __user *arg); |
221 | execve | asmlinkage long sys_execve(const char __user *filename, const char __user *const __user *argv, const char __user *const __user *envp); |
66 | writev | asmlinkage long sys_writev(unsigned long fd, const struct iovec __user *vec, unsigned long vlen); |
206 | sendto | asmlinkage long sys_sendto(int, void __user *, size_t, unsigned, struct sockaddr __user *, int); |
207 | recvfrom | asmlinkage long sys_recvfrom(int, void __user *, size_t, unsigned, struct sockaddr __user *, int __user *); |
215 | munmap | asmlinkage long sys_munmap(unsigned long addr, size_t len); |
96 | set_tid_address | asmlinkage long sys_set_tid_address(int __user *tidptr); |
57 | close | asmlinkage long sys_close(unsigned int fd); |
56 | openat | asmlinkage long sys_openat(int dfd, const char __user *filename, int flags, umode_t mode); |
130 | tkill | asmlinkage long sys_tkill(pid_t pid, int sig); |
214 | brk | asmlinkage long sys_brk(unsigned long brk); |
135 | rt_sigprocmask | asmlinkage long sys_rt_sigprocmask(int how, sigset_t __user *set, sigset_t __user *oset, size_t sigsetsize); |
198 | socket | asmlinkage long sys_socket(int, int, int); |
29 | ioctl | asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg); |
123 | sched_getaffinity | asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len, unsigned long __user *user_mask_ptr); |
172 | getpid | asmlinkage long sys_getpid(void); |
下面是LatencyTest
新增的系统调用
# | syscall | prototype |
---|---|---|
220 | clone | asmlinkage long sys_clone(unsigned long, unsigned long, int __user *, unsigned long, int __user *); |
422 | futex | asmlinkage long sys_futex(u32 __user *uaddr, int op, u32 val, struct __kernel_timespec __user *utime, u32 __user *uaddr2, u32 val3); |
226 | mprotect | asmlinkage long sys_mprotect(unsigned long start, size_t len, unsigned long prot); |
430 | clock_gettime | asmlinkage long sys_clock_gettime(clockid_t which_clock, struct __kernel_timespec __user *tp); |
LatencyTest
在 RISC-V
架构下的系统调用整理
/bin/LatencyTest both
Performing intraprocess test with 1 subscribers and 10000 samples
terminate called after throwing an instance of 'std::runtime_error'
what(): random_device::random_device(const std::string&)
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ------------------
17.81 0.002460 51 48 mmap
17.44 0.002409 344 7 writev
16.88 0.002331 2331 1 execve
10.79 0.001491 135 11 munmap
9.25 0.001278 159 8 recvfrom
5.97 0.000825 206 4 sendto
5.68 0.000784 392 2 close
3.79 0.000524 262 2 socket
2.54 0.000351 351 1 clone
2.32 0.000321 80 4 1 futex
2.19 0.000302 60 5 rt_sigprocmask
1.01 0.000140 70 2 brk
0.89 0.000123 41 3 3 openat
0.76 0.000105 105 1 mprotect
0.62 0.000085 85 1 ioctl
0.45 0.000062 62 1 set_tid_address
0.45 0.000062 62 1 tkill
0.44 0.000061 61 1 clock_gettime
0.41 0.000057 57 1 sched_getaffinity
0.30 0.000041 41 1 getpid
------ ----------- ----------- --------- --------- ------------------
100.00 0.013812 131 105 4 total
/bin/DDSHelloWorldExample publisher
11:27:35.889478 execve("/bin/DDSHelloWorldExample", ["/bin/DDSHelloWorldExample", "publisher"], 0x7fffc74d5d68 /* 5 vars */) = 0
11:27:35.909762 set_tid_address(0x6a8064) = 78
11:27:35.915371 brk(NULL) = 0x6a9000
11:27:35.917362 brk(0x6ab000) = 0x6ab000
11:27:35.919784 mmap(0x6a9000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x6a9000
11:27:35.922174 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996ff000
11:27:35.925289 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996fe000
11:27:35.928390 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996fd000
11:27:35.930635 sched_getaffinity(0, 128, [0]) = 8
11:27:35.933744 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996fc000
11:27:35.936317 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996fb000
11:27:35.940153 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996fa000
11:27:35.943408 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996f9000
11:27:35.946195 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996f8000
11:27:35.949598 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996f7000
11:27:35.952911 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996f6000
11:27:35.955841 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996f5000
11:27:35.958930 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996f3000
11:27:35.962314 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996f1000
11:27:35.965586 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996f0000
11:27:35.967853 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996ee000
11:27:35.978082 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996ed000
11:27:35.981671 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996ec000
11:27:35.983949 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996ea000
11:27:35.986637 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996e9000
11:27:35.989694 munmap(0x7fff996ec000, 4096) = 0
11:27:35.997639 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996ec000
11:27:36.000587 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996e7000
11:27:36.003539 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996e6000
11:27:36.005790 munmap(0x7fff996ec000, 4096) = 0
11:27:36.008303 munmap(0x7fff996e7000, 8192) = 0
11:27:36.009869 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996e7000
11:27:36.012084 munmap(0x7fff996e7000, 8192) = 0
11:27:36.014086 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996e7000
11:27:36.016313 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996e4000
11:27:36.018485 munmap(0x7fff996e6000, 4096) = 0
11:27:36.020713 munmap(0x7fff996e7000, 8192) = 0
11:27:36.022729 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996e7000
11:27:36.025887 munmap(0x7fff996e7000, 8192) = 0
11:27:36.028056 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996e7000
11:27:36.032498 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996e0000
11:27:36.037210 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996ec000
11:27:36.039783 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996dc000
11:27:36.044199 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996d8000
11:27:36.048757 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996d4000
11:27:36.053048 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996d0000
11:27:36.057484 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996e6000
11:27:36.060407 mmap(NULL, 73728, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996be000
11:27:36.063257 ioctl(1, TIOCGWINSZ, {ws_row=0, ws_col=0, ws_xpixel=0, ws_ypixel=0}) = 0
11:27:36.067601 writev(1, [{iov_base="Starting ", iov_len=9}, {iov_base="\n", iov_len=1}], 2Starting ) = 10
11:27:36.072236 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996bd000
11:27:36.075311 openat(AT_FDCWD, "DEFAULT_FASTRTPS_PROFILES.xml", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
11:27:36.079455 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff996bc000
11:27:36.082347 openat(AT_FDCWD, "/etc/localtime", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
11:27:36.084500 socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_ROUTE) = 3
11:27:36.087662 sendto(3, "\24\0\0\0\22\0\1\3\1\0\0\0\0\0\0\0\0\0\0\0", 20, 0, NULL, 0) = 20
11:27:36.091438 recvfrom(3, "\234\5\0\0\20\0\2\0\1\0\0\0N\0\0\0\0\0\4\3\1\0\0\0\10\0\0\0\0\0\0\0"..., 8192, MSG_DONTWAIT, NULL, NULL) = 2912
11:27:36.094200 recvfrom(3, "\310\5\0\0\20\0\2\0\1\0\0\0N\0\0\0\0\0\1\0\3\0\0\0\2\20\0\0\0\0\0\0"..., 8192, MSG_DONTWAIT, NULL, NULL) = 3044
11:27:36.096445 recvfrom(3, "\24\0\0\0\3\0\2\0\1\0\0\0N\0\0\0\0\0\0\0", 8192, MSG_DONTWAIT, NULL, NULL) = 20
11:27:36.098220 sendto(3, "\24\0\0\0\26\0\1\3\2\0\0\0\0\0\0\0\0\0\0\0", 20, 0, NULL, 0) = 20
11:27:36.100156 recvfrom(3, "\24\0\0\0\3\0\2\0\2\0\0\0N\0\0\0\0\0\0\0", 8192, MSG_DONTWAIT, NULL, NULL) = 20
11:27:36.101887 close(3) = 0
11:27:36.103466 socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_ROUTE) = 3
11:27:36.106009 sendto(3, "\24\0\0\0\22\0\1\3\1\0\0\0\0\0\0\0\0\0\0\0", 20, 0, NULL, 0) = 20
11:27:36.108083 recvfrom(3, "\234\5\0\0\20\0\2\0\1\0\0\0N\0\0\0\0\0\4\3\1\0\0\0\10\0\0\0\0\0\0\0"..., 8192, MSG_DONTWAIT, NULL, NULL) = 2912
11:27:36.110863 recvfrom(3, "\310\5\0\0\20\0\2\0\1\0\0\0N\0\0\0\0\0\1\0\3\0\0\0\2\20\0\0\0\0\0\0"..., 8192, MSG_DONTWAIT, NULL, NULL) = 3044
11:27:36.113566 recvfrom(3, "\24\0\0\0\3\0\2\0\1\0\0\0N\0\0\0\0\0\0\0", 8192, MSG_DONTWAIT, NULL, NULL) = 20
11:27:36.115621 sendto(3, "\24\0\0\0\26\0\1\3\2\0\0\0\0\0\0\0\0\0\0\0", 20, 0, NULL, 0) = 20
11:27:36.117941 recvfrom(3, "\24\0\0\0\3\0\2\0\2\0\0\0N\0\0\0\0\0\0\0", 8192, MSG_DONTWAIT, NULL, NULL) = 20
11:27:36.120707 close(3) = 0
11:27:36.122324 getpid() = 78
11:27:36.124015 openat(AT_FDCWD, "/dev/urandom", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
11:27:36.131604 mmap(NULL, 118784, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff9969f000
11:27:36.134045 mmap(NULL, 118784, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff99682000
11:27:36.207700 munmap(0x7fff99682000, 118784) = 0
11:27:36.210555 writev(2, [{iov_base="", iov_len=0}, {iov_base="terminate called after throwing "..., iov_len=48}], 2terminate called after throwing an instance of ') = 48
11:27:36.213283 writev(2, [{iov_base="", iov_len=0}, {iov_base="std::runtime_error", iov_len=18}], 2std::runtime_error) = 18
11:27:36.215820 writev(2, [{iov_base="", iov_len=0}, {iov_base="'\n", iov_len=2}], 2') = 2
11:27:36.217960 writev(2, [{iov_base="", iov_len=0}, {iov_base=" what(): ", iov_len=11}], 2 what(): ) = 11
11:27:36.220151 writev(2, [{iov_base="", iov_len=0}, {iov_base="random_device::random_device(con"..., iov_len=48}], 2random_device::random_device(const std::string&)) = 48
11:27:36.222858 writev(2, [{iov_base="", iov_len=0}, {iov_base="\n", iov_len=1}], 2) = 1
11:27:36.225051 rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
11:27:36.227800 tkill(78, SIGABRT) = 0
11:27:36.229517 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
11:27:36.230940 --- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=78, si_uid=0} ---
11:27:36.235671 +++ killed by SIGABRT +++
macOS
开发 StarryOS
环境部署说明
StarryOS,一个基于ArceOS实现的宏内核。
Starry意指布满星星的,寓意本OS的开发学习借鉴了许多前辈的思路,并将其汇总归一为这个内核。
这是一个介绍如何在macOS
系统下部署 StarryOS
开发环境的说明文档。此文档默认构建x86_64
架构的fat
磁盘镜像
仓库提交记录 https://github.com/Arceos-monolithic/Starry/pull/46
操作步骤
以下所有的操作步骤都是在当前项目根目录中操作.
- 安装
rust
$ xcode-select --install
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- 安装
qemu
$ brew install qemu
- 安装
cargo-binutils
$ cargo install cargo-binutils
$ rustup component add llvm
- 创建磁盘文件
$ dd if=/dev/zero of=disk.img bs=4M count=30
- 给磁盘文件添加文件系统
$ open disk.img
这个时候会弹出一个是否初始化的弹窗, 点击初始化,会打开磁盘管理器
- 格式化磁盘
6-1 选中磁盘, 点击格式化
6-2 格式化选项选择 MS-DOS (FAT)
格式
6-3 点击格式化按钮
6-4 格式化完成
6-5 弹出磁盘
- 后续的磁盘操作
# 创建文件夹
$ mkdir -p mnt
# 挂载磁盘
$ hdiutil attach disk.img -mountpoint mnt
# 拷贝文件
$ cp -r ./testcases/x86_64_linux_musl/* ./mnt/
# 卸载磁盘
$ hdiutil detach mnt
# 改变文件权限
$ chmod 777 disk.img
- 运行
StarryOS
# 运行宏内核
$ make run
# 运行 shell
$ make A=apps/fs/shell AARCH=x86_64 FEATURES=fp_simd run
运行效果
macOS
系统下运行StarryOS
效果
最新版本StarryOS
环境搭建说明
说明: 本教程将构建一个
riscv64
架构下的宏内核系统. 主机系统使用的是x86_64
架构下的ubuntu 22.04 LTS
版本.
最新版本的StarryOS
将所有的组件进行了组件化拆分, 使其成为一个个独立的crate
.
本教程讲详细的介绍如何从零开始搭建StarryOS
环境并成功运行一个宏内核系统.
1: 升级系统
sudo apt update -y
2: 安装必要的工具
sudo apt install -y curl wget vim git build-essential qemu-system
3: 安装Rust
, 参考Linux系统安装
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo install cargo-binutils
4: 克隆StarryOS
git clone https://github.com/Starry-OS/Starry.git
5: 更新子模块
cd Starry
git submodule update --init --recursive
6: 构建系统镜像详解
./build_img.sh -h
./build_img.sh -a [arch] -fs [filesystem] -file [testcast]
-a | --arch architecture: x86_64|riscv64|aarch64, default is x86_64
-fs | --filesystem filesystem: ext4|fat32, default is fat32
-file | --testcase If not specified, use the default testcases for different architectures.
-s | --size size of the disk image in 4MB batch size, default is set to 30, which means 120MB disk image
default testcases:
x86_64: x86_64_linux_musl
riscv64: riscv64_linux_musl
aarch64: aarch64-linux-musl
-h | --help display help
详细讲解构建参数
参数 | 说明 | 默认值 |
---|---|---|
-a --arch | 指定构建目标架构, 选项为x86_64 , riscv64 , aarch64 | x86_64 |
-fs --filesystem | 文件系统, 选项为ext4 , fat32 | fat32 |
-file --testcase | 测试用例, 如果不指定测试用例, 将采用架构的默认测试用例, 不同的架构测试用例详见下表 | - |
-s --size | 磁盘镜像blocks 块的数量, 一个block 大小为4MB | 30 , 表示默认磁盘镜像大小为120MB |
-h --help | 帮助说明 | - |
默认测试用例
架构 | 默认测试用例 |
---|---|
x86_64 | testcases 目录下的x86_64_linux_musl |
riscv64 | testcases 目录下的riscv64_linux_musl |
aarch64 | testcases 目录下的aarch64-linux-musl |
7: 构建系统镜像
./build_img.sh -a riscv64
构建过程中可能会提示输入密码, 输入当前系统账号登录的密码即可.
8: 运行一个宏内核系统
make A=apps/monolithic_userboot ARCH=riscv64 FEATURES=img LOG=error run
9: 没有错误产生的话,就会看到下面的内容
Building App: monolithic_userboot, Arch: riscv64, Platform: riscv64-qemu-virt, App type: rust
cargo build
--target riscv64gc-unknown-none-elf
--target-dir /home/echo/Dev/Starry/target
--release
--manifest-path apps/monolithic_userboot/Cargo.toml
--features "axstarry/log-level-error axstarry/fp_simd axstarry/monolithic axstarry/fatfs"
Compiling proc-macro2 v1.0.82
Compiling log v0.4.19
Compiling unicode-ident v1.0.12
Compiling hashbrown v0.14.5
Compiling serde v1.0.202
Compiling equivalent v1.0.1
Compiling winnow v0.5.40
Compiling toml_datetime v0.6.6
Compiling cfg-if v1.0.0
Compiling indexmap v2.2.6
Compiling quote v1.0.36
Compiling bitflags v2.5.0
Compiling axerrno v0.1.0 (https://github.com/Starry-OS/axerrno.git#12d36f6c)
Compiling syn v2.0.64
Compiling autocfg v1.3.0
Compiling syn v1.0.109
Compiling memory_addr v0.1.0 (https://github.com/Starry-OS/memory_addr.git#a5be547a)
Compiling toml_edit v0.19.15
Compiling lock_api v0.4.12
Compiling static_assertions v1.1.0
Compiling scopeguard v1.2.0
Compiling numeric-enum-macro v0.2.0 (https://github.com/mexus/numeric-enum-macro#20aef288)
Compiling taskctx v0.1.0 (https://github.com/Starry-OS/taskctx.git#7296a141)
Compiling spin v0.9.8
Compiling unicode-width v0.1.12
Compiling tock-registers v0.8.1
Compiling bit_field v0.10.2
Compiling base64 v0.13.1
Compiling aarch64-cpu v9.4.0
Compiling svgbobdoc v0.3.0
Compiling axconfig v0.1.0 (https://github.com/Starry-OS/axconfig.git#a19854cc)
Compiling kernel_guard v0.1.0 (https://github.com/Starry-OS/kernel_guard.git#72e00672)
Compiling const-default v1.0.0
Compiling spin v0.5.2
Compiling nb v1.1.0
Compiling lazy_static v1.4.0
Compiling nb v0.1.3
Compiling rlsf v0.2.1
Compiling spinlock v0.1.0 (https://github.com/Starry-OS/spinlock.git#81ef766c)
Compiling bitmap-allocator v0.1.0 (https://github.com/rcore-os/bitmap-allocator.git?rev=88e871a#88e871a5)
Compiling axfs_vfs v0.1.0 (https://github.com/Starry-OS/axfs_vfs.git#4ae66642)
Compiling void v1.0.2
Compiling percpu v0.1.0 (https://github.com/Starry-OS/percpu.git#939e6eb9)
Compiling riscv v0.10.1
Compiling byteorder v1.5.0
Compiling allocator v0.1.0 (https://github.com/Starry-OS/allocator.git#6923b09d)
Compiling embedded-hal v0.2.7
Compiling percpu_macros v0.1.0 (https://github.com/Starry-OS/percpu_macros.git#dca9e983)
Compiling crate_interface v0.1.1 (https://github.com/Starry-OS/crate_interface.git#d27dd960)
Compiling axhal v0.1.0 (https://github.com/Starry-OS/axhal.git#bb7589fe)
Compiling sbi-spec v0.0.4
Compiling critical-section v1.1.2
Compiling fdt v0.1.5
Compiling page_table_entry v0.1.0 (https://github.com/Starry-OS/page_table_entry.git#3d6bdc92)
Compiling axlog v0.1.0 (https://github.com/Starry-OS/axlog.git#64b47ba1)
Compiling of v0.1.0 (https://github.com/Starry-OS/of.git#8c5083c1)
Compiling page_table v0.1.0 (https://github.com/Starry-OS/page_table.git#d6ba329d)
Compiling sbi-rt v0.0.2
Compiling axalloc v0.1.0 (https://github.com/Starry-OS/axalloc.git#6665f35e)
Compiling axfs_ramfs v0.1.0 (https://github.com/Starry-OS/axfs_ramfs.git#4adca0d0)
Compiling handler_table v0.1.0 (https://github.com/Starry-OS/handler_table.git#d6495e7d)
Compiling lazy_init v0.1.0 (https://github.com/Starry-OS/lazy_init.git#0aee1e3b)
Compiling ratio v0.1.0 (https://github.com/Starry-OS/ratio.git#e3381d7b)
Compiling zerocopy-derive v0.7.34
Compiling driver_common v0.1.0 (https://github.com/Starry-OS/driver_common.git#4cdcdd9b)
Compiling linked_list v0.1.0 (https://github.com/Starry-OS/linked_list.git#3238ef86)
Compiling scheduler v0.1.0 (https://github.com/Starry-OS/scheduler.git#1142d117)
Compiling axsignal v0.1.0 (https://github.com/Starry-OS/axsignal.git#267cb5b0)
Compiling driver_net v0.1.0 (https://github.com/Starry-OS/driver_net.git#3a6861cf)
Compiling driver_block v0.1.0 (https://github.com/Starry-OS/driver_block.git#261bd624)
Compiling axdriver v0.1.0 (https://github.com/Starry-OS/axdriver.git#a21caaac)
Compiling rand_core v0.6.4
Compiling bitflags v1.3.2
Compiling timer_list v0.1.0 (https://github.com/Starry-OS/timer_list.git#0ba32228)
Compiling rand v0.8.5
Compiling axtask v0.1.0 (https://github.com/Starry-OS/axtask.git#34e5f5bd)
Compiling zero v0.1.3
Compiling xmas-elf v0.9.1
Compiling zerocopy v0.7.34
Compiling axfs_devfs v0.1.0 (https://github.com/Starry-OS/axfs_devfs.git#00c26de4)
Compiling axsync v0.1.0 (https://github.com/Starry-OS/axsync.git#1340dde1)
Compiling fatfs v0.4.0 (https://github.com/rafalh/rust-fatfs?rev=a3a834e#a3a834ef)
Compiling capability v0.1.0 (https://github.com/Starry-OS/capability.git#d00386a2)
Compiling axio v0.1.0 (https://github.com/Starry-OS/axio.git#4f70d39a)
Compiling heapless v0.8.0
Compiling elf_parser v0.1.0 (https://github.com/Starry-OS/elf_parser.git#2bcdfea0)
Compiling hash32 v0.3.1
Compiling smoltcp v0.11.0 (https://github.com/rcore-os/smoltcp.git?rev=b7134a3#b7134a31)
Compiling virtio-drivers v0.7.2
Compiling stable_deref_trait v1.2.0
Compiling managed v0.8.0
Compiling num_enum_derive v0.5.11
Compiling arch_boot v0.1.0 (https://github.com/Starry-OS/arch_boot.git#67fd8fcb)
Compiling num_enum v0.5.11
Compiling driver_virtio v0.1.0 (https://github.com/Starry-OS/driver_virtio.git#55e907a9)
Compiling axfs v0.1.0 (https://github.com/Starry-OS/axfs.git#defa32aa)
Compiling axmem v0.1.0 (https://github.com/Starry-OS/axmem.git#b5923a14)
Compiling axprocess v0.1.0 (https://github.com/Starry-OS/axprocess.git#a3aef2d4)
Compiling axnet v0.1.0 (https://github.com/Starry-OS/axnet.git#2aa071b1)
Compiling axruntime v0.1.0 (https://github.com/Starry-OS/axruntime.git#3dbaf5ee)
Compiling axfeat v0.1.0 (https://github.com/Starry-OS/axfeat.git#22c06720)
Compiling linux_syscall_api v0.1.0 (/home/echo/Dev/Starry/crates/linux_syscall_api)
Compiling axtrap v0.1.0 (https://github.com/Starry-OS/axtrap.git#1acf4c5a)
Compiling axstarry v0.1.0 (https://github.com/Starry-OS/axstarry.git#ed3c90b8)
Compiling monolithic_userboot v0.1.0 (/home/echo/Dev/Starry/apps/monolithic_userboot)
Finished `release` profile [optimized] target(s) in 38.88s
rust-objcopy
--binary-architecture=riscv64 apps/monolithic_userboot/monolithic_userboot_riscv64-qemu-virt.elf
--strip-all
-O binary apps/monolithic_userboot/monolithic_userboot_riscv64-qemu-virt.bin
Running on qemu...
qemu-system-riscv64 -m 2G -smp 1 -machine virt -bios default
-kernel apps/monolithic_userboot/monolithic_userboot_riscv64-qemu-virt.bin
-device virtio-blk-device,drive=disk0
-drive id=disk0,if=none,format=raw,file=disk.img
-device virtio-net-device,netdev=net0
-netdev user,id=net0,hostfwd=tcp::5555-:5555,hostfwd=udp::5555-:5555
-nographic
OpenSBI v0.9
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|
Platform Name : riscv-virtio,qemu
Platform Features : timer,mfdeleg
Platform HART Count : 1
Firmware Base : 0x80000000
Firmware Size : 100 KB
Runtime SBI Version : 0.2
Domain0 Name : root
Domain0 Boot HART : 0
Domain0 HARTs : 0*
Domain0 Region00 : 0x0000000080000000-0x000000008001ffff ()
Domain0 Region01 : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address : 0x0000000080200000
Domain0 Next Arg1 : 0x00000000bf000000
Domain0 Next Mode : S-mode
Domain0 SysReset : yes
Boot HART ID : 0
Boot HART Domain : root
Boot HART ISA : rv64imafdcsu
Boot HART Features : scounteren,mcounteren,time
Boot HART PMP Count : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count : 0
Boot HART MHPM Count : 0
Boot HART MIDELEG : 0x0000000000000222
Boot HART MEDELEG : 0x000000000000b109
d8888 .d88888b. .d8888b.
d88888 d88P" "Y88b d88P Y88b
d88P888 888 888 Y88b.
d88P 888 888d888 .d8888b .d88b. 888 888 "Y888b.
d88P 888 888P" d88P" d8P Y8b 888 888 "Y88b.
d88P 888 888 888 88888888 888 888 "888
d8888888888 888 Y88b. Y8b. Y88b. .d88P Y88b d88P
d88P 888 888 "Y8888P "Y8888 "Y88888P" "Y8888P"
arch = riscv64
platform = riscv64-qemu-virt
target = riscv64gc-unknown-none-elf
smp = 1
build_mode = release
log_level = error
/E #
至此一个宏内核系统已经启动起来了, 可以进行后续的开发任务了.
tokio在StarryOS中的系统调用分析
使用官方的Echo-Server
实例 https://tokio.rs/tokio/tutorial/io#echo-server
strace ./tokio-echo
execve("./tokio-echo", ["./tokio-echo"], 0xffffc88f8720 /* 26 vars */) = 0
brk(NULL) = 0xaaab0a9b1000
faccessat(AT_FDCWD, "/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=34745, ...}) = 0
mmap(NULL, 34745, PROT_READ, MAP_PRIVATE, 3, 0) = 0xffff9af97000
close(3) = 0
openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\320)\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=80200, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xffff9af95000
mmap(NULL, 144472, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffff9af4d000
mprotect(0xffff9af60000, 61440, PROT_NONE) = 0
mmap(0xffff9af6f000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0xffff9af6f000
close(3) = 0
openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0Ha\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=164304, ...}) = 0
mmap(NULL, 197624, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffff9af1c000
mprotect(0xffff9af38000, 61440, PROT_NONE) = 0
mmap(0xffff9af47000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b000) = 0xffff9af47000
mmap(0xffff9af49000, 13304, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffff9af49000
close(3) = 0
openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\360\272\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=633832, ...}) = 0
mmap(NULL, 696440, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffff9ae71000
mprotect(0xffff9af0a000, 65536, PROT_NONE) = 0
mmap(0xffff9af1a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x99000) = 0xffff9af1a000
close(3) = 0
openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0P\17\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=14560, ...}) = 0
mmap(NULL, 78080, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffff9ae5d000
mprotect(0xffff9ae60000, 61440, PROT_NONE) = 0
mmap(0xffff9ae6f000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0xffff9ae6f000
close(3) = 0
openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0`\17\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1450832, ...}) = 0
mmap(NULL, 1519552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffff9acea000
mprotect(0xffff9ae45000, 61440, PROT_NONE) = 0
mmap(0xffff9ae54000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15a000) = 0xffff9ae54000
mmap(0xffff9ae5a000, 12224, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffff9ae5a000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xffff9af93000
mprotect(0xffff9ae54000, 16384, PROT_READ) = 0
mprotect(0xffff9ae6f000, 4096, PROT_READ) = 0
mprotect(0xffff9af1a000, 4096, PROT_READ) = 0
mprotect(0xffff9af47000, 4096, PROT_READ) = 0
mprotect(0xffff9af6f000, 4096, PROT_READ) = 0
mprotect(0xaaaae43ca000, 24576, PROT_READ) = 0
mprotect(0xffff9afa2000, 4096, PROT_READ) = 0
munmap(0xffff9af97000, 34745) = 0
set_tid_address(0xffff9af938f0) = 2378159
set_robust_list(0xffff9af93900, 24) = 0
rt_sigaction(SIGRTMIN, {sa_handler=0xffff9af21bd0, sa_mask=[], sa_flags=SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0xffff9af21c90, sa_mask=[], sa_flags=SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
ppoll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, {tv_sec=0, tv_nsec=0}, NULL, 0) = 0 (Timeout)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTART}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, {sa_handler=0xaaaae436d758, sa_mask=[], sa_flags=SA_ONSTACK|SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGBUS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGBUS, {sa_handler=0xaaaae436d758, sa_mask=[], sa_flags=SA_ONSTACK|SA_SIGINFO}, NULL, 8) = 0
sigaltstack(NULL, {ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=0}) = 0
mmap(NULL, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0xffff9af9b000
mprotect(0xffff9af9b000, 4096, PROT_NONE) = 0
sigaltstack({ss_sp=0xffff9af9c000, ss_flags=0, ss_size=16384}, NULL) = 0
brk(NULL) = 0xaaab0a9b1000
brk(0xaaab0a9d2000) = 0xaaab0a9d2000
openat(AT_FDCWD, "/proc/self/maps", O_RDONLY|O_CLOEXEC) = 3
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
read(3, "aaaae4309000-aaaae43ba000 r-xp 0"..., 1024) = 1024
read(3, "/lib/aarch64-linux-gnu/libdl-2.3"..., 1024) = 1024
read(3, "usr/lib/aarch64-linux-gnu/libpth"..., 1024) = 1024
read(3, "w-p 00000000 00:00 0 \nffff9afa00"..., 1024) = 485
close(3) = 0
sched_getaffinity(2378159, 32, [0, 1, 2, 3]) = 8
getrandom("\x28\xae\x81\x2d\x85\x70\xb9\x51\x9c\x6a\x19\xf4\x6b\x42\x63\xbe", 16, 0x4 /* GRND_??? */) = 16
openat(AT_FDCWD, "/proc/self/cgroup", O_RDONLY|O_CLOEXEC) = 3
read(3, "11:blkio:/user.slice\n10:freezer:"..., 8192) = 319
read(3, "", 8192) = 0
close(3) = 0
openat(AT_FDCWD, "/proc/self/mountinfo", O_RDONLY|O_CLOEXEC) = 3
read(3, "27 33 0:25 / /sys rw,nosuid,node"..., 8192) = 3728
close(3) = 0
openat(AT_FDCWD, "/sys/fs/cgroup/cpu,cpuacct/user.slice/cpu.cfs_quota_us", O_RDONLY|O_CLOEXEC) = 3
statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR) = 0
read(3, "-1\n", 32) = 3
read(3, "", 29) = 0
close(3) = 0
sched_getaffinity(0, 128, [0, 1, 2, 3]) = 8
epoll_create1(EPOLL_CLOEXEC) = 3
eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK) = 4
epoll_ctl(3, EPOLL_CTL_ADD, 4, {EPOLLIN|EPOLLRDHUP|EPOLLET, {u32=0, u64=0}}) = 0
fcntl(3, F_DUPFD_CLOEXEC, 3) = 5
socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0, [6, 7]) = 0
fcntl(6, F_DUPFD_CLOEXEC, 3) = 8
epoll_ctl(5, EPOLL_CTL_ADD, 8, {EPOLLIN|EPOLLRDHUP|EPOLLET, {u32=1, u64=1}}) = 0
futex(0xffff9ae700e8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
mmap(NULL, 2101248, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0xffff9aae9000
mprotect(0xffff9aaea000, 2097152, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0xffff9ace89d0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tid=[2378160], tls=0xffff9ace97d0, child_tidptr=0xffff9ace91a0) = 2378160
futex(0xffff9ace9898, FUTEX_WAKE_PRIVATE, 1) = 0
mmap(NULL, 2101248, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0xffff9a8e3000
mprotect(0xffff9a8e4000, 2097152, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0xffff9aae29d0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tid=[2378161], tls=0xffff9aae37d0, child_tidptr=0xffff9aae31a0) = 2378161
mmap(NULL, 2101248, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0xffff9a6dd000
mprotect(0xffff9a6de000, 2097152, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0xffff9a8dc9d0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tid=[2378162], tls=0xffff9a8dd7d0, child_tidptr=0xffff9a8dd1a0) = 2378162
futex(0xffff9aae3898, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2101248, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0xffff9a4d7000
mprotect(0xffff9a4d8000, 2097152, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0xffff9a6d69d0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tid=[2378163], tls=0xffff9a6d77d0, child_tidptr=0xffff9a6d71a0) = 2378163
futex(0xffff9a6d7898, FUTEX_WAKE_PRIVATE, 1) = 1
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 9
setsockopt(9, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(9, {sa_family=AF_INET, sin_port=htons(12345), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
listen(9, 1024) = 0
epoll_ctl(5, EPOLL_CTL_ADD, 9, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=178000256, u64=187651594129792}}) = 0
futex(0xffff9af93fe8, FUTEX_WAIT_PRIVATE, 1, NULL
strace -c ./tokio-echo
strace: Process 2381013 detached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
20.30 0.000458 32 14 read
17.38 0.000392 98 4 1 futex
14.98 0.000338 84 4 clone
9.62 0.000217 10 20 mmap
7.31 0.000165 16 10 openat
5.27 0.000119 7 17 mprotect
4.30 0.000097 9 10 close
3.41 0.000077 25 3 epoll_ctl
2.13 0.000048 48 1 socketpair
1.95 0.000044 44 1 socket
1.91 0.000043 21 2 sched_getaffinity
1.73 0.000039 19 2 fcntl
1.68 0.000038 38 1 bind
1.37 0.000031 31 1 listen
1.24 0.000028 28 1 setsockopt
1.20 0.000027 27 1 eventfd2
1.20 0.000027 27 1 statx
1.15 0.000026 26 1 epoll_create1
1.11 0.000025 25 1 getrandom
0.75 0.000017 17 1 lseek
0.00 0.000000 0 1 1 faccessat
0.00 0.000000 0 1 ppoll
0.00 0.000000 0 7 fstat
0.00 0.000000 0 1 set_tid_address
0.00 0.000000 0 1 set_robust_list
0.00 0.000000 0 2 sigaltstack
0.00 0.000000 0 7 rt_sigaction
0.00 0.000000 0 1 rt_sigprocmask
0.00 0.000000 0 3 brk
0.00 0.000000 0 1 munmap
0.00 0.000000 0 1 execve
0.00 0.000000 0 2 prlimit64
------ ----------- ----------- --------- --------- ----------------
100.00 0.002256 124 2 total
gdb移植StarryOS
本教程主要移植的x86_64
架构的gdb
,其它架构类似
补全动态库
/dev
, /tmp
libreadline.so.8
libncursesw.so.6
libtinfo.so.6
libpython3.10.so.1.0
libexpat.so.1
liblzma.so.5
libbabeltrace.so.1
libbabeltrace-ctf.so.1
libipt.so.2
libmpfr.so.6
libgmp.so.10
libsource-highlight.so.4
libxxhash.so.0
libdebuginfod.so.1
libstdc++.so.6
libglib-2.0.so.0
libelf.so.1
libuuid.so.1
libboost_regex.so.1.74.0
libcurl-gnutls.so.4
libpcre.so.3
libicui18n.so.70
libicuuc.so.70
libnghttp2.so.14
libidn2.so.0
librtmp.so.1
libssh.so.4
libpsl.so.5
libnettle.so.8
libgnutls.so.30
libgssapi_krb5.so.2
libldap-2.5.so.0
liblber-2.5.so.0
libzstd.so.1
libbrotlidec.so.1
libicudata.so.70
libunistring.so.2
libhogweed.so.6
libcrypto.so.3
libp11-kit.so.0
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
Dora
在Linux中的系统调用分析
Dora
是一个面向数据流的机器人应用框架,使用Rust
语言开发。让机器人应用变得快速而简单。
在 x86_64
Linux
中的系统调用分析
dora-rs cli client
Usage: dora <COMMAND>
Commands:
check Check if the coordinator and the daemon is running
graph Generate a visualization of the given graph using mermaid.js.
Use --open to open browser
build Run build commands provided in the given dataflow
new Generate a new project, node or operator. Choose the language
between Rust, Python, C or C++
up Spawn a coordinator and a daemon
destroy Destroy running coordinator and daemon. If some dataflows are
still running, they will be stopped first
start Start the given dataflow path. Attach a name to the running
dataflow by using --name
stop Stop the given dataflow UUID. If no id is provided, you will
be able to choose between the running dataflows
list List running dataflows
logs Show logs of a given dataflow and node
daemon Run daemon
runtime Run runtime
coordinator Run coordinator
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ------------------
0.00 0.000000 0 7 read
0.00 0.000000 0 1 write
0.00 0.000000 0 5 close
0.00 0.000000 0 1 poll
0.00 0.000000 0 17 mmap
0.00 0.000000 0 7 mprotect
0.00 0.000000 0 2 munmap
0.00 0.000000 0 3 brk
0.00 0.000000 0 5 rt_sigaction
0.00 0.000000 0 5 1 ioctl
0.00 0.000000 0 4 pread64
0.00 0.000000 0 1 1 access
0.00 0.000000 0 1 execve
0.00 0.000000 0 3 sigaltstack
0.00 0.000000 0 2 1 arch_prctl
0.00 0.000000 0 1 sched_getaffinity
0.00 0.000000 0 1 set_tid_address
0.00 0.000000 0 5 openat
0.00 0.000000 0 5 newfstatat
0.00 0.000000 0 1 set_robust_list
0.00 0.000000 0 2 prlimit64
0.00 0.000000 0 1 getrandom
0.00 0.000000 0 1 rseq
------ ----------- ----------- --------- --------- ------------------
100.00 0.000000 0 81 3 total
$ strace -f -v dora -h
execve("/home/echo/Dev/dora/target/release/dora", ["/home/echo/Dev/dora/target/relea"..., "-h"], ["SHELL=/bin/bash", "CONDA_EXE=/home/echo/miniconda3/"..., "_CE_M=", "LANGUAGE=zh_CN:zh", "PWD=/home/echo", "LOGNAME=echo", "XDG_SESSION_TYPE=tty", "CONDA_PREFIX=/home/echo/minicond"..., "MOTD_SHOWN=pam", "HOME=/home/echo", "LANG=C.UTF-8", "LS_COLORS=rs=0:di=01;34:ln=01;36"..., "CONDA_PROMPT_MODIFIER=(base) ", "SSH_CONNECTION=172.16.203.10 493"..., "LESSCLOSE=/usr/bin/lesspipe %s %"..., "XDG_SESSION_CLASS=user", "TERM=xterm-256color", "_CE_CONDA=", "LESSOPEN=| /usr/bin/lesspipe %s", "USER=echo", "CONDA_SHLVL=1", "SHLVL=1", "XDG_SESSION_ID=4", "CONDA_PYTHON_EXE=/home/echo/mini"..., "LC_CTYPE=C.UTF-8", "XDG_RUNTIME_DIR=/run/user/1000", "SSH_CLIENT=172.16.203.10 49374 2"..., "CONDA_DEFAULT_ENV=base", "XDG_DATA_DIRS=/usr/share/gnome:/"..., "PATH=/home/echo/miniconda3/bin:/"..., "DBUS_SESSION_BUS_ADDRESS=unix:pa"..., "SSH_TTY=/dev/pts/2", "TERM_PROGRAM=WarpTerminal", "_=/usr/bin/strace"]) = 0
brk(NULL) = 0x55b1f9020000
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffee484d3c0) = -1 EINVAL (无效的参数)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7bcf735db000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (没有那个文件或目录)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_dev=makedev(0x8, 0x3), st_ino=19176588, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=128, st_size=62119, st_atime=1719544210 /* 2024-06-28T11:10:10.669757705+0800 */, st_atime_nsec=669757705, st_mtime=1719544210 /* 2024-06-28T11:10:10.645757704+0800 */, st_mtime_nsec=645757704, st_ctime=1719544210 /* 2024-06-28T11:10:10.649757704+0800 */, st_ctime_nsec=649757704}, AT_EMPTY_PATH) = 0
mmap(NULL, 62119, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7bcf735cb000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_dev=makedev(0x8, 0x3), st_ino=2214, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=248, st_size=125488, st_atime=1719476439 /* 2024-06-27T16:20:39.642014627+0800 */, st_atime_nsec=642014627, st_mtime=1683963205 /* 2023-05-13T15:33:25+0800 */, st_mtime_nsec=0, st_ctime=1718364975 /* 2024-06-14T19:36:15.293760191+0800 */, st_ctime_nsec=293760191}, AT_EMPTY_PATH) = 0
mmap(NULL, 127720, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7bcf735ab000
mmap(0x7bcf735ae000, 94208, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7bcf735ae000
mmap(0x7bcf735c5000, 16384, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1a000) = 0x7bcf735c5000
mmap(0x7bcf735c9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1d000) = 0x7bcf735c9000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_dev=makedev(0x8, 0x3), st_ino=7202, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=1840, st_size=940560, st_atime=1719469836 /* 2024-06-27T14:30:36.397596395+0800 */, st_atime_nsec=397596395, st_mtime=1715027668 /* 2024-05-07T04:34:28+0800 */, st_mtime_nsec=0, st_ctime=1718364975 /* 2024-06-14T19:36:15.982167719+0800 */, st_ctime_nsec=982167719}, AT_EMPTY_PATH) = 0
mmap(NULL, 942344, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7bcf734c4000
mmap(0x7bcf734d2000, 507904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe000) = 0x7bcf734d2000
mmap(0x7bcf7354e000, 372736, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x8a000) = 0x7bcf7354e000
mmap(0x7bcf735a9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe4000) = 0x7bcf735a9000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\237\2\0\0\0\0\0"..., 832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
pread64(3, "\4\0\0\0 \0\0\0\5\0\0\0GNU\0\2\0\0\300\4\0\0\0\3\0\0\0\0\0\0\0"..., 48, 848) = 48
pread64(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0I\17\357\204\3$\f\221\2039x\324\224\323\236S"..., 68, 896) = 68
newfstatat(3, "", {st_dev=makedev(0x8, 0x3), st_ino=2727, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=4344, st_size=2220400, st_atime=1719461821 /* 2024-06-27T12:17:01.796767217+0800 */, st_atime_nsec=796767217, st_mtime=1715027668 /* 2024-05-07T04:34:28+0800 */, st_mtime_nsec=0, st_ctime=1718364975 /* 2024-06-14T19:36:15.982167719+0800 */, st_ctime_nsec=982167719}, AT_EMPTY_PATH) = 0
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
mmap(NULL, 2264656, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7bcf73200000
mprotect(0x7bcf73228000, 2023424, PROT_NONE) = 0
mmap(0x7bcf73228000, 1658880, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x28000) = 0x7bcf73228000
mmap(0x7bcf733bd000, 360448, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bd000) = 0x7bcf733bd000
mmap(0x7bcf73416000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x215000) = 0x7bcf73416000
mmap(0x7bcf7341c000, 52816, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7bcf7341c000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7bcf734c2000
arch_prctl(ARCH_SET_FS, 0x7bcf734c2f40) = 0
set_tid_address(0x7bcf734c3210) = 4271
set_robust_list(0x7bcf734c3220, 24) = 0
rseq(0x7bcf734c38e0, 0x20, 0, 0x53053053) = 0
mprotect(0x7bcf73416000, 16384, PROT_READ) = 0
mprotect(0x7bcf735a9000, 4096, PROT_READ) = 0
mprotect(0x7bcf735c9000, 4096, PROT_READ) = 0
mprotect(0x55b1f821a000, 991232, PROT_READ) = 0
mprotect(0x7bcf73615000, 8192, PROT_READ) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
munmap(0x7bcf735cb000, 62119) = 0
poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 0 (Timeout)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7bcf73242520}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, {sa_handler=0x55b1f7c33f30, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_SIGINFO, sa_restorer=0x7bcf73242520}, NULL, 8) = 0
rt_sigaction(SIGBUS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGBUS, {sa_handler=0x55b1f7c33f30, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_SIGINFO, sa_restorer=0x7bcf73242520}, NULL, 8) = 0
sigaltstack(NULL, {ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=0}) = 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7bcf735d8000
mprotect(0x7bcf735d8000, 4096, PROT_NONE) = 0
sigaltstack({ss_sp=0x7bcf735d9000, ss_flags=0, ss_size=8192}, NULL) = 0
getrandom("\xd2\x86\xbe\x67\x6f\x87\x31\x6e", 8, GRND_NONBLOCK) = 8
brk(NULL) = 0x55b1f9020000
brk(0x55b1f9041000) = 0x55b1f9041000
openat(AT_FDCWD, "/proc/self/maps", O_RDONLY|O_CLOEXEC) = 3
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
newfstatat(3, "", {st_dev=makedev(0, 0x16), st_ino=49288, st_mode=S_IFREG|0444, st_nlink=1, st_uid=1000, st_gid=1000, st_blksize=1024, st_blocks=0, st_size=0, st_atime=1719544658 /* 2024-06-28T11:17:38.901251488+0800 */, st_atime_nsec=901251488, st_mtime=1719544658 /* 2024-06-28T11:17:38.901251488+0800 */, st_mtime_nsec=901251488, st_ctime=1719544658 /* 2024-06-28T11:17:38.901251488+0800 */, st_ctime_nsec=901251488}, AT_EMPTY_PATH) = 0
read(3, "55b1f6e22000-55b1f6f82000 r--p 0"..., 1024) = 1024
read(3, "f73415000-7bcf73416000 ---p 0021"..., 1024) = 1024
read(3, " /usr/lib/x86_64-"..., 1024) = 1024
read(3, " /usr/lib/x86_64-l"..., 1024) = 507
close(3) = 0
sched_getaffinity(4271, 32, [0, 1, 2, 3]) = 8
ioctl(1, TIOCGWINSZ, {ws_row=29, ws_col=86, ws_xpixel=991, ws_ypixel=691}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=29, ws_col=86, ws_xpixel=991, ws_ypixel=691}) = 0
ioctl(1, TCGETS, {c_iflags=0x2102, c_oflags=0x5, c_cflags=0xbd, c_lflags=0xca3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
ioctl(1, TCGETS, {c_iflags=0x2102, c_oflags=0x5, c_cflags=0xbd, c_lflags=0xca3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
write(1, "dora-rs cli client\n\n\33[1m\33[4mUsag"..., 1388dora-rs cli client
Usage: dora <COMMAND>
Commands:
check Check if the coordinator and the daemon is running
graph Generate a visualization of the given graph using mermaid.js. Use
--open to open browser
build Run build commands provided in the given dataflow
new Generate a new project, node or operator. Choose the language
between Rust, Python, C or C++
up Spawn a coordinator and a daemon
destroy Destroy running coordinator and daemon. If some dataflows are still
running, they will be stopped first
start Start the given dataflow path. Attach a name to the running
dataflow by using --name
stop Stop the given dataflow UUID. If no id is provided, you will be
able to choose between the running dataflows
list List running dataflows
logs Show logs of a given dataflow and node
daemon Run daemon
runtime Run runtime
coordinator Run coordinator
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
) = 1388
sigaltstack({ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=8192}, NULL) = 0
munmap(0x7bcf735d8000, 12288) = 0
exit_group(0) = ?
+++ exited with 0 +++
Dora在 aarch64 架构中的系统调用分析
在 aarch64
Linux
中的系统调用分析
dora-rs cli client
Usage: dora <COMMAND>
Commands:
check Check if the coordinator and the daemon is running
graph Generate a visualization of the given graph using mermaid.js. Use --open to
open browser
build Run build commands provided in the given dataflow
new Generate a new project, node or operator. Choose the language between Rust,
Python, C or C++
up Spawn a coordinator and a daemon
destroy Destroy running coordinator and daemon. If some dataflows are still running,
they will be stopped first
start Start the given dataflow path. Attach a name to the running dataflow by using
--name
stop Stop the given dataflow UUID. If no id is provided, you will be able to choose
between the running dataflows
list List running dataflows
logs Show logs of a given dataflow and node
daemon Run daemon
runtime Run runtime
coordinator Run coordinator
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
39.30 0.001780 1780 1 execve
10.36 0.000469 24 19 mmap
7.99 0.000362 45 8 openat
7.95 0.000360 24 15 mprotect
6.93 0.000314 31 10 read
6.60 0.000299 299 1 write
3.62 0.000164 20 8 fstat
3.29 0.000149 18 8 close
3.02 0.000137 19 7 rt_sigaction
2.43 0.000110 22 5 1 ioctl
1.99 0.000090 45 2 munmap
1.41 0.000064 21 3 sigaltstack
1.28 0.000058 19 3 brk
0.93 0.000042 42 1 ppoll
0.79 0.000036 18 2 prlimit64
0.75 0.000034 34 1 1 faccessat
0.51 0.000023 23 1 sched_getaffinity
0.31 0.000014 14 1 rt_sigprocmask
0.26 0.000012 12 1 set_tid_address
0.26 0.000012 12 1 set_robust_list
------ ----------- ----------- --------- --------- ----------------
100.00 0.004529 98 2 total
$ strace -f -v dora -h
execve("/home/ubuntu/EchoData/bin/dora", ["dora", "-h"], ["SHELL=/bin/bash", "PWD=/home/ubuntu", "LOGNAME=ubuntu", "XDG_SESSION_TYPE=tty", "MOTD_SHOWN=pam", "HOME=/home/ubuntu", "LANG=C.UTF-8", "LS_COLORS=rs=0:di=01;34:ln=01;36"..., "SSH_CONNECTION=103.233.162.226 6"..., "LESSCLOSE=/usr/bin/lesspipe %s %"..., "XDG_SESSION_CLASS=user", "TERM=xterm-256color", "LESSOPEN=| /usr/bin/lesspipe %s", "USER=ubuntu", "SHLVL=1", "XDG_SESSION_ID=68884", "LC_CTYPE=C.UTF-8", "XDG_RUNTIME_DIR=/run/user/1000", "SSH_CLIENT=103.233.162.226 6781 "..., "XDG_DATA_DIRS=/usr/local/share:/"..., "PATH=/home/ubuntu/.cargo/bin:/us"..., "DBUS_SESSION_BUS_ADDRESS=unix:pa"..., "SSH_TTY=/dev/pts/0", "TERM_PROGRAM=WarpTerminal", "_=/usr/bin/strace"]) = 0
brk(NULL) = 0xaaab09806000
faccessat(AT_FDCWD, "/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_dev=makedev(0x8, 0x2), st_ino=3852, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=72, st_size=34745, st_atime=1719469201 /* 2024-06-27T06:20:01.656854826+0000 */, st_atime_nsec=656854826, st_mtime=1718259523 /* 2024-06-13T06:18:43.934348858+0000 */, st_mtime_nsec=934348858, st_ctime=1718259523 /* 2024-06-13T06:18:43.938348891+0000 */, st_ctime_nsec=938348891}) = 0
mmap(NULL, 34745, PROT_READ, MAP_PRIVATE, 3, 0) = 0xffff90469000
close(3) = 0
openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0P\17\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_dev=makedev(0x8, 0x2), st_ino=8904, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=32, st_size=14560, st_atime=1719468961 /* 2024-06-27T06:16:01.378693788+0000 */, st_atime_nsec=378693788, st_mtime=1714501218 /* 2024-04-30T18:20:18+0000 */, st_mtime_nsec=0, st_ctime=1717049757 /* 2024-05-30T06:15:57.180178270+0000 */, st_ctime_nsec=180178270}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xffff90467000
mmap(NULL, 78080, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffff9042f000
mprotect(0xffff90432000, 61440, PROT_NONE) = 0
mmap(0xffff90441000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0xffff90441000
close(3) = 0
openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\320)\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_dev=makedev(0x8, 0x2), st_ino=28456, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=160, st_size=80200, st_atime=1719471001 /* 2024-06-27T06:50:01.387789263+0000 */, st_atime_nsec=387789263, st_mtime=1688885130 /* 2023-07-09T06:45:30+0000 */, st_mtime_nsec=0, st_ctime=1690871450 /* 2023-08-01T06:30:50.652317995+0000 */, st_ctime_nsec=652317995}) = 0
mmap(NULL, 144472, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffff9040b000
mprotect(0xffff9041e000, 61440, PROT_NONE) = 0
mmap(0xffff9042d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0xffff9042d000
close(3) = 0
openat(AT_FDCWD, "/lib/aarch64-linux-gnu/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\0\37\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_dev=makedev(0x8, 0x2), st_ino=9385, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=64, st_size=31584, st_atime=1719469222 /* 2024-06-27T06:20:22.484684134+0000 */, st_atime_nsec=484684134, st_mtime=1714501218 /* 2024-04-30T18:20:18+0000 */, st_mtime_nsec=0, st_ctime=1717049757 /* 2024-05-30T06:15:57.180178270+0000 */, st_ctime_nsec=180178270}) = 0
mmap(NULL, 95032, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffff903f3000
mprotect(0xffff903fa000, 61440, PROT_NONE) = 0
mmap(0xffff90409000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0xffff90409000
close(3) = 0
openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0Ha\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_dev=makedev(0x8, 0x2), st_ino=9149, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=328, st_size=164304, st_atime=1719468961 /* 2024-06-27T06:16:01.378693788+0000 */, st_atime_nsec=378693788, st_mtime=1714501218 /* 2024-04-30T18:20:18+0000 */, st_mtime_nsec=0, st_ctime=1717049757 /* 2024-05-30T06:15:57.180178270+0000 */, st_ctime_nsec=180178270}) = 0
mmap(NULL, 197624, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffff903c2000
mprotect(0xffff903de000, 61440, PROT_NONE) = 0
mmap(0xffff903ed000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b000) = 0xffff903ed000
mmap(0xffff903ef000, 13304, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffff903ef000
close(3) = 0
openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\360\272\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_dev=makedev(0x8, 0x2), st_ino=8915, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=1240, st_size=633832, st_atime=1719468961 /* 2024-06-27T06:16:01.366693873+0000 */, st_atime_nsec=366693873, st_mtime=1714501218 /* 2024-04-30T18:20:18+0000 */, st_mtime_nsec=0, st_ctime=1717049757 /* 2024-05-30T06:15:57.180178270+0000 */, st_ctime_nsec=180178270}) = 0
mmap(NULL, 696440, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffff90317000
mprotect(0xffff903b0000, 65536, PROT_NONE) = 0
mmap(0xffff903c0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x99000) = 0xffff903c0000
close(3) = 0
openat(AT_FDCWD, "/lib/aarch64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0`\17\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_dev=makedev(0x8, 0x2), st_ino=8899, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=2840, st_size=1450832, st_atime=1719468961 /* 2024-06-27T06:16:01.374693817+0000 */, st_atime_nsec=374693817, st_mtime=1714501218 /* 2024-04-30T18:20:18+0000 */, st_mtime_nsec=0, st_ctime=1717049757 /* 2024-05-30T06:15:57.180178270+0000 */, st_ctime_nsec=180178270}) = 0
mmap(NULL, 1519552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffff901a4000
mprotect(0xffff902ff000, 61440, PROT_NONE) = 0
mmap(0xffff9030e000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15a000) = 0xffff9030e000
mmap(0xffff90314000, 12224, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffff90314000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xffff90465000
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xffff901a1000
mprotect(0xffff9030e000, 16384, PROT_READ) = 0
mprotect(0xffff903c0000, 4096, PROT_READ) = 0
mprotect(0xffff903ed000, 4096, PROT_READ) = 0
mprotect(0xffff90409000, 4096, PROT_READ) = 0
mprotect(0xffff9042d000, 4096, PROT_READ) = 0
mprotect(0xffff90441000, 4096, PROT_READ) = 0
mprotect(0xaaaae9122000, 974848, PROT_READ) = 0
mprotect(0xffff90474000, 4096, PROT_READ) = 0
munmap(0xffff90469000, 34745) = 0
set_tid_address(0xffff901a10e0) = 1033268
set_robust_list(0xffff901a10f0, 24) = 0
rt_sigaction(SIGRTMIN, {sa_handler=0xffff903c7bd0, sa_mask=[], sa_flags=SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0xffff903c7c90, sa_mask=[], sa_flags=SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
ppoll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, {tv_sec=0, tv_nsec=0}, NULL, 0) = 0 (Timeout)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTART}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, {sa_handler=0xaaaae8b48400, sa_mask=[], sa_flags=SA_ONSTACK|SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGBUS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGBUS, {sa_handler=0xaaaae8b48400, sa_mask=[], sa_flags=SA_ONSTACK|SA_SIGINFO}, NULL, 8) = 0
sigaltstack(NULL, {ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=0}) = 0
mmap(NULL, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0xffff9046d000
mprotect(0xffff9046d000, 4096, PROT_NONE) = 0
sigaltstack({ss_sp=0xffff9046e000, ss_flags=0, ss_size=16384}, NULL) = 0
brk(NULL) = 0xaaab09806000
brk(0xaaab09827000) = 0xaaab09827000
openat(AT_FDCWD, "/proc/self/maps", O_RDONLY|O_CLOEXEC) = 3
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
fstat(3, {st_dev=makedev(0, 0x5), st_ino=73819201, st_mode=S_IFREG|0444, st_nlink=1, st_uid=1000, st_gid=1000, st_blksize=1024, st_blocks=0, st_size=0, st_atime=1719542835 /* 2024-06-28T02:47:15.193150107+0000 */, st_atime_nsec=193150107, st_mtime=1719542835 /* 2024-06-28T02:47:15.193150107+0000 */, st_mtime_nsec=193150107, st_ctime=1719542835 /* 2024-06-28T02:47:15.193150107+0000 */, st_ctime_nsec=193150107}) = 0
read(3, "aaaae7f4a000-aaaae9113000 r-xp 0"..., 1024) = 1024
read(3, "000000 08:02 8915 "..., 1024) = 1024
read(3, "b/aarch64-linux-gnu/librt-2.31.s"..., 1024) = 1024
read(3, "lib/aarch64-linux-gnu/libdl-2.31"..., 1024) = 985
close(3) = 0
sched_getaffinity(1033268, 32, [0, 1, 2, 3]) = 8
ioctl(1, TIOCGWINSZ, {ws_row=29, ws_col=86, ws_xpixel=991, ws_ypixel=691}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=29, ws_col=86, ws_xpixel=991, ws_ypixel=691}) = 0
ioctl(1, TCGETS, {c_iflags=0x2102, c_oflags=0x5, c_cflags=0xbd, c_lflags=0xca3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
ioctl(1, TCGETS, {c_iflags=0x2102, c_oflags=0x5, c_cflags=0xbd, c_lflags=0xca3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
write(1, "dora-rs cli client\n\n\33[1m\33[4mUsag"..., 1388dora-rs cli client
Usage: dora <COMMAND>
Commands:
check Check if the coordinator and the daemon is running
graph Generate a visualization of the given graph using mermaid.js. Use
--open to open browser
build Run build commands provided in the given dataflow
new Generate a new project, node or operator. Choose the language
between Rust, Python, C or C++
up Spawn a coordinator and a daemon
destroy Destroy running coordinator and daemon. If some dataflows are still
running, they will be stopped first
start Start the given dataflow path. Attach a name to the running
dataflow by using --name
stop Stop the given dataflow UUID. If no id is provided, you will be
able to choose between the running dataflows
list List running dataflows
logs Show logs of a given dataflow and node
daemon Run daemon
runtime Run runtime
coordinator Run coordinator
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
) = 1388
sigaltstack({ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=16384}, NULL) = 0
munmap(0xffff9046d000, 20480) = 0
exit_group(0) = ?
+++ exited with 0 +++
Dora在 ArceOS 执行分析并成功运行 Dora
在aarch64
架构下的ArceOS
执行dora
会直接报错
qemu-system-aarch64 -m 2G -smp 1 -cpu cortex-a72 -machine virt -kernel apps/monolithic_userboot/monolithic_userboot_aarch64-qemu-virt.bin -device virtio-blk-device,drive=disk0 -drive id=disk0,if=none,format=raw,file=disk.img -device virtio-net-device,netdev=net0 -netdev user,id=net0,hostfwd=tcp::5555-:5555,hostfwd=udp::5555-:5555 -nographic
d8888 .d88888b. .d8888b.
d88888 d88P" "Y88b d88P Y88b
d88P888 888 888 Y88b.
d88P 888 888d888 .d8888b .d88b. 888 888 "Y888b.
d88P 888 888P" d88P" d8P Y8b 888 888 "Y88b.
d88P 888 888 888 88888888 888 888 "888
d8888888888 888 Y88b. Y8b. Y88b. .d88P Y88b d88P
d88P 888 888 "Y8888P "Y8888 "Y88888P" "Y8888P"
arch = aarch64
platform = aarch64-qemu-virt
target = aarch64-unknown-none-softfloat
smp = 1
build_mode = release
log_level = error
/ # ./dora
[ 33.435612 0:8 axprocess::process:395] Failed to load app /dora
经过调试程序并修复各种错误后,可以成功的运行dora -h
。
运行后的效果详见下图:
Dora在 RISCV64架构中运行
开发板使用的是昉·星光 2
。VisionFive 2
是全球首款集成3D GPU
的高性能量产RISC-V
单板计算机 。与上一代相比,VisionFive 2
全面升级,在处理器工作频率、多媒体处理能力、可扩展性等方面都有显着提升。优越的性能和合理的价格使VisionFive 2
成为有史以来性价比最高的RISC-V
开发板。
最终运行效果
系统调用分析
dora-rs cli client
Usage: dora <COMMAND>
Commands:
check Check if the coordinator and the daemon is running
graph Generate a visualization of the given graph using mermaid.js. Use --open to open
browser
build Run build commands provided in the given dataflow
new Generate a new project, node or operator. Choose the language between Rust,
Python, C or C++
up Spawn a coordinator and a daemon
destroy Destroy running coordinator and daemon. If some dataflows are still running, they
will be stopped first
start Start the given dataflow path. Attach a name to the running dataflow by using
--name
stop Stop the given dataflow UUID. If no id is provided, you will be able to choose
between the running dataflows
list List running dataflows
logs Show logs of a given dataflow and node
daemon Run daemon
runtime Run runtime
coordinator Run coordinator
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
45.91 0.014351 14351 1 write
22.24 0.006952 6952 1 execve
9.74 0.003043 253 12 mmap
4.92 0.001539 219 7 mprotect
4.76 0.001488 297 5 1 openat
3.04 0.000950 237 4 read
1.63 0.000511 510 1 1 faccessat
1.49 0.000467 116 4 fstat
1.38 0.000432 54 8 ioctl
1.01 0.000317 317 1 munmap
0.92 0.000288 96 3 sigaltstack
0.85 0.000267 89 3 brk
0.80 0.000250 62 4 close
0.48 0.000149 149 1 ppoll
0.24 0.000075 75 1 set_tid_address
0.22 0.000069 69 1 set_robust_list
0.22 0.000068 13 5 rt_sigaction
0.13 0.000041 41 1 1 getrandom
0.00 0.000000 0 1 prlimit64
------ ----------- ----------- --------- --------- ----------------
100.00 0.031257 488 64 3 total
execve("/bin/dora", ["/bin/dora"], 0x7ffff3ab2d90 /* 5 vars */) = 0
brk(NULL) = 0x55555a679000
faccessat(AT_FDCWD, "/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\363\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=84280, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff9ca57000
mmap(NULL, 82384, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fff9ca42000
mmap(0x7fff9ca55000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x13000) = 0x7fff9ca55000
close(3) = 0
openat(AT_FDCWD, "/lib/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\363\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=498168, ...}) = 0
mmap(NULL, 99120, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fff9ca29000
mmap(0x7fff9ca40000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7fff9ca40000
close(3) = 0
openat(AT_FDCWD, "/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\363\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=730824, ...}) = 0
mmap(NULL, 516224, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fff9c9aa000
mmap(0x7fff9ca27000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7d000) = 0x7fff9ca27000
close(3) = 0
openat(AT_FDCWD, "/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0\363\0\1\0\0\0\364\271\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2010248, ...}) = 0
mmap(NULL, 1560760, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fff9c82c000
mmap(0x7fff9c998000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16c000) = 0x7fff9c998000
mmap(0x7fff9c99d000, 49336, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fff9c99d000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff9c82a000
set_tid_address(0x7fff9c82a510) = 46
set_robust_list(0x7fff9c82a520, 24) = 0
mprotect(0x7fff9c998000, 12288, PROT_READ) = 0
mprotect(0x7fff9ca27000, 4096, PROT_READ) = 0
mprotect(0x7fff9ca40000, 4096, PROT_READ) = 0
mprotect(0x7fff9ca55000, 4096, PROT_READ) = 0
mprotect(0x55555a56a000, 978944, PROT_READ) = 0
mprotect(0x7fff9ca7f000, 8192, PROT_READ) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
ppoll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, {tv_sec=0, tv_nsec=0}, NULL, 0) = 0 (Timeout)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTART}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, {sa_handler=0x555559faeef2, sa_mask=[], sa_flags=SA_ONSTACK|SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGBUS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGBUS, {sa_handler=0x555559faeef2, sa_mask=[], sa_flags=SA_ONSTACK|SA_SIGINFO}, NULL, 8) = 0
sigaltstack(NULL, {ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=0}) = 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7fff9c827000
mprotect(0x7fff9c827000, 4096, PROT_NONE) = 0
sigaltstack({ss_sp=0x7fff9c828000, ss_flags=0, ss_size=8192}, NULL) = 0
getrandom(0x7fff9c9a18c0, 8, GRND_NONBLOCK) = -1 EAGAIN (Resource temporarily unavailable)
brk(NULL) = 0x55555a679000
brk(0x55555a69a000) = 0x55555a69a000
openat(AT_FDCWD, "/proc/self/maps", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
ioctl(1, TIOCGWINSZ, {ws_row=0, ws_col=0, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=0, ws_col=0, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(2, TIOCGWINSZ, {ws_row=0, ws_col=0, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(2, TIOCGWINSZ, {ws_row=0, ws_col=0, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(0, TIOCGWINSZ, {ws_row=0, ws_col=0, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(0, TIOCGWINSZ, {ws_row=0, ws_col=0, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(2, TCGETS, {c_iflag=ICRNL|IXON, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD|HUPCL|CLOCAL, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
ioctl(2, TCGETS, {c_iflag=ICRNL|IXON, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B9600|CS8|CREAD|HUPCL|CLOCAL, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
write(2, "dora-rs cli client\n\n\33[1m\33[4mUsag"..., 1388dora-rs cli client
Usage: dora <COMMAND>
Commands:
check Check if the coordinator and the daemon is running
graph Generate a visualization of the given graph using mermaid.js. Use --open to open
browser
build Run build commands provided in the given dataflow
new Generate a new project, node or operator. Choose the language between Rust,
Python, C or C++
up Spawn a coordinator and a daemon
destroy Destroy running coordinator and daemon. If some dataflows are still running, they
will be stopped first
start Start the given dataflow path. Attach a name to the running dataflow by using
--name
stop Stop the given dataflow UUID. If no id is provided, you will be able to choose
between the running dataflows
list List running dataflows
logs Show logs of a given dataflow and node
daemon Run daemon
runtime Run runtime
coordinator Run coordinator
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
) = 1388
sigaltstack({ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=8192}, NULL) = 0
munmap(0x7fff9c827000, 12288) = 0
exit_group(2)
dora up
failed to start dora-coordinator: failed to get current executable path: no /proc/self/exe available. Is /proc mounted?
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
25.96 0.005635 5635 1 execve
13.50 0.002930 244 12 mmap
10.81 0.002347 469 5 close
9.69 0.002104 350 6 write
6.46 0.001401 200 7 mprotect
6.33 0.001373 274 5 1 openat
5.42 0.001176 1176 1 socket
5.13 0.001114 1114 1 1 connect
4.51 0.000978 244 4 read
2.63 0.000571 142 4 fstat
2.56 0.000555 277 2 2 statx
2.28 0.000494 247 2 1 getrandom
0.81 0.000175 175 1 ppoll
0.78 0.000170 34 5 rt_sigaction
0.65 0.000140 140 1 1 faccessat
0.59 0.000127 127 1 1 readlinkat
0.48 0.000105 35 3 brk
0.42 0.000091 30 3 sigaltstack
0.38 0.000083 83 1 prlimit64
0.32 0.000069 69 1 set_tid_address
0.30 0.000065 65 1 set_robust_list
0.00 0.000000 0 1 munmap
------ ----------- ----------- --------- --------- ----------------
100.00 0.021703 319 68 7 total
execve("/bin/dora", ["/bin/dora", "up"], 0x7fffe7866d88 /* 5 vars */) = 0
brk(NULL) = 0x555591f60000
faccessat(AT_FDCWD, "/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\363\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=84280, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff9bcb8000
mmap(NULL, 82384, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fff9bca3000
mmap(0x7fff9bcb6000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x13000) = 0x7fff9bcb6000
close(3) = 0
openat(AT_FDCWD, "/lib/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\363\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=498168, ...}) = 0
mmap(NULL, 99120, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fff9bc8a000
mmap(0x7fff9bca1000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7fff9bca1000
close(3) = 0
openat(AT_FDCWD, "/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\363\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=730824, ...}) = 0
mmap(NULL, 516224, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fff9bc0b000
mmap(0x7fff9bc88000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7d000) = 0x7fff9bc88000
close(3) = 0
openat(AT_FDCWD, "/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0\363\0\1\0\0\0\364\271\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2010248, ...}) = 0
mmap(NULL, 1560760, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fff9ba8d000
mmap(0x7fff9bbf9000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16c000) = 0x7fff9bbf9000
mmap(0x7fff9bbfe000, 49336, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fff9bbfe000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fff9ba8b000
set_tid_address(0x7fff9ba8b510) = 59
set_robust_list(0x7fff9ba8b520, 24) = 0
mprotect(0x7fff9bbf9000, 12288, PROT_READ) = 0
mprotect(0x7fff9bc88000, 4096, PROT_READ) = 0
mprotect(0x7fff9bca1000, 4096, PROT_READ) = 0
mprotect(0x7fff9bcb6000, 4096, PROT_READ) = 0
mprotect(0x555591e51000, 978944, PROT_READ) = 0
mprotect(0x7fff9bce0000, 8192, PROT_READ) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
ppoll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, {tv_sec=0, tv_nsec=0}, NULL, 0) = 0 (Timeout)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTART}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, {sa_handler=0x555591895ef2, sa_mask=[], sa_flags=SA_ONSTACK|SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGBUS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGBUS, {sa_handler=0x555591895ef2, sa_mask=[], sa_flags=SA_ONSTACK|SA_SIGINFO}, NULL, 8) = 0
sigaltstack(NULL, {ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=0}) = 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7fff9ba88000
mprotect(0x7fff9ba88000, 4096, PROT_NONE) = 0
sigaltstack({ss_sp=0x7fff9ba89000, ss_flags=0, ss_size=8192}, NULL) = 0
getrandom(0x7fff9bc028c0, 8, GRND_NONBLOCK) = -1 EAGAIN (Resource temporarily unavailable)
brk(NULL) = 0x555591f60000
brk(0x555591f81000) = 0x555591f81000
openat(AT_FDCWD, "/proc/self/maps", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
getrandom("\x22\x03\xa1\x57\xeb\xb5\x16\xf1\x85\x07\x33\xf7\x29\xa1\x85\x0e", 16, GRND_INSECURE) = 16
statx(AT_FDCWD, "dora-config.yml", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7fffd9dde158) = -1 ENOENT (No such file or directory)
statx(0, NULL, AT_STATX_SYNC_AS_STAT, STATX_ALL, NULL) = -1 EFAULT (Bad address)
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(6012), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ENETUNREACH (Network is unreachable)
close(3) = 0
readlinkat(AT_FDCWD, "/proc/self/exe", 0x555591f66ce0, 256) = -1 ENOENT (No such file or directory)
write(2, "failed to start dora-coordinator", 32failed to start dora-coordinator) = 32
write(2, ": ", 2: ) = 2
write(2, "failed to get current executable"..., 37failed to get current executable path) = 37
write(2, ": ", 2: ) = 2
write(2, "no /proc/self/exe available. Is "..., 46no /proc/self/exe available. Is /proc mounted?) = 46
write(2, "\n", 1
) = 1
sigaltstack({ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=8192}, NULL) = 0
munmap(0x7fff9ba88000, 12288) = 0
exit_group(1) = ?
+++ exited with 1 +++
从零开始在 StarryOS
中运行 Dora
第一节:环境搭建
重要提醒
最新组件化拆分后的
StarryOS
具体的命令参数和详解参考最新版本StarryOS
环境搭建说明推荐使用
Ubuntu 22.04 LTS
操作系统进行开发。Windows
系统可以使用虚拟机操作。
在 Ubuntu
中构建磁盘文件比较方便,只需要一条命令即可
$ ./build_img.sh -a x86_64 # 过程中可能需要输入当前登录账号的密码
由于 技安
使用的是 macOS
系统,具体的操作方式可参考macOS
开发StarryOS
环境部署说明
开发环境搭建完成后,我们需要做的就是把编译好的 dora
可执行程序放在磁盘的根目录下面。
假设您已经编译完成 dora
,并且把 dora
存放在当前工作目录下。
把 dora
二进制文件放到磁盘中
ubuntu
系统操作步骤
$ mkdir rootfs # 创建 rootfs 文件夹,用以挂载磁盘文件
$ sudo losetup /dev/loop50 disk.img # 把磁盘文件设置成块设备
$ sudo mount /dev/loop50 rootfs # 挂载磁盘文件到 rootfs 文件夹下
$ sudo cp dora rootfs # 把 dora 拷贝到磁盘的根目录下
$ sudo umount rootfs # 解除挂载
$ sudo losetup -d /dev/loop50 # 卸载块设备
知识点说明:
losetup
命令用来设置循环设备。循环设备可把文件虚拟成块设备,籍此来模拟整个文件系统,让用户得以将其视为硬盘驱动器,光驱或软驱等设备,并挂入当作目录来使用。loop
设备介绍: 在类UNIX
系统里,loop
设备是一种伪设备(pseudo-device
),或者也可以说是仿真设备,它将一个文件映射成块设备,从而实现对文件的读写操作。loop
设备一般以/dev/loop
开头,如/dev/loop0
、/dev/loop1
等。它能使我们像块设备一样访问一个文件。在使用之前,一个loop
设备必须要和一个文件进行连接。这种结合方式给用户提供了一个替代块特殊文件的接口。因此,如果这个文件包含有一个完整的文件系统,那么这个文件就可以像一个磁盘设备一样被mount
起来。loop50
是我选的在系统中是一个不存在的设备,如果你的系统中存在这个设备,需要更换一下后面的编号,保证唯一性。
macOS
系统下操作步骤
可视化操作
- 双击打开
disk.img
文件。 - 系统会自动挂在到新的磁盘中,在
Finder
中选中磁盘或者桌面双击挂在的磁盘,把dora
复制到磁盘根目录中。 - 弹出磁盘完成文件的复制。
命令操作
$ mkdir mnt # 创建 mnt 文件夹,用以挂载磁盘文件
$ hdiutil attach disk.img -mountpoint mnt # 附加磁盘镜像挂在在 mnt 文件夹中
$ cp dora mnt # 把 dora 复制到磁盘根目录中
$ hdiutil detach mnt # 从系统中分离分盘镜像
知识点说明:
hdiutil
: 磁盘映像工具,用于管理磁盘映像文件。详细说明可查看hdiutil
工具
启动 StarryOS
系统
执行如下命令
$ make clean && make A=apps/monolithic_userboot LOG=error ARCH=x86_64 FEATURES=img run
先清空make
缓存,再启动StarryOS
启动后将出现如下图所示
我们现在已经成功的启动了 StarryOS
系统了。尝试输入 ls
命令查看有哪些文件。
可以看到,我们放进去的 dora
可执行程序已经在系统中了。下一节,我们将继续在 StarryOS
上成功的运行 dora -h
命令。
从零开始在 StarryOS
中运行 Dora
第二节:运行 dora -h
接着上一节, 我们已经搭建好了StarryOS
的开发环境, 现在开始运行StarryOS
系统.
执行如下命令
$ make clean && make A=apps/monolithic_userboot LOG=error ARCH=x86_64 FEATURES=img run
先清空make
缓存, 再启动StarryOS
启动后将出现如下图所示
在当前的shell
中输入/dora -h
命令,如果不出意外的话会有一个错误提示.
/dora: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory
说明系统缺少动态库libgcc_s.so.1
文件. 这个动态库文件我们可以通过x86_64
架构下的ubuntu 22.04
系统中的/lib/x86_64-linux-gnu/
目录下去寻找缺少的动态库文件. 并把它复制到当前的磁盘的/lib
目录下。
注意
每次补全一个缺少的动态库之后需要清空
make
缓存之后, 再构建运行系统才可以生效。如此反复的看到提示缺少哪个的动态库,就复制过来。当然你也可以根据下面的表格对应的架构列出来的动态库文件,一次性的补全。
整理各个架构下所需要的动态库文件
x86_64
:/lib/x86_64-linux-gnu/
aarch64
:/lib/aarch64-linux-gnu/
riscv64
:/lib/risscv64-linux-gnu/
动态库文件 | x86_64 | aarch64 | riscv64 |
---|---|---|---|
libgcc_s.so.1 | √ | √ | √ |
libm.so.6 | √ | √ | √ |
ld-linux-aarch64.so.1 | √ | ||
libdl.so.2 | √ | ||
librt.so.1 | √ | ||
libc.so.6 | √ | √ | |
libpthread.so.0 | √ | ||
ld-linux-riscv64-lp64d.so.1 | √ | ||
libz.so.1 | √ |
把缺少的动态库全部补全之后, 运行/dora -h
的效果如下:
SeaBIOS (version rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org)
iPXE (http://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+7EFD0D80+7EF30D80 CA00
Booting from ROM..
Initialize IDT & GDT...
d8888 .d88888b. .d8888b.
d88888 d88P" "Y88b d88P Y88b
d88P888 888 888 Y88b.
d88P 888 888d888 .d8888b .d88b. 888 888 "Y888b.
d88P 888 888P" d88P" d8P Y8b 888 888 "Y88b.
d88P 888 888 888 88888888 888 888 "888
d8888888888 888 Y88b. Y8b. Y88b. .d88P Y88b d88P
d88P 888 888 "Y8888P "Y8888 "Y88888P" "Y8888P"
arch = x86_64
platform = x86_64-qemu-q35
target = x86_64-unknown-none
smp = 1
build_mode = release
log_level = error
[ 1.263169 0:6 axprocess::link:304] path address: 0x3fffffe6
[ 1.264362 0:6 axprocess::link:304] path address: 0x410bb38
[ 1.265586 0:6 axprocess::link:304] path address: 0x40f83d2
[ 1.266719 0:6 axprocess::link:304] path address: 0x40f8656
/ # /dora -h
[ 39.728294 0:8 axprocess::link:304] path address: 0x18b8
[ 40.063580 0:8 axprocess::link:304] path address: 0x403b2e0
7: file=/dora [0]; generating link map
7: dynamic: 0x00000000014e5600 base: 0x0000000000001000 size: 0x00000000014f9d18
7: entry: 0x00000000001b2570 phdr: 0x0000000000001040 phnum: 14
7:
[ 40.084003 0:8 axprocess::link:304] path address: 0x402fd90
7:
7: file=libgcc_s.so.1 [0]; needed by /dora [0]
[ 40.087464 0:8 axprocess::link:304] path address: 0x3fffece0
[ 40.088668 0:8 axprocess::link:304] path address: 0x3fffece0
[ 40.089849 0:8 axprocess::link:304] path address: 0x3fffece0
[ 40.091157 0:8 axprocess::link:304] path address: 0x3fffece0
[ 40.092352 0:8 axprocess::link:304] path address: 0x3fffece0
[ 40.093765 0:8 axprocess::link:304] path address: 0x3fffece0
[ 40.095157 0:8 axprocess::link:304] path address: 0x3fffece0
[ 40.096448 0:8 axprocess::link:304] path address: 0x3fffece0
[ 40.097689 0:8 axprocess::link:304] path address: 0x3fffece0
[ 40.098987 0:8 axprocess::link:304] path address: 0x402eee9
7: file=libgcc_s.so.1 [0]; generating link map
7: dynamic: 0x0000000001519de0 base: 0x00000000014fb000 size: 0x000000000001f2e8
7: entry: 0x00000000014fb000 phdr: 0x00000000014fb040 phnum: 11
7:
7:
7: file=libm.so.6 [0]; needed by /dora [0]
[ 40.105764 0:8 axprocess::link:304] path address: 0x3fffecc0
[ 40.107634 0:8 axprocess::link:304] path address: 0x402eee9
7: file=libm.so.6 [0]; generating link map
7: dynamic: 0x0000000001602d90 base: 0x000000000151d000 size: 0x00000000000e6108
7: entry: 0x000000000151d000 phdr: 0x000000000151d040 phnum: 11
7:
7:
7: file=libc.so.6 [0]; needed by /dora [0]
[ 40.114278 0:8 axprocess::link:304] path address: 0x3fffeca0
[ 40.116001 0:8 axprocess::link:304] path address: 0x402eee9
7: file=libc.so.6 [0]; generating link map
7: dynamic: 0x000000000181cbc0 base: 0x0000000001604000 size: 0x0000000000227e50
7: entry: 0x000000000162df50 phdr: 0x0000000001604040 phnum: 14
7:
7:
7: calling init: /lib64/ld-linux-x86-64.so.2
7:
7:
7: calling init: /lib/libc.so.6
7:
7:
7: calling init: /lib/libm.so.6
7:
7:
7: calling init: /lib/libgcc_s.so.1
7:
7:
7: initialize program: /dora
7:
7:
7: transferring control: /dora
7:
[ 41.134514 0:8 axprocess::link:304] path address: 0x17dd556
dora-rs cli client
Usage: dora <COMMAND>
Commands:
check Check if the coordinator and the daemon is running
graph Generate a visualization of the given graph using mermaid.js. Use --open to open
browser
build Run build commands provided in the given dataflow
new Generate a new project, node or operator. Choose the language between Rust,
Python, C or C++
up Spawn a coordinator and a daemon
destroy Destroy running coordinator and daemon. If some dataflows are still running, they
will be stopped first
start Start the given dataflow path. Attach a name to the running dataflow by using
--name
stop Stop the given dataflow UUID. If no id is provided, you will be able to choose
between the running dataflows
list List running dataflows
logs Show logs of a given dataflow and node
daemon Run daemon
runtime Run runtime
coordinator Run coordinator
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
7:
7: calling fini: /dora [0]
7:
7:
7: calling fini: /lib/libgcc_s.so.1 [0]
7:
7:
7: calling fini: /lib/libm.so.6 [0]
7:
[ 41.399522 0:6 axprocess::link:304] path address: 0x40f8656
至此dora -h
已经成功的运行起来了。
从零开始在 StarryOS
中运行 Dora
第三节:调试系统调用
上一节我们已经成功的在 StarryOS
中运行了 dora -h
,本节我们将从内核的角度来调试运行 dora up
。
我们输入 /dora up
,可以看到如下输出,输出内容做了一些精简,去除了无关的信息。
d8888 .d88888b. .d8888b.
d88888 d88P" "Y88b d88P Y88b
d88P888 888 888 Y88b.
d88P 888 888d888 .d8888b .d88b. 888 888 "Y888b.
d88P 888 888P" d88P" d8P Y8b 888 888 "Y88b.
d88P 888 888 888 88888888 888 888 "888
d8888888888 888 Y88b. Y8b. Y88b. .d88P Y88b d88P
d88P 888 888 "Y8888P "Y8888 "Y88888P" "Y8888P"
arch = x86_64
platform = x86_64-qemu-q35
target = x86_64-unknown-none
smp = 1
build_mode = release
log_level = error
/ # /dora up
7: file=/dora [0]; generating link map
7: dynamic: 0x00000000014e5600 base: 0x0000000000001000 size: 0x00000000014f9d18
7: entry: 0x00000000001b2570 phdr: 0x0000000000001040 phnum: 14
7: file=libgcc_s.so.1 [0]; needed by /dora [0]
7: file=libgcc_s.so.1 [0]; generating link map
7: dynamic: 0x0000000001519de0 base: 0x00000000014fb000 size: 0x000000000001f2e8
7: entry: 0x00000000014fb000 phdr: 0x00000000014fb040 phnum: 11
7: file=libm.so.6 [0]; needed by /dora [0]
7: file=libm.so.6 [0]; generating link map
7: dynamic: 0x0000000001602d90 base: 0x000000000151d000 size: 0x00000000000e6108
7: entry: 0x000000000151d000 phdr: 0x000000000151d040 phnum: 11
7: file=libc.so.6 [0]; needed by /dora [0]
7: file=libc.so.6 [0]; generating link map
7: dynamic: 0x000000000181cbc0 base: 0x0000000001604000 size: 0x0000000000227e50
7: entry: 0x000000000162df50 phdr: 0x0000000001604040 phnum: 14
7: calling init: /lib64/ld-linux-x86-64.so.2
7: calling init: /lib/libc.so.6
7: calling init: /lib/libm.so.6
7: calling init: /lib/libgcc_s.so.1
7: initialize program: /dora
7: transferring control: /dora
[ 5.210872 0:8 axruntime::lang_items:5] panicked at /Users/echo/.cargo/git/checkouts/linux_syscall_api-6fd063eab50f7cab/811be4c/src/syscall.rs:47:9:
unknown syscall id: 332
在输出的结果中我们可以看到上一节我们补全的动态库的加载过程,在加载完所有以来的动态库之后,系统 panic
了,并且输出了错误信息。
通过错误信息可以看到程序调用了一个未知的系统调用,这个系统调用号为 332
。同时根据输出的内容还可以知道,这个错误是在 linux_syscall_api
这个 crate
中的 /src/syscall.rs
文件中的第 47
行出现的。
由此我们得到了如下的信息:
- 错误发生在
linux_syscall_api
这个crate
中。 - 错误发生在
/src/syscall.rs
文件中的第47
行。 - 内核缺少一个系统调用号为
332
的系统调用。
上面的三个问题我们一一的解决。
组件化 StarryOS
如何添加组件包
kbuild
kbuild
是一个构建 RustOS
的 cargo
工具。仓库地址:https://github.com/Byte-OS/kbuild。详细使用查看[kbuild
工具]
如何本地调试 StarryOS
内核
组件化 StarryOS
系统如何添加系统调用
hdiutil
工具
hdiutil
是macOS
下的一个工具,用于管理磁盘镜像。可以操作磁盘映像(附加、验证、刻录等)
支持以下文件系统类型:
文件系统 | 说明 |
---|---|
UDF | Universal Disk Format (UDF) |
MS-DOS FAT12 | MS-DOS (FAT12) |
MS-DOS | MS-DOS (FAT) |
MS-DOS FAT16 | MS-DOS (FAT16) |
MS-DOS FAT32 | MS-DOS (FAT32) |
HFS+ | Mac OS Extended |
Case-sensitive HFS+ | Mac OS Extended (Case-sensitive) |
Case-sensitive Journaled HFS+ | Mac OS Extended (Case-sensitive, Journaled) |
Journaled HFS+ | Mac OS Extended (Journaled) |
ExFAT | ExFAT |
Case-sensitive APFS | APFS (Case-sensitive) |
APFS | APFS |
$ hdiutil help
Usage: hdiutil <verb> <options>
<verb> is one of the following:
help imageinfo
attach isencrypted
detach makehybrid
eject mount
verify mountvol
create unmount
compact plugins
convert resize
burn segment
info pmap
checksum udifderez
chpass udifrez
erasekeys
help display more detailed help
Usage: hdiutil attach [options] <image>
hdiutil attach -help
Usage: hdiutil detach [options] <devname>
hdiutil detach -help
eject is a synonym for detach...
Usage: hdiutil detach [options] <devname>
hdiutil detach -help
Usage: hdiutil verify [options] <image>
hdiutil verify -help
Usage: hdiutil create <sizespec> [options] <imagepath>
hdiutil create -help
Usage: hdiutil compact [options] <image>
hdiutil compact -help
Usage: hdiutil convert -format <format> -o <outfile> [options] <image>
hdiutil convert -help
Usage: hdiutil burn [options] <image>
hdiutil burn -help
Usage: hdiutil info [options]
hdiutil info -help
Usage: hdiutil checksum -type <checksumType> [options] <image>
hdiutil checksum -help
Usage: hdiutil chpass [options] <image>
hdiutil chpass -help
Usage: hdiutil erasekeys <image>
hdiutil erasekeys -help
Usage: hdiutil imageinfo [options] <image>
hdiutil imageinfo -help
Usage: hdiutil isencrypted <image>
hdiutil isencrypted -help
Usage: hdiutil makehybrid -o <outfile> [options] <source>
hdiutil makehybrid -help
Usage: hdiutil attach [options] <image>
hdiutil attach -help
Usage: hdiutil mountvol [options] <devname>
hdiutil mountvol -help
Usage: hdiutil unmount [options] <mountpoint>
hdiutil unmount -help
Usage: hdiutil plugins [options]
hdiutil plugins -help
Usage: hdiutil resize <sizespec> [options] <image>
hdiutil resize -help
Usage: hdiutil segment -o <outfile> -segmentCount <num> [options] <image> (deprecated)
hdiutil segment -o <outfile> -segmentSize <size> [options] <image> (deprecated)
hdiutil segment -help
Usage: hdiutil pmap [options] <image|device>
hdiutil pmap -help
Usage: hdiutil udifderez [options] <image>
hdiutil udifderez -help
Usage: hdiutil udifrez [options] <image>
hdiutil udifrez -help