hello_wasm.debug.json

Overview

The hello_wasm.debug.json file is a debug information mapping artifact that associates offsets in the compiled WebAssembly (WASM) bytecode with corresponding source code locations in Solidity (hello_wasm.sol) and the WASM code files (hello_wasm.code). This mapping facilitates debugging by enabling precise source-level traceability during execution or analysis of the compiled contract.

The file contains a JSON structure where keys are cryptographic hash identifiers (likely representing compilation units, functions, or code segments), and values are objects mapping bytecode offsets (expressed as numbers) to source file and line number pairs. This allows tools to resolve runtime addresses back to source lines.

Structure and Contents

Purpose of Mappings

Key Files Mapped

Usage

This file is used primarily by debugging tools or development environments that support source-level debugging of WASM contracts compiled from Solidity. When an error or breakpoint occurs at a certain bytecode offset, this file enables the debugger to locate the exact line in the Solidity source or WASM code.

Example usage in a debugging session:

  1. The debugger hits an instruction at offset 88 within the code segment identified by hash "08899a87a7d1a079a87cb156204b3332ae7eac0fabdee2cf4bbe36293199c417".

  2. The debugger looks up this offset in the JSON file.

  3. It finds the corresponding source location: hello_wasm.sol, line 81.

  4. The debugger shows this source line to the developer for inspection.

Interaction with Other System Components

This file acts as a bridge between runtime bytecode and human-readable source code, enabling effective debugging and analysis workflows.

Important Implementation Details

Visual Diagram of File Structure

flowchart TD
A[hello_wasm.debug.json]
A --> B[Code Segment Hashes]
B --> C1[Offset 0]
B --> C2[Offset 16]
B --> C3[Offset 24]
B --> Cn[...]
C1 --> D1{Source Mapping}
C2 --> D2{Source Mapping}
C3 --> D3{Source Mapping}
D1 --> E1[File: hello_wasm.sol]
D1 --> E2[Line: 76]
D2 --> F1[File: hello_wasm.sol]
D2 --> F2[Line: 81]
D3 --> G1[File: hello_wasm.code]
D3 --> G2[Line: 2]

Notes on Source Code Line Distribution

No direct functions or classes are defined in this JSON file since it serves purely as a mapping database rather than executable code.


For detailed understanding of the Solidity contract source at referenced lines, see Solidity Contract Source Overview. For WASM code structure and semantics, refer to WebAssembly Code Structure. Debugging process and tools are covered in Debugging WASM Contracts.