Skip to content

Commit b4712e1

Browse files
committed
Handy function for Stage 2 debugging
1 parent 9865325 commit b4712e1

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
testdata/*

stage2_build_tape.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package simdjson
1919
import (
2020
"bytes"
2121
"encoding/binary"
22+
"fmt"
2223
)
2324

2425
// Constants for "return address" modes
@@ -41,6 +42,22 @@ func updateChar(pj *internalParsedJson, idx_in uint64) (done bool, idx uint64) {
4142
return
4243
}
4344

45+
// Handy "debug" function to see where Stage 2 fails (rename to `updateChar`)
46+
func updateCharDebug(pj *internalParsedJson, idx_in uint64) (done bool, idx uint64) {
47+
if pj.indexesChan.index >= pj.indexesChan.length {
48+
var ok bool
49+
pj.indexesChan, ok = <-pj.index_chan // Get next element from channel
50+
if !ok {
51+
done = true // return done if channel closed
52+
return
53+
}
54+
}
55+
idx = idx_in + uint64(pj.indexesChan.indexes[pj.indexesChan.index])
56+
fmt.Printf("At 0x%x char: %s\n", idx, string(pj.Message[idx]))
57+
pj.indexesChan.index++
58+
return
59+
}
60+
4461
func peekSize(pj *internalParsedJson) uint64 {
4562
if pj.indexesChan.index >= pj.indexesChan.length {
4663
//panic("cannot peek the size") // should never happen since last string element should be saved for next buffer

0 commit comments

Comments
 (0)