Code Monkey home page Code Monkey logo

Comments (8)

aarzilli avatar aarzilli commented on September 25, 2024

You can use step-instruction (si) three times. As for making delve do this, it looks complicated.

from delve.

AlphaLxy avatar AlphaLxy commented on September 25, 2024

I use plugin for GoLand, and do not have step-instruction (si) command.
image

from delve.

aarzilli avatar aarzilli commented on September 25, 2024

The GoLand UI is not something we develop.

from delve.

AlphaLxy avatar AlphaLxy commented on September 25, 2024

I tried this, add three StepInstruction after Step when next three instructions is ADRP ADD JMP. It seems ok.

pkg/proc/target_exec.go

	err = grp.Continue()
	if err != nil {
		return err
	}
	if grp.Selected.Process.BinInfo().Arch.Name == "arm64" {
		selg := grp.Selected.SelectedGoroutine()
		curthread := grp.Selected.CurrentThread()
		topframe, _, _ := topframe(grp.Selected, selg, curthread)
		if topframe.Current.Fn != nil {
			return nil
		}
		registers, _ := grp.Selected.currentThread.Registers()
		pc := registers.PC()
		mem := make([]byte, 12)
		n, _ := grp.Selected.Process.Memory().ReadMemory(mem, pc)
		if n == 12 {
			i0 := binary.LittleEndian.Uint32(mem[0:])
			i1 := binary.LittleEndian.Uint32(mem[4:])
			i2 := binary.LittleEndian.Uint32(mem[8:])
			i0ADRP := (i0 & 0b1_00_11111_0000000000000000000_00000) == 0b1_00_10000_0000000000000000000_00000
			i1ADD := (i1 & 0b1001000100_000000000000_00000_00000) == 0b1001000100_000000000000_00000_00000
			i2JMP := (i2 & 0b1101011000011111000000_0000011111) == 0b1101011000011111000000_00000_00000
			if i0ADRP && i1ADD && i2JMP {
				err = grp.StepInstruction()
				if err != nil {
					return err
				}
				err = grp.StepInstruction()
				if err != nil {
					return err
				}
				return grp.StepInstruction()
			}
		}
	}
	return err

from delve.

aarzilli avatar aarzilli commented on September 25, 2024

This is the wrong approach, it will break if a breakpoint is encountered during step, or a manual stop, or the process exit, or if the three instructions happen to be ADRP+ADD+JMP but they aren't a trampoline for a CALL instruction.

from delve.

AlphaLxy avatar AlphaLxy commented on September 25, 2024

I check if topframe.Current.Fn == nil.

Or I can add that code after s command failed.

if err = next(grp.Selected, true, false); err != nil {
	selg := grp.Selected.SelectedGoroutine()
	curthread := grp.Selected.CurrentThread()
	topframe, _, _ := topframe(grp.Selected, selg, curthread)
	if topframe.Current.Fn == nil && grp.Selected.Process.BinInfo().Arch.Name == "arm64" {
		// ...
		return err
	}
	_ = grp.Selected.ClearSteppingBreakpoints()
	return err
}

from delve.

AlphaLxy avatar AlphaLxy commented on September 25, 2024

Make second s command ok.

(dlv) s
Stopped at: 0x11c0e72b0
=>   1:	no source available
(dlv) s // !!! this !!!
Stopped at: 0x11c0e72b0
=>   1:	no source available
Command failed: no source for PC 0x11c0e72b0

from delve.

AlphaLxy avatar AlphaLxy commented on September 25, 2024

This is the wrong approach, it will break if a breakpoint is encountered during step, or a manual stop, or the process exit, or if the three instructions happen to be ADRP+ADD+JMP but they aren't a trampoline for a CALL instruction.

I see, is there any other way?

from delve.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.