Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2024-01-08 06:52:00 -05:00
commit 54b4f4cacb
5 changed files with 45 additions and 30 deletions

View file

@ -1426,27 +1426,31 @@ public class BSimControlLaunchable implements GhidraLaunchable {
}
}
private static void printUsage() {
//@formatter:off
System.err.println("\n" +
"USAGE: bsim_ctl [command] required-args... [OPTIONS...}\n\n" +
" start </datadir-path> [--auth|-a pki|password|trust] [--noLocalAuth] [--cafile \"</cacert-path>\"] [--dn \"<distinguished-name>\"]\n" +
" stop </datadir-path> [--force]\n" +
" adduser </datadir-path> <username> [--dn \"<distinguished-name>\"]\n" +
" dropuser </datadir-path> <username>\n" +
" changeauth </datadir-path> [--auth|-a pki|password|trust] [--noLocalAuth] [--cafile \"</cacert-path>\"]\n" +
" resetpassword <username>\n" +
" changeprivilege <username> admin|user\n" +
"\n" +
"Global options:\n" +
" --port|-p <portnum>\n" +
" --user|-u <username>\n" +
" --cert </certfile-path>\n" +
"\n" +
"NOTE: Options with values may also be specified using the form: --option=value\n");
//@formatter:on
}
@Override
public void launch(GhidraApplicationLayout ghidraLayout, String[] params) {
if (params.length <= 1) {
//@formatter:off
System.err.println("USAGE: bsim_ctl [command] required-args... [OPTIONS...}\n");
System.err.println(" start </datadir-path> [--auth|-a pki|password|trust] [--noLocalAuth] [--cafile \"</cacert-path>\"] [--dn \"<distinguished-name>\"]");
System.err.println(" stop </datadir-path> [--force]");
System.err.println(" adduser </datadir-path> <username> [--dn \"<distinguished-name>\"]");
System.err.println(" dropuser </datadir-path> <username>");
System.err.println(" changeauth </datadir-path> [--auth|-a pki|password|trust] [--noLocalAuth] [--cafile \"</cacert-path>\"]");
System.err.println(" resetpassword <username>");
System.err.println(" changeprivilege <username> admin|user");
System.err.println();
System.err.println("Global options:");
System.err.println(" --port|-p <portnum>");
System.err.println(" --user|-u <username>");
System.err.println(" --cert </certfile-path>");
System.err.println();
System.err.println("NOTE: Options with values may also be specified using the form: --option=value\n");
System.err.println();
//@formatter:on
printUsage();
return;
}
layout = ghidraLayout; // Save layout for when we need to initialize application

View file

@ -930,9 +930,20 @@ public class BSimLaunchable implements GhidraLaunchable {
}
}
private static void printMaxMemory() {
long maxMemoryBytes = Runtime.getRuntime().maxMemory();
long maxMem = maxMemoryBytes >> 20; // MBytes
String units = " MBytes";
if (maxMem >= 1024) {
maxMem >>= 10;
units = " GBytes";
}
System.out.println("Max-Memory: " + maxMem + units);
}
private static void printUsage() {
//@formatter:off
System.err.println(
System.err.println("\n" +
"USAGE: bsim [command] required-args... [OPTIONS...]\n" +
" createdatabase <bsimURL> <config_template> [--name|-n \"<name>\"] [--owner|-o \"<owner>\"] [--description|-d \"<text>\"] [--nocallgraph]\n" +
" setmetadata <bsimURL> [--name|-n \"<name>\"] [--owner|-o \"<owner>\"] [--description|-d \"<text>\"]\n" +
@ -978,6 +989,9 @@ public class BSimLaunchable implements GhidraLaunchable {
@Override
public void launch(GhidraApplicationLayout ghidraLayout, String[] params) {
printMaxMemory();
if (params.length == 0) {
printUsage();
return;

View file

@ -2094,13 +2094,8 @@ public class CodeManager implements ErrorHandler, ManagerDB {
* data.
*/
private void addDataReferences(Data data, List<Address> longSegmentAddressList) {
Memory mem = program.getMemory();
MemoryBlock block = mem.getBlock(data.getAddress());
if (block == null || !block.isInitialized()) {
return;
}
DataType dt = data.getDataType();
if (Address.class.equals(dt.getValueClass(null))) {
if (Address.class.equals(dt.getValueClass(data))) {
Object obj = data.getValue();
if (obj instanceof Address) {
// creates a reference unless the value is 0 or all f's

View file

@ -2,8 +2,9 @@
#
# Command-line script for interacting with a BSim database
# maximum heap memory (may be increased)
MAXMEM=2G
# Maximum heap memory may be changed if default is inadequate. This will generally be up to 1/4 of
# the physical memory available to the OS. Uncomment MAXMEM setting if non-default value is needed.
#MAXMEM=2G
# launch mode (fg, bg, debug, debug-suspend)
LAUNCH_MODE=fg
@ -17,4 +18,4 @@ VMARG_LIST="-Djava.awt.headless=true "
SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"
SCRIPT_DIR="${SCRIPT_FILE%/*}"
${SCRIPT_DIR}/launch.sh $LAUNCH_MODE jdk "BSim" $MAXMEM "" ghidra.features.bsim.query.ingest.BSimLaunchable "$@"
${SCRIPT_DIR}/launch.sh $LAUNCH_MODE jdk "BSim" "${MAXMEM}" "" ghidra.features.bsim.query.ingest.BSimLaunchable "$@"

View file

@ -3,8 +3,9 @@
@echo off
setlocal
:: maximum heap memory (may be increased)
set MAXMEM=2G
:: Maximum heap memory may be changed if default is inadequate. This will generally be up to 1/4 of
:: the physical memory available to the OS. Uncomment MAXMEM setting if non-default value is needed.
::set MAXMEM=2G
:: launch mode (fg, bg, debug, debug-suspend)
set LAUNCH_MODE=fg