Merge remote-tracking branch 'origin/GP-4930_ghidragon_improving_goto'

This commit is contained in:
Ryan Kurtz 2024-10-01 12:03:39 -04:00
commit 5b4a391ae4
17 changed files with 2167 additions and 1176 deletions

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -238,9 +238,13 @@ public abstract class SymbolDB extends DatabaseObject implements Symbol {
}
}
private void fillListWithNamespacePath(Namespace namespace, ArrayList<String> list) {
private void fillListWithNamespacePath(Namespace namespace, List<String> list) {
if (namespace == null || namespace.getID() == Namespace.GLOBAL_NAMESPACE_ID) {
// we don't include the global namespace name in the path
return;
}
Namespace parentNamespace = namespace.getParentNamespace();
if (parentNamespace != null && parentNamespace.getID() != Namespace.GLOBAL_NAMESPACE_ID) {
if (parentNamespace != null) {
fillListWithNamespacePath(parentNamespace, list);
}
list.add(namespace.getName());

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -41,7 +41,7 @@ public interface Symbol {
/**
* Gets the full path name for this symbol as an ordered array of strings ending
* with the symbol name. The global symbol will return an empty array.
* with the symbol name.
* @return the array indicating the full path name for this symbol.
*/
public String[] getPath();

View file

@ -0,0 +1,77 @@
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.program.model.symbol;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.CircularDependencyException;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.exception.InvalidInputException;
public class StubNamespace implements Namespace {
private Namespace parent;
private String name;
public StubNamespace(String name, Namespace parent) {
this.name = name;
this.parent = parent;
}
@Override
public Symbol getSymbol() {
return new StubSymbol(name);
}
@Override
public boolean isExternal() {
return false;
}
@Override
public String getName() {
return name;
}
@Override
public String getName(boolean includeNamespacePath) {
if (!includeNamespacePath || parent == null) {
return name;
}
return parent.getName(true) + Namespace.DELIMITER + name;
}
@Override
public long getID() {
return 1;
}
@Override
public Namespace getParentNamespace() {
return parent;
}
@Override
public AddressSetView getBody() {
return null;
}
@Override
public void setParentNamespace(Namespace parentNamespace)
throws DuplicateNameException, InvalidInputException, CircularDependencyException {
// ignore
}
}

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -15,6 +15,9 @@
*/
package ghidra.program.model.symbol;
import java.util.ArrayList;
import java.util.List;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.CircularDependencyException;
import ghidra.program.model.listing.Program;
@ -30,6 +33,11 @@ public class StubSymbol implements Symbol {
private long id;
private String name;
private Address address;
private Namespace parent;
public StubSymbol(String name) {
this.name = name;
}
public StubSymbol(String name, Address address) {
this.name = name;
@ -37,6 +45,12 @@ public class StubSymbol implements Symbol {
id = nextId++;
}
public StubSymbol(String name, Namespace parent) {
this.name = name;
this.parent = parent;
id = nextId++;
}
@Override
public Address getAddress() {
return address;
@ -49,7 +63,12 @@ public class StubSymbol implements Symbol {
@Override
public String[] getPath() {
return new String[] { name };
ArrayList<String> list = new ArrayList<>();
fillListWithNamespacePath(getParentNamespace(), list);
list.add(getName());
String[] path = list.toArray(new String[list.size()]);
return path;
}
@Override
@ -64,7 +83,7 @@ public class StubSymbol implements Symbol {
@Override
public Namespace getParentNamespace() {
return null;
return parent;
}
@Override
@ -225,4 +244,15 @@ public class StubSymbol implements Symbol {
return id == other.id;
}
private void fillListWithNamespacePath(Namespace namespace, List<String> list) {
if (namespace == null || namespace.getID() == Namespace.GLOBAL_NAMESPACE_ID) {
// we don't include the global namespace name in the path
return;
}
Namespace parentNamespace = namespace.getParentNamespace();
if (parentNamespace != null) {
fillListWithNamespacePath(parentNamespace, list);
}
list.add(namespace.getName());
}
}