Skip to content

Commit

Permalink
Merge pull request eclipse-openj9#18230 from TheMarvelFan/master
Browse files Browse the repository at this point in the history
Remove support for jextract -interactive
  • Loading branch information
keithc-ca authored Oct 10, 2023
2 parents 5570f22 + 71dd731 commit 0d83d4d
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,19 @@
import com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException;
import com.ibm.j9ddr.tools.ddrinteractive.Command;

public class JextractCommand extends Command
public class JextractCommand extends Command
{
public JextractCommand()
{
addCommand("jextract", "<filename>", "dump a JExtract file to filename (or console)");
}

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException
{
try {
throw new CorruptDataException("command not implemented");
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
*******************************************************************************/
package com.ibm.jvm.j9.dump.extract;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
Expand Down Expand Up @@ -276,10 +274,8 @@ public static void main(String[] args) {
String outputName = null;
File virtualRootDirectory = null;
boolean ignoreOptions = false;
boolean interactive = false;
boolean verbose = false;
boolean throwExceptions = false;
boolean zip = true;
boolean disableBuildIdCheck = false;
boolean excludeCoreFile = false;

Expand All @@ -291,8 +287,6 @@ public static void main(String[] args) {
if (!ignoreOptions && args[i].startsWith("-")) { //$NON-NLS-1$
if ("--".equals(args[i])) { //$NON-NLS-1$
ignoreOptions = true;
} else if ("-interactive".equals(args[i])) { //$NON-NLS-1$
interactive = true;
} else if ("-help".equals(args[i])) { //$NON-NLS-1$
usageMessage(null, JEXTRACT_SUCCESS);
} else if ("-f".equals(args[i])) { //$NON-NLS-1$
Expand Down Expand Up @@ -338,14 +332,8 @@ public static void main(String[] args) {

Main dumper = new Main(dumpName, virtualRootDirectory, verbose, throwExceptions, disableBuildIdCheck, excludeCoreFile);

if (interactive) {
dumper.runInteractive();
} else {
if (zip) {
dumper.runZip(outputName);
}
report("jextract complete."); //$NON-NLS-1$
}
dumper.runZip(outputName);
report("jextract complete."); //$NON-NLS-1$

if (dumper._dump != null) {
try {
Expand Down Expand Up @@ -512,41 +500,6 @@ private void runZip(String outputName) {
}
}

private void runInteractive() {
report("Jextract interactive mode."); //$NON-NLS-1$
report("Type '!j9help' for help."); //$NON-NLS-1$
report("Type 'quit' to quit."); //$NON-NLS-1$
report("(Commands must be prefixed with '!')"); //$NON-NLS-1$

IAbstractAddressSpace addressSpace = _dump.getAddressSpace();

if (addressSpace == null) {
report("Error. Address space not found in dump: " + _dumpName //$NON-NLS-1$
+ ". Dump is truncated, corrupted or does not contain a supported JVM."); //$NON-NLS-1$
return;
}

BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

try {
while (true) {
report("> "); //$NON-NLS-1$
String command = input.readLine().trim();
if ("quit".equalsIgnoreCase(command) || "q".equalsIgnoreCase(command)) { //$NON-NLS-1$ //$NON-NLS-2$
break;
}
try {
doCommand(addressSpace, command);
} catch (Throwable e) {
report(e.getMessage());
report("Failure detected during command execution, see previous message(s)."); //$NON-NLS-1$
}
}
} catch (IOException e) {
report("Error reading input."); //$NON-NLS-1$
}
}

private static void report(String message) {
System.err.println(message);
}
Expand Down Expand Up @@ -677,7 +630,4 @@ private static void copy(ClosingFileReader from, OutputStream to, byte[] buffer)
}

private native long getEnvironmentPointer(IAbstractAddressSpace dump, boolean disableBuildIdCheck) throws Exception;

private native void doCommand(IAbstractAddressSpace dump, String command) throws Exception;

}
4 changes: 0 additions & 4 deletions runtime/jextractnatives/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,19 @@
set(OMR_ENHANCED_WARNINGS OFF)

j9vm_add_library(j9jextract SHARED
jextractglue.c
jextractnatives.c

)

target_link_libraries(j9jextract
PRIVATE
j9vm_interface

j9dbgext
j9util
j9utilcore
j9pool
)

omr_add_exports(j9jextract
Java_com_ibm_jvm_j9_dump_extract_Main_doCommand
Java_com_ibm_jvm_j9_dump_extract_Main_getEnvironmentPointer
)

Expand Down
69 changes: 0 additions & 69 deletions runtime/jextractnatives/jextractglue.c

This file was deleted.

25 changes: 0 additions & 25 deletions runtime/jextractnatives/jextractnatives.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "j9dbgext.h"
#include "j9protos.h"
#include "j9port.h"
#include "jextractnatives_internal.h"
#include "j9version.h"

#include <stdarg.h>
Expand Down Expand Up @@ -289,30 +288,6 @@ cacheIDs(JNIEnv* env, jobject dumpObj)
return 0;
}

void JNICALL
Java_com_ibm_jvm_j9_dump_extract_Main_doCommand(JNIEnv *env, jobject obj, jobject dumpObj, jstring commandObject)
{
const char *command = (*env)->GetStringUTFChars(env, commandObject, 0);
PORT_ACCESS_FROM_VMC((J9VMThread*)env);

if (command == NULL) {
return;
}

if (cacheIDs(env, dumpObj)) {
return;
}

/* hook the debug extension's malloc and free up to ours, so that it can benefit from -memorycheck */
OMRPORT_FROM_J9PORT(dbgGetPortLibrary())->mem_allocate_memory = OMRPORT_FROM_J9PORT(PORTLIB)->mem_allocate_memory;
OMRPORT_FROM_J9PORT(dbgGetPortLibrary())->mem_free_memory = OMRPORT_FROM_J9PORT(PORTLIB)->mem_free_memory;
OMRPORT_FROM_J9PORT(dbgGetPortLibrary())->port_control = OMRPORT_FROM_J9PORT(PORTLIB)->port_control;

run_command(command);

(*env)->ReleaseStringUTFChars(env, commandObject, command);
}

/**
* Gets the environment pointer from the J9RAS structure.
*/
Expand Down
48 changes: 0 additions & 48 deletions runtime/jextractnatives/jextractnatives_internal.h

This file was deleted.

1 change: 0 additions & 1 deletion runtime/jextractnatives/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
<module>

<exports group="all">
<export name="Java_com_ibm_jvm_j9_dump_extract_Main_doCommand"/>
<export name="Java_com_ibm_jvm_j9_dump_extract_Main_getEnvironmentPointer"/>
</exports>

Expand Down
11 changes: 0 additions & 11 deletions runtime/oti/jextractnatives_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ extern "C" {

/* ---------------- jextractnatives.c ---------------- */

/**
* @brief
* @param *env
* @param obj
* @param dumpObj
* @param commandObject
* @return void
*/
void JNICALL
Java_com_ibm_jvm_j9_dump_extract_Main_doCommand(JNIEnv *env, jobject obj, jobject dumpObj, jstring commandObject);

/**
* @brief
* @param *env
Expand Down

0 comments on commit 0d83d4d

Please sign in to comment.