mirror of
https://github.com/go-delve/delve.git
synced 2025-10-28 20:53:42 +08:00
proc/*: only load floating point registers when needed (#1981)
Changes implementations of proc.Registers interface and the op.DwarfRegisters struct so that floating point registers can be loaded only when they are needed. Removes the floatingPoint parameter from proc.Thread.Registers. This accomplishes three things: 1. it simplifies the proc.Thread.Registers interface 2. it makes it impossible to accidentally create a broken set of saved registers or of op.DwarfRegisters by accidentally calling Registers(false) 3. it improves general performance of Delve by avoiding to load floating point registers as much as possible Floating point registers are loaded under two circumstances: 1. When the Slice method is called with floatingPoint == true 2. When the Copy method is called Benchmark before: BenchmarkConditionalBreakpoints-4 1 4327350142 ns/op Benchmark after: BenchmarkConditionalBreakpoints-4 1 3852642917 ns/op Updates #1549
This commit is contained in:
committed by
GitHub
parent
f96663a243
commit
200994bc8f
@ -187,7 +187,9 @@ func withCoreFile(t *testing.T, name, args string) *proc.Target {
|
||||
|
||||
func logRegisters(t *testing.T, regs proc.Registers, arch *proc.Arch) {
|
||||
dregs := arch.RegistersToDwarfRegisters(0, regs)
|
||||
for i, reg := range dregs.Regs {
|
||||
dregs.Reg(^uint64(0))
|
||||
for i := 0; i < dregs.CurrentSize(); i++ {
|
||||
reg := dregs.Reg(uint64(i))
|
||||
if reg == nil {
|
||||
continue
|
||||
}
|
||||
@ -250,7 +252,7 @@ func TestCore(t *testing.T) {
|
||||
t.Errorf("main.msg = %q, want %q", msg.Value, "BOOM!")
|
||||
}
|
||||
|
||||
regs, err := p.CurrentThread().Registers(true)
|
||||
regs, err := p.CurrentThread().Registers()
|
||||
if err != nil {
|
||||
t.Fatalf("Couldn't get current thread registers: %v", err)
|
||||
}
|
||||
@ -286,7 +288,7 @@ func TestCoreFpRegisters(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
if frames[i].Current.Fn.Name == "main.main" {
|
||||
regs, err = thread.Registers(true)
|
||||
regs, err = thread.Registers()
|
||||
if err != nil {
|
||||
t.Fatalf("Could not get registers for thread %x, %v", thread.ThreadID(), err)
|
||||
}
|
||||
@ -326,7 +328,9 @@ func TestCoreFpRegisters(t *testing.T) {
|
||||
|
||||
for _, regtest := range regtests {
|
||||
found := false
|
||||
for i, reg := range dregs.Regs {
|
||||
dregs.Reg(^uint64(0))
|
||||
for i := 0; i < dregs.CurrentSize(); i++ {
|
||||
reg := dregs.Reg(uint64(i))
|
||||
regname, _, regval := arch.DwarfRegisterToString(i, reg)
|
||||
if reg != nil && regname == regtest.name {
|
||||
found = true
|
||||
|
||||
Reference in New Issue
Block a user