From c3be37d4b418280e644ca5299fb5ab34b4c60eaa Mon Sep 17 00:00:00 2001 From: Christian Banse Date: Thu, 31 Dec 2020 17:57:08 +0100 Subject: [PATCH] Trying to fix test failures --- pkg/proc/gdbserial/gdbserver.go | 34 ++++++++++++---------------- pkg/proc/gdbserial/gdbserver_conn.go | 4 ++-- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/pkg/proc/gdbserial/gdbserver.go b/pkg/proc/gdbserial/gdbserver.go index b73d051ec4..1edc1b3e61 100644 --- a/pkg/proc/gdbserial/gdbserver.go +++ b/pkg/proc/gdbserial/gdbserver.go @@ -567,7 +567,7 @@ func LLDBAttach(pid int, path string, debugInfoDirs []string) (*proc.Target, err // debugging PIEs. func (p *gdbProcess) EntryPoint() (uint64, error) { var entryPoint uint64 - if runtime.GOOS == "darwin" { + if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" { // There is no auxv on darwin, however, we can get the location of the mach-o // header from the debugserver by going through the loaded libraries, which includes // the exe itself @@ -581,13 +581,11 @@ func (p *gdbProcess) EntryPoint() (uint64, error) { break } } - } else { - if auxv, err := p.conn.readAuxv(); err == nil { - // If we can't read the auxiliary vector it just means it's not supported - // by the OS or by the stub. If we are debugging a PIE and the entry point - // is needed proc.LoadBinaryInfo will complain about it. - entryPoint = linutil.EntryPointFromAuxv(auxv, p.BinInfo().Arch.PtrSize()) - } + } else if auxv, err := p.conn.readAuxv(); err == nil { + // If we can't read the auxiliary vector it just means it's not supported + // by the OS or by the stub. If we are debugging a PIE and the entry point + // is needed proc.LoadBinaryInfo will complain about it. + entryPoint = linutil.EntryPointFromAuxv(auxv, p.BinInfo().Arch.PtrSize()) } return entryPoint, nil @@ -1623,7 +1621,7 @@ func (t *gdbThread) reloadGAtPC() error { err = t.p.conn.step(t.strID, nil, true) if err != nil { - if err == threadBlockedError { + if err == errThreadBlocked { t.regs.tls = 0 t.regs.gaddr = 0 t.regs.hasgaddr = true @@ -1676,7 +1674,7 @@ func (t *gdbThread) reloadGAlloc() error { err = t.p.conn.step(t.strID, nil, true) if err != nil { - if err == threadBlockedError { + if err == errThreadBlocked { t.regs.tls = 0 t.regs.gaddr = 0 t.regs.hasgaddr = true @@ -1785,13 +1783,14 @@ func (regs *gdbRegisters) byName(name string) uint64 { } func (regs *gdbRegisters) Get(n int) (uint64, error) { + const ( + mask8 = 0x000f + mask16 = 0x00ff + mask32 = 0xffff + ) + if runtime.GOARCH == "arm64" { reg := arm64asm.Reg(n) - const ( - mask8 = 0x000f - mask16 = 0x00ff - mask32 = 0xffff - ) switch reg { // 64-bit @@ -2001,11 +2000,6 @@ func (regs *gdbRegisters) Get(n int) (uint64, error) { } } else { reg := x86asm.Reg(n) - const ( - mask8 = 0x000f - mask16 = 0x00ff - mask32 = 0xffff - ) switch reg { // 8-bit diff --git a/pkg/proc/gdbserial/gdbserver_conn.go b/pkg/proc/gdbserial/gdbserver_conn.go index 6132be707d..7d7128d2e5 100644 --- a/pkg/proc/gdbserial/gdbserver_conn.go +++ b/pkg/proc/gdbserial/gdbserver_conn.go @@ -624,7 +624,7 @@ func (conn *gdbConn) step(threadID string, tu *threadUpdater, ignoreFaultSignal } } -var threadBlockedError = errors.New("thread blocked") +var errThreadBlocked = errors.New("thread blocked") func (conn *gdbConn) waitForvContStop(context string, threadID string, tu *threadUpdater) (string, uint8, error) { count := 0 @@ -647,7 +647,7 @@ func (conn *gdbConn) waitForvContStop(context string, threadID string, tu *threa } count++ } else if failed { - return "", 0, threadBlockedError + return "", 0, errThreadBlocked } else if err != nil { return "", 0, err } else {