Skip to content

Commit 28bb77c

Browse files
authored
* fixed: crash on remote debug to target (#812)
Steps to reproduce: - launch using gradle in debug mode: `./gradlew -Probovm.debug=true -Probovm.debugPort=7777 launchIPhoneSimulator` - attach as to remote JVM target using Idea. Root case: - debugger tries to suspend main thread while it is still waiting for JVM resume command. Probably in new JVMs/Idea something changed and now in it tries to suspend Main thread once debugger attached (previously VM resume command was sent). And this correct behaviour as from debugger POV target to attach could be running. In case RoboVM thread 0 is still not entered JVM frame and waiting resume VM command from debugger. Instead SUSPEND thread command is received that fails on building stacktrace on line as there is no any env->gatewayFrames specified: > fakeFrame = *(Frame*) env->gatewayFrames->frameAddress; Fix: in case there is no `env->gatewayFrames` (thread detached or not started yet main) -- return empty stack trace. Other fixes: - debugger not started due crash when arguments were passed to application using gradle options, --args="'-rvm:log=trace'". Root case: gradle is passing immutable list. - gradle plugin extended to respect dev mode of libraries (`-DROBOVM_DEV_ROOT=`) - using 8 workers to build native libs
1 parent d56ce25 commit 28bb77c

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

compiler/compiler/src/main/java/org/robovm/compiler/target/LaunchParameters.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ public List<String> getArguments(boolean rvmReorder) {
5454
}
5555

5656
public void setArguments(List<String> arguments) {
57-
this.arguments = arguments;
57+
// copy arguments as provided list might be immutable
58+
this.arguments.clear();
59+
this.arguments.addAll(arguments);
5860
}
5961

6062
public Map<String, String> getEnvironment() {

compiler/vm/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ SELF=$(basename $0)
44
BASE=$(cd $(dirname $0); pwd -P)
55
CLEAN=0
66
VERBOSE=
7-
WORKERS=6
7+
WORKERS=8
88

99
function usage {
1010
cat <<EOF

compiler/vm/core/src/signal.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,16 +469,20 @@ static void signalHandler_dump_thread(int signum, siginfo_t* info, void* context
469469
// Signalled in non-native code
470470
fakeFrame.prev = (Frame*) getFramePointer((ucontext_t*) context);
471471
fakeFrame.returnAddress = getPC((ucontext_t*) context);
472+
captureCallStack(env, &fakeFrame, dumpThreadStackTraceCallStack, MAX_CALL_STACK_LENGTH);
473+
} else if (env->gatewayFrames == NULL) {
474+
// there is no any frames attached: either main thread is still waiting for debugger resume (not entered into VM frame)
475+
// or thread is detached (should not happen), anyway to not crash just returning empty stack
476+
dumpThreadStackTraceCallStack->length = 0;
472477
} else {
473478
// The thread was signalled while in native code, possibly a system
474479
// function. We cannot trust that this code uses proper frame
475480
// pointers so we cannot use the context's frame pointer. The top
476481
// most GatewayFrame in env was pushed when native code was entered.
477482
// Use its frame as frame pointer.
478483
fakeFrame = *(Frame*) env->gatewayFrames->frameAddress;
484+
captureCallStack(env, &fakeFrame, dumpThreadStackTraceCallStack, MAX_CALL_STACK_LENGTH);
479485
}
480-
481-
captureCallStack(env, &fakeFrame, dumpThreadStackTraceCallStack, MAX_CALL_STACK_LENGTH);
482486
}
483487

484488
// check if its required to run suspend loop by hook.

plugins/gradle/src/main/java/org/robovm/gradle/tasks/AbstractRoboVMTask.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,18 @@ protected Config.Builder configure(Config.Builder builder) {
183183
}
184184
temporaryDirectory.mkdirs();
185185

186-
builder.home(new Config.Home(extractSdk()))
186+
Config.Home home = Config.Home.suggestDevHome();
187+
if (home == null) home = new Config.Home(extractSdk());
188+
builder.home(home)
187189
.tmpDir(temporaryDirectory)
188190
.skipInstall(true)
189191
.installDir(installDir)
190192
.cacheDir(cacheDir);
191-
193+
if (home.isDev()) {
194+
builder.useDebugLibs(true);
195+
builder.dumpIntermediates(true);
196+
builder.addPluginArgument("debug:logconsole=true");
197+
}
192198
if (project.hasProperty("mainClassName")) {
193199
builder.mainClass((String) project.property("mainClassName"));
194200
}

plugins/idea/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Not supported any more due removed `-extdir` in Java9+
1010

1111
### Development with Maven
1212
* Install recent *Intellij IDEA Community Edition * under /Applications/Intellij IDEA CE.app/ (https://download.jetbrains.com/idea/)
13+
* Install Swing UI Designer plugin
1314
* Install this plugin, it allows us to use [Maven for plugin development](https://plugins.jetbrains.com/plugin/7127?pr=). *Note*: outdated and might not work for recent versions of Idea, open source alternative is available at [dkimitsa/support-maven-devkit-plugins](https://github.com/dkimitsa/support-maven-devkit-plugins).
1415
* Clone this repo https://github.com/JetBrains/intellij-community.git
1516
* Checkout the branch that corresponds to the respective IDEA version you installed, e.g. 139 for Idea 14.0.x, see http://www.jetbrains.org/pages/viewpage.action?pageId=983225

0 commit comments

Comments
 (0)