Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add doc to show how to use profiling and code coverage functions #36

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 1-cannot-setup-guestmemory.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
qemu-system-riscv64.exe: cannot set up quest memory 'riscv.evalsoc.flashxip' Invalid argument
```

![](asserts/images/cannotsetupguestmemiry.png)
![](asserts/images/1/cannotsetupguestmemiry.png)

一般可以通过关闭某些应用,释放一部分内存以供qemu使用,即可解决些问题。
2 changes: 1 addition & 1 deletion 10-compiling_projects_with_headless_in_nuclei_studio.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ set PATH=%NSIDE%\toolchain\gcc\bin;%NSIDE%\toolchain\build-tools\bin;%PATH%

> 这个**2023.10**版本的举例的命令 会 弹出一个额外的命令行窗口进行输出。
![Nuclei Studio Command Line Build](asserts/images/wx_20231208153525.png)
![Nuclei Studio Command Line Build](asserts/images/10/wx_20231208153525.png)

- `NucleiStudio.exe`:该参数是Nuclei Studio的启动应用,在Nuclei Studio的安装目录下。
- `--launcher.suppressErrors`:该参数是用于抑制Nuclei Studio启动时的错误信息。
Expand Down
12 changes: 6 additions & 6 deletions 12-nucleisdk-0.5.0-dhrystone-score-lower-than-expected-in-IDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

4. 但实际需要跑分时,要先取消选中`-msave-restore`选项,该跑分结果为**1.664**。

![](asserts/images/12-1.png)
![](asserts/images/12-2.png)
![](asserts/images/12-3.png)
![](asserts/images/12-4.png)
![](asserts/images/12-5.png)
![](asserts/images/12-6.png)
![](asserts/images/12/12-1.png)
![](asserts/images/12/12-2.png)
![](asserts/images/12/12-3.png)
![](asserts/images/12/12-4.png)
![](asserts/images/12/12-5.png)
![](asserts/images/12/12-6.png)
4 changes: 2 additions & 2 deletions 13-error_could_not_find_an_available_hardware_trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Error: Couldn't find an available hardware trigger.
Error: can't add breakpoint: resource not available
```

![](asserts/images/13-1.png)
![](asserts/images/13/13-1.png)

![](asserts/images/13-2.png)
![](asserts/images/13/13-2.png)

是因为所运行的CPU不支持硬件断点,导致程序运行在Flash上的时候,IDE调试功能无法正常工作,这个是IDE会需要打一个临时断点的缘故导致的。如果需要下载并运行程序,切换到Run运行模式可以正常运行程序。

Expand Down
4 changes: 2 additions & 2 deletions 14-cannot_find_-lncrt_balanced_no_such_file_or_directory.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ G:/NucleiStudio/toolchain/gcc/bin/../lib/gcc/riscv64-unknown-elf/13.1.1/../../..
G:/NucleiStudio/toolchain/gcc/bin/../lib/gcc/riscv64-unknown-elf/13.1.1/../../../../riscv64-unknown-elf/bin/ld.exe: cannot find -lncrt_balanced: No such file or directory
```

![](asserts/images/14-1.png)
![](asserts/images/14/14-1.png)

是因为在创建工程时,我们创建了一个64位的工程,同时在Standard C Library时,选择了带`-lncrt_balanced``-lfileops_uart`的扩展,而此类扩展又不支持64位,导致编译不通过。

![](asserts/images/14-2.png)
![](asserts/images/14/14-2.png)

## 解决方案

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:

是因为在eclipse 2024.06版本中,有使用到一些特性,而该特性对操作系统有要求,可以参考 https://github.com/eclipse-platform/eclipse.platform.swt/issues/1252

![](asserts/images/15-1.png)
![](asserts/images/15/15-1.png)

并且在eclipse的官方文档中,针对eclipse测试的操作系统中也做了说明,对某些版本的操作系统不再做兼容。可以参考 https://eclipse.dev/eclipse/development/plans/eclipse_project_plan_4_32.xml#target_environments

![](asserts/images/15-2.png)
![](asserts/images/15/15-2.png)

而NucleiStudio 2024.06是基于eclipse 2024.06,所以也会有同类型的问题。

Expand Down
66 changes: 53 additions & 13 deletions 16-incomplete_data_output_when_using_profiling_function.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,27 +1,67 @@
# 使用Profiling功能时数据输出不完整
# 使用Profiling功能时可能遇到的一些问题

## 问题说明
目前使用 Profiling 功能可能遇到一些问题,记录如下:
* **问题1**:日志打印中报片上内存不足,没有充足空间存放 gprof/gcov 数据
* **问题2**:采用串口输出的方式收集数据,打印被冲掉,Console 或 Terminal 收集的数据不全,导致数据解析失败,不能生成`gmon.out`文件或者`*.gcno`文件
* **问题3**:删掉 `gmon.out` 文件,再次解析时,弹出 No files have been generated 错误弹框

在NucleiStudio 2024.06中,当选择使用串口输出的方式使用Profiling功能时,可能存在最终结果不及预期。
### 问题1:日志打印中报片上内存不足,没有充足空间存放 gprof/gcov 数据

![](asserts/images/16-1.png)
gprof/gcov data 需要存到片上内存上,需要占用片上内存空间(几十到几百KB不等),占用内存的大小与用例规模有关,需要确保片上内存足够大。

在使用`Parse and Generate Hexdump`时没有生成对应的`gmon.out`文件或者`*.gcno`文件,是因为在Console或者Terminal中,对输出的内容条数有限制,当输出的内容长度超过限制时,前面的内容会丢失。
![Alt text](asserts/images/16/overflow.png)

![](asserts/images/16-2.png)

![](asserts/images/16-3.png)

### 解决方案

首先需要确认软件配置的内存大小与硬件实际大小相匹配(ilm/sram/flash/ddr/),可以使用内存大一点的下载方式(如 `DOWNLOAD=ddr`)。

## 解决方案
修改软件配置的内存大小,与硬件实际大小相匹配:
比如,如果是 `DOWNLOAD=ilm` 模式下载,可以按硬件的 ilm 与 dlm 大小适配。
对于 nuclei sdk 0.6.0 版本,修改的文件为`nuclei-sdk/SoC/evalsoc/Board/nuclei_fpga_eval/Source/GCC/gcc_evalsoc_ilm.ld`

为了更方便的使用Profiling功能,可以将Console和Terminal中对输出内容的上限做修改。
~~~c
INCLUDE evalsoc.memory

建议将Console中输出内容条限修改为不受限制。
MEMORY
{
ilm (rxa!w) : ORIGIN = ILM_MEMORY_BASE, LENGTH = ILM_MEMORY_SIZE
ram (wxa!r) : ORIGIN = DLM_MEMORY_BASE, LENGTH = DLM_MEMORY_SIZE
}
~~~

![](asserts/images/16-4.png)
### 问题2:Console 或 Terminal 收集的数据不全导致数据解析时失败

建议将Terminal中输出内容条限修改为一个较大的值。
在 NucleiStudio 2024.06 中,当选择使用串口输出的方式使用 Profiling 功能时,可能遇到在使用 `Parse and Generate Hexdump` 解析数据时时没有生成对应的 `gmon.out` 文件或者 `*.gcno` 文件。这可能是因为串口数据被冲掉,导致数据不完整,从而解析失败
![generated_fail](asserts/images/16/generated_fail.png)

![](asserts/images/16-5.png)
确认方法:需确保串口打印开始时的打印没有被冲掉,参考[一个例子用来展示Profiling以及Code coverage功能](17-an_example_to_demonstrate_the_use_of_profiling_and_code_coverage.md)

![parse_profiling_fail](asserts/images/16/parse_profiling_fail.png)

### 解决方案
因为在Console或者Terminal中,对输出的内容条数有限制,当输出的内容长度超过限制时,前面的内容会被冲掉,导致内容不完整,这样会解析失败。

需要调节 Console 或 Terminal 输出大小限制,确保数据没有被冲掉。为了更方便的使用 Profiling 功能,可以将 Console 和 Terminal 中对输出内容的上限做修改。

* 建议将Console中输出内容条限修改为不受限制。
Window->Preference 进入如下界面:
![config_console_limit](asserts/images/16/config_console_limit.png)

* 建议将Terminal中输出内容条限修改为一个较大的值。
Window->Preference 进入如下界面:
![config_terminal_limit](asserts/images/16/config_terminal_limit.png)



### 问题3:删掉 gmon.out 文件,再次解析,弹出 No files have been generated 错误弹框

手动删掉工程文件夹下的 gmon.out 文件,再次解析时出现 `No files have been generated` 的错误弹框

![generated_fail](asserts/images/16/generated_fail.png)

### 解决方案

手动删掉 gmon.out 文件后,需要手动刷新一下工程。
![refresh_project](asserts/images/16/refresh_project.png)
Loading
Loading