1 year ago

#96570

test-img

CS2000

adding breakpoints manually to an assembly code

if I have the following assembly code:

foo:
  mov    $0x1,%rax
  callq  bar
  retq   

bar:
  dec    %r8
  cmp    $0x0,%r8
  je     end
  callq  foo
  mov    $0x5,%rax
  mov    $0x1,%rdi
end:
  retq   

_start:
 mov    $0x3,%r8
 callq  4000d4 <bar>
 

and I want to debug the function foo manually (by adding breakpoint to the start and end of the function using int 3 opcode to the machine code), but what is happening now is that the last time foo is called it does callq bar and doesn't return to the last line of foo thus losing the breakpoint, how can we solve this problem?

debugging

assembly

x86-64

breakpoints

ptrace

0 Answers

Your Answer

Accepted video resources