Skip to content

Commit 1b541b8

Browse files
committed
UA11-008 gnatfuzz.py: remove passing of AFL_Mode
Also add a GUI for selecting the AFL_MODE. Clear the list of previous "analyze" messages as needed. Adapt to the fact that we now pass the name of the file as first parameter to the harness executable. Solves AdaCore/gnatfuzz#440 Change-Id: Ide3c6f09bca69362b8d5a51b8ef592a9815d3997
1 parent b5a93b6 commit 1b541b8

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

share/support/ui/gnatfuzz.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class GNATfuzzPlugin(Module):
7070
X("description").children("Launch gnatfuzz fuzz"),
7171
X("command-line").children(),
7272
X("iconname").children("gps-build-all-symbolic"),
73-
X("switches", command="gnatfuzz", columns="2", lines="2").children(
73+
X("switches", command="gnatfuzz", columns="2", lines="1").children(
7474
X(
7575
"spin",
7676
line="1",
@@ -83,6 +83,25 @@ class GNATfuzzPlugin(Module):
8383
max="32",
8484
tip="The number of cores to use. Use 0 for automatic.",
8585
),
86+
X(
87+
"combo",
88+
line="1",
89+
column="1",
90+
label="AFL mode",
91+
separator="=",
92+
switch="--afl-mode",
93+
default="PERSIST",
94+
tip="The AFL run mode. See the AFL++ documentation.",
95+
).children(
96+
X("combo-entry", label="PLAIN", value="afl_plain"),
97+
X("combo-entry", label="PERSIST", value="afl_persist"),
98+
X("combo-entry", label="DEFER", value="afl_defer"),
99+
X(
100+
"combo-entry",
101+
label="DEFER_AND_PERSIST",
102+
value="afl_defer_and_persist",
103+
),
104+
),
86105
),
87106
),
88107
X(
@@ -439,13 +458,20 @@ def gnatfuzz_analyze_file_workflow(self, task):
439458
return
440459
self.process_analyze_messages()
441460

461+
def clear_analyze_messages(self):
462+
"""Clear messages generated by 'gnatfuzz analyze'"""
463+
for m in GPS.Message.list(category="Fuzzable Subprograms"):
464+
m.remove()
465+
442466
def gnatfuzz_analyze_project(self):
443467
"""Action to launch the 'gnatfuzz analyze' workflow"""
468+
self.clear_analyze_messages()
444469
workflows.task_workflow(
445470
"gnatfuzz analyze", self.gnatfuzz_analyze_project_workflow
446471
)
447472

448473
def gnatfuzz_analyze_file(self):
474+
self.clear_analyze_messages()
449475
"""Action to launch the 'gnatfuzz analyze' workflow on a file"""
450476
workflows.task_workflow("gnatfuzz analyze", self.gnatfuzz_analyze_file_workflow)
451477

@@ -484,7 +510,7 @@ def gnatfuzz_fuzz_workflow(self, task):
484510
for variable, value in GPS.Project.scenario_variables().items():
485511
# We pass all -X switches except the ones that are internal
486512
# to gnatfuzz.
487-
if not variable.startswith("GNATFUZZ"):
513+
if not (variable.startswith("GNATFUZZ") or variable == "AFL_MODE"):
488514
args.append(f"-X{variable}={value}")
489515

490516
args.extend(

share/support/ui/gnatfuzz_view.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def debug_candidate(self, task):
116116
executable=GPS.File(os.path.join(proj.object_dirs()[0], exec))
117117
)
118118
d.send("delete")
119-
d.send(f"start < {self.target_candidate}")
119+
d.send(f"start {self.target_candidate}")
120120
d.send("catch exception")
121121
d.send("cont")
122122
d.send("up") # Hack, wrong frame for gdb here.
@@ -190,7 +190,7 @@ def process_crashes(self, task):
190190
# We're actually launching the executable to get the
191191
# parameters that were passed to the crash, along with
192192
# the actual crash message.
193-
cl = ["/bin/bash", "-c", f"{executable} < {candidate}"]
193+
cl = [executable, candidate]
194194
p = ProcessWrapper(cl)
195195
status, output = yield p.wait_until_terminate()
196196
c = FuzzCrash(candidate)

0 commit comments

Comments
 (0)