Skip to content

Commit

Permalink
Add config option to emit try-catch ranges in assembler
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Sep 4, 2024
1 parent 81e49e6 commit d096b31
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public AbstractAssemblerPipeline(@Nonnull AssemblerPipelineGeneralConfig general

private void refreshContext() {
context = new PrintContext<>(generalConfig.getDisassemblyIndent().getValue());

// Enable comments that outline where try-catch ranges begin/end.
if (pipelineConfig instanceof JvmAssemblerPipelineConfig jvmConfig && jvmConfig.emitTryRangeComments())
context.setDebugTryCatchRanges(true);
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Assembler pipeline config outline.
*
* @author Justus Garbe
* @see AndroidAssemblerPipelineConfig
* @see JvmAssemblerPipelineConfig
*/
public interface AssemblerPipelineConfig extends ConfigContainer {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public AssemblerPipelineGeneralConfig() {
}

/**
* @return Indentation string.
* @return String of a single indentation level.
*/
@Nonnull
public ObservableString getDisassemblyIndent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
public class JvmAssemblerPipelineConfig extends BasicConfigContainer implements ServiceConfig, AssemblerPipelineConfig {
private final ObservableBoolean valueAnalysis = new ObservableBoolean(true);
private final ObservableBoolean simulateJvmCalls = new ObservableBoolean(true);
private final ObservableBoolean tryRangeComments = new ObservableBoolean(true);


@Inject
public JvmAssemblerPipelineConfig() {
super(ConfigGroups.SERVICE_ASSEMBLER, JvmAssemblerPipeline.SERVICE_ID + CONFIG_SUFFIX);
addValue(new BasicConfigValue<>("value-analysis", boolean.class, valueAnalysis));
addValue(new BasicConfigValue<>("simulate-jvm-calls", boolean.class, simulateJvmCalls));
addValue(new BasicConfigValue<>("try-range-comments", boolean.class, tryRangeComments));
}

@Override
Expand All @@ -32,6 +35,13 @@ public boolean isValueAnalysisEnabled() {

@Override
public boolean isSimulatingCommonJvmCalls() {
return simulateJvmCalls.hasValue();
return simulateJvmCalls.getValue();
}

/**
* @return {@code true} to emit comments for where try-catch ranges start/end/catch.
*/
public boolean emitTryRangeComments() {
return tryRangeComments.getValue();
}
}
1 change: 1 addition & 0 deletions recaf-ui/src/main/resources/translations/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ service.assembler.dalvik-assembler-config.simulate-jvm-calls=Simulate common JVM
service.assembler.jvm-assembler-config=JVM
service.assembler.jvm-assembler-config.value-analysis=Enable value analysis
service.assembler.jvm-assembler-config.simulate-jvm-calls=Simulate common JVM calls
service.assembler.jvm-assembler-config.try-range-comments=Emit try-catch range comments
service.assembler.flow-lines-config=Control flow lines
service.assembler.flow-lines-config.connection-mode=Line mode
service.assembler.flow-lines-config.render-mode=Render mode
Expand Down

0 comments on commit d096b31

Please sign in to comment.