mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Merge remote-tracking branch 'origin/GP-1602-dragonmacher-decompiler-brace-stack-trace'
This commit is contained in:
commit
0fc8055c77
1 changed files with 37 additions and 32 deletions
|
@ -354,8 +354,7 @@ public class DecompilerUtils {
|
|||
public static AddressSet findClosestAddressSet(Program program, AddressSpace functionSpace,
|
||||
List<ClangToken> tokenList) {
|
||||
AddressSet addressSet = new AddressSet();
|
||||
for (int i = 0; i < tokenList.size(); ++i) {
|
||||
ClangToken tok = tokenList.get(i);
|
||||
for (ClangToken tok : tokenList) {
|
||||
addTokenAddressRangeToSet(addressSet, tok, functionSpace);
|
||||
}
|
||||
|
||||
|
@ -574,33 +573,39 @@ public class DecompilerUtils {
|
|||
}
|
||||
|
||||
Stack<ClangSyntaxToken> braceStack = new Stack<>();
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
ClangToken token = (ClangToken) list.get(i);
|
||||
if (token instanceof ClangSyntaxToken) {
|
||||
ClangSyntaxToken syntaxToken = (ClangSyntaxToken) token;
|
||||
for (ClangNode element : list) {
|
||||
ClangToken token = (ClangToken) element;
|
||||
if (!(token instanceof ClangSyntaxToken)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (startToken == syntaxToken) {
|
||||
// found our starting token, take the current value on the stack
|
||||
ClangSyntaxToken matchingBrace = braceStack.pop();
|
||||
return matchingBrace;
|
||||
}
|
||||
|
||||
if (!isBrace(syntaxToken)) {
|
||||
continue;
|
||||
}
|
||||
ClangSyntaxToken syntaxToken = (ClangSyntaxToken) token;
|
||||
if (startToken == syntaxToken) {
|
||||
|
||||
if (braceStack.isEmpty()) {
|
||||
braceStack.push(syntaxToken);
|
||||
continue;
|
||||
return null; // this can happen if the start token has a bad parent values
|
||||
}
|
||||
|
||||
ClangSyntaxToken lastToken = braceStack.peek();
|
||||
if (isMatchingBrace(lastToken, syntaxToken)) {
|
||||
braceStack.pop();
|
||||
}
|
||||
else {
|
||||
braceStack.push(syntaxToken);
|
||||
}
|
||||
// found our starting token, take the current value on the stack
|
||||
ClangSyntaxToken matchingBrace = braceStack.pop();
|
||||
return matchingBrace;
|
||||
}
|
||||
|
||||
if (!isBrace(syntaxToken)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (braceStack.isEmpty()) {
|
||||
braceStack.push(syntaxToken);
|
||||
continue;
|
||||
}
|
||||
|
||||
ClangSyntaxToken lastToken = braceStack.peek();
|
||||
if (isMatchingBrace(lastToken, syntaxToken)) {
|
||||
braceStack.pop();
|
||||
}
|
||||
else {
|
||||
braceStack.push(syntaxToken);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue