Ghidra is a software reverse engineering (SRE) framework
Test fixes
dragonmacherf7c1714bb1c3
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkEditCmd.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkEditCmd.javaindex 504de20dfe..6f7f9aa948 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkEditCmd.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkEditCmd.java@@ -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,8 +41,8 @@ public class BookmarkEditCmd implements Command<Program> {private String presentationName;/**- * Edit a Bookmark. When editing a bookmark, all fields are used except the address- * which is determined by the first address within each range of the set.+ * Constructor+ ** @param set list of bookmark addresses.* @param type the bookmark type.* @param category the bookmark category.@@ -53,14 +53,15 @@ public class BookmarkEditCmd implements Command<Program> {this.category = category;this.comment = comment;this.set = set;- if (set == null || set.isEmpty() || type == null || type.length() == 0)+ if (set == null || set.isEmpty() || type == null || type.length() == 0) {throw new IllegalArgumentException();+ }presentationName = "Add " + type + " Bookmark(s)";}/**- * Edit a Bookmark. When editing a bookmark, all fields are used except the address- * which is provided by the addrs parameter.+ * Constructor+ ** @param addr the bookmark address.* @param type the bookmark type.* @param category the bookmark category.@@ -71,8 +72,9 @@ public class BookmarkEditCmd implements Command<Program> {this.category = category;this.comment = comment;this.addr = addr;- if (addr == null || type == null || type.length() == 0)+ if (addr == null || type == null || type.length() == 0) {throw new IllegalArgumentException();+ }presentationName = "Add " + type + " Bookmark";}@@ -80,13 +82,14 @@ public class BookmarkEditCmd implements Command<Program> {this.bookmark = bookmark;this.category = category;this.comment = comment;- if (bookmark == null)+ if (bookmark == null) {throw new IllegalArgumentException();+ }presentationName = "Edit " + bookmark.getTypeString() + " Bookmark";}/**- * The name of the edit action.+ * {@return The name of the edit action.}*/public String getPresentationName() {return presentationName;diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkNavigator.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkNavigator.javaindex bf29ce1268..33d123b09d 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkNavigator.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkNavigator.java@@ -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.@@ -82,7 +82,11 @@ public class BookmarkNavigator {Icon icon = bmt.getIcon();if (icon == null) {- icon = DEFAULT_ICON;+ if (bookmarkManager.isDefinedType(type)) {+ // This implies the client defined a type, but did not pass a valid icon. In this+ // case we will show a special icon.+ icon = DEFAULT_ICON;+ }}Color color = bmt.getMarkerColor();@@ -90,8 +94,23 @@ public class BookmarkNavigator {color = DEFAULT_COLOR;}- markerSet = markerService.createPointMarker(type + " Bookmarks", type + " Bookmarks",- bookmarkMgr.getProgram(), priority, true, true, false, color, icon);+ //+ // Be default, bookmarks appear with an icon on the left side of the Listing. If there is+ // no icon, then skip the icon and instead add a color marker on the right side of the+ // Listing so the user can see the bookmark. As long as clients call BookmarkManager's+ // defineType() method with a valid icon, then we will show the icon, which is the expected+ // behavior.+ //+ String markerName = type + " Bookmarks";+ if (icon != null) {+ markerSet = markerService.createPointMarker(markerName, markerName,+ bookmarkMgr.getProgram(), priority, true, true, false, color, icon);+ }+ else {+ markerSet =+ markerService.createAreaMarker(markerName, markerName, bookmarkMgr.getProgram(),+ priority, false, true, false, color);+ }markerSet.setMarkerDescriptor(new MarkerDescriptor() {diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkPlugin.javaindex 53495d4cc8..8484023cfa 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkPlugin.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkPlugin.java@@ -306,12 +306,6 @@ public class BookmarkPlugin extends ProgramPlugin implements PopupActionProvider}BookmarkManager bookmarkManager = currentProgram.getBookmarkManager();- if (!bookmarkManager.isDefinedType(typeString)) {- // This implies the bookmark was created by a plugin that is no longer available in- // the current tool.- return null;- }-nav = new BookmarkNavigator(markerService, bookmarkManager, type);bookmarkNavigators.put(typeString, nav);return nav;