raddebugger README

The project's README from github.com/EpicGames/raddebugger. As one markdown file: README.md.

The RAD Debugger Project

NOTE: This README does not document usage instructions and tips for the debugger itself, and is intended as a technical overview of the project. The debugger's README, which includes usage instructions and tips, can be found packaged along with debugger releases, or within the build folder after a local copy has been built. You can find pre-built release binaries here.

The RAD Debugger is a native, user-mode, multi-process, graphical debugger. It currently only supports local-machine Windows x64 debugging with PDBs, with plans to expand and port in the future. In the future we'll expand to also support native Linux debugging and DWARF debug info.

The debugger is currently in ALPHA. In order to get the debugger bullet-proof, it'd greatly help out if you submitted the issues you find here, along with any information you can gather, like dump files (along with the build you used), instructions to reproduce, test executables, and so on.

In addition to the debugger, we aim to further improve the toolchain with two additional related technologies: (1) the RAD Debug Info (RDI) format, and (2) the RAD Linker.

The RAD Debug Info (RDI) Format

The RAD Debug Info (RDI) format is our custom debug information format, which the debugger parses and uses, rather than the debug information natively produced by toolchains, like PDB or DWARF. To work with these existing toolchains, we convert PDB (and eventually PE/ELF files with embedded DWARF) into the RDI format on-demand.

The RDI format is currently specified in code, in the files within the src/lib_rdi folder. In rdi.h and rdi.c, the types and functions which define the format itself are specified. In rdi_parse.h and rdi_parse.c, helpers for parsing the format are included.

We also have an in-progress library for constructing and serializing RDI data, located within the src/lib_rdi_make folder.

Our radbin utility (accessible through the debugger too, via the --bin command line argument) is capable of converting native debug information formats to RDI, and of producing textual dumps of contents stored within RDI files.

The RAD Linker

The RAD Linker is a new performance linker for generating x64 PE/COFF binaries. It is designed to be very fast when creating gigantic executables. It generates standard PDB files for debugging, but it can also (optionally) natively create RAD Debug Info too, which is useful both to eliminate on-demand conversion time when debugging, but also for huge executables that otherwise create broken PDBs that overflow internal 32-bit tables.

The RAD Linker is primarily optimized to handle huge linking projects. In our test cases (where debug info is multiple gigabytes), we see 50% faster link times.

The command line syntax is fully compatible with MSVC; you can get a full list of implemented switches from /help.

Our current designed-for use case for the linker is to help with the compile-debug cycle of huge projects. We don't yet have support for link-time-optimizations, but this feature is on the road map.

By default, the linker spawns as many threads as there are cores, so if you plan to run multiple linkers in parallel, you can limit the number of thread workers via /rad_workers.

We also have support for large memory pages, which, when enabled, reduce link time by another 25%. To link with large pages, you need to explicitly request them via /rad_large_pages. Large pages are off by default, since Windows support for large pages is a bit buggy; we recommend they only be used in Docker or VM images where the environment is reset after each link. In a standard Windows environment, using large pages otherwise will fragment memory quickly, forcing a reboot. We are working on a Linux port of the linker that will be able to build with large pages robustly.

A benchmark of the linker's performance is below:

AMD Ryzen Threadripper PRO 3995WX 64-Cores, 256 GiB RAM (Windows x64)


Project Development Setup / Local Build Instructions

The project is actively developed both on Windows x64 and Linux x64 development machines. Click on whichever you'd like to use.

Windows x64

1. Installing the Required Tools (MSVC & Windows SDK)

First, you'll need the Microsoft C/C++ Build Tools v15 (2017) or later, for the Windows SDK, and the MSVC compiler and linker.

If the Windows SDK is installed (e.g. via installation of the Microsoft C/C++ Build Tools), you may also build with Clang.

2. Build Environment Setup

Building the codebase can be done in a terminal which is equipped with the ability to call either MSVC or Clang from command line.

This is generally done by calling vcvarsall.bat x64, which is included in the Microsoft C/C++ Build Tools. This script is automatically called by the x64 Native Tools Command Prompt for VS <year> variant of the vanilla cmd.exe. If you've installed the build tools, this command prompt may be easily located by searching for Native from the Windows Start Menu search.

You can ensure that the MSVC compiler is accessible from your command line by running:

cl

If everything is set up correctly, you should have output very similar to the following:

Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30151 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]

3. Building

Within this terminal, cd to the root directory of the codebase, and just run the build.bat script:

build

You should see the following output:

[debug mode]
[msvc compile]
[default mode, assuming `raddbg` build]
metagen_main.c
searching C:\devel\raddebugger/src... 458 files found
parsing metadesk... 16 metadesk files parsed
gathering tables... 97 tables found
generating layer code...
raddbg_main.c

If everything worked correctly, there will be a build folder in the root level of the codebase, and it will contain a freshly-built raddbg.exe.

This raddbg.exe will have been built in debug mode, which is not built with optimizations, and may perform worse. To produce a release mode executable, run build.bat with a release argument:

build release

This build will take significantly longer.

By default, build.bat only builds the debugger if no arguments (or just release) are passed, but additional arguments can be passed to build the RAD Linker, or the radbin CLI binary file utility:

build radlink release
build radbin release

Linux x64

1. Installing the Required Tools (GCC or Clang, Libraries)

First, you'll need either GCC or Clang, if you don't already have them. They can be obtained by running one of the following commands, depending on your toolchain of choice and distribution:

GCC on Ubuntu / Debian / Mint

sudo apt update && sudo apt install build-essential

Clang on Ubuntu / Debian / Mint

sudo apt update && sudo apt install clang llvm

GCC on Arch / Manjaro

sudo pacman -S base-devel

Clang on Arch / Manjaro

sudo pacman -S clang llvm

If you've installed the Clang and LLVM tooling required, you can run:

clang --version && llvm-ar --version

You should see output similar to the following:

Ubuntu clang version 18.1.3 (1ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Ubuntu LLVM version 18.1.3
  Optimized build.

If you've installed the GCC tooling required, you can run:

gcc --version && gcc-ar --version

You should see output similar to the following:

gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

GNU ar (GNU Binutils for Ubuntu) 2.42
Copyright (C) 2024 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

2. Installing Dependencies

The debugger project relies on a few dynamically linked libraries being present on the system:

You'll need the development packages for them in order to build. These can be installed using one of the following commands, depending on your distribution:

Ubuntu / Debian / Mint

sudo apt install -y libfreetype6-dev libx11-dev libxext-dev libxfixes-dev libxrandr-dev libgl-dev libegl-dev

Arch / Manjaro

sudo pacman -S --needed freetype2 libx11 libxext libxfixes libxrandr libglvnd

3. Building

To build, cd to the root directory of the codebase, and run the build.sh script:

./build.sh

You should see something similar to the following output:

[clang compile]
[debug mode]
[building metagen]
searching /mnt/c/devel/raddebugger/src... 562 files found
parsing metadesk... 23 metadesk files parsed
gathering tables... 138 tables found
generating layer code...

If everything worked correctly, there will be a build folder in the root level of the codebase, and it will contain a freshly-built raddbg binary.

This raddbg will have been built in debug mode, which is not built with optimizations, and may perform worse. To produce a release mode executable, run build.sh with a release argument:

./build.sh release

This build will take significantly longer.

By default, build.sh only builds the debugger if no arguments (or just release) are passed, but additional arguments can be passed to build the RAD Linker, or the radbin CLI binary file utility:

./build.sh radlink release
./build.sh radbin release

Project Roadmap

The Initial Alpha Battle-Testing Phase

The first priority for the project is to ensure that the most crucial components are functioning extremely reliably for local, x64, Windows development. For the debugger, this would include parts like debug info conversion, debug info loading, process control, stepping, evaluation (correct usage of both location info and type info), and a robust frontend which ensures the lower level parts are usable. For the linker, this is a matter of reliability and convergence with existing linker behavior.

We feel that we've already come a long way in all of these respects, but given the massive set of possible combinations of languages, build settings, toolchains, used language features, and patterns of generated code, we still expect some issues, and are prioritizing these issues being resolved first.

We also hope to continue to improve performance in this phase. For the debugger, this primarily includes frontend performance, introducing caches when economical to do so, and tightening existing systems up. For the linker, it has been mostly tuned thus far for giant projects, and so we'd like to improve linking speed for small-to-mid sized projects as well.

For the linker, there are also a number of features to come, like dead-code-elimination (/opt:ref), and link-time-optimizations with the help of clang (we won't support LTCG from MSVC, since it is undocumented).

Local x64 Linux Debugging Phase

The next priority for the project is to take the rock solid x64 Windows debugging experience, and port all of the relevant pieces to support local x64 Linux debugging also.

The debugger has been written to abstract over the parts that need to differ on either Linux or Windows, and this is mainly going to be a task in building out different backends for those abstraction layers.

The major parts of this phase are:

Once the above list is complete, and once every part is rock solid, the Windows debugging experience we'll have worked diligently to create will also be available natively on Linux machines.

And Beyond!

There are several directions we might take after these two major phases, like remote debugging, porting to different architectures, further improving the debugger's features (like improving the visualization engine), and so on. But for now, we're mostly focused on those first two phases.


Codebase Introduction

Top-Level Directory Descriptions

After setting up the codebase and building, the following directories will also exist:

Layer Descriptions

The codebase is organized into layers. Layers are separated either to isolate certain problems, and to allow inclusion into various builds without needing to pull everything in the codebase into a build. Layers correspond with folders inside of the src directory. Sometimes, one folder inside of the src directory will include multiple sub-layers, but the structure is intended to be fairly flat.

Layers correspond roughly 1-to-1 with namespaces. The term "namespaces" in this context does not refer to specific namespace language features, but rather a naming convention for C-style namespaces, which are written in the codebase as a short prefix, usually 1-3 characters, followed by an underscore. These namespaces are used such that the layer to which certain code belongs may be quickly understood by glancing at code. The namespaces are generally quite short to ensure that they aren't much of a hassle to write. Sometimes, multiple sub- layers will share a namespace. A few layers do not have a namespace, but most do. Namespaces are either all-caps or lowercase depending on the context in which they're used. For types, enum values, and some macros, they are capitalized. For functions and global variables, they are lowercase.

Layers depend on other layers, but circular dependencies would break the separability and isolation utility of layers (in effect, forming one big layer), so in other words, layers are arranged into a directed acyclic graph.

A few layers are built to be used completely independently from the rest of the codebase, as libraries in other codebases and projects. As such, these layers do not depend on any other layers in the codebase. The folders which contain these layers are prefixed with lib_, like lib_rdi.

A list of the layers in the codebase and their associated namespaces is below:

raddebugger (EpicGames/raddebugger)

Searching Database…

这是什么?RAD Debugger 是 Epic Games/RAD 出品的原生、用户态、多进程图形化调试器。它还附带两个相关工具:RAD Debug Info(RDI)格式,以及 RAD Linker——一个快速的 x64 PE/COFF 链接器。
这是独立的桌面应用,还是要嵌进项目里的东西?它是一个独立的原生可执行文件(raddbg.exe / raddbg),直接运行就能附加并调试其他程序,不是链接进项目的库。
怎么把它跑起来?你可以直接获取预构建的发布版二进制文件,或者克隆仓库后在 Windows 上运行 build.bat(需在启用了 MSVC 的终端里)或在 Linux 上运行 build.sh,它会在 build 文件夹里生成 raddbg 可执行文件。
自己构建之前需要装好什么?在 Windows 上需要带 Windows SDK 的 Microsoft C/C++ Build Tools(MSVC),或者 Clang。在 Linux 上需要 GCC 或 Clang,外加 libfreetype、libx11、libxext、libxfixes、libxrandr、libgl 和 libegl 的开发包。
现在能用它调试 Linux 程序吗?还不能——目前只支持基于 PDB 调试信息的本机 Windows x64 调试。基于 DWARF 的原生 Linux 调试已在计划中并正在积极移植,而且该项目仍处于 ALPHA 阶段。
至少现在能在 Linux 上构建并运行这些工具吗?可以,代码库能通过 build.sh 在 Linux x64 上构建(GCC 或 Clang 都行),只是完整的 Linux 调试支持仍在开发中。
RAD Debug Info(RDI)格式是什么?它是调试器自有的自定义调试信息格式,用来替代原生 PDB 或 DWARF。PDB 文件(最终还会支持内嵌 DWARF 的 PE/ELF)会按需转换为 RDI,radbin 工具可以在格式之间转换或导出 RDI 内容。
RAD Linker 是干什么用的?它是一个全新的高性能 x64 PE/COFF 链接器,面向超大规模的链接项目,命令行与 MSVC 完全兼容。它能生成标准 PDB 或原生输出 RDI 调试信息,在该项目自己的基准测试中链接耗时大约快了 50%。
想试用必须自己编译吗?不用,README 里提供了预构建发布版二进制文件的链接,你可以直接下载开箱即用的版本,不必从源码构建。
What are similar projects?CalcKernel, goose, Tov, gcc, scriptc, porffor, simdjson, Singeli
Creator
EpicGames
Size
32.3 MB
Stars
8.6K
Age
2y
Commits · 90 Days