{"id":21050649,"url":"https://github.com/adolbyb/architecture-in-c","last_synced_at":"2025-06-23T17:37:26.809Z","repository":{"id":187796838,"uuid":"642678596","full_name":"ADolbyB/architecture-in-c","owner":"ADolbyB","description":"A Collection of code from CDA-4102: Computer Architecture","archived":false,"fork":false,"pushed_at":"2023-08-14T01:22:16.000Z","size":138,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T18:34:45.793Z","etag":null,"topics":["architecture","c","c-programming","computer-hardware","debugging","gdb","gdb-commands"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ADolbyB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-19T05:33:52.000Z","updated_at":"2024-07-22T19:34:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"24d57578-7c11-4cb1-a3c8-80cc991e8a38","html_url":"https://github.com/ADolbyB/architecture-in-c","commit_stats":null,"previous_names":["adolbyb/architecture-in-c"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADolbyB%2Farchitecture-in-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADolbyB%2Farchitecture-in-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADolbyB%2Farchitecture-in-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADolbyB%2Farchitecture-in-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ADolbyB","download_url":"https://codeload.github.com/ADolbyB/architecture-in-c/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243495495,"owners_count":20299923,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["architecture","c","c-programming","computer-hardware","debugging","gdb","gdb-commands"],"created_at":"2024-11-19T15:46:42.510Z","updated_at":"2025-03-13T23:14:09.217Z","avatar_url":"https://github.com/ADolbyB.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Computer Architecture in C\n\nA Collection of Code from CDA-4102: Computer Architecture.\n\nA major topic in this course is: [Unix Processes in C](https://www.youtube.com/playlist?list=PLfqABt5AS4FkW5mOn2Tn9ZZLLDwA3kZUY), so there is a YouTube tutorial playlist.\n\nThe book following this course is [Computer Systems: A Programmer's Perspective, 3/E](http://csapp.cs.cmu.edu/)\n - This book uses programming in C language for assignments.\n\n## Other Sources:\n\nAnother good book for Computer Architecture is: [Structured Computer Organization](https://www.pearson.com/en-us/subject-catalog/p/structured-computer-organization/P200000003183/9780137618446)\n - This book is more about hardware and does not include programming.\n\n[C Language Placeholders](https://en.m.wikibooks.org/wiki/C_Programming/Simple_input_and_output) List and examples of usage.\n - Remember that `scanf()` is vulnerable to buffer overflow, to use `fgets()` instead, as discussed in the article.\n - Remember in C: DON'T FORGET TO CLEAR THAT INPUT BUFFER: [Stack Overflow](https://stackoverflow.com/questions/44943622/getchar-function-to-clear-input-buffer-outside-of-while-condition)\n\nC File Handling:\n\n - Reference for [C File Handling](https://www.w3schools.blog/c-file-handling) with examples.\n - [C File Handling](https://www.w3schools.in/c-programming/file-handling) examples.\n - [C Files](https://www.w3schools.com/c/c_files.php) from W3 Schools.\n - [C Program to Copy One File to Another File](https://www.sanfoundry.com/c-program-copy-file/)\n\nArchitecture References:\n \n - [x86_64 Reference Sheet](https://web.stanford.edu/class/cs107/resources/x86-64-reference.pdf): This is what I am Running\n - [X86_64 Register and Instruction Quick Start](https://wiki.cdot.senecacollege.ca/wiki/X86_64_Register_and_Instruction_Quick_Start) Wiki Page\n - [x86 Assembly/X86 Architecture](https://en.wikibooks.org/wiki/X86_Assembly/X86_Architecture)\n\nGDB Debugging:\n\n - [Harvard CS50 GDB Tutorial](https://www.youtube.com/watch?v=sCtY--xRUyI): A Great Introduction to GDB.\n - [Low Level Learning](https://www.youtube.com/watch?v=Dq8l1_-QgAc): An Excellent GDB Walkthrough Example.\n - [CppCon 2022 Back To Basics](https://www.youtube.com/watch?v=YzIBwqWC6EM): Debugging Strategies and Intro to GDB.\n - [GDB MasterClass](https://www.youtube.com/watch?v=MTkDTjdDP3c) by Mike Shah.\n - [GDB Quick Reference](https://beej.us/guide/bggdb/#qref) Guide.\n - [Debugging With GDB](https://sourceware.org/gdb/current/onlinedocs/gdb.html/) 10th Edition HTML Web Reference Manual.\n - [Debugging With GDB](https://sourceware.org/gdb/current/onlinedocs/gdb.pdf) 10th Edition Reference Manual PDF.\n \n\n## Status:\n\n![GitHub repo size](https://img.shields.io/github/repo-size/ADolbyB/architecture-in-c?label=Repo%20Size\u0026logo=Github)\n\n## GDB Quick Reference (subject to change):\n\n```bash\nrun # (short: r)                        # Start the program \nstart                                   # Synonymous to (b main \u0026\u0026 run). Puts temporary breakpoint at main()\nnext # (short: n)                       # Next Line of Code / Step OVER: Goto Next Line \u0026 Execute current line\nnexti                                   # Next Instruction: Goto Next Line of ASSEMBLY \u0026 Execute current line of ASM.\nlist # (short: l)                       # List/Print 10 lines of code next to currently executing line of code\nstep # (short: s)                       # Step INTO function call at current line\nstepi                                   # Step a single assembly instruction\nfinish # (short: fin)                   # Finish the execution of current function\ncontinue # (short: c)                   # Resume execution (After a breakpoint)\nrefresh # (short: ref or Ctrl+l)        # Repaint the interface\nquit # (short: q)                       # Quit\nbreak funcName # (short: b funcName)    # Set breakpoint at function funcName\nb file::line                            # Set breakpoint at line in file\ndelete                                  # Delete all breakpoints\ndelete breakpoint_no                    # Delete breakpoint breakpoint_no\ndisable                                 # Disable all breakpoints\nmake binaryName                         # recompile binaryName (useful to test after 'p var = value' changes)\nlayout type                             # Set the window layout (\"src\", \"asm\", \"split\", or \"reg\")\ntui reg type                            # Set the register window layout (\"general\", \"float\", \"system\", or \"next\")\nlay next                                # Cycle through the layouts of gdb\ntui disable                             # Disable TUI display mode.\ntui enable                              # Enable TUI display mode.\ntui reg                                 # TUI command to control the register window.\nprint var # (short: p)                  # Print the value of variable / object var\np var = value                           # Force set value to the var (short for print)\nset variable expression\t                # Set a variable to value, e.g. `set variable x=20`\nset (expression)                        # Works like set variable\nptype expr                              # Detailed print of datatype of expr\ninfo locals                             # Variables in local scope\ninfo variables                          # Variables declared outside current scope\ninfo functions                          # Names and datatypes of all defined functions\ninfo registers                          # Dump integer registers to screen / View Register Values ar time of crash\ninfo all-registers                      # Dump all registers to screen\ninfo b                                  # List all breakpoints\nwhatis expr                             # Print datatype of expr\nbacktrace # (short 'bt')                # Print backtrace: Call stack history\nwhere                                   # Same as backtrace\nshell cmd                               # Run shell command cmd from gdb prompt\npython gdb.execute(cmd)                 # Run a gdb command cmd from python prompt\nset print pretty on                     # Enable pretty printing (Put in ~/.gdbinit)\n$ gdb -c core.num                       # Examine the dumped core file from a SIGSEGV(shell command)\nbreak _exit                             # Breakpoint at exit of program\nwatch var                               # Stop when var is modified\nwatch -l foo                            # Watch foo location\nrwatch foo                              # Stop when foo is read\nwatch foo if foo\u003e10                     # Watch foo conditionally\ncommand breakpoint_no                   # Run user listed commands when breakpoint is hit (End commands with 'end')\nfile executable                         # Load the executable for debugging from inside gdb\ninfo                                    # GDB Manual Pages\n\n# Examine Function: Used After Crashes like 'Segmentation Faults'\nx/nfu addr                              # \nx addr                                  #\nx/                                      # Examine function: used to examine registers and see what address they point to\n\n# different output examples:\nx/x $eip                                # examine the value of eip in hexadecimal \nx/o $eip                                # examine the value of eip in octal\nx/u $eip                                # examine the value of eip in unsigned base-10 decimal\nx/t $eip                                # examine the value of eip in binary\nx/i $eip                                # examine the instruction\nx/i $pc                                 # examine the instruction at the program counter (before the crash)\nx/2xb $eip                              # examine first 2 bytes in hexadecimal  \nx/1xh $eip                              # gives the same amount of bytes but in one line ('h' stands for half-word which is a short (2 bytes))\nx/x $esp                                # examine the value of esp in hexadecimal \nx/o $ebp                                # examine the value of ebp in octal \nx/u $eip                                # examine the value of eip in unsigned decimal Base-10 \nx/t $edi                                # examine the value of edi in binary\nprint $eip                              # will make a variable for it and display the value and address\nx/2xw $1                                # Needs Description...\n\n# Number Base / Radix:\no : octal\nu : unsigned decimal\nt : binary\nx : hexadecimal\n\n# Sizes:\ng : giant (8 bytes)                     # 64-bit word: 8 bits per byte * 8 bytes\nw : word (4 bytes)                      # 32-bit word: 8 * 4 = 32\ndw : double word (4 bytes)              # 32-bit word: 8 * 4 = 32\nh : half word (2 bytes)                 # 16-bit word: 8 * 2 = 16\nb : byte (1 byte)                       # 1 byte = 8 bits\n\n# and and by the way gdb uses LITTLE ENDIAN format\n# so the bytes will be reversed for example:\nx/4xb $eip: 0x7c , 0x4f , 0x45 , 0x64\nx/1xw $eip: 0x64454f7c\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadolbyb%2Farchitecture-in-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadolbyb%2Farchitecture-in-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadolbyb%2Farchitecture-in-c/lists"}