Skip to content

Commit

Permalink
feat: add diffing uprobeconfig
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Bretting <[email protected]>
  • Loading branch information
luca-dot-sh committed Dec 10, 2024
1 parent 7fed569 commit 57fee11
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import de.amosproj3.ziofa.client.SysSendmsgConfig
import de.amosproj3.ziofa.client.UprobeConfig
import de.amosproj3.ziofa.client.VfsWriteConfig
import de.amosproj3.ziofa.ui.shared.updatePIDs
import de.amosproj3.ziofa.ui.shared.updateUProbes
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down Expand Up @@ -88,7 +89,15 @@ class ConfigurationManager(val clientFactory: ClientFactory) :
if (!enable) requestedChanges.entries.entries else setOf(),
)
} ?: previousConfiguration.sysSendmsg,
uprobes = uprobesFeature ?: prev.configuration.uprobes, // TODO diff uprobes
uprobes =
uprobesFeature.let { requestedChanges ->
if (requestedChanges == null)
return@let previousConfiguration.uprobes
previousConfiguration.uprobes.updateUProbes(
pidsToAdd = if (enable) requestedChanges else listOf(),
pidsToRemove = if (!enable) requestedChanges else listOf(),
)
},
jniReferences =
jniReferencesFeature?.let { requestedChanges ->
previousConfiguration.jniReferences.updatePIDs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package de.amosproj3.ziofa.ui.shared
import de.amosproj3.ziofa.api.configuration.ConfigurationUpdate
import de.amosproj3.ziofa.client.JniReferencesConfig
import de.amosproj3.ziofa.client.SysSendmsgConfig
import de.amosproj3.ziofa.client.UprobeConfig
import de.amosproj3.ziofa.client.VfsWriteConfig
import de.amosproj3.ziofa.ui.configuration.data.BackendFeatureOptions

Expand Down Expand Up @@ -36,6 +37,14 @@ fun SysSendmsgConfig?.updatePIDs(
)
}

fun List<UprobeConfig>?.updateUProbes(
pidsToAdd: List<UprobeConfig> = listOf(),
pidsToRemove: List<UprobeConfig> = listOf(),
): List<UprobeConfig> {
val config = this ?: listOf()
return config.minus(pidsToRemove.toSet()).plus(pidsToAdd).toSet().toList()
}

fun JniReferencesConfig?.updatePIDs(
pidsToAdd: List<UInt> = listOf(),
pidsToRemove: List<UInt> = listOf(),
Expand Down

0 comments on commit 57fee11

Please sign in to comment.