1、修复消息日志遇到中括号解析失败bug

This commit is contained in:
xuhong 2023-12-26 10:11:26 +08:00
parent 1408545364
commit 691212b1a7
3 changed files with 16 additions and 6 deletions

View File

@ -1,3 +1,6 @@
# 0.2.1
- add log message function;
- solve the problem of parsing two-dimensional arrays failure;
# 0.2.0 # 0.2.0
- support qt variable; - support qt variable;
- fix the problem of step out fail from main(); - fix the problem of step out fail from main();

View File

@ -14,7 +14,7 @@
"debug" "debug"
], ],
"license": "public domain", "license": "public domain",
"version": "0.2.0", "version": "0.2.1",
"publisher": "KylinIDETeam", "publisher": "KylinIDETeam",
"icon": "images/native-debug.png", "icon": "images/native-debug.png",
"engines": { "engines": {

View File

@ -81,7 +81,9 @@ export class MI2 extends EventEmitter implements IBackend {
protected logMsg: Breakpoint[] = []; protected logMsg: Breakpoint[] = [];
protected logMsgNum = 0; protected logMsgNum = 0;
protected logMsgVar = ""; protected logMsgVar = "";
protected logMsgVarProcess = "";
protected logMsgRplNum = 0; protected logMsgRplNum = 0;
protected logMsgRplItem: string[] = [];
load(cwd: string, target: string, procArgs: string, separateConsole: string): Thenable<any> { load(cwd: string, target: string, procArgs: string, separateConsole: string): Thenable<any> {
if (!path.isAbsolute(target)) if (!path.isAbsolute(target))
target = path.join(cwd, target); target = path.join(cwd, target);
@ -394,12 +396,15 @@ export class MI2 extends EventEmitter implements IBackend {
let content = record.content; let content = record.content;
const variableMatch = logMsgMatch.exec(content) const variableMatch = logMsgMatch.exec(content)
let value = content.substr(variableMatch[1].length).trim(); let value = content.substr(variableMatch[1].length).trim();
this.logMsgRplItem.push(value);
const result = this.logMsgVar.replace(logReplace, value); // const result = this.logMsgVar.replace(logReplace, value);
// this.logMsgVar = result;
this.logMsgRplNum--; this.logMsgRplNum--;
this.logMsgVar = result;
if(this.logMsgRplNum == 0){ if(this.logMsgRplNum == 0){
this.log("console", "Log Message:" + this.logMsgVar); for(let i=0; i<this.logMsgRplItem.length; i++){
this.logMsgVarProcess = this.logMsgVarProcess.replace("placeholderxxvvxx", this.logMsgRplItem[i]);
}
this.log("console", "Log Message:" + this.logMsgVarProcess);
} }
}else if(record.content.startsWith("No symbol")){ }else if(record.content.startsWith("No symbol")){
// this.log("log", "GDB -> App6: +++++++++:" + this.logMsgNum + ":" + record.content + ":" + this.logMsgVar); // this.log("log", "GDB -> App6: +++++++++:" + this.logMsgNum + ":" + record.content + ":" + this.logMsgVar);
@ -451,6 +456,8 @@ export class MI2 extends EventEmitter implements IBackend {
const matches = this.logMsgVar.match(logReplaceTest); const matches = this.logMsgVar.match(logReplaceTest);
const count = matches ? matches.length : 0; const count = matches ? matches.length : 0;
this.logMsgRplNum = count; this.logMsgRplNum = count;
this.logMsgVarProcess = this.logMsgVar.replace(logReplaceTest, "placeholderxxvvxx");
this.logMsgRplItem = [];
} }
}); });
break; break;
@ -670,7 +677,7 @@ export class MI2 extends EventEmitter implements IBackend {
} }
setLogPoint(bkptNum, command): Thenable<any> { setLogPoint(bkptNum, command): Thenable<any> {
this.log("stderr", `setLogoPoint : ` + command); // this.log("stderr", `setLogoPoint : ` + command);
const regex = /{([a-z0-9A-Z-_\.\>\&\*]*)}/gm; const regex = /{([a-z0-9A-Z-_\.\>\&\*]*)}/gm;
// Alternative syntax using RegExp constructor // Alternative syntax using RegExp constructor