parent
4ad697e1fe
commit
9299fe7b96
|
@ -1,3 +1,7 @@
|
|||
# 0.2.0
|
||||
- support qt variable;
|
||||
- fix the problem of step out fail from main();
|
||||
|
||||
# 0.1.9
|
||||
- fix the problem of exception prompt when clicking step out in the function;
|
||||
- fix the problem of freezing when clicking step out in the for loop of the main function;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"debug"
|
||||
],
|
||||
"license": "public domain",
|
||||
"version": "0.1.9",
|
||||
"version": "0.2.0",
|
||||
"publisher": "KylinIDETeam",
|
||||
"icon": "images/native-debug.png",
|
||||
"engines": {
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
import { MINode } from "./mi_parse";
|
||||
|
||||
const resultRegex = /^([a-zA-Z_\-][a-zA-Z0-9_\-]*|\[\d+\])\s*=\s*/;
|
||||
const variableRegex = /^[a-zA-Z_\-][a-zA-Z0-9_\-]*/;
|
||||
const resultRegex = /^([a-zA-Z_\-][a-zA-Z0-9_\-\>\ \<\:]*|\[\d+\])\s*=\s*/;
|
||||
const variableRegex = /^[a-zA-Z_\-][a-zA-Z0-9_\-\>\ ]*/;
|
||||
const errorRegex = /^\<.+?\>/;
|
||||
const referenceStringRegex = /^(0x[0-9a-fA-F]+\s*)"/;
|
||||
const referenceRegex = /^0x[0-9a-fA-F]+/;
|
||||
const referenceRegex = /^(0x[0-9a-fA-F]+)/;
|
||||
const referenceRegexQt = /^(0x[0-9a-fA-F]+)([\<a-zA-Z0-9\,\ \:\*\)\_\(]*)([\>])/;
|
||||
const cppReferenceRegex = /^@0x[0-9a-fA-F]+/;
|
||||
const nullpointerRegex = /^0x0+\b/;
|
||||
const charRegex = /^(\d+) ['"]/;
|
||||
const numberRegex = /^\d+(\.\d+)?/;
|
||||
const numberRegex = /^\d+(\.\d+)?(e-\d+)?/;
|
||||
const pointerCombineChar = ".";
|
||||
const nullTupleRegex = /^(0x[0-9a-fA-F]+)}/;
|
||||
|
||||
export function isExpandable(value: string): number {
|
||||
let match;
|
||||
|
@ -26,10 +28,78 @@ export function isExpandable(value: string): number {
|
|||
else if (match = numberRegex.exec(value)) return 0;
|
||||
else if (match = variableRegex.exec(value)) return 0;
|
||||
else if (match = errorRegex.exec(value)) return 0;
|
||||
else if (match = referenceRegexQt.exec(value)) return 2;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
|
||||
const filePath = os.homedir() + '/logs.txt';
|
||||
|
||||
|
||||
const userHomeDir = os.homedir();
|
||||
const logQueue = []; // 日志队列
|
||||
let isWriting = false; // 是否正在写入日志
|
||||
|
||||
function writeLogToFile(log, filePath) {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
fs.appendFile(filePath, log + '\n', (err) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function processLogQueue() {
|
||||
if (logQueue.length === 0 || isWriting) {
|
||||
return; // 如果队列为空或正在写入日志,则不进行处理
|
||||
}
|
||||
|
||||
isWriting = true; // 设置正在写入日志的标志
|
||||
|
||||
const { log, filePath } = logQueue.shift(); // 从队列中取出第一个日志
|
||||
|
||||
writeLogToFile(log, filePath)
|
||||
.then(() => {
|
||||
console.log('日志已成功写入文件:', filePath);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('无法写入日志文件:', err);
|
||||
})
|
||||
.finally(() => {
|
||||
isWriting = false; // 写入完成后,将正在写入日志的标志设置为false
|
||||
processLogQueue(); // 继续处理队列中的下一个日志
|
||||
});
|
||||
}
|
||||
|
||||
function addToLogQueue(log, filePath) {
|
||||
return;
|
||||
logQueue.push({ log, filePath }); // 将日志添加到队列中
|
||||
processLogQueue(); // 开始处理队列中的日志
|
||||
}
|
||||
|
||||
function isJSON(str) {
|
||||
var jList = [];
|
||||
try {
|
||||
var fLeft = str.indexOf("{");
|
||||
var number = 0;
|
||||
number++;
|
||||
var fRight = fLeft;
|
||||
JSON.parse(str);
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function expandValue(variableCreate: Function, value: string, root: string = "", extra: any = undefined): any {
|
||||
addToLogQueue("xh++++++++++++++:expandValue=====xxxx1", filePath);
|
||||
// addToLogQueue(`xh++++++++++++++:expandValue=====xxxx2 ${value}: ${JSON.stringify(extra)}`, filePath);
|
||||
|
||||
const parseCString = () => {
|
||||
value = value.trim();
|
||||
if (value[0] != '"' && value[0] != '\'')
|
||||
|
@ -58,7 +128,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
|||
const stack = [root];
|
||||
let parseValue, parseCommaResult, parseCommaValue, parseResult, createValue;
|
||||
let variable = "";
|
||||
|
||||
|
||||
const getNamespace = (variable) => {
|
||||
let namespace = "";
|
||||
let prefix = "";
|
||||
|
@ -88,6 +158,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
|||
return prefix + namespace;
|
||||
};
|
||||
|
||||
//解析字典,json
|
||||
const parseTupleOrList = () => {
|
||||
value = value.trim();
|
||||
if (value[0] != '{')
|
||||
|
@ -98,6 +169,10 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
|||
value = value.substr(1).trim();
|
||||
return [];
|
||||
}
|
||||
if (value[0] == '<') {
|
||||
value = value.substr(1).trim();
|
||||
}
|
||||
|
||||
if (value.startsWith("...")) {
|
||||
value = value.substr(3).trim();
|
||||
if (value[0] == '}') {
|
||||
|
@ -109,8 +184,10 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
|||
const newValPos1 = value.indexOf("{");
|
||||
const newValPos2 = value.indexOf(",");
|
||||
let newValPos = newValPos1;
|
||||
if (newValPos2 != -1 && newValPos2 < newValPos1)
|
||||
|
||||
if (newValPos2 != -1 && newValPos2 < newValPos1){
|
||||
newValPos = newValPos2;
|
||||
}
|
||||
if (newValPos != -1 && eqPos > newValPos || eqPos == -1) { // is value list
|
||||
const values = [];
|
||||
stack.push("[0]");
|
||||
|
@ -139,13 +216,28 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
|||
while (result = parseCommaResult(true))
|
||||
results.push(result);
|
||||
value = value.substr(1).trim(); // }
|
||||
|
||||
return results;
|
||||
}
|
||||
else if(nullTupleRegex.exec(value)){
|
||||
var match=nullTupleRegex.exec(value);
|
||||
value = value.substr(match[1].length).trim();
|
||||
const values = [];
|
||||
stack.push("[0]");
|
||||
let val = match[1];
|
||||
stack.pop();
|
||||
values.push(createValue("[0]", val));
|
||||
return values;
|
||||
}
|
||||
else{
|
||||
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const parsePrimitive = () => {
|
||||
|
||||
let primitive: any;
|
||||
let match;
|
||||
value = value.trim();
|
||||
|
@ -163,6 +255,9 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
|||
} else if (match = referenceStringRegex.exec(value)) {
|
||||
value = value.substr(match[1].length).trim();
|
||||
primitive = parseCString();
|
||||
} else if (match = referenceRegexQt.exec(value)) {
|
||||
primitive = "*" + match[0];
|
||||
value = value.substr(match[0].length).trim();
|
||||
} else if (match = referenceRegex.exec(value)) {
|
||||
primitive = "*" + match[0];
|
||||
value = value.substr(match[0].length).trim();
|
||||
|
@ -185,37 +280,52 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
|||
} else {
|
||||
primitive = value;
|
||||
}
|
||||
|
||||
return primitive;
|
||||
};
|
||||
|
||||
parseValue = () => {
|
||||
value = value.trim();
|
||||
if (value[0] == '"')
|
||||
if (value[0] == '"'){ //解析字符串
|
||||
return parseCString();
|
||||
else if (value[0] == '{')
|
||||
}
|
||||
else if (value[0] == '{'){ //解析字典
|
||||
return parseTupleOrList();
|
||||
else
|
||||
}
|
||||
else{
|
||||
return parsePrimitive();
|
||||
}
|
||||
};
|
||||
|
||||
parseResult = (pushToStack: boolean = false) => {
|
||||
value = value.trim();
|
||||
const variableMatch = resultRegex.exec(value);
|
||||
if (!variableMatch)
|
||||
{
|
||||
return undefined;
|
||||
}
|
||||
value = value.substr(variableMatch[0].length).trim();
|
||||
const name = variable = variableMatch[1];
|
||||
if (pushToStack)
|
||||
|
||||
var name = variable = variableMatch[1];
|
||||
if (name.charAt(name.length - 1) === ">") {
|
||||
name = name.slice(0, -1);
|
||||
}
|
||||
//JSON.parse()
|
||||
if (pushToStack){
|
||||
stack.push(variable);
|
||||
}
|
||||
const val = parseValue();
|
||||
if (pushToStack)
|
||||
if (pushToStack){
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
return createValue(name, val);
|
||||
};
|
||||
|
||||
createValue = (name, val) => {
|
||||
let ref = 0;
|
||||
let evaluateName;
|
||||
|
||||
if (typeof val == "object") {
|
||||
ref = variableCreate(val);
|
||||
val = "Object";
|
||||
|
@ -241,6 +351,23 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
|||
} else {
|
||||
evaluateName = getNamespace(name);
|
||||
}
|
||||
|
||||
value = value.trim();
|
||||
if (value[0] == ',')
|
||||
{
|
||||
var tmp = value
|
||||
tmp = tmp.substr(1).trim();
|
||||
tmp = tmp.trim();
|
||||
if(tmp[0] == '{'){
|
||||
tmp = ",anonymous union = " + tmp;
|
||||
value = tmp;
|
||||
}
|
||||
else if(tmp.startsWith("<No data fields>")){
|
||||
value = tmp = tmp.substr("<No data fields>".length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
name: name,
|
||||
value: val,
|
||||
|
@ -267,5 +394,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
|||
|
||||
|
||||
value = value.trim();
|
||||
return parseValue();
|
||||
var retval = parseValue()
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
|
@ -1064,9 +1064,10 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
if(command.includes("exec-finish") && node.resultRecords.results[0][1].includes("not meaningful in the outermost frame")){
|
||||
node.resultRecords.resultClass = "running";
|
||||
node.resultRecords.results = [];
|
||||
return;
|
||||
this.log("stderr", `WARNING: reject not meaningful in the outermost++++`);
|
||||
reject(new MIError(node.result("reject not meaningful in the outermost") || "reject not meaningful in the outermost", command));
|
||||
}
|
||||
// resolve(node);
|
||||
resolve(node);
|
||||
} else {
|
||||
this.log("stderr", `WARNING: reject '${command}'`);
|
||||
reject(new MIError(node.result("msg") || "Internal error", command));
|
||||
|
|
Loading…
Reference in New Issue