diff --git a/README_zh.md b/README_zh.md
index 38e2cebaeb239a565687682defad1e7cb7f6742b..2cb805c9e0319a0b704a7ceac15c1e04ea18a992 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -2,6 +2,7 @@
- [简介](#简介)
- [目录](#目录)
+- [ts二进制](#ts二进制)
- [约束](#约束)
- [相关文档](#相关文档)
@@ -42,7 +43,8 @@
│ │ ├── trace_streamer # traceStreamer 结构
│ │ │ └── kits # js/napi接口存放目录
```
-
+## ts二进制
+bin.zip
## 约束
@@ -62,4 +64,4 @@ host端构建约束
- [compile_trace_streamer](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/compile_trace_streamer.md)
- [des_stat](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/des_stat.md)
- [des_support_event](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/des_support_event.md)
-- [des_tables](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/des_tables.md)
\ No newline at end of file
+- [des_tables](https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/doc/des_tables.md)
diff --git a/host/doc/bin.zip b/host/doc/bin.zip
new file mode 100644
index 0000000000000000000000000000000000000000..96dad5396bd82740be20b58b8ca294a58ddb38c6
Binary files /dev/null and b/host/doc/bin.zip differ
diff --git a/host/ide/src/base-ui/table/lit-table.ts b/host/ide/src/base-ui/table/lit-table.ts
index 4eaeebfed3abf66f01881f0ff21d2f88062c2da7..e1c7ba7e77bfdeb3e174ff81070fb9dd125b4c85 100644
--- a/host/ide/src/base-ui/table/lit-table.ts
+++ b/host/ide/src/base-ui/table/lit-table.ts
@@ -49,6 +49,7 @@ export class LitTable extends HTMLElement {
display: grid;
grid-template-columns: repeat(1,1fr);
width: 100%;
+ font-weight: 500;
flex:1;
}
.tr{
@@ -58,13 +59,18 @@ export class LitTable extends HTMLElement {
}
.tr:nth-of-type(even){
}
-
.tr{
background-color: var(--dark-background,#FFFFFF);
}
.tr:hover{
background-color: var(--dark-background6,#DEEDFF);
}
+ .tr[selected]{
+ background-color: var(--dark-background6,#DEEDFF);
+ }
+ .tr[high-light]{
+ font-weight: 600;
+ }
.td{
box-sizing: border-box;
padding: 3px;
@@ -80,9 +86,6 @@ export class LitTable extends HTMLElement {
text-overflow: ellipsis;
white-space: nowrap;
}
- .tr[selected]{
- background-color: var(--dark-background6,#DEEDFF);
- }
.td-order{
}
.td-order:before{
@@ -137,8 +140,12 @@ export class LitTable extends HTMLElement {
display:flex;
align-items:center;
white-space: nowrap;
+ font-weight: 500;
cursor: pointer;
}
+ .tree-first-body[high-light]{
+ font-weight: 600;
+ }
.tree-first-body:hover{
background-color: var(--dark-background6,#DEEDFF); /*antd #fafafa 42b983*/
}
@@ -999,6 +1006,7 @@ export class LitTable extends HTMLElement {
let indexOf = this.currentTreeDivList.indexOf(td);
this.dispatchRowClickEvent(rowData, [(this.treeElement?.children[indexOf] as HTMLElement), newTableElement])
}
+ this.setHighLight(rowData.data.isSearch,td)
this.treeElement!.style.width = column.getAttribute('width')
this.treeElement?.append(td)
this.currentTreeDivList.push(td)
@@ -1028,6 +1036,7 @@ export class LitTable extends HTMLElement {
newTableElement.style.top = '0px'
newTableElement.style.left = '0px'
newTableElement.style.cursor = 'pointer'
+ this.setHighLight(rowData.data.isSearch,newTableElement)
newTableElement.onmouseenter = () => {
if ((newTableElement as any).data.isSelected) return;
let indexOf = this.currentRecycleList.indexOf(newTableElement);
@@ -1199,12 +1208,14 @@ export class LitTable extends HTMLElement {
return
}
let childIndex = -1
+ this.setHighLight(rowObject.data.isSearch,element);
element.childNodes.forEach((child) => {
if (child.nodeType != 1) return
childIndex++;
let idx = firstElement != undefined ? childIndex + 1 : childIndex;
if (firstElement != undefined && childIndex == 0) {
- (firstElement as any).data = rowObject.data
+ this.setHighLight(rowObject.data.isSearch,firstElement);
+ (firstElement as any).data = rowObject.data;
if ((this.columns![0] as any).template) {
firstElement.innerHTML = (this.columns![0] as any).template.render(rowObject.data).content.cloneNode(true).innerHTML
} else {
@@ -1389,4 +1400,12 @@ export class LitTable extends HTMLElement {
}
return ""
}
+
+ setHighLight(isSearch:boolean,element:any){
+ if(isSearch){
+ element.setAttribute("high-light","")
+ }else {
+ element.removeAttribute("high-light")
+ }
+ }
}
diff --git a/host/ide/src/doc/quickstart_smartperf.html b/host/ide/src/doc/quickstart_smartperf.html
index 483594174e330e3f9dd8131d7a056de925a68e66..2dd22e0e2cf6dddab756fd7dbf2ded37d032136e 100644
--- a/host/ide/src/doc/quickstart_smartperf.html
+++ b/host/ide/src/doc/quickstart_smartperf.html
@@ -791,25 +791,15 @@
单选CPU使用情况数据,单击方法会在选中的方法外层加上深色边框,能够突出当前选中色块,弹出层中会展示当前CPU上的进程名,线程名,开始时间和运行时长,线程运行状态等信息
-
- FPS是帧率的显示,每秒产生画面的个数
-
-
-
- 可以对fps的数据进行框选,框选后在最下方的弹出层中会展示框选时间区间内的统计表格,主要显示了time(时间),FPS(帧率)
-
-
- 鼠标移动到帧率的柱状图上,悬浮框会显示当前时间的FPS的值
-
-
+
下图是进程数据,左边部分展示进程名称和id
点击进程名前面向下箭头可以展开对应的线程进行查看,展开后的线程如下图,如果存在堆内存占用情况,就会显示在第一行,如果出现两个名字和id一样的线程,则第一个为线程的使用情况,第二为线程内的方法栈调用情况
- 4.1进程,线程和方法数据的框选功能
+ 3.1进程,线程和方法数据的框选功能
可以对线程的数据进行框选,框选后在最下方的弹出层中会展示框选数据的统计表格,包含线程运行状态,线程调用栈的统计情况。当框选的数据中同时存在线程运行状态和线程调用栈数据,下方的弹出层中就会出现多个tab选项,可以进行切换
下图是线程运行状态框选统计信息,包括进程名,进程号,线程名,线程号,线程状态,状态持续时间,平均持续时间,该线程状态发生的次数
@@ -817,7 +807,7 @@
下图是线程调用栈框选统计信息,包括方法名,持续时间,平均持续时间,调用的次数
+ 3.2进程,线程和方法数据的单选功能
单选线程的state数据时,会展示当前选中线程的状态数据,开始时间和持续时长,线程状态,所在进程名称、
@@ -825,32 +815,32 @@
+ 3.3.线程的跳转功能
点击画红框处的带箭头的标志,会从CPU的线程概览视图跳转到线程的详情视图,同时从线程的详情视图也能跳转到CPU的线程概览视图
-
+
+ 4.1.小旗标志的功能
将选中数据的时间点通过小旗的方式在时间轴上展示,直观的展示选中数据的时间
在下方输入空输入文字:我是trace,可以给小旗打备注
+ 4.2.收藏置顶功能
鼠标移动到某个页签,会出现星形的标志,点击该星形,可以将该行收藏置顶
+ 4.3.勾选功能
框选某一区域,该区域左边会出现CheckBox的复选框。选中的区域的复选框会出现打勾的状态。可以取消勾选,也可以重新勾选
+ 4.4.搜索功能
在搜索框中,可以输入线程,线程号等搜索自己想要的信息,搜索完成会高亮显示
在搜索框中输入调用栈的方法名,会跳转到对应的调用栈
+ 4.5.M键测量功能
放大trace中的色块,选中色块,键盘按下M,会出现像尺子一样的形状
diff --git a/host/ide/src/trace/bean/FrameChartStruct.ts b/host/ide/src/trace/bean/FrameChartStruct.ts
index 5df31fe64012795547a933cf4e01472e0e00abaf..c7c00b48db4ce007d7a990dbff94dcd846f8aebd 100644
--- a/host/ide/src/trace/bean/FrameChartStruct.ts
+++ b/host/ide/src/trace/bean/FrameChartStruct.ts
@@ -19,6 +19,12 @@ import { Rect } from "../component/trace/timer-shaft/Rect.js";
import { info } from "../../log/Log.js";
const padding: number = 1;
+const lightBlue = {
+ r: 82,
+ g: 145,
+ b: 255,
+ a: 0.9
+};
export class ChartStruct extends BaseStruct {
static hoverFuncStruct: ChartStruct | undefined;
@@ -35,7 +41,8 @@ export class ChartStruct extends BaseStruct {
parent: ChartStruct | undefined;
children: Array = [];
percent: number = 0;
- addr : string = "";
+ addr: string = "";
+ isSearch: boolean = false;
}
@@ -90,13 +97,14 @@ export function draw(ctx: CanvasRenderingContext2D, data: ChartStruct) {
// draw rect
let miniHeight = 20;
if (isSelected(data)) {
- ctx.fillStyle = `rgba(${82}, ${145}, ${255}, 0.9)`;
+ ctx.fillStyle = `rgba(${lightBlue.r}, ${lightBlue.g}, ${lightBlue.b}, ${lightBlue.a})`;
} else {
let color = getHeatColor(data.percent);
ctx.fillStyle = `rgba(${color.r}, ${color.g}, ${color.b}, 0.9)`;
}
ctx.fillRect(data.frame.x, data.frame.y, data.frame.width, miniHeight - padding * 2);
//draw border
+ ctx.lineWidth = 0.4;
if (isHover(data)) {
if (spApplication.dark) {
ctx.strokeStyle = "#fff";
@@ -109,8 +117,11 @@ export function draw(ctx: CanvasRenderingContext2D, data: ChartStruct) {
} else {
ctx.strokeStyle = "#fff";
}
+ if (data.isSearch) {
+ ctx.strokeStyle = `rgb(${lightBlue.r}, ${lightBlue.g}, ${lightBlue.b})`;
+ ctx.lineWidth = 1;
+ }
}
- ctx.lineWidth = 0.4;
ctx.strokeRect(data.frame.x, data.frame.y, data.frame.width, miniHeight - padding * 2);
//draw symbol name
diff --git a/host/ide/src/trace/component/trace/TimerShaftElement.ts b/host/ide/src/trace/component/trace/TimerShaftElement.ts
index 30b1fc5b669342c16aac869d8e830f39dcc2080c..1d31e926e4da852f9c5625511dc4ba25f992788a 100644
--- a/host/ide/src/trace/component/trace/TimerShaftElement.ts
+++ b/host/ide/src/trace/component/trace/TimerShaftElement.ts
@@ -21,7 +21,6 @@ import {SportRuler} from "./timer-shaft/SportRuler.js";
import {procedurePool} from "../../database/Procedure.js";
import {Flag} from "./timer-shaft/Flag.js";
import {info} from "../../../log/Log.js";
-import {LitIcon} from "../../../base-ui/icon/LitIcon";
//随机生成十六位进制颜色
export function randomRgbColor() {
@@ -368,7 +367,7 @@ export class TimerShaftElement extends BaseElement {
box-sizing: border-box;
display: flex;
width: 100%;
- height: 147px;
+ height: 148px;
border-bottom: 1px solid var(--dark-background,#dadada);
border-top: 1px solid var(--dark-background,#dadada);
}
@@ -431,7 +430,6 @@ export class TimerShaftElement extends BaseElement {
-
diff --git a/host/ide/src/trace/component/trace/sheet/file-system/TabPaneFileSystemEvents.ts b/host/ide/src/trace/component/trace/sheet/file-system/TabPaneFileSystemEvents.ts
index e6cf6b7ecd2748f4163bfdf97eb4c8299c005011..6e9baad4e825df2e7c761def085c42fc1a491132 100644
--- a/host/ide/src/trace/component/trace/sheet/file-system/TabPaneFileSystemEvents.ts
+++ b/host/ide/src/trace/component/trace/sheet/file-system/TabPaneFileSystemEvents.ts
@@ -85,6 +85,7 @@ export class TabPaneFileSystemEvents extends BaseElement {
setProcessFilter(){
this.processList = ["All Process"];
+ this.pathList = ["All Path"]
this.source.map(it => {
if(this.processList!.findIndex(a => a === it.process) == -1){
this.processList!.push(it.process);
@@ -152,7 +153,7 @@ export class TabPaneFileSystemEvents extends BaseElement {
this.filter = this.shadowRoot?.querySelector("#filter");
this.eventList = ['All Event','All Open Event','All Close Event','All Read Event','All Write Event'];
this.processList = ['All Process'];
- this.pathList = ["All Path"]
+ this.pathList = ["All Path"];
this.filter!.setSelectList(this.eventList,this.processList,"","",this.pathList,"");
this.filter!.firstSelect = "0";
this.filter!.getFilterData((data: FilterData) => {
diff --git a/host/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts b/host/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts
index 81c072c184d194d9c5c0b1a7a57904f858a88329..3b5b8fba4708c7b8bac36cd777cc9d936e844ee0 100644
--- a/host/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts
+++ b/host/ide/src/trace/database/logic-worker/ProcedureLogicWorkerCommon.ts
@@ -25,6 +25,7 @@ export class ChartStruct {
dur:number = 0;
parent: ChartStruct | undefined;
children: Array = [];
+ isSearch: boolean = false;
}
export class Msg{
@@ -200,6 +201,7 @@ class MerageBeanDataSplit{
this.clearSearchNode(currentTreeList)
data.forEach((process) => {
process.searchShow = true
+ process.isSearch = false
})
this.resetNewAllNode(data,currentTreeList)
if (searchValue != "") {
@@ -236,6 +238,7 @@ class MerageBeanDataSplit{
data.forEach((node) => {
if ((node.symbolName!=undefined&&node.symbolName.includes(search)) || parentSearch) {
node.searchShow = true
+ node.isSearch = (node.symbolName!=undefined&&node.symbolName.includes(search))
let parentNode = node.currentTreeParentNode
while (parentNode != undefined && !parentNode.searchShow) {
parentNode.searchShow = true
@@ -243,6 +246,7 @@ class MerageBeanDataSplit{
}
} else {
node.searchShow = false
+ node.isSearch = false
}
if (node.children.length > 0) {
this.findSearchNode(node.children, search, node.searchShow)
@@ -253,6 +257,7 @@ class MerageBeanDataSplit{
clearSearchNode(currentTreeList:any[]) {
currentTreeList.forEach((node) => {
node.searchShow = true
+ node.isSearch = false
})
}
diff --git a/host/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts b/host/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts
index f06b7bd8ed20c7614018339c46ec36f6da5fa718..0d378b574d197f79855777c0ee6f64ed2c02a857 100644
--- a/host/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts
+++ b/host/ide/src/trace/database/logic-worker/ProcedureLogicWorkerPerf.ts
@@ -546,7 +546,8 @@ group by callchain_id,s.thread_id,thread_state,process_id) p`
resetAllNode(data: PerfCallChainMerageData[]) {
this.clearSearchNode()
data.forEach((process) => {
- process.searchShow = true
+ process.searchShow = true;
+ process.isSearch = false
})
this.resetNewAllNode(data)
if (this.searchValue != "") {
@@ -584,12 +585,14 @@ group by callchain_id,s.thread_id,thread_state,process_id) p`
if ((node.symbol&&node.symbol.includes(search)) || parentSearch) {
node.searchShow = true
let parentNode = node.currentTreeParentNode
+ node.isSearch = (node.symbol!=undefined&&node.symbol.includes(search))
while (parentNode != undefined && !parentNode.searchShow) {
parentNode.searchShow = true
parentNode = parentNode.currentTreeParentNode
}
} else {
node.searchShow = false
+ node.isSearch = false
}
if (node.children.length > 0) {
this.findSearchNode(node.children, search, node.searchShow)
@@ -600,6 +603,7 @@ group by callchain_id,s.thread_id,thread_state,process_id) p`
clearSearchNode() {
this.currentTreeList.forEach((node) => {
node.searchShow = true
+ node.isSearch = false
})
}
@@ -775,7 +779,7 @@ export class PerfCallChainMerageData extends ChartStruct {
vaddrInFile: number = 0;
isSelected: boolean = false;
searchShow: boolean = true;
-
+ isSearch: boolean = false;
set parentNode(data: PerfCallChainMerageData | undefined) {
this.currentTreeParentNode = data;
this.#parentNode = data;
diff --git a/host/trace_streamer/BUILD.gn b/host/trace_streamer/BUILD.gn
index 092bb98c46e3328169c387349de1c53cf88bb3d3..2f41a95604d7fb300fb8ca8f392779a735b5dfa2 100644
--- a/host/trace_streamer/BUILD.gn
+++ b/host/trace_streamer/BUILD.gn
@@ -12,11 +12,20 @@
# limitations under the License.
group("trace_streamer") {
- if (use_wasm) {
- deps = [ "src:trace_streamer_builtin" ]
- } else if (is_test) {
+ if (is_test) {
deps = [ "test:unittest" ]
testonly = true
+ } else if (is_fuzz) {
+ deps = [ "test:fuzztest" ]
+ testonly = true
+ } else if (is_protoc) {
+ deps = [ "//third_party/protobuf:protoc" ]
+ } else if (is_sdkdemo) {
+ deps = [ "sdk:trace_streamer_sdk_builtin" ]
+ } else if (is_sdkdemo_test) {
+ deps = [ "sdk/test:sdkunittest" ]
+ } else if (use_wasm) {
+ deps = [ "src:trace_streamer_builtin" ]
} else {
deps = [ "src:trace_streamer" ]
}
diff --git a/host/trace_streamer/README.md b/host/trace_streamer/README.md
index eb0deec07b8f4c55fed4152454f49cad6d721cb9..c1b9b5c9710e99d7afed00f1b2595ed638dfb2f4 100644
--- a/host/trace_streamer/README.md
+++ b/host/trace_streamer/README.md
@@ -1,309 +1,168 @@
-# trace_streamer工具说明
-trace_streamer工具可以2种方式使用
+# TraceStreamer工具说明
+TraceStreamer是一个trace数据解析程序,可以将一个trace文本文件或者基于proto序列化的二进制文件转换成为sqlite数据库的形式。 TraceStreamer使用C++实现,支持在ohos, linux, mac等系统上使用,具有良好的跨平台特性。
+![GitHub Logo](./figures/trace_streamer_stream.png)
+## 关于TraceStreamer的使用说明
+TraceStreamer工具可以2种方式使用
1. 可以将系统离线trace文件解析并转为db,此工具支持基于文本的trace和基于proto的trace。
-2. trace_streamer工具还可以WebAssembly的方式在浏览器中运行,需暴露相关接口给js文件。
-
-## 关于trace解析工具的使用说明:
+2. TraceStreamer工具还可以WebAssembly的方式在浏览器中运行,需提供相关接口给js文件。
+
### 导出db模式
-在导出db模式下,trace_streamer.exe trace文件路径名 -e 导出db路径名.db
-此命令可以将trace文件转为db
-本应用支持在ohos, linux, windows, mac使用。
-关于db文件的说明:
-使用db查看工具查看stat表,可以浏览当前数据一共有多少类数据,各类数据都收到多少条,数据是否正常等情况。在meta表会记录数据库导出时的一些系统信息,比如导入和导出的文件全路径,解析时间等信息。
-meta表可以选择不导出(有些情况下会暴露系统敏感信息),在导出时添加 -nm选项即可。
-在数据导出之后,会在本地目录下生成一个trace_streamer.log文件,在导出db的目录下生成一个数据库文件同名,.db.ohos.ts后缀的文件
-文件内容如下:
-时间戳:执行结果(数字)
-应用运行时间
+在导出db模式下,通过下面的指令:
+```
+./trace_streamer trace文件路径名 -e 导出db路径名.db
+```
+可以将trace文件转为db文件。
+本应用支持在ohos, linux, mac使用。
+在数据导出之后,会在本地目录下生成一个trace_streamer.log文件,在导出db的目录下生成一个数据库文件同名,.db.ohos.ts后缀的文件。
+文件内容如下:
+```
+当前时间戳:执行结果(数字)
+应用运行时间
+```
+执行结果解释如下:
+```
+0 代表执行成功 1 表示输入文件不匹配, 2 表示解析错误, 3其他错误。
+```
+#### __关于db文件的说明__
+可以使用sqliteexport或DB Browser for SQLite工具加载生成的db,通过查看stat表,可以浏览当前数据一共有多少类数据,各类数据都收到多少条,数据是否正常等情况。在meta表会记录数据库导出时的一些系统信息,比如导入和导出的文件全路径,解析时间等信息。
+meta表可以选择不导出(有些情况下会暴露系统敏感信息),在导出时添加 -nm选项即可。
+更多db文件的介绍,可以参考[doc/des_tables.md](./doc/des_tables.md)。
-执行结果解释如下:0 代表执行成功 1 表示输入文件不匹配, 2 表示解析错误, 3其他错误
-### 内置浏览器方式
-trace_streamer可以WebAssembly方式在浏览器中运行,暴露如下接口给js
+### 内置浏览器模式
+TraceStreamer可以WebAssembly方式在浏览器中运行,相关接口在wasm模式下生成的trace_streamer_builtin.js文件中,js可以使用的接口如下使用如下接口访问trace_streamer:
```
extern "C" {
-/* 上传trace数据
+/* 初始化wasm,在JS中注册回调函数,并返回一段可复用的内存空间,由JS调用
*
- * @data: 数据的缓冲区
- * @dataLen: 数据长度
+ * @ replyFunction: 回调函数
+* @ reqBufferSize: 返回的内存长度
+* return: 返回一段内存地址给JS
+*/
+EMSCRIPTEN_KEEPALIVE uint8_t* Initialize(ReplyFunction replyFunction, uint32_t reqBufferSize)
+
+/* 更新起始结束时间,由JS调用
*
- * return: 0:成功; -1:失败
+ * @ len: 起始和结束时间组成的字符串长度
+* return: 成功返回0。
*/
-EMSCRIPTEN_KEEPALIVE int TraceStreamerParseData(const uint8_t* data, int dataLen);
+EMSCRIPTEN_KEEPALIVE int UpdateTraceTime(int len)
-/* 通知TS上传trace数据结束
- *
- * return: 0:成功; -1:失败
+/* 设置TraceStreamer和第三方wasm通信的回调函数,并返回一段内存,由JS调用
+ *
+ * @ sendDataCallBack:与第三方wasm通信的回调函数
+* @ reqBufferSize: 返回的内存长度
+* return: 成功返回0
*/
-EMSCRIPTEN_KEEPALIVE int TraceStreamerParseDataOver();
+EMSCRIPTEN_KEEPALIVE uint8_t* TraceStreamer_Set_ThirdParty_DataDealer(SendDataCallBack sendDataCallBack, uint32_t reqBufferSize)
-/* 通过sql语句操作数据库
+/* TraceStreamer的数据解析接口,由JS调用
*
- * @sql: sql语句
- * @sqlLen: sql语句长度
+* @ dataLen: 需要解析的数据源长度
+* return: 成功返回0,失败返回-1
+*/
+EMSCRIPTEN_KEEPALIVE int TraceStreamerParseDataEx(int dataLen)
+
+/* TraceStreamer停止解析数据,由JS调用
*
- * return: 0:成功; -1:失败
+* return: 成功返回0,失败返回-1
*/
-EMSCRIPTEN_KEEPALIVE int TraceStreamerSqlOperate(const uint8_t* sql, int sqlLen);
+EMSCRIPTEN_KEEPALIVE int TraceStreamerParseDataOver()
-/* 通过sql语句查询数据库
+/* 数据库操作接口,由JS调用
*
- * @sql: sql语句
- * @sqlLen: sql语句长度
- * @out: 查询结果的缓冲区,查询结果为json
- * @outLen: 缓冲区长度
+* @ sqlLen: 需要执行的操作类sql语句长度
+* return: 成功返回0,失败返回-1
+*/
+EMSCRIPTEN_KEEPALIVE int TraceStreamerSqlOperateEx(int sqlLen)
+
+/*清空wasm内存中的内容,由JS调用
+ *
+* return: 成功返回0,失败返回-1
+*/
+EMSCRIPTEN_KEEPALIVE int TraceStreamerReset()
+
+/*执行查询类sql语句,由JS调用
+ *
+* @ sqlLen: 需要执行的查询类sql语句长度
+* return: 成功返回0,失败返回-1
+*/
+EMSCRIPTEN_KEEPALIVE int TraceStreamerSqlQueryEx(int sqlLen)
+
+/*取消sql查询,由JS调用。
*
- * return: >0:查询成功,返回查询结果数据长度; -1:失败
+* return: 成功返回0。
*/
-EMSCRIPTEN_KEEPALIVE int TraceStreamerSqlQuery(const uint8_t* sql, int sqlLen, uint8_t* out, int outLen);
+EMSCRIPTEN_KEEPALIVE int TraceStreamerCancel()
+
+/*发送数据给第三方wasm解析,由TraceStreamer调用
+ *
+* @ pluginData: 第三方插件的数据源
+* @ len: 数据源长度
+* @ componentName: 第三方插件名称
+* return: 成功返回0
+*/
+int TraceStreamer_Plugin_Out_SendData(const char* pluginData, int len, const std::string componentName)
+
+/* 初始化配置接口,由JS调用
+ *
+* @ dataLen: 配置字符串的长度
+* return: 成功返回0
+*/
+EMSCRIPTEN_KEEPALIVE int TraceStreamer_Init_ThirdParty_Config(int dataLen)
} // extern "C"
```
### 你也可以执行如下命令查看应用帮助
-./trace_streamer --help
--i 选项可查看应用支持的事件源和具体的事件名列表
+```./trace_streamer --help```
-#### trace_streamer支持的事件解析
-本工具支持基于文本的trace(# TRACE)和基于proto的二进制日志文件的解析,支持的事件列表如下:
-##### ftrace事件
-```
-binder_transaction
-binder_transaction_received
-binder_transaction_alloc_buf
-binder_transaction_lock
-binder_transaction_locked
-binder_transaction_unlock
-sched_switch
-task_rename
-task_newtask
-tracing_mark_write
-print
-sched_wakeup
-sched_waking
-cpu_idle
-cpu_frequency
-suspend_resume
-workqueue_execute_start
-workqueue_execute_end
-clock_set_rate
-clock_enable
-clock_disable
-clk_set_rate
-clk_enable
-clk_disable
-sys_enter
-sys_exit
-regulator_set_voltage
-regulator_set_voltage_complete
-regulator_disable
-regulator_disable_complete
-ipi_entry
-ipi_exit
-irq_handler_entry
-irq_handler_exit
-softirq_raise
-softirq_entry
-softirq_exit
-sched_wakeup_new
-sched_process_exit
-trace_event_clock_sync
-```
-##### 内存事件
-```
-mem.vm.size
-mem.rss
-mem.rss.anon
-mem.rss.file
-mem.rss.schem
-mem.swap
-mem.locked
-mem.hwm
-mem.oom_score_adj
+### TraceStreamer支持解析的事件列表
+通过```./trace_streamer -i```
+查看支持的事件列表。
+支持的事件列表参见[SupportEventList.md](./doc/des_support_event.md)。
+## TraceStreamer重要概念介绍
+### 进程和线程标识符
```
-##### 系统内存事件
-```
-sys.mem.unspecified
-sys.mem.total
-sys.mem.free
-sys.mem.avaiable
-sys.mem.buffers
-sys.mem.cached
-sys.mem.swap.chard
-sys.mem.active
-sys.mem.inactive
-sys.mem.active.anon
-sys.mem.inactive.anon
-sys.mem.active_file
-sys.mem.inactive_file
-sys.mem.unevictable
-sys.mem.mlocked
-sys.mem.swap.total
-sys.mem.swap.free
-sys.mem.dirty
-sys.mem.writeback
-sys.mem.anon.pages
-sys.mem.mapped
-sys.mem.shmem
-sys.mem.slab
-sys.mem.slab.reclaimable
-sys.mem.slab.unreclaimable
-sys.mem.kernel.stack
-sys.mem.page.tables
-sys.mem.commit.limit
-sys.mem.commited.as
-sys.mem.vmalloc.total
-sys.mem.vmalloc.used
-sys.mem.vmalloc.chunk
-sys.mem.cma.total
-sys.mem.cma.free
-```
-##### 系统虚拟内存事件
-```
-sys.virtual.mem.unspecified
-sys.virtual.mem.nr.free.pages
-sys.virtual.mem.nr.alloc.batch
-sys.virtual.mem.nr.inactive.anon
-sys.virtual.mem.nr.active_anon
-sys.virtual.mem.nr.inactive.file
-sys.virtual.mem.nr.active_file
-sys.virtual.mem.nr.unevictable
-sys.virtual.mem.nr.mlock
-sys.virtual.mem.anon.pages
-sys.virtual.mem.nr.mapped
-sys.virtual.mem.nr.file.pages
-sys.virtual.mem.nr.dirty
-sys.virtual.mem.nr.writeback
-sys.virtual.mem.nr.slab.reclaimable
-sys.virtual.mem.nr.slab.unreclaimable
-sys.virtual.mem.nr.page_table.pages
-sys.virtual.mem.nr_kernel.stack
-sys.virtual.mem.nr.overhead
-sys.virtual.mem.nr.unstable
-sys.virtual.mem.nr.bounce
-sys.virtual.mem.nr.vmscan.write
-sys.virtual.mem.nr.vmscan.immediate.reclaim
-sys.virtual.mem.nr.writeback_temp
-sys.virtual.mem.nr.isolated_anon
-sys.virtual.mem.nr.isolated_file
-sys.virtual.mem.nr.shmem
-sys.virtual.mem.nr.dirtied
-sys.virtual.mem.nr.written
-sys.virtual.mem.nr.pages.scanned
-sys.virtual.mem.workingset.refault
-sys.virtual.mem.workingset.activate
-sys.virtual.mem.workingset_nodereclaim
-sys.virtual.mem.nr_anon.transparent.hugepages
-sys.virtual.mem.nr.free_cma
-sys.virtual.mem.nr.swapcache
-sys.virtual.mem.nr.dirty.threshold
-sys.virtual.mem.nr.dirty.background.threshold
-sys.virtual.mem.vmeminfo.pgpgin
-sys.virtual.mem.pgpgout
-sys.virtual.mem.pgpgoutclean
-sys.virtual.mem.pswpin
-sys.virtual.mem.pswpout
-sys.virtual.mem.pgalloc.dma
-sys.virtual.mem.pgalloc.normal
-sys.virtual.mem.pgalloc.movable
-sys.virtual.mem.pgfree
-sys.virtual.mem.pgactivate
-sys.virtual.mem.pgdeactivate
-sys.virtual.mem.pgfault
-sys.virtual.mem.pgmajfault
-sys.virtual.mem.pgrefill.dma
-sys.virtual.mem.pgrefill.normal
-sys.virtual.mem.pgrefill.movable
-sys.virtual.mem.pgsteal.kswapd.dma
-sys.virtual.mem.pgsteal.kswapd.normal
-sys.virtual.mem.pgsteal.kswapd.movable
-sys.virtual.mem.pgsteal.direct.dma
-sys.virtual.mem.pgsteal.direct.normal
-sys.virtual.mem.pgsteal_direct.movable
-sys.virtual.mem.pgscan.kswapd.dma
-sys.virtual.mem.pgscan_kswapd.normal
-sys.virtual.mem.pgscan.kswapd.movable
-sys.virtual.mem.pgscan.direct.dma
-sys.virtual.mem.pgscan.direct.normal
-sys.virtual.mem.pgscan.direct.movable
-sys.virtual.mem.pgscan.direct.throttle
-sys.virtual.mem.pginodesteal
-sys.virtual.mem.slabs_scanned
-sys.virtual.mem.kswapd.inodesteal
-sys.virtual.mem.kswapd.low.wmark.hit.quickly
-sys.virtual.mem.high.wmark.hit.quickly
-sys.virtual.mem.pageoutrun
-sys.virtual.mem.allocstall
-sys.virtual.mem.pgrotated
-sys.virtual.mem.drop.pagecache
-sys.virtual.mem.drop.slab
-sys.virtual.mem.pgmigrate.success
-sys.virtual.mem.pgmigrate.fail
-sys.virtual.mem.compact.migrate.scanned
-sys.virtual.mem.compact.free.scanned
-sys.virtual.mem.compact.isolated
-sys.virtual.mem.compact.stall
-sys.virtual.mem.compact.fail
-sys.virtual.mem.compact.success
-sys.virtual.mem.compact.daemon.wake
-sys.virtual.mem.unevictable.pgs.culled
-sys.virtual.mem.unevictable.pgs.scanned
-sys.virtual.mem.unevictable.pgs.rescued
-sys.virtual.mem.unevictable.pgs.mlocked
-sys.virtual.mem.unevictable.pgs.munlocked
-sys.virtual.mem.unevictable.pgs.cleared
-sys.virtual.mem.unevictable.pgs.stranded
-sys.virtual.mem.nr.zspages
-sys.virtual.mem.nr.ion.heap
-sys.virtual.mem.nr.gpu.heap
-sys.virtual.mem.allocstall.dma
-sys.virtual.mem.allocstall.movable
-sys.virtual.mem.allocstall.normal
-sys.virtual.mem.compact_daemon.free.scanned
-sys.virtual.mem.compact.daemon.migrate.scanned
-sys.virtual.mem.nr.fastrpc
-sys.virtual.mem.nr.indirectly.reclaimable
-sys.virtual.mem.nr_ion_heap_pool
-sys.virtual.mem.nr.kernel_misc.reclaimable
-sys.virtual.mem.nr.shadow_call.stack_bytes
-sys.virtual.mem.nr.shmem.hugepages
-sys.virtual.mem.nr.shmem.pmdmapped
-sys.virtual.mem.nr.unreclaimable.pages
-sys.virtual.mem.nr.zone.active.anon
-sys.virtual.mem.nr.zone.active.file
-ys.virtual.mem.nr.zone.inactive_anon
-sys.virtual.mem.nr.zone.inactive_file
-sys.virtual.mem.nr.zone.unevictable
-sys.virtual.mem.nr.zone.write_pending
-sys.virtual.mem.oom.kill
-sys.virtual.mem.pglazyfree
-sys.virtual.mem.pglazyfreed
-sys.virtual.mem.pgrefill
-sys.virtual.mem.pgscan.direct
-sys.virtual.mem.pgscan.kswapd
-sys.virtual.mem.pgskip.dma
-sys.virtual.mem.pgskip.movable
-sys.virtual.mem.pgskip.normal
-sys.virtual.mem.pgsteal.direct
-sys.virtual.mem.pgsteal.kswapd
-sys.virtual.mem.swap.ra
-sys.virtual.mem.swap.ra.hit
+在通用操作系统中,进程号(pid/tgid)和线程号(tid)可能会被重复用于标识不同的进程或者线程。所以在trace数据源中,进程号(pid)和线程号(tid)也可能被重用。
+TraceStreamer在解析数据过程中,使用ipid(internal pid)唯一标识进程, itid(internal tid)唯一标识线程。
```
+### 计量器
+用来记录系统中各种随时间连续变化的数值。例如: CPU的频率, 内存的使用量, 界面刷新频率。
+#### 举例
+CPU频率:
+![GitHub Logo](./figures/cpu_frequency.png)
+内存占用:
+![GitHub Logo](./figures/mem_usage.png)
-## trace_streamer开发环境搭建和编译运行指引
+### 过滤器
+TraceStreamer设计过程中使用了流式处理的思想,数据从入口进入以后,就像进入一条河流,从上游流向下游,在河道中央有很多过滤器,每种过滤器会将流过的数据中自己关注的内容吸附捕捉到。最终,每个过滤器都拥有了大量同类型的数据,而且这些数据都是按时间序列排列的。TraceStreamer使用filterid来标识同一种用途的数据,可以方便在UI中绘制。
+![GitHub Logo](./figures/filters.png)
-本应用使用gn作为构建工具,支持在linux环境同时编译linux,windows和mac使用QtCreator作为开发IDE
-### 1、开发环境
-ubuntu使用vscode,windows和mac使用QtCreator
-# 对外部的依赖
-本应用依赖与sqlite,protobuf(htrace解析部分依赖)
+## Stat表设计
+具体内容参见 [des_stat](../doc/des_stat.md)
+## TraceStreamer开发环境搭建和编译运行指引
-本应用同时依赖于src/protos目录下文件来生成相关pb.h,pb.cc文件
+本应用使用gn作为构建工具。
+### 开发环境
+可以在ubuntu、mac、windows下执行开发和编译,建议使用vscode开发工具。
+在windows平台上,需使用支持c++17标准的clang编译器。
+# 对外部的依赖
+本应用依赖与sqlite、protobuf(htrace解析部分依赖)、nlohmann_json。
+本应用同时依赖于src/protos/protogen.sh目录下文件来生成相关pb.h,pb.cc文件
+_____
-### 2.1、 编译linux版应用
-在根目录下执行相关命令进行编译
+### 编译linux和Mac应用
+在目录下有build.sh脚本,在不同的平台上会判断系统版本,编译相应系统的应用
+```
+./build.sh linux
+./build.sh macx
+```
-### 2.2、编译Windows版和Mac应用
-在项目目录下有pro文件,为QtCreator的工程文件,但部分内容赖在于上面所添加的外部依赖,如果要编译相关平台应用,开发者需自行补充相关工程文件,或者在论坛留言
+### 编译wasm
+```
+./build.sh wasm
+```
-### 2.3、开始编译
-具体方法可参考《compile_trace_streamer.md》
\ No newline at end of file
+### 开始编译
+本工具建议独立编译, 通过部署第三方依赖库,emsdk,可编译出支持不同平台的应用。
+具体方法可参考[compile_trace_streamer](./doc/compile_trace_streamer.md)。
\ No newline at end of file
diff --git a/host/trace_streamer/build.sh b/host/trace_streamer/build.sh
old mode 100644
new mode 100755
index 9e183eeac90d0bd477bbe47f73d14a24b5a55d3c..87911841b8731a2753a0ac5ecedf6851ded79622
--- a/host/trace_streamer/build.sh
+++ b/host/trace_streamer/build.sh
@@ -1,4 +1,4 @@
-#! /bin/bash
+#!/bin/bash
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -11,18 +11,44 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+set -e
PARAMS=$*
echo $PARAMS
echo "begin to check input"
target_os='linux'
+target_dir='linux'
+gn_path='linux'
is_debug='false'
is_clean='false'
+target='trace_streamer'
+gn='gn'
+ninja='ninja'
+case "$OSTYPE" in
+ solaris*) echo "SOLARIS" ;;
+ darwin*) gn_path='macx' target_os='macx' ;;
+ linux*) gn_path='linux' target_os='linux' ;;
+ bsd*) echo "is bsd os" ;;
+ msys*) gn_path='windows' target_os='windows' gn='gn.exe' ninja='ninja.exe' ;;
+ *) echo "unknown: $OSTYPE" ;;
+esac
+usage="Usage: $basename $0 wasm/test/fuzz/protoc debug/release/clean"
+
+
+if [ "$1" == 'windows' ];then
+ echo "gn only support linux and wasm build currently"
+ if [ ! -d "out/windows" ];then
+ mkdir out/windows
+ fi
+ touch out/windows/trace_streamer.exe
+ exit
+fi
+
if [ "$#" -ne "0" ];then
- if [ $1 == "wasm" ];then
+ if [ "$1" == "wasm" ];then
if [ ! -d "prebuilts/emsdk" ];then
echo "you need emsdk to compile wasm"
- mv emsdk.tar.gz prebuilts/
- mv ../emsdk.tar.gz prebuilts/
+ #mv emsdk.tar.gz prebuilts/
+ #mv ../emsdk.tar.gz prebuilts/
if [ ! -f "prebuilts/emsdk.tar.gz" ];then
# consider
# you need to get emsdk.tar.gz some where
@@ -32,44 +58,59 @@ if [ "$#" -ne "0" ];then
tar -zxvf prebuilts/emsdk.tar.gz -C prebuilts/
fi
fi
- target_os='wasm'
+ target='wasm'
+ fi
+ if [ "$1" == "test" ];then
+ target='test'
fi
- if [ $1 == "test" ];then
- target_os='test'
+ if [ "$1" == "fuzz" ];then
+ target='fuzz'
fi
+ if [ "$1" == "protoc" ];then
+ target='protoc'
+ fi
+ if [ "$1" == "sdkdemo" ];then
+ target='sdkdemo'
+ fi
+ if [ "$1" == "sdkdemotest" ];then
+ target='sdkdemotest'
+ fi
+fi
+if [ $target == "wasm" ] && [ $target_os == "windows" ];then
+ echo "!!!build wasm on winows will occur unknown error, strongly suggest you build wasm on linux(Ubuntu)"
+ exit
fi
if [ "$#" -eq "2" ];then
- if [ "$1" != 'windows' ] && [ $1 != "linux" ] && [ $1 != "wasm" ] && [ $1 != "test" ];then
+ if [ "$1" != 'trace' ] && [ "$1" != "linux" ] && [ "$1" != "windows" ] && [ "$1" != "macx" ] && [ "$1" != "trace_streamer" ] && [ "$1" != "wasm" ] && [ "$1" != "test" ] && [ "$1" != "fuzz" ] && [ "$1" != "protoc" ];then
echo "failed"
- echo "Usage: `basename $0` windows/linux/wasm/test debug/release/clean"
+ echo "$usage"
exit
fi
- if [ $2 != "debug" -a $2 != "release" -a $2 != "clean" ];then
+ if [ "$2" != "debug" -a "$2" != "release" -a "$2" != "clean" ];then
+ if [ "$2" == "protoc" ];then
+ target="$2"
+ else
echo "failed"
- echo "Usage: `basename $0` windows/linux debug/release/clean"
+ echo "$usage"
exit
fi
- if [ $2 == "debug" ];then
+ fi
+ if [ "$2" == "debug" ];then
is_debug='true'
- elif [ $2 == "clean" ];then
+ elif [ "$2" == "clean" ];then
is_clean='true'
else
is_debug='false'
fi
- target_os=$1
- if [ $target_os == "windows" ];then
- echo "gn only support linux and wasm build currently"
- mkdir out/windows
- touch out/windows/trace_streamer.exe
- exit
- fi
echo "platform is $target_os"
echo "isdebug: $is_debug"
+ echo "isclean: $is_clean"
else
- echo "Usage: `basename $0` windows/linux/wasm debug/release wasm[optional]"
+ echo "$usage"
echo "You provided $# parameters,but 2 are required."
echo "use default input paramter"
echo "platform is $target_os"
+ echo "target is $target"
echo "is_debug:$is_debug"
fi
echo "gen ..."
@@ -86,34 +127,50 @@ echo ""
echo "if you are compiling first time, or your proto has changed, you need to run ./src/protos/protogen.sh"
echo ""
echo ""
-echo
+echo
#./src/protos/protogen.sh
-mkdir prebuilts/$target_os
-if [ ! -f "prebuilts/$target_os/gn" ];then
+if [ ! -d "prebuilts/$gn_path" ];then
+ mkdir prebuilts/$gn_path
+fi
+if [ ! -f "prebuilts/$gn_path/gn" ];then
echo "you may get gn for $target_os and place it in prebuilts/$target_os"
- ehco "the file can be get at https://gitee.com/su_fu/public_tools/raw/master/gn/$target_os/gn, you need to download it manually"
- #wget https://gitee.com/su_fu/public_tools/raw/master/gn/$target_os/gn
+ echo "the file can be get at https://gitee.com/su_ze1688/public_tools/raw/master/gn/$target_os/gn, you need to download it manually"
+ #wget https://gitee.com/su_ze1688/public_tools/raw/master/gn/$target_os/gn
#mv gn prebuilts/$target_os/
#chmod +x prebuilts/$target_os/gn
exit
fi
-if [ ! -f "prebuilts/$target_os/ninja" ];then
+if [ ! -f "prebuilts/$gn_path/ninja" ];then
echo "you may get ninja for $target_os and place it in prebuilts/$target_os"
- ehco "the file can be get at https://gitee.com/su_fu/public_tools/raw/master/gn/$target_os/ninja, you need to download it manually"
- #wget "https://gitee.com/su_fu/public_tools/raw/master/gn/$target_os/ninja"
- #wget https://gitee.com/su_fu/public_tools/raw/master/gn/$target_os/ninja
+ ehco "the file can be get at https://gitee.com/su_ze1688/public_tools/raw/master/gn/$target_os/ninja, you need to download it manually"
+ #wget "https://gitee.com/su_ze1688/public_tools/raw/master/gn/$target_os/ninja"
+ #wget https://gitee.com/su_ze1688/public_tools/raw/master/gn/$target_os/ninja
#mv ninja prebuilts/$target_os/
#chmod +x prebuilts/$target_os/*
exit
fi
echo "$is_clean"
+if [ $target == 'test' ] || [ $target == 'fuzz' ] || [ $target='wasm' ] || [ $target='sdkdemo' ] || [ $target='sdkdemotest' ];then
+ target_dir=$target
+else
+ target_dir=$target_os
+fi
+if [ $target == 'trace_streamer' ] || [ $target == 'trace' ];then
+ target_dir=$target_os
+fi
+echo "target_dir:" $target_dir
+# exit
if [ "$is_clean" == 'true' ];then
- prebuilts/$target_os/gn gen out/"$target_os""$ext" --clean
- prebuilts/$target_os/ninja -C out/"$target_os""$ext" -t clean
+ prebuilts/$gn_path/$gn gen out/"$target_dir""$ext" --clean
+ prebuilts/$gn_path/$ninja -C out/"$target_dir""$ext" -t clean
else
- prebuilts/$target_os/gn gen out/"$target_os""$ext" --args='is_debug='"$is_debug"' target_os="'"$target_os"'"'
+ prebuilts/$gn_path/$gn gen out/"$target_dir""$ext" --args='is_debug='"$is_debug"' target="'"$target"'" target_os="'"$target_os"'"'
echo "begin to build ..."
mkdir -p out/windows
touch out/windows/trace_streamer.exe
- prebuilts/$target_os/ninja -v -C out/"$target_os""$ext"
+ prebuilts/$gn_path/$ninja -C out/"$target_dir""$ext"
+ if [ $target_dir == 'protoc' ];then
+ mv out/"$target_dir""$ext"/$target_dir out/$target_os/
+ fi
+ # prebuilts/$gn_path/ninja -C out/"$target_os""$ext"
fi
diff --git a/host/trace_streamer/build/test.gni b/host/trace_streamer/build/test.gni
index 6912354f710b31f32341dfbd16e51f3d78cef2be..8bdf099d0885508f019e08b7d705a0acd5ea229e 100644
--- a/host/trace_streamer/build/test.gni
+++ b/host/trace_streamer/build/test.gni
@@ -21,5 +21,28 @@ template("ohos_unittest") {
if (defined(invoker.ldflags)) {
print(invoker.ldflags)
}
+ if (defined(invoker.cflags)) {
+ print(invoker.cflags)
+ cflags += invoker.cflags
+ }
+ }
+}
+
+template("ohos_fuzztest") {
+ executable(target_name) {
+ forward_variables_from(invoker, "*")
+ testonly = true
+ deps = []
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ if (defined(invoker.cflags)) {
+ cflags += invoker.cflags
+ }
+ ldflags += [ "-fsanitize=fuzzer" ]
+ cflags += [
+ "-fno-sanitize-coverage=trace-pc-guard,edge,trace-cmp,indirect-calls,8bit-counters",
+ "-fsanitize=fuzzer",
+ ]
}
}
diff --git a/host/trace_streamer/doc/README.md b/host/trace_streamer/doc/README.md
index eb0deec07b8f4c55fed4152454f49cad6d721cb9..0e4093eef3b2d8f65ccf69e1eacacc5db6bf9027 100644
--- a/host/trace_streamer/doc/README.md
+++ b/host/trace_streamer/doc/README.md
@@ -1,309 +1,167 @@
-# trace_streamer工具说明
-trace_streamer工具可以2种方式使用
+# TraceStreamer工具说明
+TraceStreamer是一个trace数据解析程序,可以将一个trace文本文件或者基于proto序列化的二进制文件转换成为sqlite数据库的形式。 TraceStreamer使用C++实现,支持在ohos, linux, mac等系统上使用,具有良好的跨平台特性。
+![GitHub Logo](../figures/trace_streamer_stream.png)
+## 关于TraceStreamer的使用说明
+TraceStreamer工具可以2种方式使用
1. 可以将系统离线trace文件解析并转为db,此工具支持基于文本的trace和基于proto的trace。
-2. trace_streamer工具还可以WebAssembly的方式在浏览器中运行,需暴露相关接口给js文件。
-
-## 关于trace解析工具的使用说明:
+2. TraceStreamer工具还可以WebAssembly的方式在浏览器中运行,提供相关接口给js文件调用。
+
### 导出db模式
-在导出db模式下,trace_streamer.exe trace文件路径名 -e 导出db路径名.db
-此命令可以将trace文件转为db
-本应用支持在ohos, linux, windows, mac使用。
-关于db文件的说明:
-使用db查看工具查看stat表,可以浏览当前数据一共有多少类数据,各类数据都收到多少条,数据是否正常等情况。在meta表会记录数据库导出时的一些系统信息,比如导入和导出的文件全路径,解析时间等信息。
-meta表可以选择不导出(有些情况下会暴露系统敏感信息),在导出时添加 -nm选项即可。
-在数据导出之后,会在本地目录下生成一个trace_streamer.log文件,在导出db的目录下生成一个数据库文件同名,.db.ohos.ts后缀的文件
-文件内容如下:
-时间戳:执行结果(数字)
-应用运行时间
+在导出db模式下,通过下面的指令:
+```
+./trace_streamer trace文件路径名 -e 导出db路径名.db
+```
+可以将trace文件转为db文件。
+本应用支持在ohos, linux, mac使用。
+在数据导出之后,会在本地目录下生成一个trace_streamer.log文件,在导出db的目录下生成一个数据库文件同名,.db.ohos.ts后缀的文件。
+文件内容如下:
+```
+当前时间戳:执行结果(数字)
+应用运行时间
+```
+执行结果解释如下:
+```
+0 代表执行成功 1 表示输入文件不匹配, 2 表示解析错误, 3其他错误。
+```
+#### __关于db文件的说明__
+可以使用sqliteexport或DB Browser for SQLite工具加载生成的db,通过查看stat表,可以浏览当前数据一共有多少类数据,各类数据都收到多少条,数据是否正常等情况。在meta表会记录数据库导出时的一些系统信息,比如导入和导出的文件全路径,解析时间等信息。
+meta表可以选择不导出,在导出时添加 -nm选项即可。
+更多db文件的介绍,可以参考[des_tables.md](des_tables.md)。
-执行结果解释如下:0 代表执行成功 1 表示输入文件不匹配, 2 表示解析错误, 3其他错误
-### 内置浏览器方式
-trace_streamer可以WebAssembly方式在浏览器中运行,暴露如下接口给js
+### 内置浏览器模式
+TraceStreamer可以WebAssembly方式在浏览器中运行,相关接口在wasm模式下生成的trace_streamer_builtin.js文件中,js可以使用的接口如下使用如下接口访问trace_streamer:
```
extern "C" {
-/* 上传trace数据
+/* 初始化wasm,在JS中注册回调函数,并返回一段可复用的内存空间,由JS调用
*
- * @data: 数据的缓冲区
- * @dataLen: 数据长度
+ * @ replyFunction: 回调函数
+* @ reqBufferSize: 返回的内存长度
+* return: 返回一段内存地址给JS
+*/
+EMSCRIPTEN_KEEPALIVE uint8_t* Initialize(ReplyFunction replyFunction, uint32_t reqBufferSize)
+
+/* 更新起始结束时间,由JS调用
+ *
+ * @ len: 起始和结束时间组成的字符串长度
+* return: 成功返回0。
+*/
+EMSCRIPTEN_KEEPALIVE int UpdateTraceTime(int len)
+
+/* 设置TraceStreamer和第三方wasm通信的回调函数,并返回一段内存,由JS调用
*
- * return: 0:成功; -1:失败
+ * @ sendDataCallBack:与第三方wasm通信的回调函数
+* @ reqBufferSize: 返回的内存长度
+* return: 成功返回0
*/
-EMSCRIPTEN_KEEPALIVE int TraceStreamerParseData(const uint8_t* data, int dataLen);
+EMSCRIPTEN_KEEPALIVE uint8_t* TraceStreamer_Set_ThirdParty_DataDealer(SendDataCallBack sendDataCallBack, uint32_t reqBufferSize)
-/* 通知TS上传trace数据结束
- *
- * return: 0:成功; -1:失败
+/* TraceStreamer的数据解析接口,由JS调用
+ *
+* @ dataLen: 需要解析的数据源长度
+* return: 成功返回0,失败返回-1
+*/
+EMSCRIPTEN_KEEPALIVE int TraceStreamerParseDataEx(int dataLen)
+
+/* TraceStreamer停止解析数据,由JS调用
+ *
+* return: 成功返回0,失败返回-1
+*/
+EMSCRIPTEN_KEEPALIVE int TraceStreamerParseDataOver()
+
+/* 数据库操作接口,由JS调用
+ *
+* @ sqlLen: 需要执行的操作类sql语句长度
+* return: 成功返回0,失败返回-1
+*/
+EMSCRIPTEN_KEEPALIVE int TraceStreamerSqlOperateEx(int sqlLen)
+
+/*清空wasm内存中的内容,由JS调用
+ *
+* return: 成功返回0,失败返回-1
*/
-EMSCRIPTEN_KEEPALIVE int TraceStreamerParseDataOver();
+EMSCRIPTEN_KEEPALIVE int TraceStreamerReset()
-/* 通过sql语句操作数据库
+/*执行查询类sql语句,由JS调用
*
- * @sql: sql语句
- * @sqlLen: sql语句长度
+* @ sqlLen: 需要执行的查询类sql语句长度
+* return: 成功返回0,失败返回-1
+*/
+EMSCRIPTEN_KEEPALIVE int TraceStreamerSqlQueryEx(int sqlLen)
+
+/*取消sql查询,由JS调用。
*
- * return: 0:成功; -1:失败
+* return: 成功返回0。
*/
-EMSCRIPTEN_KEEPALIVE int TraceStreamerSqlOperate(const uint8_t* sql, int sqlLen);
+EMSCRIPTEN_KEEPALIVE int TraceStreamerCancel()
-/* 通过sql语句查询数据库
+/*发送数据给第三方wasm解析,由TraceStreamer调用
*
- * @sql: sql语句
- * @sqlLen: sql语句长度
- * @out: 查询结果的缓冲区,查询结果为json
- * @outLen: 缓冲区长度
+* @ pluginData: 第三方插件的数据源
+* @ len: 数据源长度
+* @ componentName: 第三方插件名称
+* return: 成功返回0
+*/
+int TraceStreamer_Plugin_Out_SendData(const char* pluginData, int len, const std::string componentName)
+
+/* 初始化配置接口,由JS调用
*
- * return: >0:查询成功,返回查询结果数据长度; -1:失败
+* @ dataLen: 配置字符串的长度
+* return: 成功返回0
*/
-EMSCRIPTEN_KEEPALIVE int TraceStreamerSqlQuery(const uint8_t* sql, int sqlLen, uint8_t* out, int outLen);
+EMSCRIPTEN_KEEPALIVE int TraceStreamer_Init_ThirdParty_Config(int dataLen)
} // extern "C"
```
-
### 你也可以执行如下命令查看应用帮助
-./trace_streamer --help
--i 选项可查看应用支持的事件源和具体的事件名列表
+```./trace_streamer --help```
-#### trace_streamer支持的事件解析
-本工具支持基于文本的trace(# TRACE)和基于proto的二进制日志文件的解析,支持的事件列表如下:
-##### ftrace事件
-```
-binder_transaction
-binder_transaction_received
-binder_transaction_alloc_buf
-binder_transaction_lock
-binder_transaction_locked
-binder_transaction_unlock
-sched_switch
-task_rename
-task_newtask
-tracing_mark_write
-print
-sched_wakeup
-sched_waking
-cpu_idle
-cpu_frequency
-suspend_resume
-workqueue_execute_start
-workqueue_execute_end
-clock_set_rate
-clock_enable
-clock_disable
-clk_set_rate
-clk_enable
-clk_disable
-sys_enter
-sys_exit
-regulator_set_voltage
-regulator_set_voltage_complete
-regulator_disable
-regulator_disable_complete
-ipi_entry
-ipi_exit
-irq_handler_entry
-irq_handler_exit
-softirq_raise
-softirq_entry
-softirq_exit
-sched_wakeup_new
-sched_process_exit
-trace_event_clock_sync
-```
-##### 内存事件
-```
-mem.vm.size
-mem.rss
-mem.rss.anon
-mem.rss.file
-mem.rss.schem
-mem.swap
-mem.locked
-mem.hwm
-mem.oom_score_adj
-```
-##### 系统内存事件
-```
-sys.mem.unspecified
-sys.mem.total
-sys.mem.free
-sys.mem.avaiable
-sys.mem.buffers
-sys.mem.cached
-sys.mem.swap.chard
-sys.mem.active
-sys.mem.inactive
-sys.mem.active.anon
-sys.mem.inactive.anon
-sys.mem.active_file
-sys.mem.inactive_file
-sys.mem.unevictable
-sys.mem.mlocked
-sys.mem.swap.total
-sys.mem.swap.free
-sys.mem.dirty
-sys.mem.writeback
-sys.mem.anon.pages
-sys.mem.mapped
-sys.mem.shmem
-sys.mem.slab
-sys.mem.slab.reclaimable
-sys.mem.slab.unreclaimable
-sys.mem.kernel.stack
-sys.mem.page.tables
-sys.mem.commit.limit
-sys.mem.commited.as
-sys.mem.vmalloc.total
-sys.mem.vmalloc.used
-sys.mem.vmalloc.chunk
-sys.mem.cma.total
-sys.mem.cma.free
-```
-##### 系统虚拟内存事件
-```
-sys.virtual.mem.unspecified
-sys.virtual.mem.nr.free.pages
-sys.virtual.mem.nr.alloc.batch
-sys.virtual.mem.nr.inactive.anon
-sys.virtual.mem.nr.active_anon
-sys.virtual.mem.nr.inactive.file
-sys.virtual.mem.nr.active_file
-sys.virtual.mem.nr.unevictable
-sys.virtual.mem.nr.mlock
-sys.virtual.mem.anon.pages
-sys.virtual.mem.nr.mapped
-sys.virtual.mem.nr.file.pages
-sys.virtual.mem.nr.dirty
-sys.virtual.mem.nr.writeback
-sys.virtual.mem.nr.slab.reclaimable
-sys.virtual.mem.nr.slab.unreclaimable
-sys.virtual.mem.nr.page_table.pages
-sys.virtual.mem.nr_kernel.stack
-sys.virtual.mem.nr.overhead
-sys.virtual.mem.nr.unstable
-sys.virtual.mem.nr.bounce
-sys.virtual.mem.nr.vmscan.write
-sys.virtual.mem.nr.vmscan.immediate.reclaim
-sys.virtual.mem.nr.writeback_temp
-sys.virtual.mem.nr.isolated_anon
-sys.virtual.mem.nr.isolated_file
-sys.virtual.mem.nr.shmem
-sys.virtual.mem.nr.dirtied
-sys.virtual.mem.nr.written
-sys.virtual.mem.nr.pages.scanned
-sys.virtual.mem.workingset.refault
-sys.virtual.mem.workingset.activate
-sys.virtual.mem.workingset_nodereclaim
-sys.virtual.mem.nr_anon.transparent.hugepages
-sys.virtual.mem.nr.free_cma
-sys.virtual.mem.nr.swapcache
-sys.virtual.mem.nr.dirty.threshold
-sys.virtual.mem.nr.dirty.background.threshold
-sys.virtual.mem.vmeminfo.pgpgin
-sys.virtual.mem.pgpgout
-sys.virtual.mem.pgpgoutclean
-sys.virtual.mem.pswpin
-sys.virtual.mem.pswpout
-sys.virtual.mem.pgalloc.dma
-sys.virtual.mem.pgalloc.normal
-sys.virtual.mem.pgalloc.movable
-sys.virtual.mem.pgfree
-sys.virtual.mem.pgactivate
-sys.virtual.mem.pgdeactivate
-sys.virtual.mem.pgfault
-sys.virtual.mem.pgmajfault
-sys.virtual.mem.pgrefill.dma
-sys.virtual.mem.pgrefill.normal
-sys.virtual.mem.pgrefill.movable
-sys.virtual.mem.pgsteal.kswapd.dma
-sys.virtual.mem.pgsteal.kswapd.normal
-sys.virtual.mem.pgsteal.kswapd.movable
-sys.virtual.mem.pgsteal.direct.dma
-sys.virtual.mem.pgsteal.direct.normal
-sys.virtual.mem.pgsteal_direct.movable
-sys.virtual.mem.pgscan.kswapd.dma
-sys.virtual.mem.pgscan_kswapd.normal
-sys.virtual.mem.pgscan.kswapd.movable
-sys.virtual.mem.pgscan.direct.dma
-sys.virtual.mem.pgscan.direct.normal
-sys.virtual.mem.pgscan.direct.movable
-sys.virtual.mem.pgscan.direct.throttle
-sys.virtual.mem.pginodesteal
-sys.virtual.mem.slabs_scanned
-sys.virtual.mem.kswapd.inodesteal
-sys.virtual.mem.kswapd.low.wmark.hit.quickly
-sys.virtual.mem.high.wmark.hit.quickly
-sys.virtual.mem.pageoutrun
-sys.virtual.mem.allocstall
-sys.virtual.mem.pgrotated
-sys.virtual.mem.drop.pagecache
-sys.virtual.mem.drop.slab
-sys.virtual.mem.pgmigrate.success
-sys.virtual.mem.pgmigrate.fail
-sys.virtual.mem.compact.migrate.scanned
-sys.virtual.mem.compact.free.scanned
-sys.virtual.mem.compact.isolated
-sys.virtual.mem.compact.stall
-sys.virtual.mem.compact.fail
-sys.virtual.mem.compact.success
-sys.virtual.mem.compact.daemon.wake
-sys.virtual.mem.unevictable.pgs.culled
-sys.virtual.mem.unevictable.pgs.scanned
-sys.virtual.mem.unevictable.pgs.rescued
-sys.virtual.mem.unevictable.pgs.mlocked
-sys.virtual.mem.unevictable.pgs.munlocked
-sys.virtual.mem.unevictable.pgs.cleared
-sys.virtual.mem.unevictable.pgs.stranded
-sys.virtual.mem.nr.zspages
-sys.virtual.mem.nr.ion.heap
-sys.virtual.mem.nr.gpu.heap
-sys.virtual.mem.allocstall.dma
-sys.virtual.mem.allocstall.movable
-sys.virtual.mem.allocstall.normal
-sys.virtual.mem.compact_daemon.free.scanned
-sys.virtual.mem.compact.daemon.migrate.scanned
-sys.virtual.mem.nr.fastrpc
-sys.virtual.mem.nr.indirectly.reclaimable
-sys.virtual.mem.nr_ion_heap_pool
-sys.virtual.mem.nr.kernel_misc.reclaimable
-sys.virtual.mem.nr.shadow_call.stack_bytes
-sys.virtual.mem.nr.shmem.hugepages
-sys.virtual.mem.nr.shmem.pmdmapped
-sys.virtual.mem.nr.unreclaimable.pages
-sys.virtual.mem.nr.zone.active.anon
-sys.virtual.mem.nr.zone.active.file
-ys.virtual.mem.nr.zone.inactive_anon
-sys.virtual.mem.nr.zone.inactive_file
-sys.virtual.mem.nr.zone.unevictable
-sys.virtual.mem.nr.zone.write_pending
-sys.virtual.mem.oom.kill
-sys.virtual.mem.pglazyfree
-sys.virtual.mem.pglazyfreed
-sys.virtual.mem.pgrefill
-sys.virtual.mem.pgscan.direct
-sys.virtual.mem.pgscan.kswapd
-sys.virtual.mem.pgskip.dma
-sys.virtual.mem.pgskip.movable
-sys.virtual.mem.pgskip.normal
-sys.virtual.mem.pgsteal.direct
-sys.virtual.mem.pgsteal.kswapd
-sys.virtual.mem.swap.ra
-sys.virtual.mem.swap.ra.hit
-```
+### TraceStreamer支持解析的事件列表
+通过```./trace_streamer -i```
+查看支持的事件列表。
+支持的事件列表参见[SupportEventList.md](des_support_event.md)。
-## trace_streamer开发环境搭建和编译运行指引
+## TraceStreamer重要概念介绍
+### 进程和线程标识符
+在通用操作系统中,进程号(pid/tgid)和线程号(tid)可能会被重复用于标识不同的进程或者线程。所以在trace数据源中,进程号(pid)和线程号(tid)也可能被重用。
+TraceStreamer在解析数据过程中,使用ipid(internal pid)唯一标识进程, itid(internal tid)唯一标识线程。
-本应用使用gn作为构建工具,支持在linux环境同时编译linux,windows和mac使用QtCreator作为开发IDE
-### 1、开发环境
-ubuntu使用vscode,windows和mac使用QtCreator
-# 对外部的依赖
-本应用依赖与sqlite,protobuf(htrace解析部分依赖)
+### 计量器
+用来记录系统中各种随时间连续变化的数值。例如: CPU的频率, 内存的使用量, 界面刷新频率。
+#### 举例
+CPU频率:
+![GitHub Logo](../figures/cpu_frequency.png)
+内存占用:
+![GitHub Logo](../figures/mem_usage.png)
+
+### 过滤器
+TraceStreamer设计过程中使用了流式处理的思想,数据从入口进入以后,就像进入一条河流,从上游流向下游,在河道中央有很多过滤器,每种过滤器会将流过的数据中自己关注的内容吸附捕捉到。最终,每个过滤器都拥有了大量同类型的数据,而且这些数据都是按时间序列排列的。TraceStreamer使用filterid来标识同一种用途的数据,可以方便在UI中绘制。
+![GitHub Logo](../figures/filters.png)
+
+## Stat表设计
+具体内容参见 [des_stat](des_stat.md)
+## TraceStreamer开发环境搭建和编译运行指引
-本应用同时依赖于src/protos目录下文件来生成相关pb.h,pb.cc文件
+本应用使用gn作为构建工具。
+### 开发环境
+可以在ubuntu、mac、windows下执行开发和编译,建议使用vscode开发工具。
+在windows平台上,需使用支持c++17标准的clang编译器。
+# 对外部的依赖
+本应用依赖与sqlite、protobuf(htrace解析部分依赖)、nlohmann_json。
+本应用同时依赖于src/protos/protogen.sh目录下文件来生成相关pb.h,pb.cc文件
+_____
-### 2.1、 编译linux版应用
-在根目录下执行相关命令进行编译
+### 编译linux和Mac应用
+在目录下有build.sh脚本,在不同的平台上会判断系统版本,编译相应系统的应用
+```
+./build.sh linux
+./build.sh macx
+```
-### 2.2、编译Windows版和Mac应用
-在项目目录下有pro文件,为QtCreator的工程文件,但部分内容赖在于上面所添加的外部依赖,如果要编译相关平台应用,开发者需自行补充相关工程文件,或者在论坛留言
+### 编译wasm
+```
+./build.sh wasm
+```
-### 2.3、开始编译
-具体方法可参考《compile_trace_streamer.md》
\ No newline at end of file
+### 开始编译
+本工具建议独立编译, 通过部署第三方依赖库,emsdk,可编译出支持不同平台的应用。
+具体方法可参考[compile_trace_streamer](compile_trace_streamer.md)。
\ No newline at end of file
diff --git a/host/trace_streamer/doc/compile_trace_streamer.md b/host/trace_streamer/doc/compile_trace_streamer.md
new file mode 100755
index 0000000000000000000000000000000000000000..b86f4aca6c41e5e2c8a4b2792c08e8b073df9116
--- /dev/null
+++ b/host/trace_streamer/doc/compile_trace_streamer.md
@@ -0,0 +1,195 @@
+# 如何独立编译TraceStreamer
+尽管TraceStreamer是在ohos工具箱中的一员,但您依然可以独立编译此工具。
+
+TraceStreamer可以编译为命令行下的可执行程序,或者WebAssembly程序。
+
+本工具默认编译方式是使用gn。
+## 编译步骤
+### 处理第三方库
+处理第三方库,您可以使用pare_third_party.sh文件来下载第三方库并做适当的处理,您需要在码云上添加您的ssh公钥,也可以按下面的步骤。
+如果pare_third_party.sh脚本出现问题,您需要按如下的步骤做检查。
+因为需要同时支持pc和WebAssembly环境,TraceStreamer构造了一个独立编译编译的环境,需对第三方库的gn脚本做适当的修改,可按下面的步骤进行。
+third_party相关控件下载链接:https://gitee.com/organizations/openharmony/projects
+在TraceStreamer的src同级目录下创建third_party目录。
+下面依次处理各个第三方库。
+#### sqlite
+1. 在第三方库中,找到并下载sqlite组件(ssh clone git@gitee.com:openharmony/third_party_sqlite.git);
+2. 把下载的文件解压后,文件夹命名为sqlite放入到third_party目录中;
+3. 使用下面的命令,把sqlite的BUILD.gn修改为TraceStreamer适用的风格。
+```
+patch -p0 third_party/sqlite/BUILD.gn prebuilts/patch_sqlite/sqlite3build.gn.patch
+```
+#### protobuf
+1. 在第三方库中,找到并下载protobuf组件(git clone git@gitee.com:openharmony/third_party_protobuf.git);
+2. 把下载的文件解压后,文件夹命名为protobuf,放入到third_party目录中;
+3. 使用下面的命令,把protobuf的BUILD.gn修改为TraceStreamer适用的风格。
+```
+patch -p0 third_party/protobuf/BUILD.gn prebuilts/patch_protobuf/protobufbuild.gn.patch
+```
+#### googletest
+1. 在第三方库中,找到并下载googletest组件(git clone git@gitee.com:openharmony/third_party_googletest.git);
+2. 把googletest文件夹放入third_party目录中;
+3. 使用下面的命令,把googletest的BUILD.gn修改为TraceStreamer适用的风格。
+```
+patch -p0 third_party/googletest/BUILD.gn prebuilts/patch_googletest/googletestbuild.gn.patch
+```
+4. 处理一系列public权限问题,处理原则是,但凡是有问题头文件的上下添加
+```
+#undef private
+#define private private
+#include // 加入这里是编译有问题的头文件
+#undef private
+#define private public
+```
+目前已知的需处理的地方有
+```
+gtest-message.h文件
++#undef private
++#define private private
+ #include
+-
++#undef private
++#define private public
+
+gtest.h文件
+-
++#undef private
++#define private private
+ #include "gtest/internal/gtest-internal.h"
++#undef private
++#define private public
+
+ gtest-tag.h文件
+ 第13行注释即可
+### nlohmann_json
+gtest-internal.h
++#undef private
++#define private private
+ #include
++#undef private
++#define private public
+
+gtest-port.h文件
++#undef private
++#define private private
+#include // NOLINT
++#undef private
++#define private public
+```
+#### json库
+1. 在第三方库中,找到并下载third_party_json库(git clone git@gitee.com:openharmony/third_party_json.git);
+2. 把下载的文件解压后,文件夹命名为json-master,放入到third_party目录中。
+
+#### libunwind
+1. 在第三方库中,找到并下载libunwind组件(git clone git@gitee.com:openharmony/third_party_libunwind.git);
+2. 把libunwind文件夹放入third_party目录中;
+3. 使用下面的命令,把libunwind的BUILD.gn修改为TraceStreamer适用的风格。
+```
+patch -p0 third_party/libunwind/BUILD.gn prebuilts/patch_libunwind/libunwindbuild.gn.patch
+```
+third_party/libunwind/src/x86_64/unwind_i.h
+第60行,注释
+```
+// #define setcontext UNW_ARCH_OBJ (setcontext)
+```
+#### 其他文件
+为了独立编译trace_streamer,你还需要在third_party目录下有2个文件
+```
+third_party/perf_include/
+├── libbpf
+│ └── linux
+│ └── perf_event.h
+└── musl
+ └── elf.h
+```
+perf_event.h文件位于如下目录,需打补丁
+wget https://gitee.com/openharmony/third_party_libbpf/raw/master/include/uapi/linux/perf_event.h
+patch -p0 perf_event.h prebuilts/patch_perf_event/perf_event.h.patch
+elf.h文件来自于musl/include/elf.h 使用原始文件,不用打补丁
+wget https://gitee.com/openharmony/third_party_musl/raw/master/include/elf.h
+
+### 开始编译
+#### 预置条件
+1. 您需要先获取一个可用的protoc可执行文件,或者在linux平台上执行:
+```
+./build.sh protoc
+```
+来生成可用的protoc可执行的程序。
+
+2. 生成proto相关文件对应的pb.h或pb.cc文件
+可执行如下脚本来完成:
+```
+./src/protos/protogen.sh
+```
+#### 编译linux、mac、windows平台的TraceStreamer
+编译不同平台的程序,您需要在各自的PC环境编译,编译脚本会自行识别平台并编译程序。
+目前wasm版本仅支持在linux平台编译。
+编译不同版本:linux, windows, mac
+注意,windows上目前支持Mingw编译,使用的mingw版本为 gcc version 8.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project)
+```
+./build.sh
+```
+特别地,如果您需要编译debug版本的应用,只需要输入debug标识即可,否则,默认是release版本的应用。
+```
+./build.sh linux debug
+```
+生成的可执行文件分别位于如下路径:
+```
+out/linux
+out/windows
+out/macx
+out/linux_debug
+```
+___在不同的平台上,均需要gn和ninja的可执行文件来执行gn工程相关的操作,比如,windows上是gn.exe和ninja.exe。
+在https://gitee.com/su_ze1688/public_tools/tree/master/gn目录下,您可以获取不同平台下可用的gn和ninja可执行文件,同时,为linux平台下提供了protoc可执行文件。您可以下载并部署在本地的prebuilts目录下。您也可以在linux平台下执行:___
+```
+./build.sh protoc
+```
+___来生成out/linux/protoc可执行文件。___
+#### 编译WebAssembly版本
+如果需要编译WebAssembly版本,您需要在prebuilts/目录下安装emsdk。
+步骤如下:
+1. 在任何目录下载emsdk
+```
+git clone https://github.com/juj/emsdk.git --depth=1
+cd emsdk
+git pull
+./emsdk update # this may not work, ignore it
+./emsdk install latest
+./emsdk activate latest
+```
+2. 部署emsdk到编译工具目录
+您将刚刚下载和安装的emsdk目录下的 upstream/* 复制到prebuilts/emsdk/emsdk,node/* 复制到prebuilts/emsdk/node。
+安装之后,目录结构当如下:
+```
+prebuilts/emsdk
+├── prebuilts/emsdk/emsdk
+│ ├── prebuilts/emsdk/emsdk/bin
+│ ├── prebuilts/emsdk/emsdk/emscripten
+│ │ ├── prebuilts/emsdk/emsdk/emscripten/cache
+│ │ ├── prebuilts/emsdk/emsdk/emscripten/cmake
+│ │ ├── prebuilts/emsdk/emsdk/emscripten/docs
+│ │ ├── prebuilts/emsdk/emsdk/emscripten/media
+│ │ ├── prebuilts/emsdk/emsdk/emscripten/node_modules
+│ │ ├── prebuilts/emsdk/emsdk/emscripten/__pycache__
+│ │ ├── prebuilts/emsdk/emsdk/emscripten/src
+│ │ ├── prebuilts/emsdk/emsdk/emscripten/system
+│ │ ├── prebuilts/emsdk/emsdk/emscripten/tests
+│ │ ├── prebuilts/emsdk/emsdk/emscripten/third_party
+│ │ └── prebuilts/emsdk/emsdk/emscripten/tools
+│ ├── prebuilts/emsdk/emsdk/include
+│ │ └── prebuilts/emsdk/emsdk/include/c++
+│ └── prebuilts/emsdk/emsdk/lib
+│ └── prebuilts/emsdk/emsdk/lib/clang
+└── prebuilts/emsdk/node
+ └── prebuilts/emsdk/node/14.18.2_64bit
+ ├── prebuilts/emsdk/node/14.18.2_64bit/bin
+ ├── prebuilts/emsdk/node/14.18.2_64bit/include
+ ├── prebuilts/emsdk/node/14.18.2_64bit/lib
+ └── prebuilts/emsdk/node/14.18.2_64bit/share
+```
+之后,在TraceStream代码根目录,也就是这个文档的上级目录下执行:
+```
+./build.sh wasm
+```
+您需要将sh脚本进行部分修改,因为这个脚本内置了一些库的下载和解析方式,您也可以在您的编译环境对此脚本做定制修改。
\ No newline at end of file
diff --git a/host/trace_streamer/doc/compiler_ut.md b/host/trace_streamer/doc/compiler_ut.md
new file mode 100644
index 0000000000000000000000000000000000000000..2c2accf3f9170f1406c80d182487d14e1278124c
--- /dev/null
+++ b/host/trace_streamer/doc/compiler_ut.md
@@ -0,0 +1,27 @@
+# 编译UT
+直接运行./build.sh test 即可编译ut代码,编译ut时,可能会遇到一些问题,需要将部分代码做如下处理:
+v412.pb.h 大约第36行,添加如下内容
+```
+#ifdef major
+#undef major
+#endif
+#ifdef minor
+#undef minor
+#endif
+```
+gtest-port.h 第286行,在
+```
+#include
+```
+修改为
+```
+#undef private
+#define private private
+#include
+#undef private
+#define private public
+```
+
+在ut代码编译完成之后,直接运行./test.sh,可以执行所有ut,显示正确与否。
+在ut执行之后,直接运行./lcov.sh,可以生成覆盖率报告。
+覆盖率报告位于out/test/html目录。
\ No newline at end of file
diff --git a/host/trace_streamer/doc/des_binder.md b/host/trace_streamer/doc/des_binder.md
new file mode 100644
index 0000000000000000000000000000000000000000..7af5fc8a159ce548f6b9d7d95dad4093ce5a265f
--- /dev/null
+++ b/host/trace_streamer/doc/des_binder.md
@@ -0,0 +1,62 @@
+# binder事件上下文如何关联
+binder事件相对复杂,这里是从ftrace事件中抽离出来的binder相关消息,用来作为开发者或用户追踪binder事件的参考
+a binder event is identified by the sender and receive device, and a reply message only end
+the last binder msg which reply the calling one.
+the alloc_buf msg can always flow the binder_transaction, so we no need to identify the alloc msg with transactionID
+
+## TAG TT need reply!!! needReply = !isReply && !(flags & 0x01);
+```
+RenderThread-2267 ( 1592) [003] ...1 168766.128108: binder_transaction: transaction=25155526 dest_node=25155471 dest_proc=506 dest_thread=0 reply=0 flags=0x10 code=0x9
+RenderThread-2267 ( 1592) [003] ...1 168766.128110: binder_transaction_alloc_buf: transaction=25155526 data_size=120 offsets_size=8
+```
+### received
+```
+Binder:506_2-537 ( 506) [003] ...1 168766.128154: binder_transaction_received: transaction=25155526
+```
+### binder is in DB, TAG A needReply
+```
+Binder:506_2-537 ( 506) [003] ...1 168766.128221: binder_transaction: transaction=25155529 dest_node=25155527 dest_proc=1592 dest_thread=2267 reply=0 flags=0x10 code=0x5f474854
+Binder:506_2-537 ( 506) [003] ...1 168766.128223: binder_transaction_alloc_buf: transaction=25155529 data_size=72 offsets_size=0
+```
+##
+```
+RenderThread-2267 ( 1592) [003] ...1 168766.128243: binder_transaction_received: transaction=25155529
+```
+### the flowing is for TAG A, this is the reply for TAG A
+```
+RenderThread-2267 ( 1592) [003] ...1 168766.128262: binder_transaction: transaction=25155530 dest_node=0 dest_proc=506 dest_thread=537 reply=1 flags=0x8 code=0x0
+
+RenderThread-2267 ( 1592) [003] ...1 168766.128264: binder_transaction_alloc_buf: transaction=25155530 data_size=4 offsets_size=0
+```
+### calc the dur of TAG A
+```
+Binder:506_2-537 ( 506) [003] ...1 168766.128288: binder_transaction_received: transaction=25155530
+```
+### binder last TAG A needReply, this is TAG B needReply!!!
+```
+Binder:506_2-537 ( 506) [003] ...1 168766.128328: binder_transaction: transaction=25155532 dest_node=25155527 dest_proc=1592 dest_thread=2267 reply=0 flags=0x10 code=0x2
+Binder:506_2-537 ( 506) [003] ...1 168766.128330: binder_transaction_alloc_buf: transaction=25155532 data_size=72 offsets_size=0
+```
+## in db
+```
+RenderThread-2267 ( 1592) [003] ...1 168766.128347: binder_transaction_received: transaction=25155532
+```
+## the reply message is not in db Session D, this is the reply for TAG B
+```
+RenderThread-2267 ( 1592) [003] ...1 168766.128361: binder_transaction: transaction=25155533 dest_node=0 dest_proc=506 dest_thread=537 reply=1 flags=0x0 code=0x0
+RenderThread-2267 ( 1592) [003] ...1 168766.128363: binder_transaction_alloc_buf: transaction=25155533 data_size=4 offsets_size=0
+```
+### no this message in db, calcate the dur of TAG B
+```
+Binder:506_2-537 ( 506) [003] ...1 168766.128385: binder_transaction_received: transaction=25155533
+```
+### no this message in db Session E, this is the reply for TAG TT
+```
+Binder:506_2-537 ( 506) [003] ...1 168766.128412: binder_transaction: transaction=25155534 dest_node=0 dest_proc=1592 dest_thread=2267 reply=1 flags=0x0 code=0x0
+
+Binder:506_2-537 ( 506) [003] ...1 168766.128413: binder_transaction_alloc_buf: transaction=25155534 data_size=68 offsets_size=0
+```
+## the dur of TAG TT is calcated by the flowing msg
+```
+RenderThread-2267 ( 1592) [003] ...1 168766.128430: binder_transaction_received: transaction=25155534
+```
\ No newline at end of file
diff --git a/host/trace_streamer/doc/des_stat.md b/host/trace_streamer/doc/des_stat.md
index e1048f51e1dbb4e9fbe08a809856d2bba903a5d2..bc03e7c47d544a2e66799f2503ff586e9164a4fc 100644
--- a/host/trace_streamer/doc/des_stat.md
+++ b/host/trace_streamer/doc/des_stat.md
@@ -1,74 +1,8 @@
# TraceStreamer 解析数据状态表
-TraceStreamer使用stat表统计解析trace数据源过程遇到的重要事件状态。通过stat表可以对trace数据源中各个类型事件的数据有一个基本了解。
-## stat表支持统计的事件列表如下:
-|event_name |
-| ---- |
-|binder_transaction |
-|binder_transaction_alloc_buf |
-|binder_transaction_lock |
-|binder_transaction_locked |
-|binder_transaction_received |
-|binder_transaction_unlock |
-|clk_disable |
-|clk_enable |
-|clk_set_rate |
-|clock_disable |
-|clock_enable |
-|clock_set_rate |
-|cpu_frequency |
-|cpu_idle |
-|hidump_fps |
-|hilog |
-|ipi_entry |
-|ipi_exit |
-|irq_handler_entry |
-|irq_handler_exit |
-|memory |
-|native_hook_free |
-|native_hook_malloc |
-|oom_score_adj_update |
-|other |
-|print |
-|regulator_disable |
-|regulator_disable_complete |
-|regulator_set_voltage |
-|regulator_set_voltage_complete |
-|sched_process_exit |
-|sched_process_free |
-|sched_switch |
-|sched_wakeup |
-|sched_wakeup_new |
-|sched_waking |
-|signal_deliver |
-|signal_generate |
-|softirq_entry |
-|softirq_exit |
-|softirq_raise |
-|suspend_resume |
-|sys_enter |
-|sys_exit |
-|sys_memory |
-|sys_virtual_memory |
-|task_newtask |
-|task_rename |
-|trace_bblock_bio_queue |
-|trace_block_bio_backmerge |
-|trace_block_bio_bounce |
-|trace_block_bio_complete |
-|trace_block_bio_frontmerge |
-|trace_block_bio_remap |
-|trace_block_dirty_buffer |
-|trace_block_getrq |
-|trace_block_plug |
-|trace_block_rq_complete |
-|trace_block_rq_insert |
-|trace_block_rq_issue |
-|trace_block_rq_remap |
-|trace_event_clock_sync |
-|tracing_mark_write |
-|workqueue_execute_end |
-|workqueue_execute_start |
-
+TraceStreamer使用stat表统计解析trace数据源过程遇到的重要事件状态。通过stat表可以对trace数据源中各个类型事件的数据的数量,数据质量有一个基本了解。
+我们对不同类型的数据,统计了收到多少条,数据逻辑是否匹配,是否有不合法数据,是否有数据丢失情况,所有这些,是基于对数据格式本身和数据前后关系的主观认识。欢迎开发者提供更多的思路来帮我们完善数据本身的校验工作。
+## stat表支持统计的事件
+如[des_support_event.md](des_support_event.md)中所描述
## 事件对应解析状态:
每种事件解析数据都有5种状态,描述如下表:
|stat_type|description|
@@ -81,333 +15,18 @@ TraceStreamer使用stat表统计解析trace数据源过程遇到的重要事件
## 数据状态级别
数据状态级别总共有4种,分别是:info, warn, error,fatal。由于数据的重要性不同,不同事件的同一种状态可能对应不同的级别。
-例如binder_transaction_received的 not_supported状态的数据为info级别,而binder_transaction_alloc_buf的not_supported状态数据为warn级别。
+例如binder_transaction_received的 not_supported状态的数据为info级别,而binder_transaction_alloc_buf的not_supported状态数据为warn级别。
+
+您可以在src/cfg/trace_streamer_config.cpp的InitSecurityMap方法中自行定义相关事件的优先级。
## 事件,状态与级别对应关系
-| event_name | stat_type | serverity |
-|---- |---- |---- |
-| binder_transaction | received | info |
-| binder_transaction | data_lost | error |
-| binder_transaction | not_match | info |
-| binder_transaction | not_supported | info |
-| binder_transaction | invalid_data | error |
-| binder_transaction_received | received | info |
-| binder_transaction_received | data_lost | error |
-| binder_transaction_received | not_match | info |
-| binder_transaction_received | not_supported | info |
-| binder_transaction_received | invalid_data | error |
-| binder_transaction_alloc_buf | received | info |
-| binder_transaction_alloc_buf | data_lost | error |
-| binder_transaction_alloc_buf | not_match | info |
-| binder_transaction_alloc_buf | not_supported | warn |
-| binder_transaction_alloc_buf | invalid_data | error |
-| binder_transaction_lock | received | info |
-| binder_transaction_lock | data_lost | error |
-| binder_transaction_lock | not_match | info |
-| binder_transaction_lock | not_supported | warn |
-| binder_transaction_lock | invalid_data | error |
-| binder_transaction_locked | received | info |
-| binder_transaction_locked | data_lost | error |
-| binder_transaction_locked | not_match | info |
-| binder_transaction_locked | not_supported | warn |
-| binder_transaction_locked | invalid_data | error |
-| binder_transaction_unlock | received | info |
-| binder_transaction_unlock | data_lost | error |
-| binder_transaction_unlock | not_match | info |
-| binder_transaction_unlock | not_supported | warn |
-| binder_transaction_unlock | invalid_data | error |
-| sched_switch | received | info |
-| sched_switch | data_lost | error |
-| sched_switch | not_match | info |
-| sched_switch | not_supported | info |
-| sched_switch | invalid_data | error |
-| task_rename | received | info |
-| task_rename | data_lost | error |
-| task_rename | not_match | info |
-| task_rename | not_supported | info |
-| task_rename | invalid_data | error |
-| task_newtask | received | info |
-| task_newtask | data_lost | error |
-| task_newtask | not_match | info |
-| task_newtask | not_supported | info |
-| task_newtask | invalid_data | error |
-| tracing_mark_write | received | info |
-| tracing_mark_write | data_lost | error |
-| tracing_mark_write | not_match | info |
-| tracing_mark_write | not_supported | info |
-| tracing_mark_write | invalid_data | error |
-| print | received | info |
-| print | data_lost | error |
-| print | not_match | info |
-| print | not_supported | info |
-| print | invalid_data | error |
-| sched_wakeup | received | info |
-| sched_wakeup | data_lost | error |
-| sched_wakeup | not_match | info |
-| sched_wakeup | not_supported | info |
-| sched_wakeup | invalid_data | error |
-| sched_waking | received | info |
-| sched_waking | data_lost | error |
-| sched_waking | not_match | info |
-| sched_waking | not_supported | info |
-| sched_waking | invalid_data | error |
-| cpu_idle | received | info |
-| cpu_idle | data_lost | error |
-| cpu_idle | not_match | info |
-| cpu_idle | not_supported | info |
-| cpu_idle | invalid_data | error |
-| cpu_frequency | received | info |
-| cpu_frequency | data_lost | error |
-| cpu_frequency | not_match | info |
-| cpu_frequency | not_supported | info |
-| cpu_frequency | invalid_data | error |
-| suspend_resume | received | info |
-| suspend_resume | data_lost | error |
-| suspend_resume | not_match | info |
-| suspend_resume | not_supported | info |
-| suspend_resume | invalid_data | error |
-| workqueue_execute_start | received | info |
-| workqueue_execute_start | data_lost | error |
-| workqueue_execute_start | not_match | info |
-| workqueue_execute_start | not_supported | info |
-| workqueue_execute_start | invalid_data | error |
-| workqueue_execute_end | received | info |
-| workqueue_execute_end | data_lost | error |
-| workqueue_execute_end | not_match | info |
-| workqueue_execute_end | not_supported | warn |
-| workqueue_execute_end | invalid_data | error |
-| clock_set_rate | received | info |
-| clock_set_rate | data_lost | error |
-| clock_set_rate | not_match | info |
-| clock_set_rate | not_supported | warn |
-| clock_set_rate | invalid_data | error |
-| clock_enable | received | info |
-| clock_enable | data_lost | error |
-| clock_enable | not_match | info |
-| clock_enable | not_supported | warn |
-| clock_enable | invalid_data | error |
-| clock_disable | received | info |
-| clock_disable | data_lost | error |
-| clock_disable | not_match | info |
-| clock_disable | not_supported | warn |
-| clock_disable | invalid_data | error |
-| clk_set_rate | received | info |
-| clk_set_rate | data_lost | error |
-| clk_set_rate | not_match | info |
-| clk_set_rate | not_supported | warn |
-| clk_set_rate | invalid_data | error |
-| clk_enable | received | info |
-| clk_enable | data_lost | error |
-| clk_enable | not_match | info |
-| clk_enable | not_supported | warn |
-| clk_enable | invalid_data | error |
-| clk_disable | received | info |
-| clk_disable | data_lost | error |
-| clk_disable | not_match | info |
-| clk_disable | not_supported | warn |
-| clk_disable | invalid_data | error |
-| sys_enter | received | info |
-| sys_enter | data_lost | error |
-| sys_enter | not_match | info |
-| sys_enter | not_supported | warn |
-| sys_enter | invalid_data | error |
-| sys_exit | received | info |
-| sys_exit | data_lost | error |
-| sys_exit | not_match | info |
-| sys_exit | not_supported | warn |
-| sys_exit | invalid_data | error |
-| regulator_set_voltage | received | info |
-| regulator_set_voltage | data_lost | error |
-| regulator_set_voltage | not_match | info |
-| regulator_set_voltage | not_supported | warn |
-| regulator_set_voltage | invalid_data | error |
-| regulator_set_voltage_complete | received | info |
-| regulator_set_voltage_complete | data_lost | error |
-| regulator_set_voltage_complete | not_match | info |
-| regulator_set_voltage_complete | not_supported | warn |
-| regulator_set_voltage_complete | invalid_data | error |
-| regulator_disable | received | info |
-| regulator_disable | data_lost | error |
-| regulator_disable | not_match | info |
-| regulator_disable | not_supported | warn |
-| regulator_disable | invalid_data | error |
-| regulator_disable_complete | received | info |
-| regulator_disable_complete | data_lost | error |
-| regulator_disable_complete | not_match | info |
-| regulator_disable_complete | not_supported | warn |
-| regulator_disable_complete | invalid_data | error |
-| ipi_entry | received | info |
-| ipi_entry | data_lost | error |
-| ipi_entry | not_match | info |
-| ipi_entry | not_supported | warn |
-| ipi_entry | invalid_data | error |
-| ipi_exit | received | info |
-| ipi_exit | data_lost | error |
-| ipi_exit | not_match | info |
-| ipi_exit | not_supported | warn |
-| ipi_exit | invalid_data | error |
-| irq_handler_entry | received | info |
-| irq_handler_entry | data_lost | error |
-| irq_handler_entry | not_match | info |
-| irq_handler_entry | not_supported | warn |
-| irq_handler_entry | invalid_data | error |
-| irq_handler_exit | received | info |
-| irq_handler_exit | data_lost | error |
-| irq_handler_exit | not_match | info |
-| irq_handler_exit | not_supported | warn |
-| irq_handler_exit | invalid_data | error |
-| softirq_raise | received | info |
-| softirq_raise | data_lost | error |
-| softirq_raise | not_match | info |
-| softirq_raise | not_supported | warn |
-| softirq_raise | invalid_data | error |
-| softirq_entry | received | info |
-| softirq_entry | data_lost | error |
-| softirq_entry | not_match | info |
-| softirq_entry | not_supported | warn |
-| softirq_entry | invalid_data | error |
-| softirq_exit | received | info |
-| softirq_exit | data_lost | error |
-| softirq_exit | not_match | info |
-| softirq_exit | not_supported | warn |
-| softirq_exit | invalid_data | error |
-| oom_score_adj_update | received | info |
-| oom_score_adj_update | data_lost | error |
-| oom_score_adj_update | not_match | info |
-| oom_score_adj_update | not_supported | warn |
-| oom_score_adj_update | invalid_data | error |
-| sched_wakeup_new | received | info |
-| sched_wakeup_new | data_lost | error |
-| sched_wakeup_new | not_match | info |
-| sched_wakeup_new | not_supported | warn |
-| sched_wakeup_new | invalid_data | error |
-| sched_process_exit | received | info |
-| sched_process_exit | data_lost | error |
-| sched_process_exit | not_match | info |
-| sched_process_exit | not_supported | warn |
-| sched_process_exit | invalid_data | error |
-| sched_process_free | received | info |
-| sched_process_free | data_lost | error |
-| sched_process_free | not_match | info |
-| sched_process_free | not_supported | warn |
-| sched_process_free | invalid_data | error |
-| trace_event_clock_sync | received | info |
-| trace_event_clock_sync | data_lost | error |
-| trace_event_clock_sync | not_match | info |
-| trace_event_clock_sync | not_supported | warn |
-| trace_event_clock_sync | invalid_data | error |
-| memory | received | info |
-| memory | data_lost | error |
-| memory | not_match | info |
-| memory | not_supported | warn |
-| memory | invalid_data | error |
-| hilog | received | info |
-| hilog | data_lost | error |
-| hilog | not_match | info |
-| hilog | not_supported | warn |
-| hilog | invalid_data | error |
-| hidump_fps | received | info |
-| hidump_fps | data_lost | error |
-| hidump_fps | not_match | info |
-| hidump_fps | not_supported | warn |
-| hidump_fps | invalid_data | error |
-| native_hook_malloc | received | info |
-| native_hook_malloc | data_lost | error |
-| native_hook_malloc | not_match | info |
-| native_hook_malloc | not_supported | warn |
-| native_hook_malloc | invalid_data | error |
-| native_hook_free | received | info |
-| native_hook_free | data_lost | error |
-| native_hook_free | not_match | info |
-| native_hook_free | not_supported | warn |
-| native_hook_free | invalid_data | error |
-| sys_memory | received | info |
-| sys_memory | data_lost | error |
-| sys_memory | not_match | info |
-| sys_memory | not_supported | warn |
-| sys_memory | invalid_data | error |
-| sys_virtual_memory | received | info |
-| sys_virtual_memory | data_lost | error |
-| sys_virtual_memory | not_match | info |
-| sys_virtual_memory | not_supported | warn |
-| sys_virtual_memory | invalid_data | error |
-| signal_generate | received | info |
-| signal_generate | data_lost | error |
-| signal_generate | not_match | info |
-| signal_generate | not_supported | warn |
-| signal_generate | invalid_data | error |
-| signal_deliver | received | info |
-| signal_deliver | data_lost | error |
-| signal_deliver | not_match | info |
-| signal_deliver | not_supported | warn |
-| signal_deliver | invalid_data | error |
-| trace_block_bio_backmerge | received | info |
-| trace_block_bio_backmerge | data_lost | error |
-| trace_block_bio_backmerge | not_match | info |
-| trace_block_bio_backmerge | not_supported | warn |
-| trace_block_bio_backmerge | invalid_data | error |
-| trace_block_bio_bounce | received | info |
-| trace_block_bio_bounce | data_lost | error |
-| trace_block_bio_bounce | not_match | info |
-| trace_block_bio_bounce | not_supported | warn |
-| trace_block_bio_bounce | invalid_data | error |
-| trace_block_bio_complete | received | info |
-| trace_block_bio_complete | data_lost | error |
-| trace_block_bio_complete | not_match | info |
-| trace_block_bio_complete | not_supported | warn |
-| trace_block_bio_complete | invalid_data | error |
-| trace_block_bio_frontmerge | received | info |
-| trace_block_bio_frontmerge | data_lost | error |
-| trace_block_bio_frontmerge | not_match | info |
-| trace_block_bio_frontmerge | not_supported | warn |
-| trace_block_bio_frontmerge | invalid_data | error |
-| trace_bblock_bio_queue | received | info |
-| trace_bblock_bio_queue | data_lost | error |
-| trace_bblock_bio_queue | not_match | info |
-| trace_bblock_bio_queue | not_supported | warn |
-| trace_bblock_bio_queue | invalid_data | error |
-| trace_block_bio_remap | received | info |
-| trace_block_bio_remap | data_lost | error |
-| trace_block_bio_remap | not_match | info |
-| trace_block_bio_remap | not_supported | warn |
-| trace_block_bio_remap | invalid_data | error |
-| trace_block_dirty_buffer | received | info |
-| trace_block_dirty_buffer | data_lost | error |
-| trace_block_dirty_buffer | not_match | info |
-| trace_block_dirty_buffer | not_supported | warn |
-| trace_block_dirty_buffer | invalid_data | error |
-| trace_block_getrq | received | info |
-| trace_block_getrq | data_lost | error |
-| trace_block_getrq | not_match | info |
-| trace_block_getrq | not_supported | warn |
-| trace_block_getrq | invalid_data | error |
-| trace_block_plug | received | info |
-| trace_block_plug | data_lost | error |
-| trace_block_plug | not_match | info |
-| trace_block_plug | not_supported | warn |
-| trace_block_plug | invalid_data | error |
-| trace_block_rq_complete | received | info |
-| trace_block_rq_complete | data_lost | error |
-| trace_block_rq_complete | not_match | info |
-| trace_block_rq_complete | not_supported | warn |
-| trace_block_rq_complete | invalid_data | error |
-| trace_block_rq_insert | received | info |
-| trace_block_rq_insert | data_lost | error |
-| trace_block_rq_insert | not_match | info |
-| trace_block_rq_insert | not_supported | warn |
-| trace_block_rq_insert | invalid_data | error |
-| trace_block_rq_remap | received | info |
-| trace_block_rq_remap | data_lost | error |
-| trace_block_rq_remap | not_match | info |
-| trace_block_rq_remap | not_supported | warn |
-| trace_block_rq_remap | invalid_data | error |
-| trace_block_rq_issue | received | info |
-| trace_block_rq_issue | data_lost | error |
-| trace_block_rq_issue | not_match | info |
-| trace_block_rq_issue | not_supported | warn |
-| trace_block_rq_issue | invalid_data | error |
-| other | received | info |
-| other | data_lost | error |
-| other | not_match | info |
-| other | not_supported | warn |
-| other | invalid_data | error |
+我们通过一张表,来记录所有事件的解析情况,拿下面这条数据举例:
+| event_name | count| stat_type | serverity |
+|---- |---|---- |---- |
+| binder_transaction |12| received | info |
+| binder_transaction |1| data_lost | error |
+| binder_transaction |3| not_match | info |
+| binder_transaction |0| not_supported | info |
+| binder_transaction |5| invalid_data | error |
+| - | - |-|- |
+上面的图表表示:一共收到了12条binder_transaction的数据,其中有3条数据业务上不匹配,有5条数据格式非法。
\ No newline at end of file
diff --git a/host/trace_streamer/doc/des_support_eventlist.md b/host/trace_streamer/doc/des_support_event.md
similarity index 80%
rename from host/trace_streamer/doc/des_support_eventlist.md
rename to host/trace_streamer/doc/des_support_event.md
index bde55dce0c0d849fdf69f5ed882f6d12c9037228..f283a1d509892f746128d02713ab51efd508c663 100644
--- a/host/trace_streamer/doc/des_support_eventlist.md
+++ b/host/trace_streamer/doc/des_support_event.md
@@ -1,5 +1,9 @@
-# TraceStreamer支持解析事件列表
+# TraceStreamer支持识别事件列表
+trace事件是指系统在运行过程中输出的日志。trace事件有内核输出的,也有用户输出的,系统或用户在输出日志时,都可以添加特定的标识,以特定的格式输出。
+所谓事件,是指特定的标签,指定了其事件类型。
## ftrace事件
+ftrace属于linux标准内核事件。
+ftrace相关事件属于系统内核事件,具体请参考linux内核相关技术网站(www.kernel.org)。
```
binder_transaction
binder_transaction_received
@@ -27,12 +31,6 @@ clk_enable
clk_disable
sys_enter
sys_exit
-regulator_set_voltage
-regulator_set_voltage_complete
-regulator_disable
-regulator_disable_complete
-ipi_entry
-ipi_exit
irq_handler_entry
irq_handler_exit
softirq_raise
@@ -41,8 +39,55 @@ softirq_exit
sched_wakeup_new
sched_process_exit
trace_event_clock_sync
+// 下面的事件,属于ftrace,TraceStream可以识别并记录,但并不做业务解析。
+ipi_entry
+ipi_exit
+regulator_set_voltage
+regulator_set_voltage_complete
+regulator_disable
+regulator_disable_complete
+signal_generate
+signal_deliver
+trace_block_bio_backmerge
+trace_block_bio_bounce
+trace_block_bio_complete
+trace_block_bio_frontmerge
+trace_bblock_bio_queue
+trace_block_bio_remap
+trace_block_dirty_buffer
+trace_block_getrq
+trace_block_plug
+trace_block_rq_complete
+trace_block_rq_insert
+trace_block_rq_remap
+trace_block_rq_issue
+```
+## 其他插件数据
+以下的数据,来自于htrace(序列化后的trace)的其他插件。
+注:如果是文本的trace的话,只支持ftrace
+```
+memory
+hilog
+hidump_fps
+native_hook_malloc
+native_hook_free
+native_hook_mmap
+native_hook_munmap
+sys_memory
+sys_virtual_memory
+trace_diskio
+trace_process
+trace_cpu_usage
+trace_network
+trace_perf
+trace_ebpf
+trace_ebpf_file_system
+trace_ebpf_paged_memory
+trace_ebpf_bio_latency
+trace_hisys_event
+trace_smaps
```
-## 内存事件
+## 进程的内存事件
```
mem.vm.size
mem.rss
diff --git a/host/trace_streamer/doc/des_tables.md b/host/trace_streamer/doc/des_tables.md
index efe0a6f7b4ab4352fc1a9cce82963d86293d8a4e..71497f9b9212b76673640ad3046447e3cd779a5f 100644
--- a/host/trace_streamer/doc/des_tables.md
+++ b/host/trace_streamer/doc/des_tables.md
@@ -1,306 +1,1159 @@
-# ___概述TraceStreamer生成的数据库___
-```
- TraceStreamer虽然对外提供了各种各样的使用方式,但核心的业务仍是将trace数据源转化为易于理解和使用的数据库。用户可以通过SmartPerf界面直观的研究系统跟踪数据,也可在理解TraceStreamer生成的数据库的基础上,在TraceStreamer的交互模式或者Smartperf的数据库查询模式下,使用SQL查询语句自由组装查看用户关心的数据。 下文将对TraceStreamer生成的数据库进行详细描述,给用户使用SQL查询系统跟踪数据提供帮助。
-```
+# TraceStreamer数据表概述
+TraceStreamer可以将trace数据源转化为易于理解和使用的数据库。用户可以通过SmartPerf界面直观的研究系统跟踪数据,也可在理解TraceStreamer生成的数据库的基础上,在TraceStreamer的交互模式或者Smartperf的数据库查询模式下,使用SQL查询语句自由组装查看用户关心的数据。下文将对TraceStreamer生成的数据库进行详细描述,给用户使用SQL查询系统跟踪数据提供帮助。
-## ___TraceStreamer输出数据库包含以下表格___
-* trace_range : 记录ftrace数据与其他类型数据的时间交集,供前端展示数据时使用。
-* process : 记录进程信息。
-* thread : 记录线程信息。
-* thread_state : 记录线程状态信息。
-* instant : 记录Sched_waking, sched_wakeup事件, 用作ThreadState表的上下文使用。
-* raw : 此数据结构主要作为ThreadState的上下文使用,这张表是sched_waking,sched_wakup, cpu_idle事件的原始记录。
-* callstack : 记录调用堆栈和异步调用,其中depth,stack_id和parent_stack_id仅在非异步调用中有效。当cookid不为空时,为异步调用,此时callid为进程唯一号,否则为线程唯一号。
-* irq : 记录中断相关事件。
-* measure : 记录所有的计量值。
-* log : 记录hilog打印日志数据。
-* heap : 记录堆内存申请与释放相关的数据。
-* heap_frame : 记录堆内存申请与释放相关的调用栈。
-* hidump : 记录FPS(Frame Per Second)数据。
-* symbols : 记录系统调用名称和其函数指针的对应关系,trace中用addr来映射function_name来节省存储空间
-* syscall : 记录用户空间函数与内核空间函数相互调用记录
-* args : 记录方法参数集合
-* sys_event_filter : 记录所有的filter
-* clk_event_filter : 记录时钟事件
-* cpu_measure_filter : cpu事件过滤器表。
-* measure_filter : 记录一个递增的filterid队列,所有其他的filter类型在获取过程中,均从此数据列表中获取下一个可用的filter_id并做记录。
-* process_measure_filter : 将进程ID作为key1,进程的内存,界面刷新,屏幕亮度等信息作为key2,唯一确定一个filter_id
-* data_type : 记录数据类型和typeId的关联关系。
-* data_dict : 记录常用的字符串,将字符串和索引关联,降低程序运行的内存占用,用作辅助数据。
-* meta : 记录执行解析操作相关的基本信息。
+## TraceStreamer输出的数据表分类
+* 常规泳道图数据表
+![GitHub Logo](../figures/db_common.png)
+* native memory数据源相关表
+![GitHub Logo](../figures/db_native_memory.png)
+* perf相关数据表
+![GitHub Logo](../figures/db_hiperf.png)
+* hisysevent相关数据表
+![GitHub Logo](../figures/db_hisys_event.png)
+## TraceStreamer输出数据库包含以下表格
+| 表名称 |作用|
+| ---- |---- |
+| app_name | 记录HiSysEvent事件的事件名与IDE部分事件的字段名为APPNAME中存放的相关信息的映射关系 |
+| args | 记录方法参数集合|
+| bio_latency_sample | 记录IO操作相关方法调用,及调用栈数据|
+| callstack | 记录调用堆栈和异步调用信息,其中depth,stack_id和parent_stack_id仅在非异步调用中有效。当cookid不为空时,为异步调用,此时callid为进程唯一号,否则为线程唯一号|
+| clk_event_filter | 记录时钟相关的信息|
+| clock_event_filter | 此结构用来维护时钟事件,cpu与唯一的ID做关联|
+| cpu_measure_filter | cpu事件过滤器表|
+| cpu_usage | 记录CPU使用率事件|
+| data_dict | 记录常用的字符串,将字符串和索引关联,降低程序运行的内存占用,用作辅助数据|
+| data_type | 记录数据类型和typeId的关联关系|
+| diskio | 记录磁盘读写数据事件|
+| ebpf_callstack | 记录了采样相关信息|
+| file_system_samp | 记录了调用栈的相关信息|
+| hidump | 记录FPS(Frame Per Second)数据|
+| hisys_event_measure | 记录了HiSysEvent事件相关数据,目前HiSysEvent事件包括了异常事件,IDE事件,器件状态事件 |
+| instant | 记录Sched_waking, sched_wakeup事件, 用作ThreadState表的上下文使用 |
+| irq | 记录中断相关事件|
+| live_process | 记录了一些实时的进程中执行的一些数据|
+| log | 记录hilog打印日志数据|
+| measure_filter | 记录一个递增的filterid队列,所有其他的filter类型在获取过程中,均从此数据列表中获取下一个可用的filter_id并做记录|
+| meta | 记录执行解析操作相关的基本信息|
+| native_hook | 记录堆内存申请与释放相关的数据|
+| native_hook_frame | 记录堆内存申请与释放相关的调用栈|
+| network | 抓取网络信息传输时产生的一些相关信息|
+| paged_memory_sample | 记录内存操作相关方法调用,及调用栈数据|
+| perf_callchain | 记录Hiperf采样数据的调用栈信息|
+| perf_files | 记录Hiperf工具采集到的函数符号表和文件名|
+| perf_report | 记录Hiperf工具采集数据时的配置信息。包括|抓取的事件类型,抓取数据的命令, 抓数据时指定的进程名称|
+| perf_sample | 记录Hiperf工具的采样信息|
+| perf_thread | 记录Hiperf工具采集到的进程和线程数据|
+| process | 记录所有的进程信息|
+| process_filter | 过滤进程|
+| process_measure | 保存进程的所有计量值|
+| process_measure_filter | 将进程ID作为key1,进程的内存,界面刷新,屏幕亮度等信息作为key2,唯一确定一个filter_id|
+| raw | 此数据结构主要作为ThreadState的上下文使用,这张表是sched_waking,sched_wakup, cpu_idle事件的原始记录|
+| sched_slice | 此数据结构主要作为ThreadState的上下文使用,这张表是sched_switch事件的原始记录|
+| smaps | 记录进程的内存消耗的相关信息采样|
+| stat | 此结果用来统计数据解析中各类数据的数据条数,数据和合法性,数据的匹配程度(begin-end),数据的损失等,查看此结构对应的表,可对数据源有基本的了解|
+| symbols | 记录系统调用名称和其函数指针的对应关系,trace中用addr来映射function_name来节省存储空间|
+| syscall | 记录用户空间函数与内核空间函数相互调用记录|
+| sys_event_filter | 记录所有的filter|
+| sys_mem_measure | 记录了所有的系统内存相关的测量信息|
+| thread | 记录所有的线程信息|
+| thread_filter | 过滤线程|
+| thread_state | 记录线程状态信息|
+| trace_range | 记录ftrace数据与其他类型数据的时间交集,供前端展示数据时使用|
+| clock_snapshot | 时钟号和时间,时钟名的映射表|
+| datasource_clockid | 数据源和时钟号的映射表|
+## 表与事件来源
+| 表名称 | 事件源 | 插件名 | 备注 |
+| ---- | ---- | ---- | ---- |
+|app_name | - |hisysevent-plugin |JSON数据源 |
+|args | - |ftrace-plugin |配合callstack使用 |
+|callstack | - |ftrace-plugin |异步或非异步的调用 |
+|cpu_measure_filter | - |ftrace-plugin |cpu跟踪器,cpu频率等 |
+|cpu_usage | - |cpu-plugin |cpu使用率 |
+|data_dict | 通用的 | - |所有字符串的记录 |
+|data_type | 通用的 | - |辅助表 |
+|file_system_callstack | - | - |ebpf文件系统 |
+|file_system_sample | - | - |ebpf文件系统 |
+|hidump | - |hidump-plugin |FPS数据 |
+|hisys_event_measure | - |hisysevent-plugin |JSON数据源 |
+|instant | - |ftrace-plugin |waking和wakeup事件 |
+|irq | - |ftrace-plugin |记录中断事件 |
+|live_process | - |process-plugin |Monitor数据 |
+|network | - |network-plugin |Monitor数据 |
+|diskio | - |diskio-plugin |Monitor数据 |
+|log | - |hilog-plugin |系统日志 |
+|measure | 通用的 | - |系统中的计量值(数值型)|
+|measure_filter | 通用的 | - |计量值的查询辅助表 |
+|meta | 通用的 | - |记录解析现场数据(解析时间,数据类型,解析工具等)|
+|native_hook | - |nativehook/hookdaemon |内存数据 |
+|native_hook_frame | - |nativehook/hookdaemon |内存数据 |
+|perf_callchain | - |perf-plugin |perf数据(非插件模式) |
+|perf_files | - | - |perf数据(非插件模式) |
+|perf_report | - | - |perf数据(非插件模式) |
+|perf_sample | - | - |perf数据(非插件模式) |
+|perf_thread | - | - |perf数据(非插件模式) |
+|process | - |ftrace-plugin |进程信息 |
+|process_filter | - |ftrace-plugin |进程计量表的辅助表 |
+|process_measure | - |ftrace-plugin |进程内存 |
+|process_measure_filter| - |ftrace-plugin |process_measure的辅助表|
+|raw | - |ftrace-plugin |线程唤醒信息 |
+|sched_slice | - |ftrace-plugin |配合现场状态表使用,dsched_switch的原始数据|
+|smaps | - |memory-plugin |进程的内存消耗 |
+|stat | 通用的 | - |记录不同种类数据的数据量|
+|symbols | - |ftrace-plugin |符号表(地址到字符串的映射)|
+|syscall | - |ftrace-plugin |系统调用 sys_enter/exit|
+|sys_event_filter | - |ftrace-plugin | |
+|sys_mem_measure | - |memory-plugin |系统内存 |
+|thread | 通用的 | - |线程信息(常用) |
+|thread_state | 通用的 |ftrace-plugin |线程调度图(常用) |
+|trace_range | 通用的 | - |trace数据的时长 |
+|thread_filter | 通用的 |ftrace-plugin |线程计量跟踪表(比较少用)|
+|clock_snapshot | 通用的 |通用的 |时钟号和时间,时钟名的映射表|
+|datasource_clockid | 通用的 |通用的 |数据源和时钟号的映射表|
## ___表格关系图___
-
-### 进程表与线程表关系图:
-![GitHub Logo](../figures/process_thread.png)
-### 描述:
+---
+### 进程表与线程表关系
当一个进程或者线程结束后,系统可能再次将该进程号或者线程号分配给其他进程或者线程,造成一个进程号或线程号代表多个进程或线程的情况。
Process和Thread表中的id字段可以唯一标识进程和线程。process表中的id在其他表中用作ipid字段。thread表中的id在其他表中用作itid字段。
-thread表通过ipid字段关联process表的id字段,可以查询线程归属进程。
-### 举例:
+thread表通过ipid字段关联process表的id字段,可以查询线程归属进程。
+![GitHub Logo](../figures/process_thread.png)
+### 查询举例
已知pid = 123,查看当前进程下的所有线程信息,可以使用如下SQL语句:
-select thread.* from thread, process where process.pid = 123 and thread.ipid = process.id
+```select thread.* from thread, process where process.pid = 123 and thread.ipid = process.id```
### 线程表与线程运行状态表关系图
+thread_state表记录所有线程的运行状态信息,包含ts(状态起始时间),dur(状态持续时间),cpu, itid, state(线程状态)。 thread表的id字段与thread_state表的itid字段相关联。
![GitHub Logo](../figures/thread_state.png)
-### 描述:
-thread_state表记录所有线程的运行状态信息,包含ts(状态起始时间),dur(状态持续时间),cpu, itid, state(线程状态)。 thread表的id字段与thread_state表的itid字段相关联。
-### 举例:
+### 查询举例
已知tid = 123, 查看当前线程的所有运行状态信息,可以使用如下SQL语句:
-select thread_state.* from thread, thread_state where thread.tid = 123 and thread.id = thread_state.itid
+```select thread_state.* from thread, thread_state where thread.tid = 123 and thread.id = thread_state.itid```
### 堆内存数据变化表关系图
+native_hook表记录堆内存申请(AllocEvent)和释放(FreeEvent)数据。native_hook表通过ipid和itid字段分别与process和thread表的id字段关联,通过callChainId与native_hook_frame表的callChainId字段相关联。
+native_hook表字段解释如下:
+ callChainId: 唯一标识一次堆内存申请或释放, 通过与native_hook_frame表关联可以拿到当前申请或释放的函数调用堆栈。
+ addr: 堆内存申请/释放的地址
+ native_hook_size: 堆内存申请/释放的大小
+native_hook_frame表记录内存申请/释放的调用堆栈。通过callChainId区分一组调用堆栈,depth为堆栈深度,depth为0时,表示当前行为栈顶数据。
![GitHub Logo](../figures/dump_and_mem.png)
-### 描述:
-heap表记录堆内存申请(AllocEvent)和释放(FreeEvent)数据。heap表通过ipid和itid字段分别与process和thread表的id字段关联,通过eventId与heap_frame表的eventId字段相关联。
-heap表字段解释如下:
- eventId: 唯一标识一次堆内存申请或释放, 通过与heap_frame表关联可以拿到当前申请或释放的函数调用堆栈。
- addr: 堆内存申请/释放的地址
- heap_size: 堆内存申请/释放的大小
-heap_frame表记录内存申请/释放的调用堆栈。通过eventId区分一组调用堆栈,depth为堆栈深度,depth为0时,表示当前行为栈顶数据。
-### 举例:
-已知tid = 123, 查看当前线程的所有堆内存变化信息,可以使用如下SQL语句:
-select heap.* from thread, heap where thread.tid = 123 and thread.id = heap.itid
-已知eventid = 0, 查看当前内存变化调用堆栈
-select * from heap_frame where eventId = 0
+### 查询举例
+- 已知tid = 123, 查看当前线程的所有堆内存变化信息,可以使用如下SQL语句:
+```select native_hook.* from thread, native_hook where thread.tid = 123 and thread.id = native_hook.itid```
+- 已知callchainid = 0, 查看当前内存变化调用堆栈
+```select * from native_hook_frame where callChainId = 0```
### 日志表与进程线程表关系图
-![GitHub Logo](../figures/log.png)
-### 描述:
-log表记录日志信息。可以根据seq字段的连续性,来判断是否存在日志丢失的情况。
-### 举例:
+log表记录日志信息。可以根据seq字段的连续性,来判断是否存在日志丢失的情况。
+![GitHub Logo](../figures/log.png)
+### 查询举例
已知tid = 123, 查看当前线程的所有error级别的日志,可以使用如下SQL语句:
-select * from log where tid = 123 and level = "error"
+```select * from log where tid = 123 and level = "error"```
+
+### perf表之间关系图
+perf_report:此表记录Hiperf工具采集数据时的配置信息。
+perf_thread:此表记录hiperf采集到的进程和线程数据。
+perf_sample:此表中记录Hiperf工具的采样信息。sample_id唯一表识一次采样记录,与perf_callchain表中的sample_id字段相关联。thread_id为线程号。与perf_thread表中的thread_id字段相关联。event_type_id为当前采样的事件类型id,与perf_report表中的id字段相关联。
+perf_callchain:此表格记录的是调用栈信息。
+Perf_files:此表格主要存放着获取到的函数符号表和文件信息。file_id唯一表识一个文件,与perf_callchain表中的file_id字段相关联。
+![GitHub Logo](../figures/perf.png)
+### 查询举例
+- 已知同步后的时间戳为28463134340470,查询采样数据
+```select * from perf_sample where timestamp_trace = 28463134340470```
+
+- 已知同步后的时间戳为28463134340470,查询采样数据对应的的调用栈信息
+```select A.* from perf_callchain as A, perf_sample as B where B.timestamp_trace = 28463134340470 and A.sample_id = B.sample_id```
+
+已知同步后的时间戳为28463134277762,查询采样数据的函数名及文件路径
+```select A.*, B.name, C.path from perf_sample as A, perf_callchain as B, perf_files as C where A.timestamp_trace = 28463134277762 and B.sample_id = A.sample_id and B.callchain_id = 0 and B.file_id = C.file_id and C.serial_id = 0```
+
+已知线程号为6700,查询所有的采样记录
+```select * from perf_sample where thread_id = 6700```
+已知进程号为7863,查询所有的采样记录
+```select A.* from perf_sample as A, perf_thread as B where B.process_id = 7863 and A.thread_id = B.thread_id```
+
+查询所有采样对应的事件类型
+```select A.*, B.report_value from perf_sample as A, perf_report as B where A.event_type_id = B.id```
## TraceStreamer输出数据库表格详细介绍
-### trace_range表
-#### 表结构:
+### app_name表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
-|start_ts |NUM |
-|end_ts |INT |
-#### 关键字段描述:
-start_ts: trace的开始时间,纳秒为单位
-end_ts: trace的结束时间,纳秒为单位
-### process表
-#### 表结构:
+|id |INT |
+|flag |INT |
+|app_name |INT |
+|app_key |INT |
+#### 表描述
+记录HiSysevent上报事件中的IDE相关事件中APPNAME的表关联信息。
+#### 字段详细描述
+id:用于与表hisys_event_measure表中的key_id字段做对应
+app_name:对应的事件的信息ID
+app_key:对应的事件的APPNAME字段的信息ID
+
+### args表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
-|id |NUM |
-|type |INT |
-|pid |NUM |
-|name |INT |
-|start_ts |NUM |
-#### 关键字段描述:
-id: 进程在数据库重新重新定义的id,从0开始序列增长
-pid: 进程的真实id
-name: 进程名字
-### thread表
-#### 表结构:
+|id |INT |
+|key |INT |
+|datatype |INT |
+|value |INT |
+|argset |INT |
+#### 表描述
+记录方法的参数集合
+#### 字段详细描述
+key:键
+datatype:数据类型
+value:取值
+argset:参数集合
+
+### bio_latency_sample表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
-|id |INT |
-|type |NUM |
-|tid |INT |
-|name |NUM |
-|start_ts |INT |
-|end_ts |INT |
-|ipid |INT |
-|is_main_thread|INT |
-#### 字段详细描述:
-id: 线程在数据库重新重新定义的id,从0开始序列增长
-ipid: 线程所属的进程id, 关联进程表中的ID
-name: 线程名字
-is_main_thread: 是否主线程,主线程即该线程实际就是进程本身
+|id |INT |
+|callchain_id |INT |
+|datatype |INT |
+|type |INT |
+|ipid |INT |
+|itid |INT |
+|start_ts |INT |
+|end_ts |INT |
+|latency_dur |INT |
+|tier |INT |
+|size |INT |
+|block_number |TEXT |
+|path |TEXT |
+|dur_per_4k |INT |
+#### 表描述
+记录IO操作相关方法调用,及调用栈数据
+#### 字段详细描述
+callchain_id:调用栈的唯一标识。与ebpf_callstack表中Callchain_id字段关联
+type:事件类型其取值为枚举类型(DATA_READ,DATA_WRITE,METADATA_READ,METADATA_WRITE,PAGE_IN,PAGE_OUT)
+ipid:TS内部进程号
+itid:TS内部线程号
+start_ts:开始时间
+end_ts:结束时间
+latency_dur:总延迟
+tier:优先级
+size:文件大小
+block_number:数据量大小(一般为4K)
+path:路径id
+dur_per_4k:每4k数据的平均延迟
-### thread_state表
-#### 表结构:
+### callstack表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
|id |INT |
-|type |NUM |
|ts |INT |
|dur |INT |
+|callid |INT |
+|cat |TEXT |
+|identify |INT |
+|name |TEXT |
+|depth |INT |
+|cookie |INT |
+|parent_id |INT |
+|argsetid |INT |
+|chainId |TEXT |
+|spanId |TEXT |
+|parentSpanId |TEXT |
+|flag |TEXT |
+|args |TEXT |
+#### 表描述
+记录调用堆栈和异步调用信息,其中depth,stack_id和parent_stack_id仅在非异步的调用中有效。当cookid不为空时,为异步调用,此时callid为进程唯一号,否则为线程唯一号。
+#### 字段详细描述
+dur:调用时长
+callid:调用者的ID,比如针对线程表里面的id
+identify:调用栈的名字,与表dataDict相关联能够取出其string值
+name:调用名称
+depth:调用深度
+parent_id:父调用的id
+spanId:分布式调用关联关系
+flag:C表示分布式调用发送方,S表示接受方
+args:分布式调用函数参数
+
+### clk_event_filter表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|type |TEXT |
+|name |TEXT |
|cpu |INT |
-|itid |INT |
-|state |NUM |
-#### 字段详细描述:
-id: 线程状态在数据库中的id,从0开始序列增长
-ts: 该线程状态的起始时间
-dur: 该线程状态的持续时间
-cpu: 该线程在哪个cpu上执行(针对running状态的线程)
-itid: 该状态所属的线程所属的进程id, 关联进程表中的ID
-state: 线程实际的的状态值
-```
-'R', Runnable状态
-'S', interruptible sleep
-'D', uninterruptible sleep
-'T', Stoped
-'t', Traced
-'X', ExitedDead
-'Z', ExitZombie
-'x', TaskDead
-'I', TaskDead
-'K', WakeKill
-'P', Parked
-'N', NoLoad
-```
-### instant表
-#### 表结构:
+#### 表描述
+记录时钟信息
+#### 字段详细描述
+Type:时钟事件类型
+Name:时钟事件名称
+
+### clock_event_filter表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|type |TEXT |
+|name |TEXT |
+|cpu |INT |
+#### 表描述
+此结构用来维护时钟事件,cpu与唯一的ID做关联
+#### 主要字段描述
+Type:时钟事件类型
+Name:时钟事件名称
+
+### cpu_measure_filter表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|type |TEXT |
+|name |TEXT |
+|cpu |INT |
+#### 表描述
+将cpu号作为key1,cpu的频率,空闲等状态作为key2,唯一确定一个filter_id
+#### 主要字段描述
+Id(filterid), cpu:事件名称,cpu号
+
+### cpu_usage表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
|ts |INT |
-|name |NUM |
-|ref |INT |
-|ref_type |NUM |
-#### 表描述:
-记录了系统中的waking和wakeup事件。
-### raw表
-#### 表结构:
+|dur |INT |
+|total_load |REAL |
+|user_load |REAL |
+|system_load |REAL |
+|process_num |INT |
+#### 表描述
+记录了与CPU使用率相关的数据
+#### 主要字段描述
+total_load:总负荷
+user_load:用户负载
+system_load:系统负载
+process_num:线程数
+
+### data_dict表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|data |TEXT |
+#### 表描述
+此表记录了一个数据类型ID和字符串的映射。
+#### 主要字段描述
+id:索引值
+data:字符串
+
+### data_type表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
|id |INT |
-|type |NUM |
+|typeId |INT |
+|desc |TEXT |
+#### 表描述
+此表记录了一个数据类型ID和数据描述的映射。
+#### 主要字段描述
+typeId::数据类型id
+Desc:数据类型描述
+
+### diskio表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
|ts |INT |
-|name |NUM |
-|cpu |INT |
+|dur |INT |
+|rd |INT |
+|wr |INT |
+|rd_speed |REAL |
+|wr_speed |REAL |
+|rd_count |INT |
+|wr_count |INT |
+|rd_count_speed |REAL |
+|wr_count_speed |REAL |
+#### 表描述
+记录了与磁盘读写相关的数据
+#### 主要字段描述
+rd_sectors_kb:读数据的速度
+wr_sectors_kb:写入数据的速度
+ts:时间戳
+
+### ebpf_callstack表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|callchain_id |INT |
+|depth |TEXT |
+|ip |TEXT |
+|symbols_id |INT |
+|file_path_id |INT |
+#### 表描述
+记录了与磁盘读写相关的数据
+#### 主要字段描述
+callchain_id:调用栈的唯一标识。与ebpf_callstack表中Callchain_id字段关联
+depth:调用栈深度。取值为零时表示栈顶
+ip:调用栈ip
+symbols_id:调用栈函数名称, 与data_dict中的id字段关联
+file_path_id:调用栈函数所属文件路径, 与data_dict中的id字段关联
+
+### file_system_sample表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|callchain_id |INT |
+|type |INT |
+|ipid |INT |
|itid |INT |
-#### 表描述:
-记录了系统中的waking、wakup、cpu_idel、cpu_frequency数据。
+|start_ts |INT |
+|end_ts |INT |
+|dur |INT |
+|return_value |TEXT |
+|error_code |TEXT |
+|fd |INT |
+|file_id |INT |
+|size |INT |
+|first_argument |TEXT |
+|second_argument |TEXT |
+|third_argument |TEXT |
+|fourth_argument |TEXT |
+#### 表描述
+记录了调用栈的相关信息。
+#### 主要字段描述
+callchain_id:调用栈信息ID与file_system_callstack表中call_chain_id字段相关联
+type:对应文件操作open,close,read,write
+ipid:线程所属的进程ID
+start_ts:开始时间
+end_ts:结束时间
+dur:耗时
+return_value:文件操作的返回值
+error_code:文件操作发生错误时的错误码
+fd:文件描述符fd
+file_id:当type为open,close时为其操作的文件路径,当type为read,write时为固定字段(null)
+size:在type为read,write时对应的文件的读或者写的大小
+first_argument:参数一
+second_argument:参数二
+third_argument:参数三
+fourth_argument:参数四
-### callstack表
-#### 表结构:
+### hidump表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|ts |INT |
+|fps |INT |
+#### 表描述
+此表记录了设备的帧率信息,fps。
+#### 相关字段描述
+fps:帧率值
+
+### hisys_event_measure表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|serial |INT |
+|ts |INT |
+|name_id |INT |
+|key_id |INT |
+|type |INT |
+|int_value |REAL |
+|string_value |TEXT |
+#### 表描述
+记录所有的system event事件的相关数据,及其相关表的映射信息。
+#### 相关字段描述
+serial:每条数据过来携带唯一一条id作为标识
+name_id:存放事件对应的ID,与data_dict表相关联可以取出对应的字段
+key_id:存放事件包含的字段的ID,与表app_name的id字段相关联,找到app_name表的id字段对应行的app_key字段与表data_dict表相关联取出对应的字段
+type:存放事件所包含的字段的值所属的类型为int型还是string(0为int,1为string)
+int_value:存放本事件所包含的字段的int型的值
+string_value:存放本事件所包含的字段的string型的值
+
+### instant表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|ts |INT |
+|name |TEXT |
+|ref |INT |
+|wakeup_from |INT |
+|ref_type |TEXT |
+|value |REAL |
+#### 表描述
+记录了系统中的waking和wakeup事件。
+#### 字段描述
+ts:唤醒时间
+name:唤醒事件的名称
+ref:索引号
+wakeup_from:唤醒当前线程的内部线程号(itid)
+ref_type:描述了value字段的类型(一般取值为itid)
+value:一般为当前线程的内部线程号取值
+
+### irq表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
|id |INT |
|ts |INT |
|dur |INT |
|callid |INT |
-|cat |NUM |
-|name |NUM |
+|cat |TEXT |
+|name |TEXT |
|depth |INT |
|cookie |INT |
|parent_id |INT |
|argsetid |INT |
-|chainId |NUM |
-|spanId |NUM |
-|parentSpanId |NUM |
-|flag |NUM |
-|args |NUM |
-#### 字段详细描述:
-dur: 调用时长
-callid: 调用者的ID,比如针对线程表里面的id
-name: 调用名称
-depth: 调用深度
-parent_id: 父调用的id
+|chainId |TEXT |
+|spanId |TEXT |
+|parentSpanId |TEXT |
+|flag |TEXT |
+|args |TEXT |
+#### 表描述
+记录中断相关事件。
+#### 相关字段描述
+dur:调用中断时长
+callid:调用中断者的ID,比如针对线程表里面的id
+cat:调用栈数据类型(取值范围:irq,softirq...)
+name:调用中断的名称
+depth:中断调用的深度
+parent_id:父调用中断的id
+spanId:分布式调用中断关联关系
+
+### live_process表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|ts |INT |
+|dur |INT |
+|cpu_time |INT |
+|process_id |INT |
+|process_name |TEXT |
+|parent_process_id |INT |
+|uid |INT |
+|user_name |TEXT |
+|cpu_usage |REAL |
+|pss_info |INT |
+|thread_num |INT |
+|disk_writes |INT |
+|disk_reads |INT |
+#### 表描述
+记录了一些实时的进程中执行的一些数据(Monitor)。
+#### 主要字段描述
+process_id:进程id
+process_name:进程名
+parent_process_id:父进程的id
+uid:用户id
+user_name:用户名
+cpu_usage:cpu使用率
+pss_info:进程信息
+thread_num:线程数量
+disk_writes:磁盘写量
+disk_reads:磁盘读量
+
+### log表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|seq |INT |
+|ts |INT |
+|pid |INT |
+|tid |INT |
+|level |TEXT |
+|tag |TEXT |
+|context |TEXT |
+|origints |INT |
+#### 表描述
+记录日志信息。
+#### 关键字段描述
+Seq:日志序号,保证日志解析的准确性
+Ts:打印日志时间
+Pid:日志的进程号
+Tid:日志的线程号
+Level:日志级别
+Tag:日志标签
+Context:日志内容
### measure表
-#### 表结构:
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
-|type |NUM |
+|type |TEXT |
|ts |INT |
|value |INT |
|filter_id |INT |
-#### 字段详细描述:
+#### 表描述
+记录所有的计量值。
+#### 关键字段描述
+type:固定字段(measure)
+ts:事件时间
+value:数值
+filter_id:对应filter表中的ID
-### heap表
-#### 表结构:
+### measure_filter表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|type |TEXT |
+|name |TEXT |
+|source_arg_set_id |INT |
+#### 表描述
+记录一个递增的filterid队列,所有其他的filter类型在获取过程中,均从此数据列表中获取下一个可用的filter_id并做记录。
+#### 字段详细描述
+过滤分类(type),过滤名称(key2),数据ID(key1)。
+数据ID在process_measure_filter, sys_event_filter中作为id。
+
+### meta表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
-|eventId |INT |
+|name |TEXT |
+|value |TEXT |
+#### 表描述
+此表记录了数据解析或导出时的一些现场数据,比如使用的TraceStreamer版本, 工具的发布时间,数据解析的时间,数据的持续时长,以及原始数据的格式。
+#### 主要字段描述
+Name:指定元数据的key
+Value:指定元数据的value
+
+### native_hook表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|callChainId |INT |
|ipid |INT |
|itid |INT |
-|event_type |NUM |
+|event_type |TEXT |
+|sub_type_id |NUM |
|start_ts |INT |
|end_ts |INT |
|dur |INT |
|addr |INT |
|heap_size |INT |
|all_heap_size |INT |
-#### 字段详细描述:
+|current_size_dur |INT |
+|last_lib_id |INT |
+#### 表描述
+记录native_hook抓取的某个进程的堆内存,内存映射相关数据。
+#### 关键字段描述
+callChainId:唯一标识一条native_hook数据
+event_type:事件类型取值范围(AllocEvent,FreeEvent,MmapEvent, MunmapEvent)
+sub_type_id:子事件类型(只有sub_type字段为MmapEvent时,该字段才会有值)
+start_ts:申请内存开始时间
+end_ts:释放内存时间
+Dur:申请内存活跃时间
+Addr:申请内存地址
+mem_size:申请或释放内存大小
+all_mem_size:从采集数据开始到当前时刻,申请并活跃的内存总量。 event_type为AllocEvent或者FreeEvent时,表示活跃的堆内存总量。当event_type为MmapEvent或者MunmapEvent时,表示活跃的映射内存总量
+current_size_dur:表示当前活跃内存总量的持续时间
+last_lib_id:函数调用栈他最后一个函数所属的文件路径,除了文件名中带musl和libc++
-### heap_frame表
-#### 表结构:
+### native_hook_frame表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
-|eventId |INT |
+|id |INT |
+|callchain_id |INT |
|depth |INT |
-|ip |INT |
-|sp |INT |
-|symbol_name |NUM |
-|file_path |NUM |
+|symbol_id |INT |
+|file_id |INT |
|offset |INT |
|symbol_offset |INT |
-#### 表描述:
+#### 表描述
记录了内存的申请和释放的堆栈。
-### hidump表
-#### 表结构:
+#### 相关字段描述
+callchain_id:标识一组调用堆栈
+depth:调用栈深度
+symbol_id:函数名
+file_id:函数所属文件
+
+### network表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
|ts |INT |
-|fps |INT |
-#### 表描述:
-此表记录了设备的帧率信息,fps。
-### symbols表
-#### 表结构:
+|dur |INT |
+|tx |INT |
+|rx |INT |
+|tx_speed |REAL |
+|rx_speed |REAL |
+|packet_in |INT |
+|packet_in_sec |REAL |
+|packet_out |INT |
+|packet_out_sec |REAL |
+|net_type |TEXT |
+#### 表描述
+记录了网络数据传输相关的信息。
+#### 主要字段描述
+tv_sec:时间,秒为单位
+tv_nsec:时间,纳秒为单位
+tx_bytes:网络数据的写入量
+rx_bytes:网络数据的读取量
+
+### paged_memory_sample表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
|id |INT |
-|funcname |NUM |
-|addr |INT |
-#### 表描述:
-此表记录了数值和函数调用名称的映射关系。
+|callchain_id |INT |
+|type |INT |
+|ipid |INT |
+|start_ts |INT |
+|end_ts |INT |
+|dur |INT |
+|size |INT |
+|addr |TEXT |
+|itid |INT |
+#### 表描述
+记录了网络数据传输相关的信息。
+#### 主要字段描述
+callchain_id: 取值相同的一组数据,表示一个完整的调用栈
+type:事件类型
+ipid:TS内部进程号
+start_ts:开始时间
+end_ts:结束时间
+dur:持续时间
+size:操作页数
+itid:TS内部线程号
-### measure_filter表
-记录一个递增的filterid队列,所有其他的filter类型在获取过程中,均从此数据列表中获取下一个可用的filter_id并做记录。
-#### 表结构:
-| Columns Name | SQL TYPE |
-|---- |---- |
-|id |NUM |
-|type |NUM |
-|name |INT |
-|source_arg_set_id |INT |
+### perf_callchain表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|callchain_id |INT |
+|depth |INT |
+|vaddr_in_file |INT |
+|file_id |INT |
+|symbol_id |INT |
+|name |TEXT |
+#### 表描述
+记录了Hiperf采样数据的调用栈信息。
+#### 主要字段描述
+callchain_id:标识一组调用堆栈
+depth:调用栈深度
+vaddr_in_file:函数在文件中的虚拟地址
+file_id:与PerfFiles中的file_id字段相关联
+symbol_id:与PerfFiles中的symbol_id相关联
+name:函数名
+
+### perf_files表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|file_id |INT |
+|serial_id |INT |
+|symbol |TEXT |
+|path |TEXT |
+#### 表描述
+记录Hiperf工具采集到的函数符号表和文件名。
+#### 主要字段描述
+file_id:文件编号
+serial_id:一个文件中可能有多个函数,serial_id表示函数的编号
+symbol:函数名
+path:文件路径
+
+### perf_report表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|report_type |TEXT |
+|report_value |TEXT |
+#### 表描述
+记录Hiperf工具采集数据时的配置信息。包括:抓取的事件类型,抓取数据的命令, 抓数据时指定的进程名称。
+#### 主要字段描述
+report_type:数据类型。取值只有三种类型:config_name(事件类型), workload(抓取的进程名), cmdline(抓取命令)
+report_value:对应类型的取值
+
+### perf_sample表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|callchain_id |INT |
+|timestamp |INT |
+|thread_id |INT |
+|event_count |INT |
+|event_type_id |INT |
+|timestamp_trace |INT |
+|cpu_id |INT |
+|thread_state |TEXT |
+#### 表描述
+记录Hiperf工具的采样信息。
+#### 主要字段描述
+timestamp:未进行时钟源同步的时间戳
+thread_id:线程号
+event_count:采样统计
+event_type_id:事件类型编号。与PerfReport表的id字段相关联
+timestamp_trace:时钟源同步后的时间戳
+cpu_id:cpu核编号
+thread_state:线程状态。采样对应Sched_Waking事件时,为Runing;对应Sched_Switch事件时,为Suspend。其余事件类型,为“-”
+
+### perf_thread表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|thread_id |INT |
+|process_id |INT |
+|thread_name |TEXT |
+#### 表描述
+记录Hiperf工具采集到的进程和线程数据。
+#### 主要字段描述
+thread_id:线程号
+process_id:进程号
+thread_name:线程名
+
+### process表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|ipid |INT |
+|type |TEXT |
+|pid |INT |
+|name |TEXT |
+|start_ts |INT |
+|switch_count |INT |
+|thread_count |INT |
+|slice_count |INT |
+|mem_count |INT |
+#### 表描述
+记录了进程相关数据。
+#### 关键字段描述
+id:进程在数据库重新重新定义的id,从0开始序列增长
+ipid:TS内部进程id
+type:固定取值:process
+pid:进程的真实id
+name:进程名字
+start_ts:开始时间
+switch_count:统计其切换次数
+thread_count:统计其线程个数
+slice_count:进程是否有线程和线程切换数据
+mem_count:进程是否有内存数据
+
+### process_filter表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|type |TEXT |
+|name |TEXT |
+|ipid |INT |
+#### 表描述
+将进程ID作为key1,进程的内存,界面刷新,屏幕亮度等信息作为key2,唯一确定一个filter_id, filter_id同时被记录在filter表中。
+#### 主要字段描述
+id:进程id
+type:固定取值:process_filter
+name:进程名
+ipid:该进程表中的id与process表中的id相关联
+
+### process_measure表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|type |TEXT |
+|ts |INT |
+|value |NUM |
+|filter_id |INT |
+#### 表描述
+保存进程的内存,堆栈值等所有计量值信息。
+#### 字段详细描述
+ts:事件时间
+value:数值
+filter_id:对应process_measure_filter表中的ID
-#### 字段详细描述:
-过滤分类(type),过滤名称(key2),数据ID(key1)。
-数据ID在process_measure_filter, sys_event_filter中作为id。
### process_measure_filter表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|type |TEXT |
+|name |TEXT |
+|ipid |INT |
+#### 表描述
将进程ID作为key1,进程的内存,界面刷新,屏幕亮度等信息作为key2,唯一确定一个filter_id, filter_id同时被记录在measure_filter表中。
-#### 表结构:
+#### 字段详细描述
+type:固定取值:process_measure_filter
+name:cpu状态名
+ipid:进程内部编号
+
+### raw表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|type |TEXT |
+|ts |INT |
+|name |TEXT |
+|cpu |INT |
+|itid |INT |
+#### 表描述
+记录了系统中的waking、wakup、cpu_idel、cpu_frequency数据。
+#### 相关字段描述
+type:固定字段(raw)
+name:调度名称(取值:cpu_idle,sched_wakeup,sched_waking)
+cpu:事件发生在哪个CPU
+itid:时间对应哪个utid
+
+### sched_slice表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
|id |INT |
-|type |NUM |
-|name |NUM |
+|type |TEXT |
+|ts |INT |
+|dur |INT |
+|ts_end |INT |
+|cpu |INT |
+|itid |INT |
+|end_state |TEXT |
+|priority |INT |
+#### 表描述
+此数据结构主要作为ThreadState的上下文使用,这张表是sched_switch事件的原始记录。
+#### 主要字段描述
+ts:事件发生事件
+type:固定字段(sched_slice)
+dur:状态持续时长
+ts_end:状态结束时长
+cpu:事件发生在哪个cpu
+itid:事件对应哪个utid
+end_state:线程的终结状态
+
+### smaps表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|timestamp |INT |
+|start_addr |TEXT |
+|end_addr |TEXT |
+|dirty |INT |
+|swapper |INT |
+|resident_size |INT |
+|pss |INT |
+|virtaul_size |INT |
+|reside |REAL |
+|protection_id |INT |
+|path_id |INT |
+#### 表描述
+记录进程的内存消耗的相关信息采样。
+#### 主要字段描述
+id:状态持续时长
+timestamp:事件发生事件
+start_addr:内存段地址的起始位置
+end_addr:内存段地址的结束位置
+dirty:其他进程共享的被写的页的大小 + 已被改写的私有页面的大小
+swapper:存在于交换分区的数据大小
+resident_size:实际分配的内存大小
+pss:平摊计算后的实际物理使用内存
+virtaul_size:虚拟内存空间的大小
+reside:实际分配的内存大小与虚拟内存空间的大小的比
+protection_id:内存段的权限id与表data_dict的id字段相关联
+path_id:如果区域是从文件映射的,则这是文件的名称对应的id序号与表data_dict的id字段相关联
+
+### stat表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|event_name |TEXT |
+|stat_type |TEXT |
+|count |INT |
+|serverity |TEXT |
+|source |TEXT |
+#### 表描述
+此结果用来统计数据解析中各类数据的数据条数,数据和合法性,数据的匹配程度(begin-end),数据的损失等,查看此结构对应的表,可对数据源有基本的了解。
+#### 主要字段描述
+event_name:数据类型
+stat_type:数据状态
+count:数据条数
+severity:严重级别
+source:数据来源
+
+### symbols表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|funcname |TEXT |
+|addr |INT |
+#### 表描述
+此表记录了被调用函数与其地址的映射关系。
+#### 相关字段描述
+funcname:系统调用名称
+adr:系统调用地址
+
+### syscall表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|syscall_num |INT |
+|type |TEXT |
|ipid |INT |
-#### 字段详细描述:
-filterid: 来自measure_filter表
-name: cpu状态名
-ipid: 进程内部编号
-### data_type表
-#### 表结构:
+|ts |INT |
+|ret |INT |
+#### 表描述
+记录用户空间函数与内核空间函数相互调用记录。
+#### 相关字段描述
+syscall_num:系统调用的序号
+type:固定取值:enter或者exit
+ipid:线程所属的进程ID
+ts:时间戳
+ret:返回值,在type为exit时有效
+
+### sys_event_filter表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
|id |INT |
-|typeId |INT |
-|desc |NUM |
-#### 表描述:
-此表记录了一个数据类型ID和数据描述的映射。
-### data_dict表
-#### 表结构:
+|type |TEXT |
+|name |TEXT |
+#### 表描述
+记录所有的filter。
+#### 相关字段描述
+type:文件类型
+name:文件名
+
+### sys_mem_measure表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|type |TEXT |
+|ts |INT |
+|value |INT |
+|filter_id |INT |
+#### 表描述
+记录系统内存与系统虚拟内存。
+#### 相关字段描述
+ts:事件时间
+value:数值
+filter_id:对应filter表中的ID
+
+### thread表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|id |INT |
+|itid |INT |
+|type |TEXT |
+|tid |INT |
+|name |TEXT |
+|start_ts |INT |
+|end_ts |INT |
+|ipid |INT |
+|is_main_thread|INT |
+|switch_count |INT |
+#### 表描述
+记录了线程相关数据。
+#### 字段详细描述
+id:线程在数据库重新重新定义的id,从0开始序列增长
+itid:TS内部线程id
+type:固定字段(thread)
+tid:线程号
+name:线程名
+start_ts:开始时间
+end_ts:结束时间
+ipid:线程所属的进程id, 关联process表中的ID
+is_main_thread:是否主线程,主线程即该线程实际就是进程本身
+switch_count:当前线程的切换次数
+
+### thread_filter表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
|id |INT |
-|data |NUM |
-#### 表描述:
-此表记录了一个数据类型ID和字符串的映射。
-### meta表
-#### 表结构:
+|type |TEXT |
+|name |TEXT |
+|itid |INT |
+#### 表描述
+将线程ID作为key1,线程的内存,界面刷新,屏幕亮度等信息作为key2,唯一确定一个filter_id, filter_id同时被记录在filter表中。
+#### 主要字段描述
+id:线程id
+type:线程类型
+name:线程名称
+itid:该表中的tid与thread表中的tid相关联
+
+### thread_state表
+#### 表结构
| Columns Name | SQL TYPE |
|---- |---- |
-|name |NUM |
-|value |NUM |
-#### 表描述:
-此表记录了数据解析或导出时的一些现场数据,比如使用的trace_streamer版本, 工具的发布时间,数据解析的时间,数据的持续时长,以及原始数据的格式。
+|id |INT |
+|type |TEXT |
+|ts |INT |
+|dur |INT |
+|cpu |INT |
+|itid |INT |
+|tid |INT |
+|pid |INT |
+|state |TEXT |
+#### 表描述
+记录了线程状态相关的数据。
+#### 字段详细描述
+id:线程状态在数据库中的id,从0开始序列增长
+ts:该线程状态的起始时间
+dur:该线程状态的持续时间
+cpu:该线程在哪个cpu上执行(针对running状态的线程)
+itid:该状态所属的线程id, 关联线程表中的id
+tid:线程号
+pid:进程号
+state:线程实际的的状态值
+```
+'R', Runnable状态
+'S', interruptible sleep
+'D', uninterruptible sleep
+'T', Stoped
+'t', Traced
+'X', ExitedDead
+'Z', ExitZombie
+'x', TaskDead
+'I', TaskDead
+'K', WakeKill
+'P', Parked
+'N', NoLoad
+```
+
+### clock_snapshot表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|clock_id |INT |
+|ts |INT |
+|clock_name |TEXT |
+#### 表描述
+时钟号和时间,时钟名的映射表。
+#### 关键字段描述
+clock_id:时钟号
+ts:时钟快照报的时间
+clock_name:时钟号对应的时钟名字
+时钟快照是用来对齐不同时钟号的时间。
+比如,时钟号1的时间100,和时钟号2的时间200对齐。
+则时钟号为2 的250,转换为时钟号1的时间后,为150
+
+### datasource_clockid表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|data_source_name |TEXT |
+|clock_id |INT |
+#### 表描述
+数据源和时钟号的映射表。
+#### 关键字段描述
+data_source_name:数据源的名称,和数据源的插件名保持一致
+clock_id:时钟号,对应clock_snapshot中的时钟号
+这个表是用来告诉IDE,不同的事件源的事件,原始时钟号是多少,在数据库中保存的事件,通常是转换为boottime后的时间,但有些情况下,IDE仍然需要知道原始的时钟号是怎样的
+
+### trace_range表
+#### 表结构
+| Columns Name | SQL TYPE |
+|---- |---- |
+|start_ts |INT |
+|end_ts |INT |
+#### 表描述
+记录解析解析开始时间以及结束时间。
+#### 关键字段描述
+start_ts:trace的开始时间,纳秒为单位
+end_ts:trace的结束时间,纳秒为单位
\ No newline at end of file
diff --git a/host/trace_streamer/doc/des_wakeup.md b/host/trace_streamer/doc/des_wakeup.md
new file mode 100644
index 0000000000000000000000000000000000000000..c6675cef62c52e81be59a2cd0afb06802ed75c1c
--- /dev/null
+++ b/host/trace_streamer/doc/des_wakeup.md
@@ -0,0 +1,4 @@
+# 关于wakeup事件和waking事件的处理说明
+对于trace事件的waking和wakeup处理,我们的策略如下:
+waking是开始唤醒线程,wakeup是线程正式被唤醒,进入runnable(可运行状态);
+我们的策略是:被唤醒才是真正进入runnable状态,在没有wakeup事件的情况下,以waking为准。
\ No newline at end of file
diff --git a/host/trace_streamer/figures/db_common.png b/host/trace_streamer/figures/db_common.png
new file mode 100755
index 0000000000000000000000000000000000000000..29dbb080e1d213672b74d553610f6a24445663ad
Binary files /dev/null and b/host/trace_streamer/figures/db_common.png differ
diff --git a/host/trace_streamer/figures/db_hiperf.png b/host/trace_streamer/figures/db_hiperf.png
new file mode 100755
index 0000000000000000000000000000000000000000..85cacf15a7153a0853c7aeee2fe34fba1f8983a8
Binary files /dev/null and b/host/trace_streamer/figures/db_hiperf.png differ
diff --git a/host/trace_streamer/figures/db_hisys_event.png b/host/trace_streamer/figures/db_hisys_event.png
new file mode 100755
index 0000000000000000000000000000000000000000..215265182de684f1b4a31fd7158309f8c7532053
Binary files /dev/null and b/host/trace_streamer/figures/db_hisys_event.png differ
diff --git a/host/trace_streamer/figures/db_native_memory.png b/host/trace_streamer/figures/db_native_memory.png
new file mode 100755
index 0000000000000000000000000000000000000000..0e1403e958fbf76f3d2c31fc6304426de6579afb
Binary files /dev/null and b/host/trace_streamer/figures/db_native_memory.png differ
diff --git a/host/trace_streamer/figures/dump_and_mem.png b/host/trace_streamer/figures/dump_and_mem.png
old mode 100644
new mode 100755
index b7e3cc26ca286702c9ca9869fc203aff34a8da39..2c3f59eef7476de91cafb8f59832c93fe4117e51
Binary files a/host/trace_streamer/figures/dump_and_mem.png and b/host/trace_streamer/figures/dump_and_mem.png differ
diff --git a/host/trace_streamer/figures/log.png b/host/trace_streamer/figures/log.png
old mode 100644
new mode 100755
index dbe3780eb647493dec252d69f23e71cf66ac15a8..0c9ac304183f2276454caeb2fea593a5e88bdc13
Binary files a/host/trace_streamer/figures/log.png and b/host/trace_streamer/figures/log.png differ
diff --git a/host/trace_streamer/figures/perf.png b/host/trace_streamer/figures/perf.png
new file mode 100755
index 0000000000000000000000000000000000000000..9fc88ad255cece0040093392329e639e261c8bd9
Binary files /dev/null and b/host/trace_streamer/figures/perf.png differ
diff --git a/host/trace_streamer/figures/process_thread.png b/host/trace_streamer/figures/process_thread.png
old mode 100644
new mode 100755
index abc3867130c10413197482d0156ce0ee00aca255..305a9bdb02d7776f086f8f13d5f6f72e72443226
Binary files a/host/trace_streamer/figures/process_thread.png and b/host/trace_streamer/figures/process_thread.png differ
diff --git a/host/trace_streamer/figures/thread_state.png b/host/trace_streamer/figures/thread_state.png
old mode 100644
new mode 100755
index 186ffb16905c7cfa0178f7c14a0189223f6c9e22..aa9f846fcc4b88c1b8e9df75e3aff7ada69537dc
Binary files a/host/trace_streamer/figures/thread_state.png and b/host/trace_streamer/figures/thread_state.png differ
diff --git a/host/trace_streamer/gn/BUILD.gn b/host/trace_streamer/gn/BUILD.gn
old mode 100644
new mode 100755
index a44389bdd809eccfeeb146bb62d42242f4a1c6ae..53914a5d744d46531250393481a313460d524721
--- a/host/trace_streamer/gn/BUILD.gn
+++ b/host/trace_streamer/gn/BUILD.gn
@@ -11,6 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
print("target_os", target_os)
+print("target_name", target)
group("default_deps") {
public_configs = [ ":default_config" ]
public_deps = []
@@ -24,10 +25,17 @@ config("default_config") {
config("trace_cfg") {
cflags_cc = [
"-std=c++17",
- "-fno-rtti",
- "-fno-exceptions",
+
+ # "-std=gnu++17",
"-fvisibility=hidden",
+ "-Wno-unused-variable",
]
+ if (!is_test) {
+ cflags_cc += [
+ "-fno-rtti",
+ "-fno-exceptions",
+ ]
+ }
}
config("visibility_hidden") {
@@ -41,12 +49,14 @@ config("default") {
cflags = [
"-fstrict-aliasing",
- "-fPIC",
"-g",
"-Wformat",
+ "-Wno-unused-variable",
]
-
- if (is_linux) {
+ if (is_debug && is_win) {
+ ldflags = [ "-fstack-protector" ]
+ }
+ if (is_linux || is_macx) {
cflags += [
"-Wa,--noexecstack",
"-fcolor-diagnostics",
@@ -55,25 +65,73 @@ config("default") {
]
if (!use_wasm) {
cflags += [
- "-fPIE",
"-fstack-protector-strong",
"-fstack-protector-all",
"-D_FORTIFY_SOURCE=2 -O2",
+ "-D SUPPORTTHREAD", # if support thread
+
+ # "-D HAVE_ELF_H",
+ "-D target_cpu_x64",
+
+ # "-D HAVE_LINK_H",
+ # "-D_GNU_SOURCE",
+ "-DHAVE_CONFIG_H",
+ "-DNDEBUG",
+ "-DCC_IS_CLANG",
]
+ # with_libunwind = true
}
- libs += [
- "pthread",
- "rt",
- ]
- if (is_debug) {
- libs += [ "dl" ]
+ if (!use_wasm && !is_win && !is_macx && !is_test) {
+ cflags += [ "-D HAVE_LIBUNWIND" ]
+ }
+
+ cflags += [ "-D USE_VTABLE" ]
+ if (use_wasm) {
+ cflags += [
+ "-D IS_WASM",
+ "-D GOOGLE_PROTOBUF_NO_RDTSC",
+
+ # "-D HAVE_LIBUNWIND",
+ "-D target_cpu_x64",
+ "-DHAVE_CONFIG_H",
+ "-DNDEBUG",
+ "-DCC_IS_CLANG",
+ "-D__x86_64__",
+ ]
+ }
+ cflags += [ "-D BINDER_ASYNC" ]
+ libs += [ "pthread" ]
+ if (!is_macx) {
+ libs += [ "rt" ]
+ }
+ if (!is_win) {
+ cflags += [
+ "-fPIE",
+ "-fPIC",
+ ]
}
}
+ if (is_win) {
+ cflags += [ "-D is_mingw" ]
+ defines = [ "WIN32_LEAN_AND_MEAN" ]
+ libs += [ "wsock32" ]
+ libs += [ "Ws2_32" ]
+ cflags += [
+ "-D SECUREC_IS_DLL_LIBRARY",
+ "-D __KERNEL__",
+ ]
+ }
+ if (with_perf) {
+ cflags += [ "-D WITH_PERF" ]
+ }
+ if (with_ebpf_help_table) {
+ cflags += [ "-D WITH_EBPF_HELP" ]
+ }
}
config("symbols") {
cflags = [ "-O0" ]
- if (is_linux) {
+ if (is_linux || is_macx) {
cflags += [ "-funwind-tables" ]
}
}
@@ -85,42 +143,69 @@ config("release") {
]
cflags += [ "-O3" ]
- ldflags = [
- "-fuse-ld=gold",
- "-fstack-protector",
- "-Wl,--gc-sections",
- "-Wl,-O1",
- "-fpie",
- "-pie",
- ]
+ ldflags = [ "-fstack-protector" ]
+ if (!is_macx) {
+ ldflags += [ "-Wl,-O1" ]
+ if (!is_win) {
+ ldflags += [
+ "-fuse-ld=gold",
+ "-Wl,--gc-sections",
+ ]
+ }
+ }
+
+ if (!is_win && !is_macx) {
+ ldflags += [
+ "-fPIC",
+ "-fpie",
+ "-pie",
+ ]
+ }
defines = [ "NDEBUG" ]
}
config("shared_library") {
- ldflags = [ "-fPIC" ]
+ if (!is_win) {
+ ldflags = [ "-fPIC" ]
+ }
}
config("executable") {
print("use_wasm", use_wasm)
ldflags = []
- if (is_linux && !use_wasm) {
- ldflags += [
- # "-Wl,-rpath=\$ORIGIN/.",
+ if (is_linux || (is_macx && !use_wasm)) {
+ ldflags += []
+ }
+ if (!is_macx && !use_wasm && !is_win) {
+ ldflags = [
+ "-Wl,--disable-new-dtags",
+ "-Wl,-z,noexecstack",
+ "-lrt",
+ "-fuse-ld=gold",
"-Wl,-z,now",
-
- # "-Wl,-rpath-link=.",
"-Wl,-z,relro",
- "-lrt",
- "-fpie",
- "-pie",
- "-Wl,-z,noexecstack",
- "-Wl,--disable-new-dtags",
+ ]
+ }
+ if (!is_macx && !use_wasm) {
+ ldflags += [ "-fpie" ]
+ }
+ if (!is_macx && !use_wasm && !is_win) {
+ ldflags += [ "-pie" ]
+ }
- # "-s", # delete sambols
+ if (is_macx) {
+ ldflags += [
+ "-fdata-sections",
+ "-ffunction-sections",
]
+ if (!use_wasm) {
+ ldflags += [ "-Wl,-U,__sanitizer_options_link_helper" ]
+ }
}
- if (!is_debug) {
+ if (!is_debug && !is_macx) {
ldflags += [ "-s" ]
+ } else if (!is_debug && is_macx) {
+ ldflags += [ "-dead_strip" ]
}
}
diff --git a/host/trace_streamer/gn/CONFIG.gn b/host/trace_streamer/gn/CONFIG.gn
old mode 100644
new mode 100755
index babf9755e98d0478a5f2d895668a9d296c026c0d..fc52b2f69947f7aa1da034aeb7080fe14620aab1
--- a/host/trace_streamer/gn/CONFIG.gn
+++ b/host/trace_streamer/gn/CONFIG.gn
@@ -12,32 +12,59 @@
# limitations under the License.
is_win = false
is_linux = false
+is_macx = false
+is_protoc = false
+with_perf = true
+with_ebpf_help_table = false
+is_mingw = false
+with_libunwind = false
+is_sdkdemo = false
+is_sdkdemo_test = false
+target_cpu = "x64"
declare_args() {
ar = "ar"
is_debug = true
use_wasm = false
is_test = false
+ is_sdkdemo = false
+ is_sdkdemo_test = false
+ testonly = false
+ is_fuzz = false
+ is_macx = false
+ target = "trace_streamer"
}
if (target_os == "linux") {
- is_win = false
is_linux = true
- is_test = false
+} else if (target_os == "macx") {
+ is_macx = true
} else if (target_os == "windows") {
is_win = true
- is_linux = false
- is_test = false
-} else if (target_os == "wasm") {
- is_win = false
- is_linux = true
+ is_mingw = true
+} else {
+ print("unknown platform " + target_os)
+ exit(-1)
+}
+
+if (target == "wasm") {
use_wasm = true
- is_test = false
-} else if (target_os == "test") {
- is_win = false
- is_linux = true
- use_wasm = false
+} else if (target == "test") {
is_test = true
+ testonly = true
+} else if (target == "fuzz") {
+ is_fuzz = true
+ testonly = true
+} else if (target == "protoc") {
+ is_protoc = true
+} else if (target == "sdkdemo") {
+ is_sdkdemo = true
+ use_wasm = true
+} else if (target == "sdkdemotest") {
+ is_sdkdemo_test = true
+ testonly = true
+} else if (target == "trace_streamer" || target == "streamer") {
+ print("build " + target)
} else {
- print("unknown platform " + target_os)
+ print("unknown target " + target_os)
exit(-1)
}
@@ -55,11 +82,16 @@ if (!is_debug) {
default_configs -= [ "//gn:symbols" ]
default_configs += [ "//gn:release" ]
}
+if (is_debug) {
+ with_ebpf_help_table = true
+}
set_defaults("ohos_source_set") {
configs = default_configs
}
-
+set_defaults("ohos_shared_library") {
+ configs = default_configs
+}
set_defaults("executable") {
configs = default_configs
configs += [ "//gn:executable" ]
diff --git a/host/trace_streamer/gn/toolchain/BUILD.gn b/host/trace_streamer/gn/toolchain/BUILD.gn
old mode 100644
new mode 100755
index e1b24fd43144cd73b0ff6dfff19499fef1b9f63c..3b31509464aa0660a9b73a9d08b4865bff5d292d
--- a/host/trace_streamer/gn/toolchain/BUILD.gn
+++ b/host/trace_streamer/gn/toolchain/BUILD.gn
@@ -13,12 +13,20 @@
import("//gn/wasm.gni")
declare_args() {
- if (target_os == "linux" || target_os == "wasm" || target_os == "test") {
+ if (target_os == "linux" || target_os == "macx") {
cc = "/usr/bin/clang"
cxx = "/usr/bin/clang++"
+ pic = "-fPIC"
+ rebuild_string = ""
+ extra_asmflags = ""
+ asm = "/usr/bin/clang"
} else if (target_os == "windows") {
- cc = "~/mingw-w64/ohos/linux-x86_64/clang-mingw/bin/clang"
- cxx = "~/mingw-w64/ohos/linux-x86_64/clang-mingw/bin/clang++"
+ cc = "gcc.exe"
+ cxx = "g++.exe"
+ rebuild_string = ""
+ extra_asmflags = ""
+ asm = "gcc.exe"
+ pic = ""
}
if (use_wasm == true) {
print("make_wasm")
@@ -26,12 +34,13 @@ declare_args() {
print("no make_wasm")
}
cc_wrapper = ""
- is_mac = false
}
toolchain("wasm") {
# emsdk_dir and em_config are defined in wasm.gni.
print("use gcc_like_chain wasm")
- ar = "$emsdk_dir/emscripten/emar --em-config $em_config"
+ if (!is_macx) {
+ ar = "$emsdk_dir/emscripten/emar --em-config $em_config"
+ }
cc = "$emsdk_dir/emscripten/emcc --em-config $em_config"
cxx = "$emsdk_dir/emscripten/em++ --em-config $em_config"
@@ -82,7 +91,11 @@ toolchain("wasm") {
tool("alink") {
rspfile = "{{output}}.rsp" # must be defined
rspfile_content = "{{inputs}}"
- command = "rm -rf {{output}} && $ar rcsD {{output}} @$rspfile"
+ if (is_macx) {
+ command = "rm -f {{output}} && libtool -static {{arflags}} -o {{output}} -filelist $rspfile"
+ } else {
+ command = "rm -rf {{output}} && $ar rcsD {{output}} @$rspfile"
+ }
outputfiles = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
outputs = [ outputfiles ]
output_prefix = "lib"
@@ -124,7 +137,7 @@ toolchain("gcc_like") {
tool("cxx") {
depfile = "{{output}}.d" # must be defined
- command = "$cxx -o {{output}} -MMD -MF $depfile {{defines}} -fPIC {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}}"
+ command = "$cxx -o {{output}} -MMD -MF $depfile {{defines}} $pic {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}}"
outputfiles =
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"
outputs = [ outputfiles ]
@@ -133,16 +146,29 @@ toolchain("gcc_like") {
tool("cc") {
depfile = "{{output}}.d"
- command = "$cc -o {{output}} -MMD -MF $depfile {{defines}} -fPIC {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}}"
+ command = "$cc -o {{output}} -MMD -MF $depfile {{defines}} $pic {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}}"
outputfiles =
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"
outputs = [ outputfiles ]
description = "step: compile {{source}}"
}
+ tool("asm") {
+ depfile = "{{output}}.d"
+ command = "$asm -o {{output}} -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{asmflags}}${extra_asmflags} -c {{source}}"
+ depsformat = "gcc"
+ outputfiles =
+ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"
+ outputs = [ outputfiles ]
+ }
tool("alink") {
rspfile = "{{output}}.rsp" # this must be defined
- rspfile_content = "{{inputs}}" # this must be defined
- command = "rm -f {{output}} && $ar rcsD {{output}} @$rspfile"
+ if (is_macx) {
+ rspfile_content = "{{inputs_newline}}"
+ command = "rm -f {{output}} && libtool -static {{arflags}} -filelist $rspfile -o {{output}}"
+ } else {
+ rspfile_content = "{{inputs}}" # this must be defined
+ command = "rm -f {{output}} && $ar rcsD {{output}} @$rspfile"
+ }
outputsfiles = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
outputs = [ outputsfiles ]
default_output_extension = ".a"
diff --git a/host/trace_streamer/gn/wasm.gni b/host/trace_streamer/gn/wasm.gni
index 7209ff6666891129c98ee7cce901d63564e7bd88..b4c986495cbb7afe176ebaa0972e22e932b6fa75 100644
--- a/host/trace_streamer/gn/wasm.gni
+++ b/host/trace_streamer/gn/wasm.gni
@@ -46,6 +46,7 @@ template("wasm_lib") {
"EXPORT_NAME=${target_name}",
"-s",
"MODULARIZE=1",
+ "-lworkerfs.js", # For FS.filesystems.WORKERFS
]
_lib_name = invoker.name
if (is_debug) {
@@ -61,10 +62,10 @@ template("wasm_lib") {
]
} else {
_target_ldflags += [
- "-g2", # Required for getting C++ symbol names.
+ # "-g2", # Required for getting C++ symbol names.
"-O3",
- "-s",
- "ASSERTIONS=1",
+ # "-s",
+ # "ASSERTIONS=1",
]
}
diff --git a/host/trace_streamer/pare_third_party.sh b/host/trace_streamer/pare_third_party.sh
new file mode 100755
index 0000000000000000000000000000000000000000..7135a968dde59de998a6edc9bdf9a0d346ac473e
--- /dev/null
+++ b/host/trace_streamer/pare_third_party.sh
@@ -0,0 +1,100 @@
+#!/bin/bash
+# Copyright (c) 2021 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+patch='patch'
+sed='sed'
+case "$OSTYPE" in
+ msys*) patch='patch.exe' sed='sed.exe' ;;
+ darwin*) out='../../out/macx' ;;
+ linux*) out='../../out/linux' ;;
+ *) echo "other: $OSTYPE" ;;
+esac
+
+if [ ! -d "third_party" ];then
+ mkdir third_party
+fi
+cd third_party
+
+if [ ! -f "sqlite/BUILD.gn" ];then
+ rm -rf sqlite
+ git clone git@gitee.com:openharmony/third_party_sqlite.git
+ if [ -d "third_party_sqlite" ];then
+ mv third_party_sqlite sqlite
+ $patch -p0 ../third_party/sqlite/BUILD.gn ../prebuilts/patch_sqlite/sqlite3build.gn.patch
+ else
+ echo 'third_party_sqlite not exist'
+ fi
+fi
+if [ ! -f "protobuf/BUILD.gn" ];then
+ rm -rf protobuf
+ git clone git@gitee.com:openharmony/third_party_protobuf.git
+ if [ -d "third_party_protobuf" ];then
+ mv third_party_protobuf protobuf
+ $patch -p0 ../third_party/protobuf/BUILD.gn ../prebuilts/patch_protobuf/protobufbuild.gn.patch
+ else
+ echo 'third_party_protobuf not exist'
+ fi
+fi
+
+if [ ! -f "googletest/BUILD.gn" ];then
+ rm -rf googletest
+ git clone git@gitee.com:openharmony/third_party_googletest.git
+ if [ -d "third_party_googletest" ];then
+ mv third_party_googletest googletest
+ $patch -p0 ../third_party/googletest/BUILD.gn ../prebuilts/patch_googletest/googletestbuild.gn.patch
+ $patch -p0 ../third_party/googletest/googletest/include/gtest/internal/gtest-internal.h ../prebuilts/patch_googletest/gtest_internal.h.patch
+ $patch -p0 ../third_party/googletest/googletest/include/gtest/internal/gtest-port.h ../prebuilts/patch_googletest/gtest_port.h.patch
+ $patch -p0 ../third_party/googletest/googletest/include/gtest/gtest-message.h ../prebuilts/patch_googletest/gtest-message.h.patch
+ $sed -i "/using ::std::string/s/^\(.*\)$/\/\/\1/g" ../third_party/googletest/googletest/include/gtest/hwext/gtest-tag.h
+
+ else
+ echo 'third_party_googletest not exist'
+ fi
+fi
+
+if [ ! -f "json-master/BUILD.gn" ];then
+ rm -rf json-master
+ git clone git@gitee.com:openharmony/third_party_json.git
+ if [ -d "third_party_json" ];then
+ mv third_party_json json-master
+ else
+ echo 'third_party_json not exist'
+ fi
+fi
+
+if [ ! -f "libunwind/BUILD.gn" ];then
+ rm -rf libunwind
+ git clone git@gitee.com:openharmony/third_party_libunwind.git
+ if [ -d "third_party_libunwind" ];then
+ mv third_party_libunwind libunwind
+ $patch -p0 libunwind/BUILD.gn ../prebuilts/patch_libunwind/libunwindbuild.gn.patch
+ else
+ echo 'third_party_libunwind not exist'
+ fi
+fi
+
+if [ ! -f "perf_include/libbpf/linux/perf_event.h" ];then
+ mkdir -p perf_include/libbpf/linux
+ rm -rf perf_event.h
+ curl https://gitee.com/openharmony/third_party_libbpf/raw/master/include/uapi/linux/perf_event.h > perf_event.h
+ mv perf_event.h perf_include/libbpf/linux/perf_event.h
+ $patch -p0 perf_include/libbpf/linux/perf_event.h ../prebuilts/patch_perf_event/perf_event.h.patch
+fi
+
+if [ ! -f "perf_include/musl/elf.h" ];then
+ mkdir -p perf_include/musl
+ rm -rf elf.h
+ curl https://gitee.com/openharmony/third_party_musl/raw/master/include/elf.h > elf.h
+ mv elf.h perf_include/musl/elf.h
+fi
\ No newline at end of file
diff --git a/host/trace_streamer/prebuilts/buildprotobuf/libprotobuf_lite_la_SOURCES.pri b/host/trace_streamer/prebuilts/buildprotobuf/libprotobuf_lite_la_SOURCES.pri
deleted file mode 100644
index 39c051faf41b82d7cf1e62dda7c147eeb95d9494..0000000000000000000000000000000000000000
--- a/host/trace_streamer/prebuilts/buildprotobuf/libprotobuf_lite_la_SOURCES.pri
+++ /dev/null
@@ -1,64 +0,0 @@
-# Copyright (C) 2021 Huawei Device Co., Ltd.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
- message("qmake" $${PROTOBUDIR}"/src")
-win32 {
-SOURCES += $${PROTOBUDIR}/src/google/protobuf/io/io_win32.cc
-}
-SOURCES += \
- $${PROTOBUDIR}/src/google/protobuf/stubs/bytestream.cc \
- $${PROTOBUDIR}/src/google/protobuf/stubs/common.cc \
- $${PROTOBUDIR}/src/google/protobuf/stubs/int128.cc \
-# $${PROTOBUDIR}/src/google/protobuf/stubs/once.cc \
- $${PROTOBUDIR}/src/google/protobuf/stubs/int128.h \
-# $${PROTOBUDIR}/src/google/protobuf/io/io_win32.cc \
- $${PROTOBUDIR}/src/google/protobuf/stubs/status.cc \
- $${PROTOBUDIR}/src/google/protobuf/stubs/statusor.cc \
- $${PROTOBUDIR}/src/google/protobuf/stubs/statusor.h \
- $${PROTOBUDIR}/src/google/protobuf/stubs/stringpiece.cc \
- $${PROTOBUDIR}/src/google/protobuf/stubs/stringprintf.cc \
- $${PROTOBUDIR}/src/google/protobuf/stubs/structurally_valid.cc \
- $${PROTOBUDIR}/src/google/protobuf/stubs/strutil.cc \
- $${PROTOBUDIR}/src/google/protobuf/stubs/time.cc \
-# $${PROTOBUDIR}/src/google/protobuf/any_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/arena.cc \
-# $${PROTOBUDIR}/src/google/protobuf/arenastring.cc \
- $${PROTOBUDIR}/src/google/protobuf/extension_set.cc \
- $${PROTOBUDIR}/src/google/protobuf/generated_enum_util.cc \
- $${PROTOBUDIR}/src/google/protobuf/generated_message_util.cc \
-# $${PROTOBUDIR}/src/google/protobuf/generated_message_table_driven_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/implicit_weak_message.cc \
- $${PROTOBUDIR}/src/google/protobuf/message_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/parse_context.cc \
- $${PROTOBUDIR}/src/google/protobuf/repeated_field.cc \
-# $${PROTOBUDIR}/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc \
-# $${PROTOBUDIR}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc \
- $${PROTOBUDIR}/src/google/protobuf/wire_format_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/io/coded_stream.cc \
- $${PROTOBUDIR}/src/google/protobuf/io/strtod.cc \
- $${PROTOBUDIR}/src/google/protobuf/io/zero_copy_stream.cc \
- $${PROTOBUDIR}/src/google/protobuf/io/zero_copy_stream_impl.cc \
- $${PROTOBUDIR}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
-
-HEADERS += \
- $${PROTOBUDIR}/src/google/protobuf/stubs/bytestream.h \
- $${PROTOBUDIR}/src/google/protobuf/stubs/hash.h \
- $${PROTOBUDIR}/src/google/protobuf/io/coded_stream_inl.h \
-# $${PROTOBUDIR}/src/google/protobuf/generated_message_table_driven_lite.h \
- $${PROTOBUDIR}/src/google/protobuf/stubs/time.h \
- $${PROTOBUDIR}/src/google/protobuf/stubs/stringprintf.h \
- $${PROTOBUDIR}/src/google/protobuf/stubs/stringpiece.h \
- $${PROTOBUDIR}/src/google/protobuf/stubs/status.h \
- $${PROTOBUDIR}/src/google/protobuf/stubs/status_macros.h \
-# $${PROTOBUDIR}/src/google/protobuf/io/io_win32.h \
- $${PROTOBUDIR}/src/google/protobuf/stubs/map_util.h \
- $${PROTOBUDIR}/src/google/protobuf/stubs/mathutil.h
diff --git a/host/trace_streamer/prebuilts/buildprotobuf/libprotoc_la_SOURCES.pri b/host/trace_streamer/prebuilts/buildprotobuf/libprotoc_la_SOURCES.pri
deleted file mode 100644
index ed1da78266e36cf066115d956dfe442f8c2743d2..0000000000000000000000000000000000000000
--- a/host/trace_streamer/prebuilts/buildprotobuf/libprotoc_la_SOURCES.pri
+++ /dev/null
@@ -1,173 +0,0 @@
-# Copyright (C) 2021 Huawei Device Co., Ltd.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
- message("qmake" $${PROTOBUDIR}"/src/google/protobuf/compiler/")
-SOURCES += \
- $${PROTOBUDIR}/src/google/protobuf/compiler/code_generator.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/command_line_interface.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/plugin.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/plugin.pb.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/subprocess.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/zip_writer.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_enum.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_enum_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_extension.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_file.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_generator.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_helpers.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_map_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_message.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_message_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_service.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_string_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_context.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_enum.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_enum_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_enum_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_enum_field_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_extension.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_extension_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_file.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_generator.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_generator_factory.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_helpers.cc \
-# $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_lazy_message_field.cc \
-# $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_map_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_map_field_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_message_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_message_builder.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_message_builder_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_message_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_message_field_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_name_resolver.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_primitive_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_primitive_field_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_shared_code_generator.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_service.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_string_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_string_field_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_doc_comment.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/js/js_generator.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/js/well_known_types_embed.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_enum.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_extension.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_file.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_generator.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_message.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc \
-# $${PROTOBUDIR}/src/google/protobuf/compiler/php/php_generator.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/python/python_generator.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/ruby/ruby_generator.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_enum.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_enum_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_field_base.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_generator.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_message.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_helpers.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_map_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_message.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_message_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc \
-
-HEADERS += \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_primitive_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_options.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_service.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_string_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_enum_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_enum_field_lite.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_context.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_enum.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_enum_lite.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_extension.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_map_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_map_field_lite.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_helpers.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_file.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_message_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_generator_factory.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_extension_lite.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_message_field_lite.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_message.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_message_lite.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_message_builder.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_message_builder_lite.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_name_resolver.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_options.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_primitive_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_primitive_field_lite.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_shared_code_generator.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_service.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_string_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_enum.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_string_field_lite.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/scc.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/subprocess.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/zip_writer.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_enum.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_enum_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_extension.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_file.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_helpers.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_map_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_message.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_message_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/java/java_doc_comment.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_extension.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_file.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_helpers.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_map_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_message.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_message_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_oneof.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_doc_comment.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_message_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_options.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_primitive_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_reflection_class.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_enum.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_enum_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_field_base.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_helpers.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_map_field.h \
- $${PROTOBUDIR}/src/google/protobuf/compiler/csharp/csharp_message.h \
diff --git a/host/trace_streamer/prebuilts/buildprotobuf/protobuf.pri b/host/trace_streamer/prebuilts/buildprotobuf/protobuf.pri
deleted file mode 100644
index 1bfc0847435faaf99b4e88841f30d67c37d65530..0000000000000000000000000000000000000000
--- a/host/trace_streamer/prebuilts/buildprotobuf/protobuf.pri
+++ /dev/null
@@ -1,69 +0,0 @@
-# Copyright (C) 2021 Huawei Device Co., Ltd.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-PROTOBUDIR = $$PWD/../../third_party/protobuf
- message("qmake" $${PROTOBUDIR}"/src/google/protobuf/")
-SOURCES += \
-$${PROTOBUDIR}/src/google/protobuf/any.cc \
-$${PROTOBUDIR}/src/google/protobuf/any_lite.cc \
- $${PROTOBUDIR}/src/google/protobuf/any.pb.cc \
- $${PROTOBUDIR}/src/google/protobuf/api.pb.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/importer.cc \
- $${PROTOBUDIR}/src/google/protobuf/compiler/parser.cc \
- $${PROTOBUDIR}/src/google/protobuf/descriptor.cc \
- $${PROTOBUDIR}/src/google/protobuf/descriptor.pb.cc \
- $${PROTOBUDIR}/src/google/protobuf/descriptor_database.cc \
- $${PROTOBUDIR}/src/google/protobuf/duration.pb.cc \
- $${PROTOBUDIR}/src/google/protobuf/dynamic_message.cc \
- $${PROTOBUDIR}/src/google/protobuf/empty.pb.cc \
- $${PROTOBUDIR}/src/google/protobuf/extension_set_heavy.cc \
- $${PROTOBUDIR}/src/google/protobuf/field_mask.pb.cc \
- $${PROTOBUDIR}/src/google/protobuf/generated_message_reflection.cc \
- $${PROTOBUDIR}/src/google/protobuf/generated_message_table_driven.cc \
- $${PROTOBUDIR}/src/google/protobuf/io/gzip_stream.cc \
- $${PROTOBUDIR}/src/google/protobuf/io/printer.cc \
- $${PROTOBUDIR}/src/google/protobuf/io/tokenizer.cc \
- $${PROTOBUDIR}/src/google/protobuf/map_field.cc \
- $${PROTOBUDIR}/src/google/protobuf/message.cc \
- $${PROTOBUDIR}/src/google/protobuf/reflection_ops.cc \
- $${PROTOBUDIR}/src/google/protobuf/service.cc \
- $${PROTOBUDIR}/src/google/protobuf/source_context.pb.cc \
- $${PROTOBUDIR}/src/google/protobuf/struct.pb.cc \
-# $${PROTOBUDIR}/src/google/protobuf/stubs/mathlimits.cc \
- $${PROTOBUDIR}/src/google/protobuf/stubs/substitute.cc \
- $${PROTOBUDIR}/src/google/protobuf/text_format.cc \
- $${PROTOBUDIR}/src/google/protobuf/timestamp.pb.cc \
- $${PROTOBUDIR}/src/google/protobuf/type.pb.cc \
- $${PROTOBUDIR}/src/google/protobuf/unknown_field_set.cc \
-# $${PROTOBUDIR}/src/google/protobuf/util/delimited_message_util.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/field_comparator.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/field_mask_util.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/internal/datapiece.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/internal/default_value_objectwriter.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/internal/error_listener.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/internal/field_mask_utility.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/internal/json_escaping.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/internal/json_objectwriter.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/internal/json_stream_parser.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/internal/object_writer.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/internal/proto_writer.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/internal/protostream_objectsource.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/internal/protostream_objectwriter.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/internal/type_info.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/internal/type_info_test_helper.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/internal/utility.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/json_util.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/message_differencer.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/time_util.cc \
- $${PROTOBUDIR}/src/google/protobuf/util/type_resolver_util.cc \
- $${PROTOBUDIR}/src/google/protobuf/wire_format.cc \
- $${PROTOBUDIR}/src/google/protobuf/wrappers.pb.cc
diff --git a/host/trace_streamer/prebuilts/patch_googletest/googletestbuild.gn.patch b/host/trace_streamer/prebuilts/patch_googletest/googletestbuild.gn.patch
new file mode 100644
index 0000000000000000000000000000000000000000..7efd6627c4ec9f2ca379132b2141b72d1447d43c
--- /dev/null
+++ b/host/trace_streamer/prebuilts/patch_googletest/googletestbuild.gn.patch
@@ -0,0 +1,191 @@
+--- googletest/BUILD.gn 2023-01-04 17:01:37.911633386 +0800
++++ ../prebuilts/buildgoogletest/googletestbuild.gn 2022-11-29 14:31:52.355999207 +0800
+@@ -9,12 +9,6 @@
+
+ config("gtest_config") {
+ include_dirs = [ "googletest/include" ]
+- if (is_mingw) {
+- cflags_cc = [
+- "-Wno-unused-const-variable",
+- "-Wno-unused-private-field",
+- ]
+- }
+ }
+
+ static_library("gtest") {
+@@ -23,9 +17,24 @@
+ "googletest/include/gtest/gtest-spi.h",
+ "googletest/include/gtest/gtest.h",
+ ]
++
++ cflags = [
++ "-Wno-inconsistent-missing-override",
++
++ # "-Dprivate=public", #allow test code access private members
++ "-fprofile-arcs",
++ "-ftest-coverage",
++ "-Wno-unused-command-line-argument",
++ "-Wno-format",
++ "-Wno-unused-const-variable",
++ "-Wno-unused-variable",
++ "-Wno-used-but-marked-unused",
++ "-Wno-exit-time-destructors",
++ "-Wno-missing-noreturn",
++ "-Wno-missing-noreturn",
++ ]
+ sources = [
+ "googletest/include/gtest/gtest-death-test.h",
+- "googletest/include/gtest/gtest-matchers.h",
+ "googletest/include/gtest/gtest-message.h",
+ "googletest/include/gtest/gtest-param-test.h",
+ "googletest/include/gtest/gtest-printers.h",
+@@ -43,16 +52,18 @@
+ "googletest/include/gtest/internal/gtest-death-test-internal.h",
+ "googletest/include/gtest/internal/gtest-filepath.h",
+ "googletest/include/gtest/internal/gtest-internal.h",
++ "googletest/include/gtest/internal/gtest-linked_ptr.h",
++ "googletest/include/gtest/internal/gtest-param-util-generated.h",
+ "googletest/include/gtest/internal/gtest-param-util.h",
+ "googletest/include/gtest/internal/gtest-port-arch.h",
+ "googletest/include/gtest/internal/gtest-port.h",
+ "googletest/include/gtest/internal/gtest-string.h",
++ "googletest/include/gtest/internal/gtest-tuple.h",
+ "googletest/include/gtest/internal/gtest-type-util.h",
+ "googletest/src/gtest-all.cc",
+ "googletest/src/gtest-death-test.cc",
+ "googletest/src/gtest-filepath.cc",
+ "googletest/src/gtest-internal-inl.h",
+- "googletest/src/gtest-matchers.cc",
+ "googletest/src/gtest-port.cc",
+ "googletest/src/gtest-printers.cc",
+ "googletest/src/gtest-test-part.cc",
+@@ -66,14 +77,31 @@
+ sources -= [ "googletest/src/gtest-all.cc" ]
+ public_configs = [ ":gtest_config" ]
+ configs += [ ":gtest_private_config" ]
+- configs -= [ "//build/config/coverage:default_coverage" ]
++
++ # configs -= ["//build/config/coverage:default_coverage"]
+ }
+
+ static_library("gtest_main") {
+ testonly = true
+ sources = [ "googletest/src/gtest_main.cc" ]
++
++ cflags = [
++ "-Wno-inconsistent-missing-override",
++
++ # "-Dprivate=public", #allow test code access private members
++ "-fprofile-arcs",
++ "-ftest-coverage",
++ "-Wno-unused-command-line-argument",
++ "-Wno-format",
++ "-Wno-unused-const-variable",
++ "-Wno-unused-variable",
++ "-Wno-used-but-marked-unused",
++ "-Wno-exit-time-destructors",
++ "-Wno-missing-noreturn",
++ ]
+ public_deps = [ ":gtest" ]
+- configs -= [ "//build/config/coverage:default_coverage" ]
++
++ # configs -= ["//build/config/coverage:default_coverage"]
+ }
+
+ config("gmock_private_config") {
+@@ -92,26 +120,56 @@
+ # fixed.
+ "-Wno-inconsistent-missing-override",
+ ]
++ cflags = [
++ "-Wno-inconsistent-missing-override",
++
++ # "-Dprivate=public", #allow test code access private members
++ "-fprofile-arcs",
++ "-ftest-coverage",
++ "-Wno-unused-command-line-argument",
++ "-Wno-format",
++ "-Wno-unused-const-variable",
++ "-Wno-unused-variable",
++ "-Wno-used-but-marked-unused",
++ "-Wno-exit-time-destructors",
++ "-Wno-missing-noreturn",
++ ]
+ }
+
+ static_library("gmock") {
+ testonly = true
+ public = [ "googlemock/include/gmock/gmock.h" ]
++ cflags = [
++ "-Wno-inconsistent-missing-override",
++
++ # "-Dprivate=public", #allow test code access private members
++ "-fprofile-arcs",
++ "-ftest-coverage",
++ "-Wno-unused-command-line-argument",
++ "-Wno-format",
++ "-Wno-unused-const-variable",
++ "-Wno-unused-variable",
++ "-Wno-used-but-marked-unused",
++ "-Wno-exit-time-destructors",
++ "-Wno-missing-noreturn",
++ ]
+ sources = [
+ "googlemock/include/gmock/gmock-actions.h",
+ "googlemock/include/gmock/gmock-cardinalities.h",
+- "googlemock/include/gmock/gmock-function-mocker.h",
++ "googlemock/include/gmock/gmock-generated-actions.h",
++ "googlemock/include/gmock/gmock-generated-function-mockers.h",
++ "googlemock/include/gmock/gmock-generated-matchers.h",
++ "googlemock/include/gmock/gmock-generated-nice-strict.h",
+ "googlemock/include/gmock/gmock-matchers.h",
+ "googlemock/include/gmock/gmock-more-actions.h",
+ "googlemock/include/gmock/gmock-more-matchers.h",
+- "googlemock/include/gmock/gmock-nice-strict.h",
+ "googlemock/include/gmock/gmock-spec-builders.h",
+ "googlemock/include/gmock/internal/custom/gmock-generated-actions.h",
+ "googlemock/include/gmock/internal/custom/gmock-matchers.h",
+ "googlemock/include/gmock/internal/custom/gmock-port.h",
++ "googlemock/include/gmock/internal/gmock-generated-internal-utils.h",
+ "googlemock/include/gmock/internal/gmock-internal-utils.h",
+ "googlemock/include/gmock/internal/gmock-port.h",
+- "googlemock/include/gmock/internal/gmock-pp.h",
+ "googlemock/src/gmock-all.cc",
+ "googlemock/src/gmock-cardinalities.cc",
+ "googlemock/src/gmock-internal-utils.cc",
+@@ -122,16 +180,33 @@
+ sources -= [ "googlemock/src/gmock-all.cc" ]
+ public_configs = [ ":gmock_config" ]
+ configs += [ ":gmock_private_config" ]
+- configs -= [ "//build/config/coverage:default_coverage" ]
++
++ # configs -= ["//build/config/coverage:default_coverage"]
+ deps = [ ":gtest" ]
+ }
+
+ static_library("gmock_main") {
+ testonly = true
++
++ cflags = [
++ "-Wno-inconsistent-missing-override",
++
++ # "-Dprivate=public", #allow test code access private members
++ "-fprofile-arcs",
++ "-ftest-coverage",
++ "-Wno-unused-command-line-argument",
++ "-Wno-format",
++ "-Wno-unused-const-variable",
++ "-Wno-unused-variable",
++ "-Wno-used-but-marked-unused",
++ "-Wno-exit-time-destructors",
++ "-Wno-missing-noreturn",
++ ]
+ sources = [ "googlemock/src/gmock_main.cc" ]
+ public_deps = [
+ ":gmock",
+ ":gtest",
+ ]
+- configs -= [ "//build/config/coverage:default_coverage" ]
++
++ # configs -= ["//build/config/coverage:default_coverage"]
+ }
diff --git a/host/trace_streamer/prebuilts/patch_googletest/gtest-message.h.patch b/host/trace_streamer/prebuilts/patch_googletest/gtest-message.h.patch
new file mode 100644
index 0000000000000000000000000000000000000000..266103762b66274a49f8321cb336c2ccb017ab2d
--- /dev/null
+++ b/host/trace_streamer/prebuilts/patch_googletest/gtest-message.h.patch
@@ -0,0 +1,15 @@
+--- third_party/googletest/googletest/include/gtest/gtest-message.h 2023-01-17 16:10:56.252360383 +0800
++++ /home/suze/tp/code/ohos_devtools_trace_resolver/third_party/googletest/googletest/include/gtest/gtest-message.h 2023-01-06 17:58:25.830759482 +0800
+@@ -49,8 +49,11 @@
+
+ #include
+ #include
++#undef private
++#define private private
+ #include
+-
++#undef private
++#define private public
+ #include "gtest/internal/gtest-port.h"
+
+ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
diff --git a/host/trace_streamer/prebuilts/patch_googletest/gtest_internal.h.patch b/host/trace_streamer/prebuilts/patch_googletest/gtest_internal.h.patch
new file mode 100644
index 0000000000000000000000000000000000000000..e47ac4faa2343fc71ba90adae8cccb66b8cf0fa4
--- /dev/null
+++ b/host/trace_streamer/prebuilts/patch_googletest/gtest_internal.h.patch
@@ -0,0 +1,14 @@
+--- third_party/googletest/googletest/include/gtest/internal/gtest-internal.h 2023-01-17 16:10:56.252360383 +0800
++++ /home/suze/tp/code/ohos_devtools_trace_resolver/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h 2023-01-06 17:58:25.830759482 +0800
+@@ -54,7 +54,11 @@
+ #include
+ #include
+ #include
++#undef private
++#define private private
+ #include
++#undef private
++#define private public
+ #include
+ #include