Skip to content

Commit 1260cc6

Browse files
authored
Detect GDBMODE and compile fuzz targets appropriately (#78)
1 parent f67fa10 commit 1260cc6

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

ossfuzz.sh

+17-6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ OPENSSLDIR=/src/openssl
3232
NGHTTPDIR=/src/nghttp2
3333
GDBDIR=/src/gdb
3434

35+
# Check for GDB-specific behaviour by checking for the GDBMODE flag.
36+
# - Compile with -O0 so that DEBUGASSERTs can be debugged in gdb.
37+
if [[ -n ${GDBMODE:-} ]]
38+
then
39+
export CFLAGS="$CFLAGS -O0"
40+
export CXXFLAGS="$CXXFLAGS -O0"
41+
fi
42+
3543
echo "BUILD_ROOT: $BUILD_ROOT"
3644
echo "SRC: ${SRC:-undefined}"
3745
echo "CC: $CC"
@@ -47,13 +55,16 @@ export MAKEFLAGS+="-j$(nproc)"
4755
# Make an install directory
4856
export INSTALLDIR=/src/curl_install
4957

50-
# If necessary (i.e. this is inside the ossfuzz shell environment and
51-
# you've set the environment variable) then download and install GDB.
52-
# This installs to the default configure location.
53-
if [[ ${INSTALLGDB:-} == "yes" ]]
58+
# Check for GDB-specific behaviour by checking for the GDBMODE flag.
59+
# - Compile and installing GDB if necessary.
60+
if [[ -n ${GDBMODE:-} ]]
5461
then
55-
# Install GDB
56-
${SCRIPTDIR}/handle_x.sh gdb ${GDBDIR} system || exit 1
62+
if ! type gdb 2>/dev/null
63+
then
64+
# If gdb isn't found, then download and install GDB.
65+
# This installs to the default configure location.
66+
${SCRIPTDIR}/handle_x.sh gdb ${GDBDIR} system || exit 1
67+
fi
5768
fi
5869

5970
# Install zlib

0 commit comments

Comments
 (0)