mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 09:46:56 +08:00
proc: only format registers value when it's necessary (#1860)
A significant amount of time is spent generating the string representation for the proc.Registers object of each thread, since this field is rarely used (only when the Registers API is called) it should be generated on demand. Also by changing the internal representation of proc.Register to be closer to that of op.DwarfRegister it will help us implement #1838 (when Delve will need to be able to display the registers of an internal frame, which we currently represent using op.DwarfRegister objects). Benchmark before: BenchmarkConditionalBreakpoints-4 1 22292554301 ns/op Benchmark after: BenchmarkConditionalBreakpoints-4 1 17326345671 ns/op Reduces conditional breakpoint latency from 2.2ms to 1.7ms. Updates #1549, #1838
This commit is contained in:
committed by
GitHub
parent
abb57ff017
commit
b9d0ddd82c
@ -244,8 +244,9 @@ func TestCore(t *testing.T) {
|
||||
t.Fatalf("Couldn't get current thread registers: %v", err)
|
||||
}
|
||||
regslice := regs.Slice(true)
|
||||
arch := p.BinInfo().Arch
|
||||
for _, reg := range regslice {
|
||||
t.Logf("%s = %s", reg.Name, reg.Value)
|
||||
t.Logf("%s = %s", reg.Name, arch.DwarfRegisterToString(reg.Name, reg.Reg))
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,8 +313,9 @@ func TestCoreFpRegisters(t *testing.T) {
|
||||
{"XMM8", "0x4059999a404ccccd4059999a404ccccd"},
|
||||
}
|
||||
|
||||
arch := p.BinInfo().Arch
|
||||
for _, reg := range regs.Slice(true) {
|
||||
t.Logf("%s = %s", reg.Name, reg.Value)
|
||||
t.Logf("%s = %s", reg.Name, arch.DwarfRegisterToString(reg.Name, reg.Reg))
|
||||
}
|
||||
|
||||
for _, regtest := range regtests {
|
||||
@ -321,8 +323,9 @@ func TestCoreFpRegisters(t *testing.T) {
|
||||
for _, reg := range regs.Slice(true) {
|
||||
if reg.Name == regtest.name {
|
||||
found = true
|
||||
if !strings.HasPrefix(reg.Value, regtest.value) {
|
||||
t.Fatalf("register %s expected %q got %q", reg.Name, regtest.value, reg.Value)
|
||||
regval := arch.DwarfRegisterToString(reg.Name, reg.Reg)
|
||||
if !strings.HasPrefix(regval, regtest.value) {
|
||||
t.Fatalf("register %s expected %q got %q", reg.Name, regtest.value, regval)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user