usage of disassemble_info variables
Doug Evans
dje@transmeta.com
Thu Dec 6 14:13:00 GMT 2001
Ian Lance Taylor writes:
> Doug Evans <dje@transmeta.com> writes:
>
> > There seems to be an unwritten rule that a disassemble_info
> > variable can't be a (non-static) local variable.
> > Either that or INIT_DISASSEMBLE_mumble must initialize disassembler_options
> > or each caller to print_insn_i386* is responsible for setting it.
> >
> > We have various entry points into the x86 disassembler
> > and I'm seeing a segv'ing because disassembler_options has garbage.
> >
> > objdump initializes it.
> > gdb doesn't but gets away with it because tm_print_insn_info is a global.
> >
> > What's up?
>
> I think that INIT_DISASSEMBLE_* should always be called on an instance
> of disassembler_options before it is used. From dis-asm.h:
>
> /* Macro to initialize a disassemble_info struct. This should be called
> by all applications creating such a struct. */
>
> I think this applies whether the disassembler_options is global,
> static, or local. If gdb doesn't initialize it, it should.
Heh.
Look at it this way.
Working code stopped working when i386-dis.c started refering
to disassemble_info.disassembler_options.
Is the bug that INIT_DISASSEMBLE_mumble wasn't changed to initialize
disassembler_options when disassembler_options was added
to disassemble_info?
Or must all callers of print_insn_i386* now start initializing
disassembler_options first (hint: they _already_ call INIT_DISASSEMBLE_INFO).
And for bonus points, will all such callers go through this again and again
and again each time similar things are added to dissemble_info?
["Boo! The fans cry foul as he pulls out the sledgehammer."]
More information about the Binutils
mailing list