executor: main 内部步骤块注释补充(参数解析/读映像/信任链/sidecar 路径/回放打开)
This commit is contained in:
@@ -234,6 +234,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::string stb_path = argv[1];
|
const std::string stb_path = argv[1];
|
||||||
|
// 参数:--cycles N / --replay <file> / --step(缺省 cycles=10、无回放、非单步)
|
||||||
uint32_t cycles = 10;
|
uint32_t cycles = 10;
|
||||||
bool step_mode = false;
|
bool step_mode = false;
|
||||||
std::string replay;
|
std::string replay;
|
||||||
@@ -247,6 +248,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 读 .stb 映像(二进制)到字节缓冲
|
||||||
std::string err;
|
std::string err;
|
||||||
std::vector<uint8_t> bytes;
|
std::vector<uint8_t> bytes;
|
||||||
{
|
{
|
||||||
@@ -257,6 +259,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
bytes.assign(std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>());
|
bytes.assign(std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>());
|
||||||
}
|
}
|
||||||
|
// 结构校验(Image::from)+ 型号/SHA-256 校验(Machine::create)
|
||||||
const vm::Image img = vm::Image::from(bytes);
|
const vm::Image img = vm::Image::from(bytes);
|
||||||
if (!img.ok()) {
|
if (!img.ok()) {
|
||||||
std::fprintf(stderr, "error: %s\n", img.error().c_str());
|
std::fprintf(stderr, "error: %s\n", img.error().c_str());
|
||||||
@@ -268,7 +271,7 @@ int main(int argc, char** argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sidecar:<name>.runtime.toml
|
// sidecar 路径推导:<name>.stb → <name>.runtime.toml
|
||||||
std::string sidecar_path = stb_path;
|
std::string sidecar_path = stb_path;
|
||||||
const size_t dot = sidecar_path.find_last_of('.');
|
const size_t dot = sidecar_path.find_last_of('.');
|
||||||
if (dot != std::string::npos) {
|
if (dot != std::string::npos) {
|
||||||
@@ -281,7 +284,7 @@ int main(int argc, char** argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 回放缓冲
|
// 回放缓冲(当前行 0/1 序列)+ 打开回放文件;打不开 → 报错退出
|
||||||
std::vector<int> replay_line;
|
std::vector<int> replay_line;
|
||||||
std::ifstream replay_in;
|
std::ifstream replay_in;
|
||||||
if (!replay.empty()) {
|
if (!replay.empty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user