Skip to content
  • Changbin Du's avatar
    3bc2609d
    gdbstub: Fix single-step issue by confirming 'vContSupported+' feature to gdb · 3bc2609d
    Changbin Du authored
    
    
    Recently when debugging an arm32 system on qemu, I found sometimes the
    single-step command (stepi) is not working. This can be reproduced by
    below steps:
     1) start qemu-system-arm -s -S .. and wait for gdb connection.
     2) start gdb and connect to qemu. In my case, gdb gets a wrong value
        (0x60) for PC, which is an another bug.
     3) After connected, type 'stepi' and expect it will stop at next ins.
    
    But, it has never stopped. This because:
     1) We doesn't report ‘vContSupported’ feature to gdb explicitly and gdb
        think we do not support it. In this case, gdb use a software breakpoint
        to emulate single-step.
     2) Since gdb gets a wrong initial value of PC, then gdb inserts a
        breakpoint to wrong place (PC+4).
    
    Not only for the arm target, Philippe has also encountered this on MIPS.
    Probably gdb has different assumption for different architectures.
    
    Since we do support ‘vContSupported’ query command, so let's tell gdb that
    we support it.
    
    Before this change, gdb send below 'Z0' packet to implement single-step:
    gdb_handle_packet: Z0,4,4
    
    After this change, gdb send "vCont;s.." which is expected:
    gdb_handle_packet: vCont?
    put_packet: vCont;c;C;s;S
    gdb_handle_packet: vCont;s:p1.1;c:p1.-1
    
    Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
    Tested-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
    Message-Id: <20200221002559.6768-1-changbin.du@gmail.com>
    [AJB: fix for static gdbstub]
    Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
    Reviewed-by: default avatarLuc Michel <luc.michel@greensocs.com>
    Message-Id: <20200316172155.971-29-alex.bennee@linaro.org>
    3bc2609d
    gdbstub: Fix single-step issue by confirming 'vContSupported+' feature to gdb
    Changbin Du authored
    
    
    Recently when debugging an arm32 system on qemu, I found sometimes the
    single-step command (stepi) is not working. This can be reproduced by
    below steps:
     1) start qemu-system-arm -s -S .. and wait for gdb connection.
     2) start gdb and connect to qemu. In my case, gdb gets a wrong value
        (0x60) for PC, which is an another bug.
     3) After connected, type 'stepi' and expect it will stop at next ins.
    
    But, it has never stopped. This because:
     1) We doesn't report ‘vContSupported’ feature to gdb explicitly and gdb
        think we do not support it. In this case, gdb use a software breakpoint
        to emulate single-step.
     2) Since gdb gets a wrong initial value of PC, then gdb inserts a
        breakpoint to wrong place (PC+4).
    
    Not only for the arm target, Philippe has also encountered this on MIPS.
    Probably gdb has different assumption for different architectures.
    
    Since we do support ‘vContSupported’ query command, so let's tell gdb that
    we support it.
    
    Before this change, gdb send below 'Z0' packet to implement single-step:
    gdb_handle_packet: Z0,4,4
    
    After this change, gdb send "vCont;s.." which is expected:
    gdb_handle_packet: vCont?
    put_packet: vCont;c;C;s;S
    gdb_handle_packet: vCont;s:p1.1;c:p1.-1
    
    Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
    Tested-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
    Message-Id: <20200221002559.6768-1-changbin.du@gmail.com>
    [AJB: fix for static gdbstub]
    Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
    Reviewed-by: default avatarLuc Michel <luc.michel@greensocs.com>
    Message-Id: <20200316172155.971-29-alex.bennee@linaro.org>
Loading