hm-pt-core 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/trace/parse.js +19 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export type { Endian, BuildTraceParserRegistryOptions } from "./trace/parse.js";
|
|
|
9
9
|
export { TraceFieldDecodeError } from "./trace/parse.js";
|
|
10
10
|
export type { PrintfSpec } from "./trace/printf.js";
|
|
11
11
|
export { parseTraceFormat, parseCommonFieldsFromRaw, parseAllFieldsFromRaw, rawHexLinesToBuffer, bufferToRawHexLines, buildTraceParserRegistry, } from "./trace/parse.js";
|
|
12
|
-
export { formatPrintfValue, tokenizePrintfFormat } from "./trace/printf.js";
|
|
12
|
+
export { formatPrintfValue, tokenizePrintfFormat, renderPrintFmt, renderPrintFmtAsFieldDict } from "./trace/printf.js";
|
|
13
13
|
export { decodeRawByRegistry } from "./trace/decode_raw.js";
|
package/dist/index.js
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
export { isPerfDataLike } from "./perf/is_perf_data_like.js";
|
|
5
5
|
export { TraceFieldDecodeError } from "./trace/parse.js";
|
|
6
6
|
export { parseTraceFormat, parseCommonFieldsFromRaw, parseAllFieldsFromRaw, rawHexLinesToBuffer, bufferToRawHexLines, buildTraceParserRegistry, } from "./trace/parse.js";
|
|
7
|
-
export { formatPrintfValue, tokenizePrintfFormat } from "./trace/printf.js";
|
|
7
|
+
export { formatPrintfValue, tokenizePrintfFormat, renderPrintFmt, renderPrintFmtAsFieldDict } from "./trace/printf.js";
|
|
8
8
|
export { decodeRawByRegistry } from "./trace/decode_raw.js";
|
package/dist/trace/parse.js
CHANGED
|
@@ -138,6 +138,24 @@ function scanBalancedPrintArgs(argsPart) {
|
|
|
138
138
|
}
|
|
139
139
|
return args;
|
|
140
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* 从 print fmt 逗号后参数段提取表达式。
|
|
143
|
+
* 内核 trace 常在首个 __data_loc 参数外套 ((char*)((void *)...)),括号平衡切分只得 1 段;
|
|
144
|
+
* 此时回退为按 `REC->` 切分(与 hiperf 1.x 行为一致)。
|
|
145
|
+
*/
|
|
146
|
+
function parsePrintArgExpressions(argsPart) {
|
|
147
|
+
const balanced = scanBalancedPrintArgs(argsPart);
|
|
148
|
+
const recExprs = argsPart.match(/REC->[^,]+/g)?.map((s) => s.trim().replace(/\)+$/, "")) ?? [];
|
|
149
|
+
if (recExprs.length > balanced.length) {
|
|
150
|
+
return recExprs;
|
|
151
|
+
}
|
|
152
|
+
if (recExprs.length === 1 &&
|
|
153
|
+
balanced.length === 1 &&
|
|
154
|
+
balanced[0] !== recExprs[0]) {
|
|
155
|
+
return recExprs;
|
|
156
|
+
}
|
|
157
|
+
return balanced;
|
|
158
|
+
}
|
|
141
159
|
function parsePrintFmtLine(line) {
|
|
142
160
|
const prefix = line.match(/^print\s+fmt\s*:\s*/i);
|
|
143
161
|
if (!prefix)
|
|
@@ -151,7 +169,7 @@ function parsePrintFmtLine(line) {
|
|
|
151
169
|
const argsMatch = rest.match(/^,\s*(.*)$/);
|
|
152
170
|
if (!argsMatch)
|
|
153
171
|
return undefined;
|
|
154
|
-
return { printFmt: lit.value, printArgs:
|
|
172
|
+
return { printFmt: lit.value, printArgs: parsePrintArgExpressions(argsMatch[1]) };
|
|
155
173
|
}
|
|
156
174
|
function splitTypeAndName(rest) {
|
|
157
175
|
const trimmed = rest.trim();
|