core

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2019 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const NT_AUXV elf.NType = 0x6

NT_AUXV is the note type for notes containing a copy of the Auxv array

View Source
const NT_FILE elf.NType = 0x46494c45 // "FILE".

NT_FILE is file mapping information, e.g. program text mappings. Desc is a LinuxNTFile.

View Source
const NT_X86_XSTATE elf.NType = 0x202 // Note type for notes containing X86 XSAVE area.

NT_X86_XSTATE is other registers, including AVX and such.

Variables

View Source
var (
	// ErrWriteCore is returned when attempting to write to the core
	// process memory.
	ErrWriteCore = errors.New("can not write to core process")

	// ErrShortRead is returned on a short read.
	ErrShortRead = errors.New("short read")

	// ErrContinueCore is returned when trying to continue execution of a core process.
	ErrContinueCore = errors.New("can not continue execution of core process")

	// ErrChangeRegisterCore is returned when trying to change register values for core files.
	ErrChangeRegisterCore = errors.New("can not change register values of core process")
)
View Source
var ErrUnrecognizedFormat = errors.New("unrecognized core format")

ErrUnrecognizedFormat is returned when the core file is not recognized as any of the supported formats.

Functions

This section is empty.

Types

type ELFNotesHdr

type ELFNotesHdr struct {
	Namesz uint32
	Descsz uint32
	Type   uint32
}

ELFNotesHdr is the ELF Notes header. Same size on 64 and 32-bit machines.

type LinuxCoreTimeval

type LinuxCoreTimeval struct {
	Sec  int64
	Usec int64
}

Copied from golang.org/x/sys/unix.Timeval since it's not available on all systems.

type LinuxNTFile

type LinuxNTFile struct {
	LinuxNTFileHdr
	// contains filtered or unexported fields
}

LinuxNTFile contains information on mapped files.

type LinuxNTFileEntry

type LinuxNTFileEntry struct {
	Start   uint64
	End     uint64
	FileOfs uint64
}

LinuxNTFileEntry is an entry of an NT_FILE note.

type LinuxNTFileHdr

type LinuxNTFileHdr struct {
	Count    uint64
	PageSize uint64
}

LinuxNTFileHdr is a header struct for NTFile.

type LinuxPrPsInfo

type LinuxPrPsInfo struct {
	State uint8
	Sname int8
	Zomb  uint8
	Nice  int8

	Flag                 uint64
	Uid, Gid             uint32
	Pid, Ppid, Pgrp, Sid int32
	Fname                [16]uint8
	Args                 [80]uint8
	// contains filtered or unexported fields
}

LinuxPrPsInfo has various structures from the ELF spec and the Linux kernel. AMD64 specific primarily because of unix.PtraceRegs, but also because some of the fields are word sized. See http://lxr.free-electrons.com/source/include/uapi/linux/elfcore.h

type LinuxPrStatus

type LinuxPrStatus struct {
	Siginfo LinuxSiginfo
	Cursig  uint16

	Sigpend                      uint64
	Sighold                      uint64
	Pid, Ppid, Pgrp, Sid         int32
	Utime, Stime, CUtime, CStime LinuxCoreTimeval
	Reg                          linutil.AMD64PtraceRegs
	Fpvalid                      int32
	// contains filtered or unexported fields
}

LinuxPrStatus is a copy of the prstatus kernel struct.

type LinuxSiginfo

type LinuxSiginfo struct {
	Signo int32
	Code  int32
	Errno int32
}

LinuxSiginfo is a copy of the siginfo kernel struct.

type Note

type Note struct {
	Type elf.NType
	Name string
	Desc interface{} // Decoded Desc from the
}

Note is a note from the PT_NOTE prog. Relevant types: - NT_FILE: File mapping information, e.g. program text mappings. Desc is a LinuxNTFile. - NT_PRPSINFO: Information about a process, including PID and signal. Desc is a LinuxPrPsInfo. - NT_PRSTATUS: Information about a thread, including base registers, state, etc. Desc is a LinuxPrStatus. - NT_FPREGSET (Not implemented): x87 floating point registers. - NT_X86_XSTATE: Other registers, including AVX and such.

type OffsetReaderAt

type OffsetReaderAt struct {
	// contains filtered or unexported fields
}

OffsetReaderAt wraps a ReaderAt into a MemoryReader, subtracting a fixed offset from the address. This is useful to represent a mapping in an address space. For example, if program text is mapped in at 0x400000, an OffsetReaderAt with offset 0x400000 can be wrapped around file.Open(program) to return the results of a read in that part of the address space.

func (*OffsetReaderAt) ReadMemory

func (r *OffsetReaderAt) ReadMemory(buf []byte, addr uintptr) (n int, err error)

ReadMemory will read the memory at addr-offset.

type Process

type Process struct {
	Threads map[int]*Thread
	// contains filtered or unexported fields
}

Process represents a core file.

func OpenCore

func OpenCore(corePath, exePath string, debugInfoDirs []string) (*Process, error)

OpenCore will open the core file and return a Process struct. If the DWARF information cannot be found in the binary, Delve will look for external debug files in the directories passed in.

func (*Process) BinInfo

func (p *Process) BinInfo() *proc.BinaryInfo

BinInfo will return the binary info.

func (*Process) Breakpoints

func (p *Process) Breakpoints() *proc.BreakpointMap

Breakpoints will return all breakpoints for the process.

func (*Process) CheckAndClearManualStopRequest

func (p *Process) CheckAndClearManualStopRequest() bool

CheckAndClearManualStopRequest will always return false and have no effect since there are no manual stop requests as there is no controlling execution of a core file.

func (*Process) Checkpoint

func (p *Process) Checkpoint(string) (int, error)

Checkpoint for core files returns an error, there is no execution of a core file.

func (*Process) Checkpoints

func (p *Process) Checkpoints() ([]proc.Checkpoint, error)

Checkpoints returns nil on core files, you cannot set checkpoints when debugging core files.

func (*Process) ClearBreakpoint

func (p *Process) ClearBreakpoint(addr uint64) (*proc.Breakpoint, error)

ClearBreakpoint will always return an error as you cannot set or clear breakpoints on core files.

func (*Process) ClearCheckpoint

func (p *Process) ClearCheckpoint(int) error

ClearCheckpoint clears a checkpoint, but will only return an error for core files.

func (*Process) ClearInternalBreakpoints

func (p *Process) ClearInternalBreakpoints() error

ClearInternalBreakpoints will always return nil and have no effect since you cannot set breakpoints on core files.

func (*Process) Common added in v1.1.0

func (p *Process) Common() *proc.CommonProcess

Common returns common information across Process implementations.

func (*Process) ContinueOnce

func (p *Process) ContinueOnce() (proc.Thread, error)

ContinueOnce will always return an error because you cannot control execution of a core file.

func (*Process) CurrentThread

func (p *Process) CurrentThread() proc.Thread

CurrentThread returns the current active thread.

func (*Process) Detach

func (p *Process) Detach(bool) error

Detach will always return nil and have no effect as you cannot detach from a core file and have it continue execution or exit.

func (*Process) Direction

func (p *Process) Direction(proc.Direction) error

Direction will only return an error as you cannot continue a core process.

func (*Process) EntryPoint added in v1.2.0

func (p *Process) EntryPoint() (uint64, error)

EntryPoint will return the entry point address for this core file.

func (*Process) FindThread

func (p *Process) FindThread(threadID int) (proc.Thread, bool)

FindThread will return the thread with the corresponding thread ID.

func (*Process) Pid

func (p *Process) Pid() int

Pid returns the process ID of this process.

func (*Process) Recorded

func (p *Process) Recorded() (bool, string)

Recorded returns whether this is a live or recorded process. Always returns true for core files.

func (*Process) RequestManualStop

func (p *Process) RequestManualStop() error

RequestManualStop will return nil and have no effect as you cannot control execution of a core file.

func (*Process) Restart

func (p *Process) Restart(string) error

Restart will only return an error for core files, as they are not executing.

func (*Process) ResumeNotify

func (p *Process) ResumeNotify(chan<- struct{})

ResumeNotify is a no-op on core files as we cannot control execution.

func (*Process) SelectedGoroutine

func (p *Process) SelectedGoroutine() *proc.G

SelectedGoroutine returns the current active and selected goroutine.

func (*Process) SetBreakpoint

func (p *Process) SetBreakpoint(addr uint64, kind proc.BreakpointKind, cond ast.Expr) (*proc.Breakpoint, error)

SetBreakpoint will always return an error for core files as you cannot write memory or control execution.

func (*Process) SetSelectedGoroutine added in v1.2.0

func (p *Process) SetSelectedGoroutine(g *proc.G)

SetSelectedGoroutine will set internally the goroutine that should be the default for any command executed, the goroutine being actively followed.

func (*Process) StepInstruction

func (p *Process) StepInstruction() error

StepInstruction will always return an error as you cannot control execution of a core file.

func (*Process) SwitchGoroutine

func (p *Process) SwitchGoroutine(gid int) error

SwitchGoroutine will change the selected and active goroutine.

func (*Process) SwitchThread

func (p *Process) SwitchThread(tid int) error

SwitchThread will change the selected and active thread.

func (*Process) ThreadList

func (p *Process) ThreadList() []proc.Thread

ThreadList will return a list of all threads currently in the process.

func (*Process) Valid added in v1.1.0

func (p *Process) Valid() (bool, error)

Valid returns whether the process is active. Always returns true for core files as it cannot exit or be otherwise detached from.

func (*Process) When

func (p *Process) When() (string, error)

When does not apply to core files, it is to support the Mozilla 'rr' backend.

type SplicedMemory

type SplicedMemory struct {
	// contains filtered or unexported fields
}

A SplicedMemory represents a memory space formed from multiple regions, each of which may override previously regions. For example, in the following core, the program text was loaded at 0x400000: Start End Page Offset 0x0000000000400000 0x000000000044f000 0x0000000000000000 but then it's partially overwritten with an RW mapping whose data is stored in the core file: Type Offset VirtAddr PhysAddr

FileSiz            MemSiz              Flags  Align

LOAD 0x0000000000004000 0x000000000049a000 0x0000000000000000

0x0000000000002000 0x0000000000002000  RW     1000

This can be represented in a SplicedMemory by adding the original region, then putting the RW mapping on top of it.

func (*SplicedMemory) Add

func (r *SplicedMemory) Add(reader proc.MemoryReader, off, length uintptr)

Add adds a new region to the SplicedMemory, which may override existing regions.

func (*SplicedMemory) ReadMemory

func (r *SplicedMemory) ReadMemory(buf []byte, addr uintptr) (n int, err error)

ReadMemory implements MemoryReader.ReadMemory.

type Thread

type Thread struct {
	// contains filtered or unexported fields
}

Thread represents a thread in the core file being debugged.

func (*Thread) Arch

func (t *Thread) Arch() proc.Arch

Arch returns the architecture the target is built for and executing on.

func (*Thread) BinInfo

func (t *Thread) BinInfo() *proc.BinaryInfo

BinInfo returns information about the binary.

func (*Thread) Blocked

func (t *Thread) Blocked() bool

Blocked will return false always for core files as there is no execution.

func (*Thread) Breakpoint

func (t *Thread) Breakpoint() proc.BreakpointState

Breakpoint returns the current breakpoint this thread is stopped at. For core files this always returns an empty BreakpointState struct, as there are no breakpoints when debugging core files.

func (*Thread) Common added in v1.1.0

func (t *Thread) Common() *proc.CommonThread

Common returns a struct containing common information across thread implementations.

func (*Thread) Location

func (t *Thread) Location() (*proc.Location, error)

Location returns the location of this thread based on the value of the instruction pointer register.

func (*Thread) ReadMemory

func (t *Thread) ReadMemory(data []byte, addr uintptr) (n int, err error)

ReadMemory will return memory from the core file at the specified location and put the read memory into `data`, returning the length read, and returning an error if the length read is shorter than the length of the `data` buffer.

func (*Thread) Registers

func (t *Thread) Registers(floatingPoint bool) (proc.Registers, error)

Registers returns the current value of the registers for this thread.

func (*Thread) RestoreRegisters added in v1.1.0

func (t *Thread) RestoreRegisters(proc.Registers) error

RestoreRegisters will only return an error for core files, you cannot change register values for core files.

func (*Thread) SetCurrentBreakpoint

func (t *Thread) SetCurrentBreakpoint(adjustPC bool) error

SetCurrentBreakpoint will always just return nil for core files, as there are no breakpoints in core files.

func (*Thread) SetDX added in v1.1.0

func (t *Thread) SetDX(uint64) error

SetDX will always return an error, you cannot change register values when debugging core files.

func (*Thread) SetPC added in v1.1.0

func (t *Thread) SetPC(uint64) error

SetPC will always return an error, you cannot change register values when debugging core files.

func (*Thread) SetSP added in v1.1.0

func (t *Thread) SetSP(uint64) error

SetSP will always return an error, you cannot change register values when debugging core files.

func (*Thread) StepInstruction

func (t *Thread) StepInstruction() error

StepInstruction will only return an error for core files, you cannot execute a core file.

func (*Thread) ThreadID

func (t *Thread) ThreadID() int

ThreadID returns the ID for this thread.

func (*Thread) WriteMemory

func (t *Thread) WriteMemory(addr uintptr, data []byte) (int, error)

WriteMemory will only return an error for core files, you cannot write to the memory of a core process.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL