Skip to content

Commit 545afad

Browse files
authored
Merge pull request #102 from parca-dev/update2
Bring in batch of changes from upstream
2 parents a610305 + 249e740 commit 545afad

91 files changed

Lines changed: 1595 additions & 68627 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ RUN cross_debian_arch=$(uname -m | sed -e 's/aarch64/amd64/' -e 's/x86_64/arm64
1010
cross_pkg_arch=$(uname -m | sed -e 's/aarch64/x86-64/' -e 's/x86_64/aarch64/'); \
1111
apt-get update -y && \
1212
apt-get dist-upgrade -y && \
13-
apt-get install -y curl wget make git cmake clang-17 unzip libc6-dev g++ gcc pkgconf \
13+
apt-get install -y --no-install-recommends --no-install-suggests \
14+
curl wget make git cmake unzip libc6-dev g++ gcc pkgconf \
15+
clang-17 clang-format-17 \
1416
gcc-${cross_pkg_arch}-linux-gnu libc6-${cross_debian_arch}-cross \
1517
musl-dev:amd64 musl-dev:arm64 && \
1618
apt-get clean autoclean && \

LICENSES/luajit/COPYRIGHT

Lines changed: 0 additions & 56 deletions
This file was deleted.

LICENSES/zyantific/zydis/LICENSE

Lines changed: 0 additions & 23 deletions
This file was deleted.

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ debug-agent:
154154
legal:
155155
@go install github.com/google/go-licenses@latest
156156
@go-licenses save --force . --save_path=LICENSES
157-
@./legal/add-non-go.sh legal/non-go-dependencies.json LICENSES
158157

159158
codespell:
160159
@codespell

armhelpers/arm_helpers.go

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func Xreg2num(arg interface{}) (int, bool) {
2929
if !ok {
3030
return 0, false
3131
}
32-
ndx = aa.Reg(n)
32+
ndx = n
3333
default:
3434
return 0, false
3535
}
@@ -46,7 +46,9 @@ func Xreg2num(arg interface{}) (int, bool) {
4646

4747
// DecodeRegister converts the result of calling Reg.String()
4848
// into the initial register's value.
49-
func DecodeRegister(reg string) (uint64, bool) {
49+
func DecodeRegister(reg string) (aa.Reg, bool) {
50+
const maxRegister = uint64(aa.V31)
51+
5052
// This function is essentially just the inverse
5153
// of https://cs.opensource.google/go/x/arch/+/fc48f9fe:arm64/arm64asm/inst.go;l=335
5254
length := len(reg)
@@ -65,7 +67,10 @@ func DecodeRegister(reg string) (uint64, bool) {
6567
if err != nil {
6668
return 0, false
6769
}
68-
return val, true
70+
if val > maxRegister {
71+
return 0, false
72+
}
73+
return aa.Reg(val), true
6974
}
7075

7176
// Otherwise, we want to strip out the
@@ -98,16 +103,20 @@ func DecodeRegister(reg string) (uint64, bool) {
98103
return 0, false
99104
}
100105

101-
return val + regOffset, true
106+
res := val + regOffset
107+
if res > maxRegister {
108+
return 0, false
109+
}
110+
return aa.Reg(res), true
102111
}
103112

104113
// DecodeImmediate converts an arm64asm Arg of immediate type to it's value.
105-
func DecodeImmediate(arg aa.Arg) (uint64, bool) {
114+
func DecodeImmediate(arg aa.Arg) (int64, bool) {
106115
switch val := arg.(type) {
107116
case aa.Imm:
108-
return uint64(val.Imm), true
117+
return int64(val.Imm), true
109118
case aa.PCRel:
110-
return uint64(val), true
119+
return int64(val), true
111120
case aa.MemImmediate:
112121
// The MemImmediate layout changes quite
113122
// a bit depending on its mode.
@@ -139,13 +148,13 @@ func DecodeImmediate(arg aa.Arg) (uint64, bool) {
139148
// Note that the second %s here is the print
140149
// format from a register. Annoyingly this isn't a
141150
// register type, so we have to unwind it manually
142-
val, err := DecodeRegister(fields[1])
143-
if !err {
151+
reg, ok := DecodeRegister(fields[1])
152+
if !ok {
144153
return 0, false
145154
}
146155
// The Go disassembler always adds X0 here.
147156
// See https://cs.opensource.google/go/x/arch/+/fc48f9fe:arm64/arm64asm/inst.go;l=526
148-
return val - uint64(aa.X0), true
157+
return int64(reg - aa.X0), true
149158
}
150159

151160
// Otherwise all of the strings end with a ], so we just parse
@@ -156,12 +165,12 @@ func DecodeImmediate(arg aa.Arg) (uint64, bool) {
156165
if err != nil {
157166
return 0, false
158167
}
159-
return uint64(out), true
168+
return out, true
160169

161170
case aa.ImmShift:
162171
// Sadly, ImmShift{} does not have public fields.
163172
// https://github.com/golang/go/issues/51517
164-
var imm uint64
173+
var imm int64
165174
n, err := fmt.Sscanf(val.String(), "#%v", &imm)
166175
if err != nil || n != 1 {
167176
return 0, false

asm/amd/interpreter.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ func (i *Interpreter) Step() (x86asm.Inst, error) {
8080
switch inst.Op {
8181
case x86asm.ADD:
8282
if dst, ok := inst.Args[0].(x86asm.Reg); ok {
83-
left := i.Regs.getX86asm(dst)
83+
left := i.Regs.GetX86(dst)
8484
switch src := inst.Args[1].(type) {
8585
case x86asm.Imm:
8686
right := expression.Imm(uint64(src))
8787
i.Regs.setX86asm(dst, expression.Add(left, right))
8888
case x86asm.Reg:
89-
right := i.Regs.getX86asm(src)
89+
right := i.Regs.GetX86(src)
9090
i.Regs.setX86asm(dst, expression.Add(left, right))
9191
case x86asm.Mem:
9292
right := i.MemArg(src)
@@ -98,7 +98,7 @@ func (i *Interpreter) Step() (x86asm.Inst, error) {
9898
if dst, ok := inst.Args[0].(x86asm.Reg); ok {
9999
if src, imm := inst.Args[1].(x86asm.Imm); imm {
100100
v := expression.Multiply(
101-
i.Regs.getX86asm(dst),
101+
i.Regs.GetX86(dst),
102102
expression.Imm(uint64(math.Pow(2, float64(src)))),
103103
)
104104
i.Regs.setX86asm(dst, v)
@@ -110,7 +110,7 @@ func (i *Interpreter) Step() (x86asm.Inst, error) {
110110
case x86asm.Imm:
111111
i.Regs.setX86asm(dst, expression.Imm(uint64(src)))
112112
case x86asm.Reg:
113-
i.Regs.setX86asm(dst, i.Regs.getX86asm(src))
113+
i.Regs.setX86asm(dst, i.Regs.GetX86(src))
114114
case x86asm.Mem:
115115
v := i.MemArg(src)
116116

@@ -137,7 +137,7 @@ func (i *Interpreter) Step() (x86asm.Inst, error) {
137137
if dst, ok := inst.Args[0].(x86asm.Reg); ok {
138138
if src, imm := inst.Args[1].(x86asm.Imm); imm {
139139
if src == 3 { // todo other cases
140-
i.Regs.setX86asm(dst, expression.ZeroExtend(i.Regs.getX86asm(dst), 2))
140+
i.Regs.setX86asm(dst, expression.ZeroExtend(i.Regs.GetX86(dst), 2))
141141
}
142142
}
143143
}
@@ -159,11 +159,11 @@ func (i *Interpreter) MemArg(src x86asm.Mem) expression.Expression {
159159
vs = append(vs, expression.Imm(uint64(src.Disp)))
160160
}
161161
if src.Base != 0 {
162-
vs = append(vs, i.Regs.getX86asm(src.Base))
162+
vs = append(vs, i.Regs.GetX86(src.Base))
163163
}
164164
if src.Index != 0 {
165165
v := expression.Multiply(
166-
i.Regs.getX86asm(src.Index),
166+
i.Regs.GetX86(src.Index),
167167
expression.Imm(uint64(src.Scale)),
168168
)
169169
vs = append(vs, v)

asm/amd/regs_state.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ func (r *Registers) setX86asm(reg x86asm.Reg, v expression.Expression) {
215215
r.regs[e.idx] = v
216216
}
217217

218-
func (r *Registers) getX86asm(reg x86asm.Reg) expression.Expression {
218+
// GetX86 returns the expression.Expression value associated with the given x86asm.Reg, with
219+
// appropriate zero-extension if necessary.
220+
func (r *Registers) GetX86(reg x86asm.Reg) expression.Expression {
219221
e := regMappingFor(reg)
220222
res := r.regs[e.idx]
221223
if e.bits != 64 {
@@ -224,6 +226,7 @@ func (r *Registers) getX86asm(reg x86asm.Reg) expression.Expression {
224226
return res
225227
}
226228

229+
// Get returns the expression.Expression value associated with the given Reg register
227230
func (r *Registers) Get(reg Reg) expression.Expression {
228231
if int(reg) >= len(r.regs) {
229232
return r.regs[0]

asm/expression/expression.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ func cmpOrder(u Expression) int {
6060
return 1
6161
case *op:
6262
return 2
63-
case *ImmediateCapture:
64-
return 3
6563
case *named:
64+
return 3
65+
case *ImmediateCapture:
6666
return 4
6767
case *immediate:
6868
return 5

go.mod

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.23.6
55
require (
66
github.com/aws/aws-sdk-go-v2 v1.36.5
77
github.com/aws/aws-sdk-go-v2/config v1.29.17
8-
github.com/aws/aws-sdk-go-v2/service/s3 v1.83.0
8+
github.com/aws/aws-sdk-go-v2/service/s3 v1.84.0
99
github.com/cespare/xxhash/v2 v2.3.0
1010
github.com/cilium/ebpf v0.19.0
1111
github.com/docker/go-connections v0.5.0
@@ -33,11 +33,11 @@ require (
3333
go.opentelemetry.io/otel v1.37.0
3434
go.opentelemetry.io/otel/metric v1.37.0
3535
golang.org/x/arch v0.19.0
36-
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b
36+
golang.org/x/exp v0.0.0-20250717185816-542afb5b7346
3737
golang.org/x/mod v0.26.0
3838
golang.org/x/sync v0.16.0
3939
golang.org/x/sys v0.34.0
40-
google.golang.org/grpc v1.73.0
40+
google.golang.org/grpc v1.74.1
4141
)
4242

4343
require (
@@ -116,10 +116,10 @@ require (
116116
go.opentelemetry.io/otel/trace v1.37.0 // indirect
117117
go.uber.org/multierr v1.11.0 // indirect
118118
go.uber.org/zap v1.27.0 // indirect
119-
golang.org/x/crypto v0.37.0 // indirect
120-
golang.org/x/net v0.39.0 // indirect
121-
golang.org/x/text v0.24.0 // indirect
122-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect
119+
golang.org/x/crypto v0.38.0 // indirect
120+
golang.org/x/net v0.40.0 // indirect
121+
golang.org/x/text v0.25.0 // indirect
122+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect
123123
google.golang.org/protobuf v1.36.6 // indirect
124124
gopkg.in/yaml.v3 v3.0.1 // indirect
125125
)

0 commit comments

Comments
 (0)