Gå til innhold

Debuging av programmer


Anbefalte innlegg

Skrevet

Hei folkens siden det er mange som pressenterer kodesnutter og lurer på hva som er feil i koden o.s.v. La oss lage en tråd som kan hjelpe andre å finne feil i sin egen kode.

 

Nyttig for å feilsøke på sin egen kode kan være å skrive ut variabler og data fra sitt program til skjerm. Dette for å se at de inneholder det som en antar. Er ofte en feil at en antar innholdet på variabler, men det faktisk ikke stemmer.

 

En annen metode som kan brukes er såkalte exceptions der en fanger opp hendelser som egentlig aldri skulle oppstått i utgangspunktet.

 

 

 

 

Håper at andre også bidrar i denne tråden.

Videoannonse
Annonse
Skrevet

http://valgrind.org/

«Valgrind is an award-winning suite of tools for debugging and profiling Linux programs. With the tools that come with Valgrind, you can automatically detect many memory management and threading bugs, avoiding hours of frustrating bug-hunting, making your programs more stable. You can also perform detailed profiling, to speed up and reduce memory use of your programs.

 

The Valgrind distribution currently includes four tools: a memory error detector, a cache (time) profiler, a call-graph profiler, and a heap (space) profiler. It runs on the following platforms: X86/Linux, AMD64/Linux, PPC32/Linux, PPC64/Linux.»

 

http://sourceware.org/gdb/

«GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it crashed.

 

GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:

 

* Start your program, specifying anything that might affect its behavior.

* Make your program stop on specified conditions.

* Examine what has happened, when your program has stopped.

* Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.

 

The program being debugged can be written in Ada, C, C++, Objective-C, Pascal (and many other languages). Those programs might be executing on the same machine as GDB (native) or on another machine (remote). GDB can run on most popular UNIX and Microsoft Windows variants.»

 

Personlig har jeg ikke brukt valgrind veldig mye, men det skal visst være veldig bra.. Funker dog bare til Linux.

 

GDB anbefales på det sterkeste. Det har et meget godt innebygd "hjelpe-system" også, så det er veldig lett å lære seg det enkleste.

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...