Remote debugging Based on QT creator and GDB

Source: Internet
Author: User
Description: My Development Board photo.
Image:

Environment: The Virtual Machine fedora12 and the ARM development environment for building QT creator under fedora12 and porting qt4.6.2 to micro2440

Software preparation:

Follow the instructions in "Building the ARM development environment of QT creator under fedora12 and porting qt4.6.2 to micro2440" to transplant qt4.6.3, and upgrade QT creator to 2.0.1. Everything else remains unchanged.

Download gdb-7.0.tar.gz on the Internet. Google it and forget where it is.

* The establishment of the environment is the same as the article titled building the ARM development environment of QT creator under fedora12 and porting qt4.6.2 to micro2440, for details about the software path, refer to the above article ......

1、decompress the downloaded gdb-7.0.tar.gz to a directory, such as/root/tmp/gdb-7.0

Open the terminal command line, enter the/root/tmp/gdb-7.0 directory, execute the command

#./Configure -- target = arm-Linux -- prefix =/usr/local/GDB-arm
-V

# Make

# Make install

I have not encountered any errors here. After compilation, GDB will be installed to/usr/local/GDB-arm.

2. Compile gdbserver (refer to the README file in the/root/tmp/gdb-7.0/GDB/gdbserver directory)

Go to/root/tmp/gdb-7.0/GDB/gdbserver directory

# Cd/root/tmp/gdb-7.0/GDB/gdbserver

Run the following command:

# Export Path = $ path:/usr/local/GDB-arm

# Export cc =/opt/toolchaos/arm920t-eabi/bin/ARM-Linux-gcc

#./Configure -- target = arm-Linux -- Host = arm-Linux

# Make cc =/opt/toolchains/arm920t-eabi/bin/ARM-Linux-gcc

After compilation, copy the executable gdbserver files in the directory to the/root/tmp/rootfs_qtopia_qt4/bin directory, that is, the root directory of nfs startup. Put it in the bin folder so that we can directly execute the gdbserver command on the terminal.

3. debugging

We have textedit Demos as an example. If you do not know how to use QT creator to compile the program, refer to the above article.

Here I copied the demos textedit to the/root/tmp/rootfs_qtopia_qt4/home/PLG directory.

Use QT creator to open the project (double-click textedit. Pro ).

3.1 configuration project

Click projects (the folder icon button) in the left sidebar on the build settings configuration page.

Set edit build configuration to qt4.6.3-arm debug, and debug mode for the arm environment where the compiling environment is qt4.6.3.

Set build directory to/root/tmp/rootfs_qtopia_qt4/home/PLG/textedit to delete the long string (-Build-desktop) after textedit.

Switch back to edit (click the edit button), build the project, and rebuild the project as needed. If the configuration is correct, the compilation process is smooth. I have not encountered any problems here.

3.2 start debugging

After compilation, start the system through NFS. (Here, my virtual machine IP address is 192.168.1.1, and the development board ip address is 192.168.1.70)

3.2.1 enter the/home/PLG/textedit directory under minicom and execute the command

# Gdbserver 192.168.1.1: 2345 textedit-qws &

Note: The "&" symbol here can prevent the program from occupying the terminal and cannot execute other commands. If the program freezes, we can also use the PS and kill commands to kill it. "192.168.1.1: 2345" is the IP address of the VM and the port number used for remote debugging. This port number should be set to not occupied. Otherwise, an error will occur. "-Qws" means that textedit is started in guiserver mode. If other qt4.6.3 programs are started, this parameter is not required (you can also use the qapplication app (argc, argv, qapplication :: guiserver); set the program to start with guiserver, so you don't need the-qws parameter.) You can give it a try and get it ready. Google will address this issue!

If the program is correctly started, it will be displayed in minicom.

Process textedit created; pid = 750

Listening on port 2345

The meaning is quite understandable.

3.2.2 switch QT creator to debug mode and click debug-> start debugging-> Start and attach to remote application... Command on behalf of Open start debugger window

Click Browse... Click the button to set the debugger to "/usr/local/GDB-arm/bin/ARM-Linux-GDB", that is, the installation path of GDB (ARM-Linux-GDB) We edited earlier;

Click Browse... The Local Executable button is set to "/root/tmp/rootfs_qtopia_qt4/home/PLG/textedit", which is the executable file of the compiled textedit example;

In host and port, type "192.168.1.70: 2345", that is, the IP address and port number of our development board;

Select architecture as "i386 ".

OK! Click the OK button to start debugging (do not forget to set the breakpoint in advance). The configuration should be correct so far ......

Check that there should be some feedback from minicom. My example is "gdbserver: Error initializing thread_db Library: Version mismatch between libthread_db and libpthread", which does not affect debugging and will not be investigated for the time being, if that expert knows, please give guidance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.