Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support time and random native calls in trace debugger #541

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

zhelenskiy
Copy link
Collaborator

No description provided.

@zhelenskiy zhelenskiy requested a review from eupp February 20, 2025 16:51
@zhelenskiy zhelenskiy force-pushed the native-calls-attempt2 branch from 93fb82c to 5f3b23e Compare February 20, 2025 17:44
@zhelenskiy zhelenskiy force-pushed the native-calls-attempt2 branch from 5f3b23e to f9ed737 Compare February 20, 2025 18:50
@@ -83,7 +81,18 @@ abstract class ManagedStrategy(
// Tracker of objects' allocations and object graph topology.
protected abstract val objectTracker: ObjectTracker?
// Tracker of objects' identity hash codes.
internal abstract val identityHashCodeTracker: ObjectIdentityHashCodeTracker
private val identityHashCodeTracker = ObjectIdentityHashCodeTracker()
private val nativeMethodCallStatesTracker = NativeMethodCallStatesTracker()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comment similar to other trackers.

internal abstract val identityHashCodeTracker: ObjectIdentityHashCodeTracker
private val identityHashCodeTracker = ObjectIdentityHashCodeTracker()
private val nativeMethodCallStatesTracker = NativeMethodCallStatesTracker()
internal val traceDebuggerEventTrackers: Map<TraceDebuggerTracker, AbstractTraceDebuggerEventTracker> = mapOf(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an empty line before this tracker.

}
internal fun closeTraceDebuggerTrackers() {
traceDebuggerEventTrackers.values.forEach { it.close() }
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add missing empty lines.

@@ -1153,6 +1164,12 @@ abstract class ManagedStrategy(
objectTracker?.registerNewObject(obj)
}
}

override fun getNativeCallStateOrNull(id: Id): Any? = nativeMethodCallStatesTracker.getStateOrNull(id)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty line + wrap method body in {} or put on next line.

* with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.jetbrains.kotlinx.lincheck.strategy.managed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything ASM or bytecode related should be put in transformation subpackage.

val expectedResult = List(10) { 0 }
require(randomList == expectedResult) { "Wrong randomizer: $randomList != $expectedResult" }
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: add representation test for native method call trackers

void advanceCurrentTraceDebuggerEventTrackerId(TraceDebuggerTracker tracker, long oldId);

Object getNativeCallStateOrNull(long id);
void setNativeCallState(long id, Object state);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think about how these methods should interact with beforeMethodCall and other method tracking functions.

@@ -66,34 +72,94 @@ internal class DeterministicHashCodeTransformer(
}

/**
* [DeterministicTimeTransformer] tracks invocations of [System.nanoTime] and [System.currentTimeMillis] methods,
* [FakeDeterministicTimeTransformer] tracks invocations of [System.nanoTime] and [System.currentTimeMillis] methods,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's now split it into DeterministicRandomTransformers.kt and DeterministicTimeTransformers.kt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants