4
votes

Just curious, but would someone be able to explain to me this info frame output. Here's a toy program:

#include <stdio.h>

int foo(int argc) {
    printf("Hello world! %d\n", argc);
}

int main(int argc, char *argv[]) {
    foo(argc);
    return 0;
}

and here's the gdb info frame output when breaking at foo:

(gdb) info frame
Stack level 0, frame at 0x28abf0:
 eip = 0x401196 in foo (a.c:4); saved eip 0x4011c4
 called by frame at 0x28ac10
 source language c.
 Arglist at 0x28abe8, args: argc=1
 Locals at 0x28abe8, Previous frame's sp is 0x28abf0
 Saved registers:
  ebp at 0x28abe8, eip at 0x28abec
(gdb) p &argc
$1 = (int *) 0x28abf0
(gdb)

Why are locals and arglist at the same location? As far as I understand, Locals at should denote the current ebp value as the upper-bound address for the locals of the current frame (which it does). But why does arglist point to the same location? Based on printing &argc, the value for Arglist at definitely doesn't seem to point to the arguments.

As an aside, I do understand the x86 calling convention and the structure of the stack frames. It just seemed odd to me that all the online info frames I could find had identical Arglist at and Locals at values, but only this one lonely post about this inconsistency:

http://forums.devshed.com/programming-42/gdb-info-frames-arglist-locals-address-782598.html

At any rate, wondering to some degree whether there's a known reason for this, and/or how one actually goes about posting a gdb bug. Thanks!

1
wow only one upvote. i ran into the same issue :/PleaseHelp

1 Answers

2
votes

This output is just a relic from pre-DWARF days. It ought to just be removed, at least in some cases. See the remarkably pithy gdb bug: https://sourceware.org/bugzilla/show_bug.cgi?id=13260