Skip to content

gdb: micro patch for gdb stepping #6834

Closed
@glycerine

Description

@glycerine
Seen on linux/amd64 with golang 1.2rc3, suspected still there with 1.2rc5

Opening a new ticket, related to 6776 [
https://golang.org/issue/6776 ], in case you wish to both consider
long-term issues in 6776, and take care of the immediate gdb-debugging issue now with a
trivial fix, using this ticket.

Proposed: change go1.2rc3/go/src/pkg/runtime/sys_x86.c:36 from
    if(pc[0] == 0xeb) { // jmp 1-byte offset
to
    if(pc[0] == 0xeb || pc[0] == 0xcc) { // jmp 1-byte offset     

As in the comments on 6776, the check for a debugger interrupt 0xcc allows gdb debugging
to continue stepping (or just continue) and not invoke the panic that follows in
sys_x86.c because gdb has set a breakpoint 0xcc.

It's not necessary to fix the gdb debugging experience as soon as possible. But it's so
valuable that I thought it worth considering for inclusion.

I would appreciate any thoughts on correctness. Note however that there are only two
possible acceptable values at pc[0] now (0xeb or 0xe9) in runtime*rewindmorestack() at
the moment, so it is easy to construct a proof that the above patch cannot regress any
existing code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions