This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: baffling assembly-level weirdness


On Mon, Jan 26, 2009 at 7:41 AM, Daniel Jacobowitz <drow@false.org> wrote:
> On Mon, Jan 26, 2009 at 04:24:40PM +0100, Mathieu Lacage wrote:
>> hi,
>>
>> The following gdb session baffles me completely: %edx is reset to zero
>> by the mov at address 0x0804ad62 instead of being set to the constant
>> 0x804ad62. Of course, this code segfaults at $pc = 0x804ad68 when zero
>> is dereferenced...
>>
>> Version: GNU gdb 6.8
>>
>> (gdb) disas $pc $pc+10
>> Dump of assembler code from 0x804ad62 to 0x804ad6c:
>> 0x0804ad62 <indent+50>:       mov    0x805e3c0,%edx
>
> This is a load from memory at address 0x805e3c0, in x86 syntax.

Additional clues:

  (gdb) p/a 0x805e3c0

will likely print "stdout". If you break in main, and do

  (gbd) x/a 0x805e3c0

it will likely print something like:

  0x8053ac0 <stdout>:	0x4dcdb5e0 <_IO_2_1_stdout_>

It sounds like your program is corrupting stdout somewhere.
The fastest way to find out where that happens:

  (gdb) watch *(int **)0x8053ac0


Cheers,
-- 
Paul Pluzhnikov


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]