Skip to content

Commit

Permalink
1. fix std::unique_ptr and std::atomic<int> and std::deque<std::deque…
Browse files Browse the repository at this point in the history
…<int>> parse issue
  • Loading branch information
HenryRiley0 committed Sep 13, 2024
1 parent d67b0ed commit 4c51a66
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/backend/gdb_expansion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { VariableObject } from "./backend";
import { MINode } from "./mi_parse";

const resultRegex = /^([a-zA-Z_\-][a-zA-Z0-9_\-:]*|\[\d+\])\s*=\s*/;
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*)"/;
Expand Down Expand Up @@ -113,6 +112,9 @@ export function expandValue(variableCreate: (arg: VariableObject | string, optio
stack.push("[0]");
let val = parseValue();
stack.pop();
if(typeof val == "string" && val.endsWith('>')){
val = val.substring(0, val.length - 2);
}
values.push(createValue("[0]", val));
const remaining = value;
let i = 0;
Expand Down Expand Up @@ -201,13 +203,22 @@ export function expandValue(variableCreate: (arg: VariableObject | string, optio
};

parseResult = (pushToStack: boolean = false) => {
if (value[0] == '<') {
value = value.substring(1).trim();
}
value = value.trim();
value = value.replace(/^static /, "");
const variableMatch = resultRegex.exec(value);
if (!variableMatch)
return undefined;
value = value.substring(variableMatch[0].length).trim();
const name = variable = variableMatch[1];
let name = variable = variableMatch[1].trim();

const tmpName = name.split(" ");
if(tmpName.length > 1 && !name.includes("anonymous union")){
name = tmpName[tmpName.length - 1];
}

if (pushToStack)
stack.push(variable);
const val = parseValue();
Expand Down Expand Up @@ -236,6 +247,17 @@ export function expandValue(variableCreate: (arg: VariableObject | string, optio
ref = variableCreate(getNamespace(name));
val = "...";
}

value = value.trim();
if (value[0] == ',')
{
let tmp = value;
tmp = tmp.substring(1).trim();
if(tmp.startsWith("<No data fields>")){
value = tmp = tmp.substring("<No data fields>".length);
}
}

return {
name: name,
value: val,
Expand Down

0 comments on commit 4c51a66

Please sign in to comment.