2015年6月24日 星期三

[GDB] How to use gdbserver

  1. Upload gdbserver to Embedded Board
  2. Create a c file
  3. #include <stdio.h>
    //This function will cause "Segmentation fault"
    void memory_violation()
    {
        char* ptr = 0;
        for(int i=0; i<10; ++i)
        {
            ptr[i] = i;
        }
    }
    
    int main(int argc, char* argv[])
    {
        memory_violation();
        return 0;
    }


    compile it.
    -ggdb create symbol.
    armeb-unknown-linux-uclibcgnueabi-gcc -ggdb -std=gnu99 -o hello hello.c


  4. Upload program && Execute the gdbserver

  5. ./gdbserver “embedded ip”:”embedded port” “program”
    ./gdbserver 111.6.1.191:12345 ./hello


  6. On the Local Machine

  7. ./armeb-linux-gdb ./hello
    When see (gdb), the type
    target extended-remote 111.6.1.191:12345
    Type run will see result appear on Embedded board
PS. Still can use ddd, but no working.
ddd –debugger /tmp/happy1/bin/armeb-linux-gdb /tmp/test2/hello –eval-command=”target extended-remote 111.6.1.191:12345”
Reference:

0 意見:

張貼留言