#23 GDB is still not showing variable correct in main()

open
nobody
None
5
2012-08-30
2012-08-30
Soren Petersen
No

Referring to SF 3420924. It seems like this problem still exists. Does any know it the problem should have been solved?

Discussion

  • Peter A. Bigot
    Peter A. Bigot
    2012-08-30

    The bug report says it's been fixed. If the problem still exists for you, provide information about which version of mspgcc (compiler and gdb) you're using, and if possible a test case, preferably through a new ticket in the bug tracker or by re-opening 3420924.

     
  • Soren Petersen
    Soren Petersen
    2012-08-30

    This is the text from 3417263 "The patch for ticket 3417263 works for normal functions, but not for naked functions like main where the frame offset does not include a return address. Fix this for the next major release"
    But did it get fixed?
    And by the way - thank for the good work!

     
  • Peter A. Bigot
    Peter A. Bigot
    2012-08-30

    That's actually the text for 3420924, which was the separate ticket to address the fact that the fix for 3417263 didn't work for main(). 3420924 itself was fixed in March (see the comment in that tracker item marking the commit that fixed it), and back-ported to the then-current LTS release. The test case for it has been in the regression suite since then, so it should be fixed in all current releases (including LTS-20110716 if the current patch set is installed.) Unless I'm confused about something, or my test case was inadequate. Have you noticed a problem, or were you just checking before you updated?

    BTW: You're welcome.

     
  • Soren Petersen
    Soren Petersen
    2012-08-31

    Ok, then it might be something with my tool installation on RHEL5.

    mkdir msp430-build
    #copy all the downloaded files into here
    cd msp430-build

    # extract all the following files into the msp430-build directory
    tar xvfj ../binutils-2.21.1a.tar.bz2
    tar xvfj ../gcc-core-4.6.3.tar.bz2
    tar xvfj ../gdb-7.2a.tar.bz2
    tar xvfj ../mspgcc-20120406.tar.bz2
    tar xvfj ../msp430mcu-20120716.tar.bz2
    tar xvfj ../msp430-libc-20120224.tar.bz2

    # Make sure any additional patch files (from LTS) are located here as well

    # Are there any ??

    # The next line is optional for the debugger and is not officially part of the mspgcc project.
    #tar xvfz mspdebug-0.19.tar.gz
    #not used

    cd gcc-4.6.3
    ./contrib/download_prerequisites
    cd ..

    # patch binutils (using the files provided in the Release Files, and repeat for any additional patches or LTS files)
    cd binutils-2.21.1
    # Patch binutils to bring it to Release 20120406 (still at 20120406)
    patch -p1<../mspgcc-20120406/msp430-binutils-2.21.1a-20120406.patch

    # Return to the build directory
    cd ..

    # patch GCC to bring it up to Release 20120406
    cd gcc-4.6.3
    patch -p1<../mspgcc-20120406/msp430-gcc-4.6.3-20120406.patch

    # Return to the build directory
    cd ..

    # Patch GDB to bring it to release 20120311
    cd gdb-7.2
    patch -p1<../mspgcc-20120406/msp430-gdb-7.2a-20111205.patch

    # Return to the build directory
    cd ..

    #Create a sub-set of Build Directories
    mkdir binutils-2.21.1-msp430
    mkdir gcc-4.6.3-msp430
    mkdir gdb-7.2-msp430

    # Configure Binutils
    cd binutils-2.21.1-msp430
    # We need to build binutils for the msp430
    ../binutils-2.21.1/configure --target=msp430 --prefix="/net/corona/vol/dat2/tools/crosscompilers/msp430/2.0/lnx86/" --program-prefix="msp430-"

    make
    # Do the install as root (e.g., sudo)
    #sudo make install
    make install

    # I have seen issues where the msp430-ranlib doesn't get detected correctly causing build issues later.
    # if that happens uncomment the following:
    # cd /usr/bin
    # sudo ln -s /usr/local/bin/msp430-ranlib

    #Configure GCC
    cd ../gcc-4.6.3-msp430
    ../gcc-4.6.3/configure --target=msp430 --enable-languages=c --prefix="/net/corona/vol/dat2/tools/crosscompilers/msp430/2.0/lnx86/" --program-prefix="msp430-"
    make
    # Do the install as root (e.g., sudo)
    make install

    #Configure GDB
    cd ../gdb-7.2-msp430
    ../gdb-7.2/configure --target=msp430 --prefix="/net/corona/vol/dat2/tools/crosscompilers/msp430/2.0/lnx86/" --program-prefix="msp430-"
    make
    # Do the install as root (e.g., sudo)
    make install

    #Install the mspgcc-mcu files
    cd ../msp430mcu-20120716
    #sudo MSP430MCU_ROOT=`pwd` ./scripts/install.sh /usr/local/
    MSP430MCU_ROOT=`pwd` ./scripts/install.sh /net/corona/vol/dat2/tools/crosscompilers/msp430/2.0/lnx86/

    # Install the mspgcc-libc
    cd ../msp430-libc-20120224

    PATH=$PATH:/net/corona/vol/dat2/tools/crosscompilers/msp430/2.0/lnx86/bin
    ./configure --prefix="/net/corona/vol/dat2/tools/crosscompilers/msp430/2.0/lnx86/"
    cd src
    PREFIX="/net/corona/vol/dat2/tools/crosscompilers/msp430/2.0/lnx86/"
    make
    # Do the install as root (e.g., sudo)
    make PREFIX="/net/corona/vol/dat2/tools/crosscompilers/msp430/2.0/lnx86/" install
    cd ..

    The MCU is msp430f2350. I use Eclipse as IDE and my test code is as below

    int main(void)
    {
    int a, b, c, d, e;

    a=1;
    b=2;
    c=3;
    d=4;
    e=5;
    a=b+c;
    c=d+e;
    d=a+b;

    return 0;
    }

    Stopping execution at line "a=b+c" gives me the following values for the variables.
    a=0;
    b=1;
    c=2;
    d=3;
    e=4;

    Stopping execution at line "return 0" gives me the following values for the variables.
    a=0;
    b=5;
    c=2;
    d=9;
    e=7;

    It seems like variable are ok in functions.

    Does it give any meaning?

     
  • Peter A. Bigot
    Peter A. Bigot
    2012-08-31

    There are patches (https://sourceforge.net/projects/mspgcc/files/Patches/LTS/20120406/) but probably not related to that. Looks like you're mixing various versions, so I don't know what the impact of that will be (msp430mcu-20120716 is not approved for use with mspgcc 20120406: stick with the versions identified in the mspgcc-20120406 distribution). I wouldn't expect that to be the cause of what you see, which does look wrong. I also don't know the effect of having eclipse in the way.

    I won't be able to investigate for a couple weeks, but will try to remember to check this out when I get back to mspgcc. It'd help if you'd open a bug report and provide just your test code and what you see in gdb. If I can duplicate the problem with my builds, I'll see whether it can be fixed; if the problem occurs because of the way you built the toolchain that's not something I can help diagnose.

     
  • Soren Petersen
    Soren Petersen
    2012-09-03

    I see the same on a windows installation using mspgcc-20120406-p20120502.zip. I have investigated the problem a little further. I see the same behaviour using msp430-gdb directly. So I guess it is not a tool setup nor a Eclipse problem. I have created a bug repport on the issue.