1/99
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
What is the primary goal of debugging?
To identify and fix errors in a program.
What should you do when your program crashes?
Use a debugger to get a stack trace and follow the control flow to find the error.
Why is it important to write smaller functions?
Smaller functions have fewer things to go wrong and are easier to test and understand.
What does the command 'gcc -Wall -Werror' do?
It enables all warnings and treats them as errors during compilation.
What is a breakpoint in debugging?
A breakpoint allows you to pause the program execution at a specific line to inspect the state.
What is a watchpoint?
A watchpoint pauses execution whenever a specified variable is about to be read or written.
What is the purpose of assertions in programming?
Assertions are used to test conditions that should never be false during execution.
What is the compilation toolchain?
The sequence of programs used to convert source code into an executable file.
What does the preprocessor do in C/C++?
It processes lines starting with '#' for directives like #include before compilation.
What is the role of the linker in the compilation process?
The linker combines object files into a single executable file.
What is the significance of the #include directive?
It copies the entire contents of a specified file into the program at the point of inclusion.
What should you do to test your functions effectively?
Write tests for normal conditions, weird inputs, and error conditions.
What is the benefit of using an Integrated Development Environment (IDE)?
IDEs can compile code continuously, find errors, and provide suggestions to prevent mistakes.
How can logging frameworks assist in debugging?
They allow you to log messages with different severity levels to track program execution.
What is a common mistake when debugging?
Assuming the line where a crash occurs is the actual source of the error.
What should you check when determining the cause of a bug?
Check your assumptions about what should happen at various points in your code.
What is the purpose of writing tests for your functions?
To ensure that they behave correctly under various conditions.
What is a common approach to finding bugs faster?
Use breakpoints and watchpoints to narrow down the location of the error.
What does the command 'gcc -g' do?
It enables debugging information in the compiled program.
What is the importance of checking control flow in debugging?
It helps identify where the program deviates from expected behavior.
What is a common debugging technique when a program behaves unexpectedly?
Working backwards from the point of failure to find the root cause.
What is the benefit of using multiple programming languages in a project?
You can leverage the strengths of each language for different parts of the program.
What is the difference between a breakpoint and a watchpoint?
A breakpoint pauses execution at a specific line, while a watchpoint pauses when a variable is accessed.
What does 'your brain is squishy' imply in the context of debugging?
It suggests that humans can only handle a limited amount of information at once, making debugging challenging.
What is a common pitfall when using assertions?
Using them to check parameters on public methods instead of internal conditions.
What is the purpose of enabling debugging info during development?
To provide detailed information about the program's execution for easier debugging.
What does the .h file extension represent?
.h stands for 'header' files.
What is the purpose of #include
It includes a standard library header.
What does #include "filename.h" do?
It includes a user-defined or third-party header.
What is the function of the #define directive?
It allows you to create constants or macros for text replacement.
What happens when you use #define NUM_ITEMS 1000?
The preprocessor replaces NUM_ITEMS with 1000 throughout the code.
What is conditional compilation?
It allows code to be compiled based on certain conditions using directives like #ifdef and #ifndef.
What is a preprocessor macro?
A macro that performs text replacement, resembling a function but not actually being one.
What is a translation unit in C?
A translation unit is a single source file that is compiled into an object file.
What is the role of header files in C programming?
Header files define the public interface for source files, allowing them to share function prototypes and structures.
What does #pragma once do?
It prevents a header file from being included multiple times, avoiding duplicate definition errors.
What should not be included in a header file?
Private function prototypes, variables, and any implementation details should not be included.
What is an object file?
An object file is the output of compiling a source file, containing machine code and data segments.
What are the three kinds of data segments in an object file?
.data for initialized globals, .bss for uninitialized globals, and .rodata for read-only data.
What is the symbol table in an object file?
A list of all symbols (names) in the file, indicating their type and segment.
What is the purpose of linking in C programming?
Linking combines multiple object files into a single executable, resolving dependencies between them.
What is a static function in C?
A static function is not visible outside its compilation unit, similar to private in Java.
What does the extern keyword do?
It declares a global variable that can be shared across multiple files.
What is dynamic linking?
Dynamic linking allows a program to link to libraries at runtime rather than at compile time.
What is the difference between an object file and an executable?
An executable contains all necessary components to run, while an object file is incomplete and requires linking.
What can cause linker errors?
Linker errors can occur from multiple definitions of a symbol or missing symbols that are not exported.
What does the command gcc -c do?
It compiles source files into object files without linking.
What is the purpose of the .text segment in an object file?
The .text segment contains the executable machine code.
What is the .bss segment used for?
The .bss segment is for global variables that are initialized to zero.
What does the .rodata segment contain?
The .rodata segment contains read-only data, such as string literals.
What is the function of the linker?
The linker combines object files and resolves references to create an executable program.
What is a library in C programming?
A library is a collection of object files that can be linked to provide additional functionality.
What is the significance of the symbol table during linking?
The symbol table helps the linker resolve function and variable references between object files.
What is the role of the linker in C programming?
The linker matches up names between source files, allowing them to reference each other.
What does the 'nm' program do?
It displays the symbol tables of object files, showing the types of symbols.
What does the symbol 'T' represent in the output of 'nm'?
'T' indicates an exported Text symbol.
What does the symbol 'U' represent in the output of 'nm'?
'U' indicates an Undefined symbol that needs to be imported.
What is a shared object file in C?
A shared object file (*.so) contains libraries like the C standard library (libc) that can be linked dynamically.
What are the downsides of static linking?
Static linking results in larger executables and can embed bugs, requiring recompilation to fix.
What is the main advantage of dynamic linking?
It allows for automatic updates of shared libraries, fixing bugs without needing to recompile dependent programs.
What are function pointers in C?
Function pointers are variables that store the address of a function, allowing functions to be passed as arguments.
How does dynamic method dispatch relate to function pointers?
Dynamic method dispatch in languages like Java is similar to function pointers in C, providing a layer of type safety.
What is dynamic loading?
Dynamic loading allows libraries to be loaded into a program's memory while it is running, often used for plugins.
What is the loader's role in an operating system?
The loader unpacks the executable into memory and loads any required dynamically-linked libraries.
What is the difference between static linking and dynamic linking?
Static linking includes all code in the executable at link-time, while dynamic linking resolves dependencies at load-time.
What happens if a shared library cannot be found during dynamic linking?
If a shared library cannot be found, the program cannot run.
What is a dynamically loaded library?
A dynamically loaded library is a shared library that the application decides to load at runtime.
What is the purpose of the 'printf' function in C?
The 'printf' function is used to output formatted text to the standard output.
What is the structure of a function pointer declaration in C?
A function pointer declaration in C is written as 'int (*fp)(int);', indicating it points to a function taking an int and returning an int.
What is the significance of the symbol table in an object file?
The symbol table contains information about the symbols defined and used in the object file, aiding in linking.
What is the purpose of the 'ld' command in Linux?
'ld' is the linker that combines object files into an executable and resolves symbol references.
What is the difference between 'libc.so' and 'libc.a'?
'libc.so' is a shared library for dynamic linking, while 'libc.a' is a static library for static linking.
What does the '.text' section of an executable contain?
The '.text' section contains the machine code or instructions of the program.
What does the '.data' section of an executable contain?
The '.data' section contains initialized global and static variables.
What is the role of the operating system in dynamic loading?
The operating system manages the loading of shared objects into the program's memory upon request.
What is a process in the context of an operating system?
A process is the in-memory representation of a program, including its data and resources.
What are the common executable formats for different operating systems?
UNIX uses ELF, macOS uses Mach-O, and Windows uses PE/COFF.
What is the purpose of the '.bss' section in an executable?
The '.bss' section contains uninitialized global and static variables.
How does dynamic linking affect the size of executables?
Dynamic linking generally results in smaller executables since shared libraries are not included in the executable.
What is the role of the loader in an operating system?
The loader unpacks the executable into memory.
What are the different executable formats used by various operating systems?
UNIXes use ELF, macOS uses Mach-O, and Windows uses PE/COFF.
What is the main responsibility of the operating system regarding processes?
The OS controls access to resources and ensures processes operate without interfering with each other.
What is the OS kernel?
The kernel is a special process that makes the OS work and manages all other processes.
What is an address space in an operating system?
An address space is a memory compartment allocated to each process, preventing them from accessing each other's memory.
What is virtual memory?
Virtual memory abstracts memory addresses so that processes access virtual addresses instead of real physical addresses.
How does the OS keep track of physical memory?
The OS splits memory into pages and keeps track of which pages belong to which process.
What is the typical size of a memory page in modern operating systems?
Usually, a page is 4KiB.
What is the purpose of the stack in a process's memory?
The stack holds activation records and manages function calls and returns.
What is a calling convention?
A calling convention is the method by which functions call one another in machine language.
What happens during a function call?
Arguments and return addresses are placed in the correct locations, the program jumps to the new function, and an activation record is set up on the stack.
What is the x86-64 architecture?
x86-64 is a popular architecture in personal computers, originally developed as a 16-bit architecture.
What does the term 'segfault' refer to?
Segfault refers to a segmentation fault, which occurs when a process tries to access memory outside its allocated address space.
What is the purpose of the page table in virtual memory?
The page table maps virtual addresses to physical addresses for each process.
What is the function of the 'sbrk()' system call?
The 'sbrk()' system call is used by processes to request new pages of memory.
What does 'mmap()' do in memory management?
'mmap()' is another way for processes to request pages of memory from the OS.
What is the significance of NULL being address 0 in memory management?
NULL is address 0, and valid memory addresses should never include this to prevent errors.
What is the memory map of a process?
The memory map is the arrangement of a process's address space, showing where code, globals, heap, and stack are located.
What does the OS do when a process is done with memory pages?
The OS allows the process to give back the pages for reuse.
What is the role of the activation record in function calls?
The activation record holds information about the function call, including parameters and return addresses.
What is the difference between physical memory and virtual memory?
Physical memory refers to actual RAM, while virtual memory is an abstraction that allows processes to use addresses that do not correspond to physical locations.