File: README.md

package info (click to toggle)
golang-github-segmentio-asm 1.2.0%2Bgit20231107.1cfacc8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 932 kB
  • sloc: asm: 6,093; makefile: 32
file content (69 lines) | stat: -rw-r--r-- 1,643 bytes parent folder | download
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# valid

This program is a helper to check the output of `utf8.Valid` facilitate
debugging. It accepts some input, runs both this library and stdlib's version of
`utf8.Valid`, and prints out the result.

## Usage

Provide the input as the the first argument to the program:

```
$ go run main.go "hello! 😊"
hello! 😊
[104 101 108 108 111 33 32 240 159 152 138]
11 bytes
stdlib: utf8: true ascii: false
valid:  utf8: true ascii: false v: 1
```

The input is parsed as a double quoted Go string, so you can use escape codes:

```
$ go run main.go "\xFA"

[250]
1 bytes
stdlib: utf8: false ascii: false
valid:  utf8: false ascii: false v: 0
```

Alternatively it can also conusme input from stdin:

```
$ cat example.txt
hello! 😊
$ go run main.go < example.txt
hello! 😊

[104 101 108 108 111 33 32 240 159 152 138 10]
12 bytes
stdlib: utf8: true ascii: false
valid:  utf8: true ascii: false v: 1
```

As a bonus, if the file is the result of a failure reported by Go 1.18 fuzz, the
program extracts the actual value of the test:

```
$ cat fuzz.out
go test fuzz
[]byte("000000000000000000~\xFF")
$ go run main.go < fuzz.out
Got fuzzer input
000000000000000000~
[48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 126 255]
20 bytes
stdlib: utf8: false ascii: false
valid:  utf8: false ascii: false v: 0
```

## GDB

A useful way to debug is to run this program with some problematic input and use
GDB to step through the execution and inspect registers. The `debug.gdb` file is
a basic helper to automate part of the process. For example:

```
$ go build main.go && gdb --command=debug.gdb  -ex "set args < ./example.txt" ./main
```