mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-02 01:56:56 +08:00
Merge remote-tracking branch 'origin/GP-1875-dragonmacher-decompiler-reference-finder-address-fix'
This commit is contained in:
+23
-2
@@ -15,8 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package ghidra.app.extension.datatype.finder;
|
package ghidra.app.extension.datatype.finder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import ghidra.app.decompiler.*;
|
import ghidra.app.decompiler.*;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
@@ -173,6 +172,10 @@ public abstract class DecompilerVariable {
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parent instanceof ClangTokenGroup) {
|
||||||
|
return getAddressFromParent((ClangTokenGroup) parent, variable);
|
||||||
|
}
|
||||||
|
|
||||||
Address parentAddress = parent.getMinAddress();
|
Address parentAddress = parent.getMinAddress();
|
||||||
if (parentAddress != null) {
|
if (parentAddress != null) {
|
||||||
return parentAddress;
|
return parentAddress;
|
||||||
@@ -183,6 +186,24 @@ public abstract class DecompilerVariable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Address getAddressFromParent(ClangTokenGroup parent, ClangToken child) {
|
||||||
|
|
||||||
|
// get as close as possible to the given token without going over
|
||||||
|
Address bestAddress = parent.getMinAddress();
|
||||||
|
Iterator<ClangNode> iterator = parent.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
ClangNode node = iterator.next();
|
||||||
|
if (child.equals(node)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Address nextAddress = node.getMinAddress();
|
||||||
|
if (nextAddress != null) {
|
||||||
|
bestAddress = nextAddress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bestAddress;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
String text = variable.getText();
|
String text = variable.getText();
|
||||||
return text;
|
return text;
|
||||||
|
|||||||
Reference in New Issue
Block a user