Skip to content

Commit 19812a1

Browse files
committed
Merge remote-tracking branch
'origin/GP-4297_fix_screen_reader_duplicate_line_reading--SQUASHED' into patch (Closes NationalSecurityAgency#6177)
2 parents 4a0e945 + 97fdfdd commit 19812a1

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/ListingFieldDescriptionProvider.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import docking.widgets.fieldpanel.FieldDescriptionProvider;
1919
import docking.widgets.fieldpanel.field.Field;
2020
import docking.widgets.fieldpanel.support.FieldLocation;
21+
import ghidra.program.model.address.Address;
2122
import ghidra.program.util.ProgramLocation;
2223

2324
public class ListingFieldDescriptionProvider implements FieldDescriptionProvider {
@@ -27,8 +28,9 @@ public String getDescription(FieldLocation loc, Field field) {
2728
if (field instanceof ListingField listingField) {
2829
FieldFactory fieldFactory = listingField.getFieldFactory();
2930
ProgramLocation location = fieldFactory.getProgramLocation(0, 0, listingField);
30-
return fieldFactory.getFieldName() + " Field at Address " + location.getAddress() +
31-
" text = " + field.getText();
31+
Address address = location.getAddress();
32+
String addressString = address.toString(address.getAddressSpace().showSpaceName(), 1);
33+
return fieldFactory.getFieldName() + " Field at Address " + addressString;
3234
}
3335
return "Unknown Field";
3436
}

Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponent.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,22 @@ private String getFieldDescription(FieldLocation fieldLoc, Field field) {
102102
ByteBlockInfo info = indexMap.getBlockInfo(fieldLoc.getIndex(), fieldLoc.getFieldNum());
103103
if (info != null) {
104104
String modelName = model.getName();
105-
return modelName + " format at " +
106-
info.getBlock().getLocationRepresentation(info.getOffset()) + ", value = " +
107-
field.getText();
105+
String location = getAccessibleLocationInfo(info.getBlock(), info.getOffset());
106+
return modelName + " format at " + location;
108107
}
109108
return null;
110109
}
111110

111+
private String getAccessibleLocationInfo(ByteBlock block, BigInteger offset) {
112+
if (block instanceof MemoryByteBlock memBlock) {
113+
// location represents an address, remove leading zeros to make screen reading concise
114+
Address address = memBlock.getAddress(offset);
115+
return address.toString(address.getAddressSpace().showSpaceName(), 1);
116+
}
117+
// otherwise use generic location representation
118+
return block.getLocationRepresentation(offset);
119+
}
120+
112121
@Override
113122
public void buttonPressed(FieldLocation fieldLocation, Field field, MouseEvent mouseEvent) {
114123
if (fieldLocation == null || field == null) {

Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
package ghidra.app.decompiler.component;
1717

1818
import java.awt.*;
19-
import java.awt.event.ComponentAdapter;
20-
import java.awt.event.ComponentEvent;
21-
import java.awt.event.MouseEvent;
19+
import java.awt.event.*;
2220
import java.math.BigInteger;
2321
import java.util.*;
2422
import java.util.List;
@@ -45,7 +43,6 @@
4543
import ghidra.app.decompiler.component.margin.*;
4644
import ghidra.app.plugin.core.decompile.DecompilerClipboardProvider;
4745
import ghidra.app.plugin.core.decompile.actions.FieldBasedSearchLocation;
48-
import ghidra.app.util.viewer.listingpanel.MarginProvider;
4946
import ghidra.app.util.viewer.util.ScrollpaneAlignedHorizontalLayout;
5047
import ghidra.program.model.address.*;
5148
import ghidra.program.model.listing.Function;
@@ -128,7 +125,7 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
128125
fieldPanel.addFieldMouseListener(this);
129126
fieldPanel.addFieldLocationListener(this);
130127
fieldPanel.addLayoutListener(this);
131-
128+
132129
fieldPanel.addComponentListener(new ComponentAdapter() {
133130
@Override
134131
public void componentResized(ComponentEvent e) {
@@ -1317,7 +1314,7 @@ public DecompilerFieldPanel(LayoutModel model) {
13171314
if (f == null) {
13181315
return null;
13191316
}
1320-
return "line " + (l.getIndex().intValue() + 1) + ", " + f.getText();
1317+
return "line " + (l.getIndex().intValue() + 1);
13211318
});
13221319
}
13231320

0 commit comments

Comments
 (0)