Skip to content
Snippets Groups Projects
  • Andrew Burgess's avatar
    deb65a3c
    gdb: add gdbarch::displaced_step_buffer_length · deb65a3c
    Andrew Burgess authored
    
    The gdbarch::max_insn_length field is used mostly to support displaced
    stepping; it controls the size of the buffers allocated for the
    displaced-step instruction, and is also used when first copying the
    instruction, and later, when fixing up the instruction, in order to
    read in and parse the instruction being stepped.
    
    However, it has started to be used in other places in GDB, for
    example, it's used in the Python disassembler API, and it is used on
    amd64 as part of branch-tracing instruction classification.
    
    The problem is that the value assigned to max_insn_length is not
    always the maximum instruction length, but sometimes is a multiple of
    that length, as required to support displaced stepping, see rs600,
    ARM, and AArch64 for examples of this.
    
    It seems to me that we are overloading the meaning of the
    max_insn_length field, and I think that could potentially lead to
    confusion.
    
    I propose that we add a new gdbarch field,
    gdbarch::displaced_step_buffer_length, this new field will do
    exactly what it says on the tin; represent the required displaced step
    buffer size.  The max_insn_length field can then do exactly what it
    claims to do; represent the maximum length of a single instruction.
    
    As some architectures (e.g. i386, and amd64) only require their
    displaced step buffers to be a single instruction in size, I propose
    that the default for displaced_step_buffer_length will be the
    value of max_insn_length.  Architectures than need more buffer space
    can then override this default as needed.
    
    I've updated all architectures to setup the new field if appropriate,
    and I've audited all calls to gdbarch_max_insn_length and switched to
    gdbarch_displaced_step_buffer_length where appropriate.
    
    There should be no user visible changes after this commit.
    
    Approved-By: default avatarSimon Marchi <simon.marchi@efficios.com>
    deb65a3c
    History
    gdb: add gdbarch::displaced_step_buffer_length
    Andrew Burgess authored
    
    The gdbarch::max_insn_length field is used mostly to support displaced
    stepping; it controls the size of the buffers allocated for the
    displaced-step instruction, and is also used when first copying the
    instruction, and later, when fixing up the instruction, in order to
    read in and parse the instruction being stepped.
    
    However, it has started to be used in other places in GDB, for
    example, it's used in the Python disassembler API, and it is used on
    amd64 as part of branch-tracing instruction classification.
    
    The problem is that the value assigned to max_insn_length is not
    always the maximum instruction length, but sometimes is a multiple of
    that length, as required to support displaced stepping, see rs600,
    ARM, and AArch64 for examples of this.
    
    It seems to me that we are overloading the meaning of the
    max_insn_length field, and I think that could potentially lead to
    confusion.
    
    I propose that we add a new gdbarch field,
    gdbarch::displaced_step_buffer_length, this new field will do
    exactly what it says on the tin; represent the required displaced step
    buffer size.  The max_insn_length field can then do exactly what it
    claims to do; represent the maximum length of a single instruction.
    
    As some architectures (e.g. i386, and amd64) only require their
    displaced step buffers to be a single instruction in size, I propose
    that the default for displaced_step_buffer_length will be the
    value of max_insn_length.  Architectures than need more buffer space
    can then override this default as needed.
    
    I've updated all architectures to setup the new field if appropriate,
    and I've audited all calls to gdbarch_max_insn_length and switched to
    gdbarch_displaced_step_buffer_length where appropriate.
    
    There should be no user visible changes after this commit.
    
    Approved-By: default avatarSimon Marchi <simon.marchi@efficios.com>