Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-42 changed remote searching to its own button

dev7473689b7299492e24
diff --git a/Ghidra/Features/PDB/src/main/help/help/topics/Pdb/LoadPDBNew.html b/Ghidra/Features/PDB/src/main/help/help/topics/Pdb/LoadPDBNew.html
index f60a94d9f5..2c916b99dc 100644
--- a/Ghidra/Features/PDB/src/main/help/help/topics/Pdb/LoadPDBNew.html
+++ b/Ghidra/Features/PDB/src/main/help/help/topics/Pdb/LoadPDBNew.html
@@ -33,7 +33,7 @@
<LI><CODE><FONT COLOR="BLUE">myprogram.pdb</FONT>/<FONT COLOR="RED">012345670123012301230123456789AB</FONT><FONT COLOR="GREEN">1</FONT>/<FONT COLOR="BLUE">myprogram.pdb</FONT></CODE>.</LI>
<LI><CODE><FONT COLOR="BLUE">myprogram.pdb</FONT></CODE> is the name of the file and the name of the initial subdirectory off the root of the server.</LI>
<LI><CODE><FONT COLOR="RED">012345670123012301230123456789AB</FONT></CODE> is the 32 character hexadecimal value (made up for this example) of the GUID
- "012345678-0123-0123-0123-0123456789ABC" of the PDB file.</LI>
+ "012345678-0123-0123-0123-0123456789AB" of the PDB file.</LI>
<UL><LI>This value might instead be a 8 character hexadecimal value of the ID of the symbol file if it was created by an older version of the tool chain.</LI></UL>
<LI><CODE><FONT COLOR="GREEN">1</FONT></CODE> is the hexadecimal value of the 'age' (build number) of the PDB file. Note: most PDB files will have an age value of 1.</LI>
</UL>
diff --git a/Ghidra/Features/PDB/src/main/help/help/topics/Pdb/images/LoadPdb_Advanced_NeedsConfig.png b/Ghidra/Features/PDB/src/main/help/help/topics/Pdb/images/LoadPdb_Advanced_NeedsConfig.png
index 949d45f8ba..d713737905 100644
Binary files a/Ghidra/Features/PDB/src/main/help/help/topics/Pdb/images/LoadPdb_Advanced_NeedsConfig.png and b/Ghidra/Features/PDB/src/main/help/help/topics/Pdb/images/LoadPdb_Advanced_NeedsConfig.png differ
diff --git a/Ghidra/Features/PDB/src/main/help/help/topics/Pdb/images/LoadPdb_Advanced_Screenshot.png b/Ghidra/Features/PDB/src/main/help/help/topics/Pdb/images/LoadPdb_Advanced_Screenshot.png
index 74072b1047..14c0387613 100644
Binary files a/Ghidra/Features/PDB/src/main/help/help/topics/Pdb/images/LoadPdb_Advanced_Screenshot.png and b/Ghidra/Features/PDB/src/main/help/help/topics/Pdb/images/LoadPdb_Advanced_Screenshot.png differ
diff --git a/Ghidra/Features/PDB/src/main/java/pdb/symbolserver/ui/LoadPdbDialog.java b/Ghidra/Features/PDB/src/main/java/pdb/symbolserver/ui/LoadPdbDialog.java
index 97f1d99638..cf234ea194 100644
--- a/Ghidra/Features/PDB/src/main/java/pdb/symbolserver/ui/LoadPdbDialog.java
+++ b/Ghidra/Features/PDB/src/main/java/pdb/symbolserver/ui/LoadPdbDialog.java
@@ -16,7 +16,8 @@
package pdb.symbolserver.ui;
import java.awt.*;
-import java.awt.event.*;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -104,7 +105,7 @@ public class LoadPdbDialog extends DialogComponentProvider {
private SymbolFileInfo programSymbolFileInfo;
private List<Supplier<StatusText>> statusTextSuppliers = new ArrayList<>();
- private boolean hasPerformedSearch;
+ private Set<FindOption> lastSearchOptions;
private boolean searchCanceled;
private Program program;
@@ -181,7 +182,7 @@ public class LoadPdbDialog extends DialogComponentProvider {
symbolServerService.getLocalSymbolFileLocation(results.get(0), monitor);
File symbolFile = getLocalSymbolFile(symbolFileLocation);
Swing.runLater(() -> {
- setSearchResults(results);
+ setSearchResults(results, null);
setPdbLocationValue(symbolFileLocation, symbolFile);
setSelectedPdbFile(symbolFileLocation);
selectRowByLocation(symbolFileLocation);
@@ -247,8 +248,8 @@ public class LoadPdbDialog extends DialogComponentProvider {
*
* @param results list of {@link SymbolFileLocation}s to add to results
*/
- public void setSearchResults(List<SymbolFileLocation> results) {
- hasPerformedSearch = true;
+ public void setSearchResults(List<SymbolFileLocation> results, Set<FindOption> findOptions) {
+ lastSearchOptions = findOptions;
symbolFilePanel.getTableModel().setSearchResults(programSymbolFileInfo, results);
}
@@ -320,7 +321,7 @@ public class LoadPdbDialog extends DialogComponentProvider {
return SymbolFileInfo.fromValues(pdbPath, uid, age);
}
- private void searchForPdbs(ActionEvent e) {
+ private void searchForPdbs(boolean allowRemote) {
if (symbolServerService == null || !symbolServerService.isValid()) {
return;
}
@@ -336,13 +337,16 @@ public class LoadPdbDialog extends DialogComponentProvider {
return;
}
Set<FindOption> findOptions = symbolFilePanel.getFindOptions();
+ if (allowRemote) {
+ findOptions.add(FindOption.ALLOW_REMOTE);
+ }
executeMonitoredRunnable("Search for PDBs", true, true, 0, monitor -> {
try {
searchCanceled = false;
List<SymbolFileLocation> results =
symbolServerService.find(symbolFileInfo, findOptions, monitor);
Swing.runLater(() -> {
- setSearchResults(results);
+ setSearchResults(results, findOptions);
if (results.size() == 1) {
selectRowByLocation(results.get(0));
}
@@ -366,7 +370,7 @@ public class LoadPdbDialog extends DialogComponentProvider {
buildParserOptionsPanel();
setHelpLocation(new HelpLocation(PdbPlugin.PDB_PLUGIN_HELP_TOPIC, "Load PDB File"));
- addStatusTextSupplier(() -> hasPerformedSearch && advancedToggleButton.isSelected()
+ addStatusTextSupplier(() -> lastSearchOptions != null && advancedToggleButton.isSelected()
? symbolServerConfigPanel.getSymbolServerWarnings()
: null);
addStatusTextSupplier(this::getSelectedPdbNoticeText);
@@ -647,11 +651,10 @@ public class LoadPdbDialog extends DialogComponentProvider {
private StatusText getAllowRemoteWarning() {
int remoteSymbolServerCount =
symbolServerService != null ? symbolServerService.getRemoteSymbolServerCount() : 0;
- Set<FindOption> findOptions = symbolFilePanel.getFindOptions();
- return hasPerformedSearch && advancedToggleButton.isSelected() &&
- remoteSymbolServerCount != 0 && !findOptions.contains(FindOption.ALLOW_REMOTE)
+ return lastSearchOptions != null && advancedToggleButton.isSelected() &&
+ remoteSymbolServerCount != 0 && !lastSearchOptions.contains(FindOption.ALLOW_REMOTE)
? new StatusText(
- "Remote servers were excluded. Select \"Allow Remote\" checkbox to search remote servers.",
+ "Remote servers were excluded. Use \"Search All\" button to also search remote servers.",
MessageType.INFO, false)
: null;
}
@@ -661,7 +664,7 @@ public class LoadPdbDialog extends DialogComponentProvider {
if (searchCanceled) {
return new StatusText("Search canceled", MessageType.INFO, false);
}
- if (hasPerformedSearch) {
+ if (lastSearchOptions != null) {
int foundCount = symbolFilePanel.getTableModel().getModelData().size();
return new StatusText(
"Found " + foundCount + " file" + (foundCount != 1 ? "s" : ""),
@@ -751,11 +754,10 @@ public class LoadPdbDialog extends DialogComponentProvider {
SameDirSymbolStore.createManuallySelectedSymbolFileLocation(file,
pdbSymbolFileInfo);
Swing.runLater(() -> {
- setSearchResults(List.of(symbolFileLocation));
+ setSearchResults(List.of(symbolFileLocation), null);
setSelectedPdbFile(symbolFileLocation);
setPdbLocationValue(symbolFileLocation, file);
selectRowByLocation(symbolFileLocation);
- hasPerformedSearch = false;
updateStatusText();
updateButtonEnablement();
updateParserOptionEnablement(true);
diff --git a/Ghidra/Features/PDB/src/main/java/pdb/symbolserver/ui/SymbolFilePanel.java b/Ghidra/Features/PDB/src/main/java/pdb/symbolserver/ui/SymbolFilePanel.java
index b4848cfee5..2dc709a66f 100644
--- a/Ghidra/Features/PDB/src/main/java/pdb/symbolserver/ui/SymbolFilePanel.java
+++ b/Ghidra/Features/PDB/src/main/java/pdb/symbolserver/ui/SymbolFilePanel.java
@@ -15,12 +15,10 @@
*/
package pdb.symbolserver.ui;
-import java.util.EnumSet;
-import java.util.Set;
-
import java.awt.BorderLayout;
import java.awt.Dimension;
-import java.awt.event.ActionListener;
+import java.util.EnumSet;
+import java.util.Set;
import javax.swing.*;
import javax.swing.table.TableColumn;
@@ -39,6 +37,9 @@ import pdb.symbolserver.FindOption;
* Also allows the user to tweak search options.
*/
class SymbolFilePanel extends JPanel {
+ interface SearchCallback {
+ void searchForPdbs(boolean allowRemote);
+ }
static final String SEARCH_OPTIONS_HELP_ANCHOR = "PDB_Search_Search_Options";
private SymbolFileTableModel tableModel;
private GhidraTable table;
@@ -46,17 +47,18 @@ class SymbolFilePanel extends JPanel {
private JPanel tablePanel;
private JPanel welcomePanel;
- private JButton searchButton;
- private GCheckBox allowRemote;
+ private JButton searchLocalButton;
+ private JButton searchAllButton;
private GCheckBox ignorePdbUid;
private GCheckBox ignorePdbAge;
- SymbolFilePanel(ActionListener searchButtonActionListener) {
+ SymbolFilePanel(SearchCallback searchButtonsCallback) {
super(new BorderLayout());
build();
setEnablement(false);
- searchButton.addActionListener(searchButtonActionListener);
+ searchLocalButton.addActionListener(e -> searchButtonsCallback.searchForPdbs(false));
+ searchAllButton.addActionListener(e -> searchButtonsCallback.searchForPdbs(true));
}
SymbolFileTableModel getTableModel() {
@@ -69,9 +71,6 @@ class SymbolFilePanel extends JPanel {
Set<FindOption> getFindOptions() {
Set<FindOption> findOptions = EnumSet.noneOf(FindOption.class);
- if (allowRemote.isSelected()) {
- findOptions.add(FindOption.ALLOW_REMOTE);
- }
if (ignorePdbAge.isSelected()) {
findOptions.add(FindOption.ANY_AGE);
}
@@ -82,13 +81,13 @@ class SymbolFilePanel extends JPanel {
}
void setFindOptions(Set<FindOption> findOptions) {
- allowRemote.setSelected(findOptions.contains(FindOption.ALLOW_REMOTE));
ignorePdbAge.setSelected(findOptions.contains(FindOption.ANY_AGE));
ignorePdbUid.setSelected(findOptions.contains(FindOption.ANY_ID));
}
void setEnablement(boolean hasSymbolServerService) {
- searchButton.setEnabled(hasSymbolServerService);
+ searchLocalButton.setEnabled(hasSymbolServerService);
+ searchAllButton.setEnabled(hasSymbolServerService);
if (welcomePanel != null && hasSymbolServerService) {
remove(welcomePanel);
@@ -149,13 +148,15 @@ class SymbolFilePanel extends JPanel {
}
private JPanel buildButtonPanel() {
- searchButton = new JButton("Search");
-
- allowRemote = new GCheckBox("Allow Remote");
- allowRemote.setToolTipText("Allow searching remote symbol servers.");
+ searchLocalButton = new JButton("Search Local");
+ searchLocalButton.setToolTipText("Search local symbol servers only.");
+ searchAllButton = new JButton("Search All");
+ searchAllButton.setToolTipText("Search local and remote symbol servers.");
ignorePdbUid = new GCheckBox("Ignore GUID/ID");
- ignorePdbUid.setToolTipText("Find any PDB with same name (local locations only).");
+ ignorePdbUid.setToolTipText(
+ "Find any PDB with same name (local locations only). Age ignored also.");
+ ignorePdbUid.addChangeListener(l -> updateSearchOptionEnablement());
ignorePdbAge = new GCheckBox("Ignore Age");
ignorePdbAge.setToolTipText("Find PDB with any age value (local locations only).");
@@ -168,10 +169,10 @@ class SymbolFilePanel extends JPanel {
panel.add(ignorePdbAge);
panel.add(Box.createHorizontalStrut(10));
panel.add(ignorePdbUid);
- panel.add(Box.createHorizontalStrut(10));
- panel.add(allowRemote);
panel.add(Box.createHorizontalGlue());
- panel.add(searchButton);
+ panel.add(searchLocalButton);
+ panel.add(Box.createHorizontalStrut(10));
+ panel.add(searchAllButton);
DockingWindowManager.getHelpService()
.registerHelp(panel,
@@ -179,4 +180,8 @@ class SymbolFilePanel extends JPanel {
return panel;
}
+
+ private void updateSearchOptionEnablement() {
+ ignorePdbAge.setEnabled(!ignorePdbUid.isSelected());
+ }
}
diff --git a/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/PdbScreenShots.java b/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/PdbScreenShots.java
index 63c56cb4fe..a59dd267c3 100644
--- a/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/PdbScreenShots.java
+++ b/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/PdbScreenShots.java
@@ -15,11 +15,11 @@
*/
package help.screenshot;
-import java.util.List;
-
import java.io.File;
import java.io.IOException;
import java.net.URI;
+import java.util.List;
+import java.util.Set;
import org.apache.commons.io.FilenameUtils;
import org.junit.*;
@@ -143,12 +143,12 @@ public class PdbScreenShots extends GhidraScreenShotGenerator {
SymbolFileInfo.fromValues("HelloWorld.pdb", GUID1_STR, 1)),
new SymbolFileLocation("HelloWorld_ver2.pdb", sameDirSymbolStoreWithFakePath,
SymbolFileInfo.fromValues("HelloWorld.pdb", GUID1_STR, 2)));
+ Set<FindOption> findOptions = FindOption.of(FindOption.ALLOW_REMOTE, FindOption.ANY_AGE);
runSwing(() -> {
- loadPdbDialog
- .setSearchOptions(FindOption.of(FindOption.ALLOW_REMOTE, FindOption.ANY_AGE));
+ loadPdbDialog.setSearchOptions(findOptions);
loadPdbDialog.setSymbolServers(symbolServers);
loadPdbDialog.setSymbolStorageDirectoryTextOnly("/home/user/symbols");
- loadPdbDialog.setSearchResults(symbolFileLocations);
+ loadPdbDialog.setSearchResults(symbolFileLocations, findOptions);
loadPdbDialog.selectRowByLocation(symbolFileLocations.get(0));
});
waitForSwing();