-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wufei
committed
Apr 10, 2024
1 parent
ddacb0e
commit 161954d
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
layout: post | ||
title: Git Bisect定位问题 | ||
author: "Fei Wu" | ||
header-mask: 0.4 | ||
tags: | ||
- git-bisect | ||
- RISC-V | ||
- Debug | ||
--- | ||
|
||
# 复现问题 | ||
|
||
发现rva22s64出现hang,复现脚本 | ||
|
||
``` | ||
$QEMU -machine virt -nographic -m 2G -smp 2 \ | ||
-cpu rva22s64 \ | ||
-bios $d/fw_jump.elf \ | ||
-kernel $d/kernel-latest &> log & | ||
``` | ||
|
||
只要看到最后停在哪里就可以知道有没有问题 | ||
|
||
# bisect脚本 | ||
|
||
稍微改造一下上面的测试用例 | ||
|
||
``` | ||
$ cat check-qemu | ||
#!/bin/bash | ||
QEMU_SRC=~/qemu | ||
QEMU=$QEMU_SRC/install/bin/qemu-system-riscv64 | ||
pushd $QEMU_SRC | ||
make -j 64 install | ||
popd | ||
$d=~/wufei/rvsp | ||
tm=$(date +%s) | ||
log=$d/log-$tm | ||
$QEMU -machine virt -nographic -m 2G -smp 2 \ | ||
-cpu rva22s64 \ | ||
-bios $d/fw_jump.elf \ | ||
-kernel $d/kernel-latest &> log & | ||
pid=$! | ||
sleep 5 | ||
kill -9 $pid | ||
if tail -1 $log | grep MEDELEG; then | ||
exit 1 | ||
else | ||
exit 0 | ||
fi | ||
``` | ||
|
||
# 执行bisect | ||
|
||
``` | ||
$ git bisect start master dfa3c4c57e | ||
$ git bisect run check-qemu | ||
d06f28db60c536b9d7f159adedca397979f6e5ca is the first bad commit | ||
commit d06f28db60c536b9d7f159adedca397979f6e5ca | ||
Author: Daniel Henrique Barboza <[email protected]> | ||
Date: Fri Jan 5 20:05:33 2024 -0300 | ||
target/riscv: move 'mmu' to riscv_cpu_properties[] | ||
``` | ||
|
||
bisect特别适合这类任务,总共不到一小时内定位问题,直接上去调试代码肯定需要更多时间。 |