Difference: Lecture4:DevelopmentTools (2 vs. 3)

Revision 32017-09-11 - uli

Line: 1 to 1
 
META TOPICPARENT name="LectureSlides"

Start Presentation

Slide 1: Development Tools: Editor, Compiler, Linker, Debugger, Make

Line: 7 to 7
 

The development cycle

Changed:
<
<
The first and most important part in the development cycle is that you think!
>
>
The first and most important part in the development cycle is that you think!
  Of course a hello world program you can start implementing immediately.
Line: 40 to 40
 
  • eclipse: originally developed for Java but has “perspectives” for other languages like C, C++
  • qtcreator: an IDE tailored to development of window based Qt programs. Mainly C++
  • netbeans: tailored to Java but can also do C/C++
Changed:
<
<
+++--
>
>

 

Linking several object files

We have seen that functions can be implemented in dedicated files.

Line: 93 to 94
  You want to know how to really use emacs to its full potential?
Changed:
<
<
Get the manual (some 400 pages!)
>
>
Get the manual (some 635 pages!)
 

gcc

Line: 195 to 196
 

A simpler Makefile

Changed:
<
<
Make has predefined rules and it knows that a .c file
>
>
Make has predefined rules and it knows hot to produce
 
Changed:
<
<
must be compiled into a .o file
>
>
a .o file from a .c file
  We can therefore restrict out Makefile to this:
Line: 215 to 216
 
  • $@ is the file to be made
  • $? are the dependent files that have changed
  • $^ are all dependent files
Changed:
<
<
--++
>
>

 

more Makefile examples

%.o: %.c:

Line: 268 to 269
  How do we spot these errors?
Added:
>
>

Printing debug information

Very often programmers put print statements purely for the sake of debugging.

This is annoying when running the final program

where this information should not be needed any more.

One easy way out of the dilemma is given by the C preprocessor:

#define DEBUG 1

#ifdef DEBUG

p rintf(“printing some variable contents %d\n”,variable);

#endif

Commenting out the #define statement will get rid of all debugging prints.

The debugger gdb

Sometimes printing debug information is not enough

and we have to use a debugger.

gdb the GNU debugger is still the standard tool

Compile your program with the -g option to retain the symbol table

Then run the program within the debugger

gdb yourProgram

Using gdb

  • break: set a breakpoint to stop running when arriving at this point
  • run: start the program
  • continue: continue running after a breakpoint
  • next: execute the program line next line
  • step: step into the function if the next line is a function call
  • list: print the source code at the current position in the program
  • bt: backtrace, show the program stack
  • print: print a variable
For more information read the manual.

This is rather short (a bit more than 800 pages)

 %SLIDESHOWEND%

-- Uli Raich - 2017-09-08

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback