Skip to content

Commit

Permalink
use ptype instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Trass3r committed Aug 6, 2020
1 parent 6c35684 commit d34269c
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/MIDebugEngine/Engine.Impl/Variables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,30 +188,34 @@ private VariableInformation(ThreadContext ctx, AD7Engine engine, AD7Thread threa
_debuggedProcess.ActiveVariables.Add(this);
}
}

private static Regex ptypeRegex = new Regex(@"type = (const )?(class|struct|union|enum)?([^\[{]+)[^}]*\}?(.*)", RegexOptions.Singleline | RegexOptions.Compiled);
public static async Task<string> resolveType(DebuggedProcess process, string type)
{
// avoid useless requests
if (string.IsNullOrEmpty(type) || type.Contains("{...}"))
return type;

// support the common case of a single-level */&
char last = type[type.Length - 1];
string orgtype = type;
if (last == '*' || last == '&')
type = type.Substring(0, type.Length - 1);
try
{
// N.B.: whatis only strips 1 typedef level and fails when type is a * or &
type = await process.ConsoleCmdAsync("whatis " + type, false);
type = await process.ConsoleCmdAsync("ptype/mt " + type, false);
}
catch(UnexpectedMIResultException e)
{
process.WriteOutput(e.ToString());
return orgtype;
return type;
}
if (last == '*' || last == '&')
type += last;
return Regex.Match(type, "type = (.+)").Groups[1].Value;
process.WriteOutput(type);
var matches = ptypeRegex.Match(type);
string prefix = matches.Groups[1].Value;
string typename = matches.Groups[3].Value;
string tail = matches.Groups[4].Value;
int i = typename.IndexOf(" : "); // inheritance
if (i > 0)
typename = typename.Substring(0, i);

process.WriteOutput(prefix + typename + tail);
return prefix + typename + tail;
}

//this constructor is used to create root nodes (local/params)
Expand Down

0 comments on commit d34269c

Please sign in to comment.