mirror of
https://github.com/danog/gllvm.git
synced 2024-11-26 19:14:43 +01:00
Better error reporting if things go pear shaped.
This commit is contained in:
parent
30cc3b22fa
commit
3ea1db0849
@ -4,7 +4,7 @@ To edit the code locally use the repository here:
|
||||
|
||||
Then do:
|
||||
|
||||
go install -a github.com/SRI-CSL/gllvm/cmd/...
|
||||
go install github.com/SRI-CSL/gllvm/cmd/...
|
||||
|
||||
|
||||
To format for the badge:
|
||||
|
@ -191,6 +191,9 @@ func parseSwitches() (ea extractionArgs) {
|
||||
|
||||
func handleExecutable(ea extractionArgs) {
|
||||
artifactPaths := ea.Extractor(ea.InputFile)
|
||||
|
||||
LogInfo("handleExecutable: artifactPaths = %v\n", artifactPaths)
|
||||
|
||||
if len(artifactPaths) == 0 {
|
||||
return
|
||||
}
|
||||
@ -211,6 +214,8 @@ func handleArchive(ea extractionArgs) {
|
||||
var bcFiles []string
|
||||
var artifactFiles []string
|
||||
|
||||
LogInfo("handleArchive: extractionArgs = %v\n", ea)
|
||||
|
||||
// Create tmp dir
|
||||
tmpDirName, err := ioutil.TempDir("", "gllvm")
|
||||
if err != nil {
|
||||
@ -222,6 +227,9 @@ func handleArchive(ea extractionArgs) {
|
||||
arArgs := ea.ArArgs
|
||||
inputAbsPath, _ := filepath.Abs(ea.InputFile)
|
||||
arArgs = append(arArgs, inputAbsPath)
|
||||
|
||||
LogInfo("handleArchive: executing ar %v %v\n", arArgs, tmpDirName)
|
||||
|
||||
success, err := execCmd("ar", arArgs, tmpDirName)
|
||||
if !success {
|
||||
LogFatal("Failed to extract object files from %s to %s because: %v.\n", ea.InputFile, tmpDirName, err)
|
||||
@ -235,7 +243,9 @@ func handleArchive(ea extractionArgs) {
|
||||
artifactPaths := ea.Extractor(path)
|
||||
for _, artPath := range artifactPaths {
|
||||
bcPath := resolveBitcodePath(artPath)
|
||||
bcFiles = append(bcFiles, bcPath)
|
||||
if bcPath != "" {
|
||||
bcFiles = append(bcFiles, bcPath)
|
||||
}
|
||||
}
|
||||
artifactFiles = append(artifactFiles, artifactPaths...)
|
||||
}
|
||||
@ -246,16 +256,22 @@ func handleArchive(ea extractionArgs) {
|
||||
// Handle object files
|
||||
filepath.Walk(tmpDirName, walkHandlingFunc)
|
||||
|
||||
// Build archive
|
||||
if ea.BuildBitcodeArchive {
|
||||
extractTimeLinkFiles(ea, bcFiles)
|
||||
} else {
|
||||
archiveBcFiles(ea, bcFiles)
|
||||
}
|
||||
LogDebug("handleArchive: walked %v\nartifactFiles:\n%v\nbcFiles:\n%v\n", tmpDirName, artifactFiles, bcFiles)
|
||||
|
||||
// Write manifest
|
||||
if ea.WriteManifest {
|
||||
writeManifest(ea, bcFiles, artifactFiles)
|
||||
if len(bcFiles) > 0 {
|
||||
// Build archive
|
||||
if ea.BuildBitcodeArchive {
|
||||
extractTimeLinkFiles(ea, bcFiles)
|
||||
} else {
|
||||
archiveBcFiles(ea, bcFiles)
|
||||
}
|
||||
|
||||
// Write manifest
|
||||
if ea.WriteManifest {
|
||||
writeManifest(ea, bcFiles, artifactFiles)
|
||||
}
|
||||
} else {
|
||||
LogError("No bitcode files found\n")
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,6 +365,7 @@ func resolveBitcodePath(bcPath string) string {
|
||||
}
|
||||
return storeBcPath
|
||||
}
|
||||
LogWarning("Failed to find the file %v\n", bcPath)
|
||||
return ""
|
||||
}
|
||||
return bcPath
|
||||
|
@ -54,6 +54,15 @@ var loggingLevels = map[string]int{
|
||||
"DEBUG": debugV,
|
||||
}
|
||||
|
||||
var loggingPrefixes = map[int]string{
|
||||
errorV: "Error: ",
|
||||
warningV: "Warning: ",
|
||||
infoV: "Info: ",
|
||||
debugV: "Debug: ",
|
||||
}
|
||||
|
||||
|
||||
|
||||
//loggingLevel is the user configured level of logging: ERROR, WARNING, INFO, DEBUG
|
||||
var loggingLevel = errorV
|
||||
|
||||
@ -86,6 +95,10 @@ func makeLogger(lvl int) func(format string, a ...interface{}) {
|
||||
//and send output to both os.Stderr and loggingFilePointer. We wouldn't
|
||||
//want the user to miss any excitement. Then the sanity checker would not
|
||||
//need to futz with it.
|
||||
prefix := loggingPrefixes[lvl]
|
||||
if len(prefix) > 0 {
|
||||
loggingFilePointer.WriteString(prefix)
|
||||
}
|
||||
loggingFilePointer.WriteString(msg)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user