Added a command-line option to change how much stack the unknown functions are given
This commit is contained in:
parent
eb99480484
commit
6e66cf7521
5
Main.hs
5
Main.hs
|
@ -73,6 +73,8 @@ optionsNoWarnings =
|
||||||
, Option [] ["sanity-check"] (ReqArg optSanityCheck "SETTING") "internal sanity check (options: on, off)"
|
, Option [] ["sanity-check"] (ReqArg optSanityCheck "SETTING") "internal sanity check (options: on, off)"
|
||||||
, Option [] ["occam2-mobility"] (ReqArg optClassicOccamMobility "SETTING") "occam2 implicit mobility (EXPERIMENTAL) (options: on, off)"
|
, Option [] ["occam2-mobility"] (ReqArg optClassicOccamMobility "SETTING") "occam2 implicit mobility (EXPERIMENTAL) (options: on, off)"
|
||||||
, Option [] ["usage-checking"] (ReqArg optUsageChecking "SETTING") "usage checking (options: on, off)"
|
, Option [] ["usage-checking"] (ReqArg optUsageChecking "SETTING") "usage checking (options: on, off)"
|
||||||
|
, Option [] ["unknown-stack-size"] (ReqArg optStackSize "BYTES")
|
||||||
|
"stack amount to allocate for unknown C functions"
|
||||||
, Option ['v'] ["verbose"] (NoArg $ optVerbose) "be more verbose (use multiple times for more detail)"
|
, Option ['v'] ["verbose"] (NoArg $ optVerbose) "be more verbose (use multiple times for more detail)"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -130,6 +132,9 @@ optKeepTemporaries ps = return $ ps { csKeepTemporaries = True }
|
||||||
optRunIndent :: OptFunc
|
optRunIndent :: OptFunc
|
||||||
optRunIndent ps = return $ ps { csRunIndent = True }
|
optRunIndent ps = return $ ps { csRunIndent = True }
|
||||||
|
|
||||||
|
optStackSize :: String -> OptFunc
|
||||||
|
optStackSize s ps = return $ ps { csUnknownStackSize = read s }
|
||||||
|
|
||||||
optOutput :: String -> OptFunc
|
optOutput :: String -> OptFunc
|
||||||
optOutput s ps = return $ ps { csOutputFile = s }
|
optOutput s ps = return $ ps { csOutputFile = s }
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ import qualified Data.Set as Set
|
||||||
import Numeric (readDec)
|
import Numeric (readDec)
|
||||||
import Text.Printf
|
import Text.Printf
|
||||||
|
|
||||||
|
import CompState
|
||||||
import Errors
|
import Errors
|
||||||
import Pass
|
import Pass
|
||||||
import PrettyShow
|
import PrettyShow
|
||||||
|
@ -148,10 +149,6 @@ collectInfo ais = collectInfo' ais ""
|
||||||
modify $ Map.insert func fi'
|
modify $ Map.insert func fi'
|
||||||
collectInfo' ais func'
|
collectInfo' ais func'
|
||||||
|
|
||||||
-- | Stack size for unknown functions.
|
|
||||||
unknownSize :: Int
|
|
||||||
unknownSize = 512
|
|
||||||
|
|
||||||
-- | Additional stack size to give to all functions.
|
-- | Additional stack size to give to all functions.
|
||||||
-- This is necessary because CCSP does odd things with the provided stack
|
-- This is necessary because CCSP does odd things with the provided stack
|
||||||
-- size; it doesn't calculate the space that it needs for the arguments.
|
-- size; it doesn't calculate the space that it needs for the arguments.
|
||||||
|
@ -159,8 +156,8 @@ baseStackSize :: Int
|
||||||
baseStackSize = 32
|
baseStackSize = 32
|
||||||
|
|
||||||
-- | Add the stack sizes for called functions to their callers.
|
-- | Add the stack sizes for called functions to their callers.
|
||||||
addCalls :: AAM ()
|
addCalls :: Int -> AAM ()
|
||||||
addCalls
|
addCalls unknownSize
|
||||||
= do fmap <- get
|
= do fmap <- get
|
||||||
sequence_ $ map computeStack (Map.keys fmap)
|
sequence_ $ map computeStack (Map.keys fmap)
|
||||||
where
|
where
|
||||||
|
@ -193,7 +190,8 @@ analyseAsm :: String -> PassM String
|
||||||
analyseAsm asm
|
analyseAsm asm
|
||||||
= do let stream = parseAsm asm
|
= do let stream = parseAsm asm
|
||||||
veryDebug $ pshow stream
|
veryDebug $ pshow stream
|
||||||
info <- execStateT (collectInfo stream >> addCalls) Map.empty
|
cs <- getCompState
|
||||||
|
info <- execStateT (collectInfo stream >> addCalls (csUnknownStackSize cs)) Map.empty
|
||||||
debug $ "Analysed function information:"
|
debug $ "Analysed function information:"
|
||||||
debug $ concat [printf " %-40s %5d %5d %s\n"
|
debug $ concat [printf " %-40s %5d %5d %s\n"
|
||||||
func (fiStack fi) (fiTotalStack fi)
|
func (fiStack fi) (fiTotalStack fi)
|
||||||
|
|
|
@ -108,6 +108,7 @@ data CompState = CompState {
|
||||||
csEnabledWarnings :: Set WarningType,
|
csEnabledWarnings :: Set WarningType,
|
||||||
csRunIndent :: Bool,
|
csRunIndent :: Bool,
|
||||||
csClassicOccamMobility :: Bool,
|
csClassicOccamMobility :: Bool,
|
||||||
|
csUnknownStackSize :: Int,
|
||||||
|
|
||||||
-- Set by preprocessor
|
-- Set by preprocessor
|
||||||
csCurrentFile :: String,
|
csCurrentFile :: String,
|
||||||
|
@ -155,6 +156,7 @@ emptyState = CompState {
|
||||||
-- TODO enable WarnUninitialisedVariable by default
|
-- TODO enable WarnUninitialisedVariable by default
|
||||||
csRunIndent = False,
|
csRunIndent = False,
|
||||||
csClassicOccamMobility = False,
|
csClassicOccamMobility = False,
|
||||||
|
csUnknownStackSize = 512,
|
||||||
|
|
||||||
csCurrentFile = "none",
|
csCurrentFile = "none",
|
||||||
csUsedFiles = Set.empty,
|
csUsedFiles = Set.empty,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user