1

I am trying to use the gdbinit file from https://github.com/gdbinit/Gdbinit while debugging some old fortran code. Everything works fine with GDB if I don't include the gdbinit file; however, when including the file I get the following error:

Error while running hook_stop:
A syntax error in expression, near `= 1'.

After digging around inside the file and using some comments I believe the issue is with the if statements in the following code:

# ____________________misc____________________
define hook-stop
# Display instructions formats
    if $ARM == 1
        if $ARMOPCODES == 1
            set arm show-opcode-bytes 1
        else
            set arm show-opcode-bytes 1
        end
    else
        if $X86FLAVOR == 0
            set disassembly-flavor intel
        else
            set disassembly-flavor att
        end
    end

    # this makes 'context' be called at every BP/step
    if ($SHOW_CONTEXT > 0)
        printf "%i", $SHOW_CONTEXT
        context
    end
    if ($SHOW_NEST_INSN > 0)
        set $x = $_nest
        while ($x > 0)
            printf "\t"
            set $x = $x - 1
        end
    end
end
document hook-stop
!!! FOR INTERNAL USE ONLY - DO NOT CALL !!!
end

The reason I know that the if statements are the issue is because when I edit to code to be :

# ____________________misc____________________
define hook-stop
# Display instructions formats
#    if $ARM == 1
#        if $ARMOPCODES == 1
#            set arm show-opcode-bytes 1
#        else
#            set arm show-opcode-bytes 1
#        end
#    else
#        if $X86FLAVOR == 0
#            set disassembly-flavor intel
#        else
#            set disassembly-flavor att
#        end
#    end

    # this makes 'context' be called at every BP/step
    if ($SHOW_CONTEXT > 0)
        printf "%i", $SHOW_CONTEXT
        context
    end
    if ($SHOW_NEST_INSN > 0)
        set $x = $_nest
        while ($x > 0)
            printf "\t"
            set $x = $x - 1
        end
    end
end
document hook-stop
!!! FOR INTERNAL USE ONLY - DO NOT CALL !!!
end

The error becomes: Error while running hook_stop A syntax error in expression, near '> 0'.

Does anyone know what is going on? I don't really know how the gdbinit file is read or the proper syntax for it.

For what it is worth I am running gdb 7.7.1 on Mac OSX 10.9.3.

I have also put in a bug report with the gi repository but thought that I might get a quicker answer here.

Thanks for your help!

Andrew

Andrew
  • 693
  • 6
  • 19

1 Answers1

0

This code refers to various convenience variables, like $ARM, but you don't show how, or whether, they are defined. So, that would be the first place I would look.

Tom Tromey
  • 21,507
  • 2
  • 45
  • 63
  • Thanks for the response @Tom. The variables are definitely defined. I confirmed this by a) looking at the code and seeing that they are defined, and b) using `printf "%i", $SHOW_CONTEXT` with the various variables (before the if statements are called) to confirm that they are maintaining their values. Part of the problem may be that this gdbinit file is apparently only for use with assembly code which I didn't realize, though I am not convinced that this is the reason the above problem is occurring. – Andrew Jul 18 '14 at 14:14