Skip to content
Snippets Groups Projects
Commit b6860222 authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

Merge branch 'fix/andre/analysis-scripts-misc' into 'master'

Fix/andre/analysis scripts misc

See merge request frama-c/frama-c!4477
parents f3beb0a0 700ab875
No related branches found
No related tags found
No related merge requests found
#!/bin/bash #!/bin/bash -eu
########################################################################## ##########################################################################
# # # #
# This file is part of Frama-C. # # This file is part of Frama-C. #
...@@ -21,18 +21,8 @@ ...@@ -21,18 +21,8 @@
# # # #
########################################################################## ##########################################################################
WORKING_DIR="."
while [ "$1" != "" ] ; do
case "$1" in
-check) shift;;
-C) shift; WORKING_DIR="$1";;
*) break;;
esac
shift
done
usage() { usage() {
echo "usage: $0 [-C working-dir] cmd [args]" echo "usage: $0 cmd [args]"
echo "" echo ""
echo " where cmd is:" echo " where cmd is:"
echo "" echo ""
...@@ -48,7 +38,7 @@ usage() { ...@@ -48,7 +38,7 @@ usage() {
echo " and non-POSIX external libraries." echo " and non-POSIX external libraries."
echo " (run 'frama-c -machdep help' to get the list of machdeps)." echo " (run 'frama-c -machdep help' to get the list of machdeps)."
echo "" echo ""
echo " - creduce <args>" echo " - creduce [[file] args]"
echo " Use the external tool C-Reduce to minimize C files when" echo " Use the external tool C-Reduce to minimize C files when"
echo " debugging crashes and fatal errors. Run without arguments for" echo " debugging crashes and fatal errors. Run without arguments for"
echo " more details." echo " more details."
...@@ -101,7 +91,7 @@ usage() { ...@@ -101,7 +91,7 @@ usage() {
echo " Creates a new machdep definition for a specific target." echo " Creates a new machdep definition for a specific target."
echo " Use $0 make-machdep --help for more information" echo " Use $0 make-machdep --help for more information"
echo "" echo ""
echo " - make-wrapper target arg..." echo " - make-wrapper [target] [arg...]"
echo " Runs 'make target arg...', parsing the output to suggest" echo " Runs 'make target arg...', parsing the output to suggest"
echo " useful commands in case of failure." echo " useful commands in case of failure."
echo "" echo ""
...@@ -122,13 +112,13 @@ if [ $# -lt 1 ]; then ...@@ -122,13 +112,13 @@ if [ $# -lt 1 ]; then
fi fi
DIR="$( cd "$( dirname "$0" )" && pwd )" DIR="$( cd "$( dirname "$0" )" && pwd )"
cd "$WORKING_DIR"
# All scripts called by frama-c-script may rely on FRAMAC_BIN pointing to the # All scripts called by frama-c-script may rely on FRAMAC_BIN pointing to the
# directory containing frama-c, frama-c-config and frama-c-script. # directory containing frama-c, frama-c-config and frama-c-script.
export FRAMAC_BIN="$DIR" export FRAMAC_BIN="$DIR"
FRAMAC_LIB=$("${DIR}/frama-c-config" -print-lib-path) FRAMAC_LIB=$("${DIR}/frama-c-config" -print-lib-path)
FRAMAC_SHARE=$("${DIR}/frama-c-config" -print-share-path) FRAMAC_SHARE=$("${DIR}/frama-c-config" -print-share-path)
ANALYSIS_SCRIPTS_DIR="${FRAMAC_LIB}/analysis-scripts"
if [ -z ${FRAMAC_SESSION+x} ]; then if [ -z ${FRAMAC_SESSION+x} ]; then
FRAMAC_SESSION="./.frama-c"; FRAMAC_SESSION="./.frama-c";
fi fi
...@@ -139,7 +129,7 @@ command="$1" ...@@ -139,7 +129,7 @@ command="$1"
# ask if it should be overwritten # ask if it should be overwritten
check_path_exists() { check_path_exists() {
if [ -e "$1" ]; then if [ -e "$1" ]; then
read -p "warning: '$1' already exists. Overwrite? [y/N] " yn read -r -p "warning: '$1' already exists. Overwrite? [y/N] " yn
case $yn in case $yn in
[Yy]) ;; [Yy]) ;;
*) *)
...@@ -184,10 +174,10 @@ flamegraph() { ...@@ -184,10 +174,10 @@ flamegraph() {
mkdir "$dir" || { echo "error: could not create '$dir'"; exit 1; } mkdir "$dir" || { echo "error: could not create '$dir'"; exit 1; }
fi fi
out_svg="$dir/flamegraph.svg" out_svg="$dir/flamegraph.svg"
"${FRAMAC_LIB}/analysis-scripts/flamegraph.pl" \ "$ANALYSIS_SCRIPTS_DIR/flamegraph.pl" \
--title "Eva Flamegraph" --inverted --hash "$path" \ --title "Eva Flamegraph" --inverted --hash "$path" \
--width 1400 --fontsize 11 > "$out_svg.tmp" --width 1400 --fontsize 11 > "$out_svg.tmp"
if [ ! $? -eq 0 ]; then if [ ! $? ]; then
echo "Error creating flamegraph, aborting." echo "Error creating flamegraph, aborting."
exit 1 exit 1
fi fi
...@@ -226,22 +216,22 @@ case "$command" in ...@@ -226,22 +216,22 @@ case "$command" in
;; ;;
"build") "build")
shift; shift;
${FRAMAC_LIB}/analysis-scripts/build.py "$@"; "$ANALYSIS_SCRIPTS_DIR/build.py" "$@";
;; ;;
"list-files") "list-files")
shift; shift;
"${FRAMAC_LIB}"/analysis-scripts/list_files.py "$@"; "$ANALYSIS_SCRIPTS_DIR/list_files.py" "$@";
;; ;;
"list-functions") "list-functions")
shift; shift;
# to avoid a slow startup, we only load plugins which perform syntactic # to avoid a slow startup, we only load plugins which perform syntactic
# transformations. This may trigger annotation errors due to missing # transformations. This may trigger annotation errors due to missing
# plugins, so we disable those # plugins, so we disable those
"${DIR}"/frama-c "$@" -no-autoload-plugins -load-module variadic,instantiate,frama-c.analysis-scripts -kernel-warn-key annot-error=inactive -kernel-verbose 0; "${DIR}/frama-c" "$@" -no-autoload-plugins -load-module variadic,instantiate,frama-c.analysis-scripts -kernel-warn-key annot-error=inactive -kernel-verbose 0;
;; ;;
"find-fun") "find-fun")
shift; shift;
"${FRAMAC_LIB}"/analysis-scripts/find_fun.py "$@"; "$ANALYSIS_SCRIPTS_DIR/find_fun.py" "$@";
;; ;;
"flamegraph") "flamegraph")
shift; shift;
...@@ -249,7 +239,7 @@ case "$command" in ...@@ -249,7 +239,7 @@ case "$command" in
;; ;;
"summary") "summary")
shift; shift;
"${FRAMAC_LIB}"/analysis-scripts/summary.py "$@"; "$ANALYSIS_SCRIPTS_DIR/summary.py" "$@";
;; ;;
"configure") "configure")
shift; shift;
...@@ -257,36 +247,36 @@ case "$command" in ...@@ -257,36 +247,36 @@ case "$command" in
;; ;;
"heuristic-print-callgraph") "heuristic-print-callgraph")
shift; shift;
${FRAMAC_LIB}/analysis-scripts/print_callgraph.py "$@"; "$ANALYSIS_SCRIPTS_DIR/print_callgraph.py" "$@";
;; ;;
"heuristic-detect-recursion") "heuristic-detect-recursion")
shift; shift;
${FRAMAC_LIB}/analysis-scripts/detect_recursion.py "$@"; "$ANALYSIS_SCRIPTS_DIR/detect_recursion.py" "$@";
;; ;;
"heuristic-list-functions") "heuristic-list-functions")
shift; shift;
${FRAMAC_LIB}/analysis-scripts/heuristic_list_functions.py "$@"; "$ANALYSIS_SCRIPTS_DIR/heuristic_list_functions.py" "$@";
;; ;;
"estimate-difficulty") "estimate-difficulty")
shift; shift;
${FRAMAC_LIB}/analysis-scripts/estimate_difficulty.py "$@"; "$ANALYSIS_SCRIPTS_DIR/estimate_difficulty.py" "$@";
;; ;;
"make-wrapper") "make-wrapper")
shift; shift;
"${FRAMAC_LIB}"/analysis-scripts/make_wrapper.py "$0" "$@"; "$ANALYSIS_SCRIPTS_DIR/make_wrapper.py" "$0" "$@";
;; ;;
"normalize-jcdb") "normalize-jcdb")
shift; shift;
"${FRAMAC_LIB}"/analysis-scripts/normalize_jcdb.py "$@"; "$ANALYSIS_SCRIPTS_DIR/normalize_jcdb.py" "$@";
;; ;;
"creduce") "creduce")
shift; shift;
${FRAMAC_LIB}/analysis-scripts/creduce.sh "$@"; "$ANALYSIS_SCRIPTS_DIR/creduce.sh" "$@";
;; ;;
"make-machdep") "make-machdep")
shift; shift;
${FRAMAC_LIB}/make_machdep/make_machdep.py \ "${FRAMAC_LIB}/make_machdep/make_machdep.py" \
--machdep-schema ${FRAMAC_SHARE}/machdeps/machdep-schema.yaml "$@" --machdep-schema "${FRAMAC_SHARE}/machdeps/machdep-schema.yaml" "$@"
;; ;;
*) *)
echo "error: unrecognized command: $command"; echo "error: unrecognized command: $command";
......
; Almost all frama-c-script commands require Python ; Almost all frama-c-script commands require Python
(cram (cram
(enabled_if %{read:../../python-3.7-available}) (enabled_if %{read:../../python-3.7-available})
(deps
%{bin:frama-c}
%{bin:frama-c-script}
(glob_files "../../share/analysis-scripts/*")
(glob_files "../../share/compliance/*")
(glob_files "../../share/machdeps/*")
(glob_files "../../share/machdeps/make_machdep/*")
)
) )
(cram (cram
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment