GP-42 change pdb logging enablement to jvm property, fix button tooltip

This commit is contained in:
dev747368 2021-05-14 14:39:57 -04:00
parent 0fe06ffb2f
commit bb924294a1
7 changed files with 27 additions and 42 deletions

View file

@ -32,7 +32,8 @@ public class PdbLog {
private static Writer nullWriter;
private static Writer fileWriter;
private static boolean enabled = false;
private static final boolean SYSTEM_LOGGING_ENABLED = Boolean.getBoolean("pdb.logging");
private static boolean enabled = SYSTEM_LOGGING_ENABLED;
/**
* Enable or disable future messages to be output to the appropriate log resource. This

View file

@ -15,14 +15,12 @@
*/
package ghidra.app.util.bin.format.pdb2.pdbreader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
import ghidra.framework.options.Options;
import ghidra.program.model.data.CharsetInfo;
import ghidra.util.HelpLocation;
import ghidra.util.Msg;
/**
* Options used while reading a PDB ({@link AbstractPdb}) that control various aspects. These
@ -97,7 +95,6 @@ public class PdbReaderOptions extends Exception {
public void loadOptions(Options options) {
pdbLogging = options.getBoolean(OPTION_NAME_PDB_READER_APPLICATOR_LOGGING, pdbLogging);
setPdbLogging();
if (developerMode) {
oneByteCharsetName =
@ -114,22 +111,12 @@ public class PdbReaderOptions extends Exception {
*/
public void setDefaults() {
pdbLogging = DEFAULT_PDB_READER_APPLICATOR_LOGGING;
setPdbLogging();
oneByteCharsetName = DEFAULT_ONE_BYTE_CHARSET_NAME;
wideCharCharsetName = DEFAULT_TWO_BYTE_CHARSET_NAME;
setOneByteCharsetForName(oneByteCharsetName);
setWideCharCharsetForName(wideCharCharsetName);
}
private void setPdbLogging() {
try {
PdbLog.setEnabled(pdbLogging);
}
catch (IOException e) {
Msg.info(this, "Failure opening PDB log file: ", e);
}
}
/**
* Returns list of Charsets names that encode one byte characters.
* @return Charsets that encode one byte characters.

View file

@ -24,7 +24,8 @@ import ghidra.app.plugin.core.datamgr.archive.DuplicateIdException;
import ghidra.app.services.DataTypeManagerService;
import ghidra.app.util.bin.format.pdb.PdbException;
import ghidra.app.util.bin.format.pdb.PdbParser;
import ghidra.app.util.bin.format.pdb2.pdbreader.*;
import ghidra.app.util.bin.format.pdb2.pdbreader.AbstractPdb;
import ghidra.app.util.bin.format.pdb2.pdbreader.PdbReaderOptions;
import ghidra.app.util.importer.MessageLog;
import ghidra.app.util.pdb.pdbapplicator.*;
import ghidra.framework.options.Options;
@ -39,18 +40,16 @@ class LoadPdbTask extends Task {
private final Program program;
private final boolean useMsDiaParser;
private final PdbApplicatorControl control; // PDB Universal Parser only
private boolean debugLogging;
private String resultMessages;
private Exception resultException;
LoadPdbTask(Program program, File pdbFile, boolean useMsDiaParser, PdbApplicatorControl control,
boolean debugLogging, DataTypeManagerService service) {
DataTypeManagerService service) {
super("Load PDB", true, false, true, true);
this.program = program;
this.pdbFile = pdbFile;
this.useMsDiaParser = useMsDiaParser;
this.control = control;
this.debugLogging = debugLogging;
this.service = service;
}
@ -136,8 +135,6 @@ class LoadPdbTask extends Task {
private boolean parseWithNewParser(MessageLog log, TaskMonitor monitor)
throws IOException, CancelledException {
PdbLog.setEnabled(debugLogging);
PdbReaderOptions pdbReaderOptions = new PdbReaderOptions(); // use defaults
PdbApplicatorOptions pdbApplicatorOptions = new PdbApplicatorOptions();

View file

@ -143,9 +143,8 @@ public class PdbPlugin extends Plugin {
// note: We intentionally use a 0-delay here. Our underlying task may show modal
// dialog prompts. We want the task progress dialog to be showing before any
// prompts appear.
LoadPdbTask loadPdbTask =
new LoadPdbTask(program, pdbFile, loadPdbResults.useMsDiaParser,
loadPdbResults.control, loadPdbResults.debugLogging, dataTypeManagerService);
LoadPdbTask loadPdbTask = new LoadPdbTask(program, pdbFile,
loadPdbResults.useMsDiaParser, loadPdbResults.control, dataTypeManagerService);
TaskBuilder.withTask(loadPdbTask)
.setStatusTextAlignment(SwingConstants.LEADING)
.setLaunchDelay(0);

View file

@ -71,7 +71,6 @@ public class LoadPdbDialog extends DialogComponentProvider {
public File pdbFile;
public PdbApplicatorControl control;
public boolean useMsDiaParser;
public boolean debugLogging;
}
/**
@ -94,7 +93,6 @@ public class LoadPdbDialog extends DialogComponentProvider {
results.control =
(PdbApplicatorControl) choosePdbDlg.applicatorControlCombo.getSelectedItem();
results.useMsDiaParser = choosePdbDlg.msdiaParserButton.isSelected();
results.debugLogging = choosePdbDlg.debugLoggingCheckbox.isSelected();
return results;
}
@ -139,7 +137,6 @@ public class LoadPdbDialog extends DialogComponentProvider {
private JRadioButton universalParserButton;
private JRadioButton msdiaParserButton;
private GComboBox<PdbApplicatorControl> applicatorControlCombo;
private GCheckBox debugLoggingCheckbox;
/**
* Creates a new instance of the LoadPdbDialog class.
@ -549,7 +546,6 @@ public class LoadPdbDialog extends DialogComponentProvider {
universalParserButton.setSelected(false);
}
applicatorControlCombo.setEnabled(universalParserButton.isSelected());
debugLoggingCheckbox.setEnabled(universalParserButton.isSelected());
}
private JPanel buildParserOptionsPanel() {
@ -577,10 +573,6 @@ public class LoadPdbDialog extends DialogComponentProvider {
applicatorControlCombo = new GComboBox<>(PdbApplicatorControl.values());
applicatorControlCombo.setSelectedItem(PdbApplicatorControl.ALL);
debugLoggingCheckbox = new GCheckBox();
debugLoggingCheckbox.setToolTipText(
"If checked, logs information to the pdb.analyzer.log file for debug/development.");
parserOptionsPanel = new JPanel(new PairLayout(5, 5));
parserOptionsPanel.setBorder(BorderFactory.createTitledBorder("PDB Parser"));
DockingWindowManager.getHelpService()
@ -594,9 +586,6 @@ public class LoadPdbDialog extends DialogComponentProvider {
parserOptionsPanel.add(new GLabel("Control:"));
parserOptionsPanel.add(applicatorControlCombo);
parserOptionsPanel.add(new GLabel("[Dev] PDB Reader/Applicator Debug Logging:"));
parserOptionsPanel.add(debugLoggingCheckbox);
return parserOptionsPanel;
}

View file

@ -15,15 +15,14 @@
*/
package pdb.symbolserver.ui;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import javax.swing.*;
import javax.swing.table.TableColumn;
@ -200,8 +199,7 @@ class SymbolServerPanel extends JPanel {
}
private JPanel buildButtonPanel() {
refreshSearchLocationsStatusButton =
ButtonPanelFactory.createImageButton(Icons.REFRESH_ICON, "Refresh Status",
refreshSearchLocationsStatusButton = createImageButton(Icons.REFRESH_ICON, "Refresh Status",
ButtonPanelFactory.ARROW_SIZE);
refreshSearchLocationsStatusButton.addActionListener(e -> refreshSearchLocationStatus());
DockingWindowManager.getHelpService()
@ -226,7 +224,7 @@ class SymbolServerPanel extends JPanel {
new HelpLocation(PdbPlugin.PDB_PLUGIN_HELP_TOPIC,
"SymbolServerConfig MoveUpDown"));
deleteLocationButton = ButtonPanelFactory.createImageButton(Icons.DELETE_ICON, "Delete",
deleteLocationButton = createImageButton(Icons.DELETE_ICON, "Delete",
ButtonPanelFactory.ARROW_SIZE);
deleteLocationButton.addActionListener(e -> deleteLocation());
DockingWindowManager.getHelpService()
@ -234,7 +232,7 @@ class SymbolServerPanel extends JPanel {
new HelpLocation(PdbPlugin.PDB_PLUGIN_HELP_TOPIC,
"SymbolServerConfig Delete"));
addLocationButton = ButtonPanelFactory.createImageButton(Icons.ADD_ICON, "Add",
addLocationButton = createImageButton(Icons.ADD_ICON, "Add",
ButtonPanelFactory.ARROW_SIZE);
addLocationButton.addActionListener(e -> addLocation());
DockingWindowManager.getHelpService()
@ -591,4 +589,15 @@ class SymbolServerPanel extends JPanel {
return false;
}
private static JButton createImageButton(ImageIcon buttonIcon, String alternateText,
Dimension preferredSize) {
JButton button = ButtonPanelFactory.createButton("");
button.setIcon(buttonIcon);
button.setToolTipText(alternateText);
button.setPreferredSize(preferredSize);
return button;
}
}

View file

@ -107,3 +107,6 @@ VMARGS=--illegal-access=permit
# Limit on XML parsing. See https://docs.oracle.com/javase/tutorial/jaxp/limits/limits.html
#VMARGS=-Djdk.xml.totalEntitySizeLimit=50000000
# Enables debug logging during Pdb import and analysis
#VMARGS=-Dpdb.logging=true