-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (31 loc) · 690 Bytes
/
main.go
File metadata and controls
35 lines (31 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// oops2core: convert Linux kernel crash report to a core file
package main
import (
"fmt"
"io/ioutil"
"os"
"opensource.go.fig.lu/oops2core/internal/elfcore32"
"opensource.go.fig.lu/oops2core/internal/parser"
)
func handleFatalError() {
if e := recover(); e != nil {
fmt.Fprintln(os.Stderr, "Fatal error occured: ", e)
os.Exit(1)
}
}
func main() {
defer handleFatalError()
rawtext, err := ioutil.ReadAll(os.Stdin)
if err != nil {
panic(err)
}
ci, err := parser.ParseCrash(string(rawtext))
if err != nil {
panic(err)
}
_, err = os.Stdout.Write(elfcore32.NewElfcore(ci).Bytes())
if err != nil {
panic(err)
}
os.Stdout.Write(elfcore32.NewElfcore(ci).Bytes())
}