Debugging and Testing Tips for ENEE150 Course

testing and debugging n.w
1 / 7
Embed
Share

Get valuable insights into testing, debugging, and using the GDB debugger for the ENEE150 course. Learn how to test your code, compare outputs efficiently with diff, and utilize GDB commands effectively. Enhance your coding skills with practical tips and tricks provided in the course material.

  • Debugging
  • Testing
  • ENEE150
  • GDB
  • Coding

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Testing and Debugging ENEE150 0102 ANDREW GOFFIN

  2. Testing Your Code With projects, we will provide public test vectors These are simple text files that can be redirected through stdin If your output matches the test s output, you ve passed the test! Can redirect input/output with the > and < characters ./a.out < test.in > test.out This uses test.in as input and redirects the output to test.out Goffin ENEE150

  3. Testing Your Code Use diff to see if your output and test output are the same diff test.out correct_test.out > diff.txt Redirects all differences between the outputs into a file called diff.txt If diff.txt is empty, you ve passed! Goffin ENEE150

  4. Debugging Your Code The debugger for C in Unix systems is GDB Command line based Typical GDB commands: next (n) go to next line in current function step (s) go to next line that runs (goes into subroutines) run (r) run the program break <location> - stop program at line/function print (p) <variable> - prints the value of a variable To run GDB on a program, compile the program with the -g flag gcc g <file> Goffin ENEE150

  5. Debugging Your Code Running GDB gdb a.out will start the debugger Goffin ENEE150

  6. Debugging your Code GDB tips and tricks Use the tui flag to see the code as you step through Always set a break point before running, otherwise it ll just run the code as normal Try to pinpoint where an error may be in your code and set the breakpoint at that line/function Goffin ENEE150

  7. Project 1 Questions? Some tips: You re reading the input as (x,y), however the chess array is indexed using the y coordinate (row) first! Use the_board_color[y][x], not the_board_color[x][y] Test modularly Test each function individually the public tests are made for this to be easy Make sure your output matches that of the tests!!! You WILL lose points if the outputs are different Goffin ENEE150

More Related Content