Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
34ca70b2
Commit
34ca70b2
authored
9 years ago
by
Kostyantyn Vorobyov
Browse files
Options
Downloads
Patches
Plain Diff
[e-acsl-gcc.sh] Functionality specify several models via -m option
parent
01939607
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/e-acsl/scripts/e-acsl-gcc.sh
+63
-27
63 additions, 27 deletions
src/plugins/e-acsl/scripts/e-acsl-gcc.sh
with
63 additions
and
27 deletions
src/plugins/e-acsl/scripts/e-acsl-gcc.sh
+
63
−
27
View file @
34ca70b2
...
@@ -74,7 +74,8 @@ OPTION_GMP= # Use GMP integers everywhere
...
@@ -74,7 +74,8 @@ OPTION_GMP= # Use GMP integers everywhere
OPTION_DEBUG_MACRO
=
"-DE_ACSL_DEBUG"
# Debug macro
OPTION_DEBUG_MACRO
=
"-DE_ACSL_DEBUG"
# Debug macro
OPTION_DEBUG_LOG_MACRO
=
""
# Specification of debug log file
OPTION_DEBUG_LOG_MACRO
=
""
# Specification of debug log file
OPTION_FRAMAC_CPP_EXTRA
=
""
# Extra CPP flags for Frama-C
OPTION_FRAMAC_CPP_EXTRA
=
""
# Extra CPP flags for Frama-C
OPTION_EACSL_MMODEL
=
"bittree"
# Memory model used
OPTION_EACSL_MMODELS
=
"bittree"
# Memory model used
OPTION_EACSL_SHARE
=
# Custom E-ACSL share directory
# The following option controls whether to use gcc builtins
# The following option controls whether to use gcc builtins
# (e.g., __builtin_strlen) in RTL or fall back to custom implementations
# (e.g., __builtin_strlen) in RTL or fall back to custom implementations
# of standard functions.
# of standard functions.
...
@@ -280,12 +281,11 @@ do
...
@@ -280,12 +281,11 @@ do
OPTION_EACSL_SHARE
=
"
$1
"
OPTION_EACSL_SHARE
=
"
$1
"
shift
;
shift
;
;;
;;
# A memory model to link against
# A memory model
(or models)
to link against
-m
|
--memory-model
)
-m
|
--memory-model
)
shift
;
shift
;
echo
$1
|
grep
"
\(
tree
\|
bittree
\|
splaytree
\|
list
\|
segment
\)
"
# Convert comma-separated string into white-space separated string
error
"no such memory model:
$1
"
$?
OPTION_EACSL_MMODELS
=
"
`
echo
$1
|
sed
-s
's/,/ /g'
`
"
OPTION_EACSL_MMODEL
=
"
$1
"
shift
;
shift
;
;;
;;
esac
esac
...
@@ -345,6 +345,38 @@ else
...
@@ -345,6 +345,38 @@ else
fi
fi
fi
fi
# Check if the E-ACSL share directory is indeed an E-ACSL share directory that
# contains required C code. The check involves looking up
# $EACSL_SHARE/e_acsl_mmodel_api.h - one of the headers required by the Frama-C
# invocation. This is a week check but it is better than nothing.
error
"Cannot find required
$EACSL_SHARE
/e_acsl_mmodel_api.h header"
\
`
test
-f
$EACSL_SHARE
/e_acsl_mmodel_api.h
;
echo
$?
`
# Echo the name of the source file corresponding to the name of a memory model
# or report an error of the given model does not exist.
mmodel_sources
()
{
model
=
""
case
"
$1
"
in
bittree
)
model
=
"adt_models/e_acsl_bittree_mmodel.c"
;;
splaytree
)
model
=
"adt_models/e_acsl_splaytree_mmodel.c"
;;
tree
)
model
=
"adt_models/e_acsl_tree_mmodel.c"
;;
list
)
model
=
"adt_models/e_acsl_list_mmodel.c"
;;
foo
)
model
=
"adt_models/e_acsl_foo_mmodel.c"
;;
*
)
error
"Memory model '
$1
' does not exist"
;;
esac
model
=
"
$EACSL_SHARE
/
$model
"
if
!
[
-f
"
$model
"
]
;
then
error
"Memory model '
$1
' exists but not available in this distribution"
else
echo
"
$model
"
fi
}
# Once EACSL_SHARE is defined check the memory models provided at inputs
for
mod
in
$OPTION_EACSL_MMODELS
;
do
mmodel_sources
$mod
>
/dev/null
done
# Macro that identifies E-ACSL compilation. Passed to Frama-C
# Macro that identifies E-ACSL compilation. Passed to Frama-C
# and GCC runs but not to the original compilation
# and GCC runs but not to the original compilation
EACSL_MACRO_ID
=
"__E_ACSL__"
EACSL_MACRO_ID
=
"__E_ACSL__"
...
@@ -352,7 +384,7 @@ EACSL_MACRO_ID="__E_ACSL__"
...
@@ -352,7 +384,7 @@ EACSL_MACRO_ID="__E_ACSL__"
# Gcc and related flags
# Gcc and related flags
CC
=
"
$OPTION_CC
"
CC
=
"
$OPTION_CC
"
CFLAGS
=
"
$OPTION_CFLAGS
CFLAGS
=
"
$OPTION_CFLAGS
-std=c99
$GCCMACHDEP
-g3 -O2 -pedantic -fno-builtin
-w
-std=c99
$GCCMACHDEP
-g3 -O2 -pedantic -fno-builtin
-Wall
\
-Wall
\
-Wno-long-long
\
-Wno-long-long
\
-Wno-attributes
\
-Wno-attributes
\
...
@@ -365,7 +397,6 @@ CFLAGS="$OPTION_CFLAGS
...
@@ -365,7 +397,6 @@ CFLAGS="$OPTION_CFLAGS
-Wno-unused-variable
\
-Wno-unused-variable
\
-Wno-unused-but-set-variable
\
-Wno-unused-but-set-variable
\
-Wno-implicit-function-declaration
\
-Wno-implicit-function-declaration
\
-Wno-extra-semi
\
-Wno-empty-body"
-Wno-empty-body"
# Disable extra warning for clang
# Disable extra warning for clang
...
@@ -388,13 +419,6 @@ EACSL_CPPFLAGS="
...
@@ -388,13 +419,6 @@ EACSL_CPPFLAGS="
-D__FC_errno=(*__errno_location())"
-D__FC_errno=(*__errno_location())"
EACSL_LDFLAGS
=
"-lgmp -lm"
EACSL_LDFLAGS
=
"-lgmp -lm"
# Memory model sources
if
[
$OPTION_EACSL_MMODEL
=
"segment"
]
;
then
error
"Segment model not available in this distribution"
else
EACSL_RTL
=
"
$EACSL_SHARE
/adt_models/e_acsl_"
$OPTION_EACSL_MMODEL
"_mmodel.c"
fi
# Output file names
# Output file names
OUTPUT_CODE
=
"
$OPTION_OUTPUT_CODE
"
# E-ACSL instrumented source
OUTPUT_CODE
=
"
$OPTION_OUTPUT_CODE
"
# E-ACSL instrumented source
OUTPUT_EXEC
=
"
$OPTION_OUTPUT_EXEC
"
# Output name of the original executable
OUTPUT_EXEC
=
"
$OPTION_OUTPUT_EXEC
"
# Output name of the original executable
...
@@ -435,18 +459,30 @@ if [ -n "$OPTION_COMPILE" ]; then
...
@@ -435,18 +459,30 @@ if [ -n "$OPTION_COMPILE" ]; then
else
else
OUTPUT_CODE
=
"
$@
"
OUTPUT_CODE
=
"
$@
"
fi
fi
# Compile and link E-ACSL-instrumented file
# Compile and link E-ACSL-instrumented file with all models specified
(
$OPTION_ECHO
;
for
mod
in
$OPTION_EACSL_MMODELS
;
do
$CC
\
# If multiple models are specified then the generated executable
$CFLAGS
$CPPFLAGS
\
# is appended a '-MODEL' suffix, where MODEL is the name of the memory
$EACSL_CFLAGS
$EACSL_CPPFLAGS
\
# model used
$EACSL_RTL
\
if
!
[
"
`
echo
$OPTION_EACSL_MMODELS
|
wc
-w
`
"
=
1
]
;
then
$OPTION_DEBUG_MACRO
\
OUTPUT_EXEC
=
"
$EACSL_OUTPUT_EXEC
-
$mod
"
$OPTION_DEBUG_LOG_MACRO
\
else
$OPTION_BUILTINS
\
OUTPUT_EXEC
=
"
$EACSL_OUTPUT_EXEC
"
-o
"
$EACSL_OUTPUT_EXEC
"
\
fi
"
$OUTPUT_CODE
"
\
# Sources of the selected memory model
$LDFLAGS
$EACSL_LDFLAGS
)
EACSL_RTL
=
`
mmodel_sources
"
$mod
"
`
error
"fail to compile/link instrumented code:
$@
"
$?
;
(
$OPTION_ECHO
;
$CC
\
$CFLAGS
$CPPFLAGS
\
$EACSL_CFLAGS
$EACSL_CPPFLAGS
\
$EACSL_RTL
\
$OPTION_DEBUG_MACRO
\
$OPTION_DEBUG_LOG_MACRO
\
$OPTION_BUILTINS
\
-o
"
$OUTPUT_EXEC
"
\
"
$OUTPUT_CODE
"
\
$LDFLAGS
$EACSL_LDFLAGS
)
error
"fail to compile/link instrumented code:
$@
"
$?
;
done
fi
fi
exit
0
;
exit
0
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment