# txuna/debugger architecture

> Architecture diagram of the GitHub repository txuna/debugger, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/txuna/debugger
- Repository: https://github.com/txuna/debugger

## Overview

Primary Flow:
- Input Binary -> ELF Parser -> Disassembler -> Debugger Core -> User Interface

Secondary Flows:
- Breakpoint Management: Debugger Core ↔ Breakpoint Handler
- Memory Operations: Debugger Core ↔ Memory Management
- Symbol Resolution: ELF Parser ↔ Symbol Table Manager

##### Component Details

- Blue: Core debugging functionality
- Green: Analysis components
- Yellow: User interface elements
- Red: Critical system interactions (ptrace)

##### Specific Implementation Details

Technical notes for:
- Opcode parsing logic
- Breakpoint implementation (0xCC interrupts)
- Memory injection capabilities
- Register state tracking

- Top: User Interface Layer
- Middle: Core Processing Layer
- Bottom: System Interaction Layer

##### Debugger's key features
- Single-stepping capability
- Breakpoint management
- Memory manipulation
- Register state inspection

##### Interaction between
- Static analysis (disassembly)
- Dynamic debugging (ptrace-based)
- Memory management
- User command processing

##### Technical constraints
- 32-bit architecture specifics
- ELF binary format requirements
- System call interactions

##### Error handling paths
- Invalid commands
- Memory access violations
- Process control errors

Remember to include version information (v1.0.0) and any limitations (e.g., partial opcode support) in supplementary notes.

This design should reflect both the current implementation and allow for the planned expansions mentioned in the README (floating point, multi-byte opcodes, etc.).

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef core fill:#2374ab,stroke:#2374ab,color:white
    classDef support fill:#48a9a6,stroke:#48a9a6,color:white
    classDef interface fill:#e4cc37,stroke:#e4cc37,color:black
    classDef system fill:#d64933,stroke:#d64933,color:white
    classDef memory fill:#4a5859,stroke:#4a5859,color:white

    %% User Interface Layer
    subgraph UI
        CLI["Command Line Interface"]:::interface
        VIS["Visualization Component"]:::interface
    end

    %% Core Processing Layer
    subgraph Core
        ELF["ELF Parser Module"]:::core
        DIS["Disassembler Engine"]:::core
        DBG["Debugger Core"]:::core
        STK["Stack Management"]:::core
    end

    %% Support Layer
    subgraph Support
        BPH["Breakpoint Handler"]:::support
        MM["Memory Management"]:::support
        STM["Symbol Table Manager"]:::support
    end

    %% System Interaction Layer
    subgraph System
        PT["ptrace API"]:::system
        MEM["System Memory"]:::memory
    end

    %% Connections
    CLI --> ELF
    CLI --> DBG
    ELF --> DIS
    DIS --> DBG
    DBG --> VIS
    DBG <--> BPH
    DBG <--> MM
    ELF <--> STM
    DBG <--> PT
    MM <--> MEM
    DBG <--> STK

    %% Click events
    click ELF "https://github.com/txuna/Debugger/blob/master/elf_parser.c"
    click DIS "https://github.com/txuna/Debugger/blob/master/disassembler.c"
    click DBG "https://github.com/txuna/Debugger/blob/master/ptrace.c"
    click STK "https://github.com/txuna/Debugger/blob/master/ListBaseStack.c"
    click BPH "https://github.com/txuna/Debugger/blob/master/bp_list.c"
    click MM "https://github.com/txuna/Debugger/blob/master/dumpcode.h"
    click VIS "https://github.com/txuna/Debugger/blob/master/visual_graph_function.c"

    %% Legend
    subgraph Legend
        C1["Core Components"]:::core
        S1["Support Components"]:::support
        I1["Interface Components"]:::interface
        SY1["System Components"]:::system
        M1["Memory Components"]:::memory
    end
```
