1
0
mirror of https://github.com/golang/go synced 2024-11-17 13:35:08 -07:00

internal/trace: err if binary is not supplied for old trace

Change-Id: Id25c90993c4cbb7449d7031301b6d214a67d7633
Reviewed-on: https://go-review.googlesource.com/24134
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Hana Kim 2016-06-15 12:53:05 -04:00 committed by Hyang-Ah Hana Kim
parent ea2ac3fe5f
commit c3818e56d0
2 changed files with 22 additions and 7 deletions

View File

@ -60,21 +60,34 @@ const (
// Parse parses, post-processes and verifies the trace.
func Parse(r io.Reader, bin string) ([]*Event, error) {
ver, rawEvents, strings, err := readTrace(r)
ver, events, err := parse(r, bin)
if err != nil {
return nil, err
}
if ver < 1007 && bin == "" {
return nil, fmt.Errorf("for traces produced by go 1.6 or below, the binary argument must be provided")
}
return events, nil
}
// parse parses, post-processes and verifies the trace. It returns the
// trace version and the list of events.
func parse(r io.Reader, bin string) (int, []*Event, error) {
ver, rawEvents, strings, err := readTrace(r)
if err != nil {
return 0, nil, err
}
events, stacks, err := parseEvents(ver, rawEvents, strings)
if err != nil {
return nil, err
return 0, nil, err
}
events, err = removeFutile(events)
if err != nil {
return nil, err
return 0, nil, err
}
err = postProcessTrace(ver, events)
if err != nil {
return nil, err
return 0, nil, err
}
// Attach stack traces.
for _, ev := range events {
@ -84,10 +97,10 @@ func Parse(r io.Reader, bin string) ([]*Event, error) {
}
if ver < 1007 && bin != "" {
if err := symbolize(events, bin); err != nil {
return nil, err
return 0, nil, err
}
}
return events, nil
return ver, events, nil
}
// rawEvent is a helper type used during parsing.

View File

@ -42,7 +42,9 @@ func TestParseCanned(t *testing.T) {
if err != nil {
t.Fatalf("failed to read input file: %v", err)
}
_, err = Parse(bytes.NewReader(data), "")
// Instead of Parse that requires a proper binary name for old traces,
// we use 'parse' that omits symbol lookup if an empty string is given.
_, _, err = parse(bytes.NewReader(data), "")
switch {
case strings.HasSuffix(f.Name(), "_good"):
if err != nil {