Catalog · How the catalog works
pascal-diagnostics-reporter
Thread-safe diagnostics, log encryption, and remote crash reporting framework in pure Object Pascal
- ★ 1 on GitHub
Anyone may press Interesting, signed in or not. It helps others find this project.
README
Pascal Diagnostics & Crash Reporter
A professional-grade, multi-threaded system diagnostics and automated remote crash reporting framework written in pure Object Pascal.
This repository demonstrates production-ready Pascal engineering, system programming, concurrency, network sockets, exception trapping, and low-level stack unwinding. It is designed to be highly compatible with Embarcadero RAD Studio (Delphi/C++Builder) and the Free Pascal Compiler (FPC).
Key Features
- Thread-Safe Logging: Utilizes a background worker thread (
TLogWriterThread) with a critical section-guarded queue to process logs asynchronously, ensuring that disk write operations never block the main application or UI thread. - Secure Log Obfuscation: Encrypts logs using a rolling-key symmetric stream cipher. Obfuscated binary data is serialized into hexadecimal strings to prevent platform-specific carriage-return or line-feed (
\r\n) translations from corrupting the ciphertext. - System Telemetry: Queries operating system details, CPU core count, total physical memory, and available memory at startup.
- Runtime Exception Hooking: Overrides the Pascal runtime exception vector (
ExceptProc) to trap global unhandled exceptions and software failures. - Call Stack Resolution: Decodes the exception instruction pointer and walking call frames into human-readable symbols, including function names, source files, and exact line numbers (resolves dwarf symbols).
- Automated Remote Upload: On application crash, the exception handler automatically flushes background logs and uploads the encrypted diagnostic log to a support server over TCP.
- Diagnostics Server: A low-level TCP socket server written in Object Pascal that runs 24/7, accepts crash uploads, decrypts them, and logs the parsed stack traces for support teams.
Project Structure
????????? src/
??? ????????? Diagnostics.pas - Thread-safe logging, system stats, encryption, and stack trace format
??? ????????? CrashReporter.pas - TCP client socket code to upload log files
??? ????????? Server.pas - Standalone TCP receiver that decrypts and saves uploaded logs
??? ????????? TestApp.pas - Test program simulating thread logging, unhandled exception, and upload
????????? build.sh - Script to compile Server and TestApp using FPC
????????? .gitignore - Version control exclusionsHow to Build and Run
1. Compile the Project
Make sure the Free Pascal Compiler (fpc) is installed on your system. Run the build script:
./build.shThis compiles the code with the -gl compiler switch to include dwarf line information and debug symbols (necessary for backtrace line numbers). Executables will be placed in the bin/ directory.
2. Start the Support Server
In one terminal window, start the central diagnostics server:
./bin/ServerThe server listens on port 8080 for crash uploads.
3. Run the Client Application
In another terminal window, run the test application:
./bin/TestAppThe application will:
- Initialize the thread-safe diagnostic log.
- Query and log system telemetry.
- Spawn 3 concurrent threads logging iterations to demonstrate safety.
- Raise a software exception to simulate a critical application crash.
- Traps the exception, resolves the call stack, and uploads
app_crash.logto the server.
4. Review the Crash Report
Check the server terminal output or look inside the received_crashes/ folder. You will find the fully decrypted log file detailing the system stats, worker thread operations, and the resolved crash call stack:
2026-07-18 22:42:21.047 [CRITICAL] [Thread 00007A2C401EB740]: Unhandled Exception Exception: Simulated critical crash!
Call Stack:
at $0000000000401974 TRIGGERCRASH, line 80 of src/TestApp.pas
at $0000000000401DB0 main, line 109 of src/TestApp.pasCross-Platform Compatibility
This framework is written in standard Object Pascal. The logging and networking routines run natively on:
- Windows (Delphi / RAD Studio C++Builder)
- Linux (Free Pascal Compiler)
- macOS (Free Pascal Compiler)
License
This project is licensed under the MIT License.

