class: title # Debugging Practice ## CSC 213 – September 5, 2025 --- # Agenda for Today 1. Department Events 2. Upcoming Work 3. C Practice 4. Debugging 5. Wrap Up --- # Department Events ## Conversation in the Humanities: A Humanistic Approach to Generative AI .indent[ Friday, September 5th at 4:30pm in HSSC S1325 ] ## CS Table: Developer Experience with AI Coding Assistants .indent[ Tuesday, September 9th at noon in JRC 224C ] *To receive 0.25% extra credit, send an email to let me know you attended no more than 48 hours after the event.* --- class: section, blue # Upcoming Work --- # Assignment 1: Ngram Generator **Due:** Monday, September 8th by 11:59pm ## Questions **Getting the starter code produces a `git` error. What should I do?** The `git` error will print a command you should run first, then you can retry. Or run this command first and `git` should stop complaining: ``` git config --global --add safe.directory /home/curtsinger/csc213 ``` --- class: section, green # C Practice --- # C Practice: The Problem We are going to write a C program called `charsort` together as a class (I will drive). The program should do the following: 1. The program must accept exactly one string as a command line argument. 2. The output should be all of the letters in the input string, but printed in sorted order. For example: ```shell $ ./charsort hello ehllo ``` Take a minute to consider how you might approach this problem and what you might need to look up to implement your approach. --- class: section, gray # C Practice: Live Coding --- # C Practice: Style Guide Good C code should do the following: .left-col[ - Indent every block of code - Always use curly braces around blocks - Write explanatory comments, with at least one by each block of code - Cite resources in comments next to the relevant code - Use descriptive variable names - Use whitespace to break code into logical chunks - Validate user input - Print helpful error messages ] .right-col[ - Use standard library functions instead of re-implementing them. - Try to follow modern C conventions - Check return values from library functions - Fix code that generates compiler warnings - Use resources, and cite them appropriately - Use local memory whenever possible (instead of calling `malloc`) - Free allocated memory when you are done with it ] -- **Is this list missing anything?** --- class: section, blue # Debugging --- # Discussion: Debugger Commands For each `gdb` command below: what does it do, and when would you use it? - `start` - `continue` - `break` - `watch` - `step` - `next` *Start by thinking of answers on your own. I will let you know when to start discussion.* --- class: section, green # Debugging Exercise --- class: section, blue # Wrap Up --- # Reminders ## Assignment The Ngram Generator assignment is due on Monday evening. Start early so you have time to get stuck. ## Reading - **The Abstraction: The Processes** (OSTEP, Chapter 4) - **Interlude: Process API** (OSTEP, Chapter 5) - **Mechanism: Limited Direct Execution** (OSTEP, Chapter 6)