Using GDB to debug C + + cgi__c++

Source: Internet
Author: User

1. Compile

Remove the strip from the compiled file (if Makefile contains) and add the-G option

2. Setting of environment variable

The variable parameters that are entered by CGI are generally set by environment variables. This is the main difference between debugging CGI and debugging common C + + programs. The CGI input parameters, in CGI, are implemented by reading the environment variables.

(1) can be set in the shell with export

Onionxie@c2c_206_45_sles10sp1:~/c2cforcc/clubs/mcs/web/caseproc/cgi> Export workerid=1001

(2) can be set in GDB using Set environment s

(GDB) Set environment VARNAME [=] VALUE

(GDB) Show environment [VARNAME]

Look at the Workerid in the figure below set in the shell, Kfguin is set in GDB

3. Debugging

Debug in a normal gdb way.

In general, use L to view the main function, and then set breakpoints to track debugging. Will not repeat the narrative.

Related Article

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.