⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdbfileformat.txt

📁 This a FREE tool chain which compiles C codes into 8051 binary code, converts the binary to RTL ROM,
💻 TXT
📖 第 1 页 / 共 3 页
字号:


CDB File Format

Lenny Story

SDCC Development Team

Table of Contents

    1 Overview
    2 Usage
    3 Conventions
    4 Record Formats
        4.1 Basic Record Format
        4.2 Module Record
        4.3 Symbol Records
        4.4 Type Chain Record
        4.5 Function Records
        4.6 Type Records
        4.7 Type Member
        4.8 Link Address of Symbol
        4.9 Linker Symbol End Address Record
        4.10 Linker ASM Line Record
        4.11 Linker C-Line Record
    5 Source File Example 
    6 CDB File Example



1 Overview

The CDB File is used to record all of the information 
that describes the variables, functions, lines, and 
memory items. These records provide the critical 
information that allows external utilities to properly 
locate and interpret variables, functions, and types. 
Development tools such as simulators debuggers and 
profilers use these records to analyze and describe the 
code in terms of the high level language in which it 
was written. The CDB file is therefore the critical 
link to bridging the compiled code image to the source 
files from which it was built.

2 Usage

CDB files are created when the "--debug" option is 
used. Each source file will have its own CDB file 
associated with it. When the --debug flag is used 
during the link process, the CDB file of the FIRST 
source module will contain all the records from all the 
source modules linked as well as the linker records.

Code and variables that are removed during the 
optimization phase will not be present in the debug 
file. Images created for debugging purposes should 
always disable as much optimization as possible. The 
following options are critical for the completeness of 
the resulting debugging file.

--debug Mandatory to produce a debugging file. 

--noinduction Induction processing occurs at the very 
latest stages of compilation. This results in the 
inability to report the location of the resulting 
variables. Including this option disables the loop 
induction optimization. 

--nooverlay Overlay variables will not show up in the 
debug file. Including this option will force variables 
to the data segment.

3 Conventions

The record examples and grammar shown in this document 
are displayed on multiple lines only for the purposes 
of readability. The records contained within the CDB 
files are always encoded on a single line. 

Record grammar is indicated here using a custom format 
of the following specifications:

* Record Elements are surrounded using the characters 
  `<' and '>'.

* Alternation is indicated using the `|' character.

* Non-mandatory items are surrounded using the 
  characters `{` and `}'.

4 Record Formats

4.1 Basic Record Format

  <RecordType><:><RecordSpec>

+---------+------------------------------------+----------------------+
| 

Type  | 

Description                      | 

Form               |
+---------+------------------------------------+----------------------+
+---------+------------------------------------+----------------------+
|  

M    | 

Module Record                    | 

Compiler           |
+---------+------------------------------------+----------------------+
|  

F    | 

Function Record                  | 

Compiler           |
+---------+------------------------------------+----------------------+
|  

S    | 

Symbol Record                    | 

Compiler           |
+---------+------------------------------------+----------------------+
|  

T    | 

Structure (Complex Type) Record  | 

Compiler           |
+---------+------------------------------------+----------------------+
|  

L    | 

Linker Record                    | 

Assembler / Linker |
+---------+------------------------------------+----------------------+


All records are ASCII text, with one record per line. 
The record type is the first character, followed by a 
single colon ":". Sub types are often included as part 
of the record specific format.

4.2 Module Record

  <M><:><Filename>

+-------------+-------------------------------------------------------------+
|    

M      | 

Module record type indicator                              |
+-------------+-------------------------------------------------------------+
| 

Filename  | 

The filename of the module that this CDB file represents. |
+-------------+-------------------------------------------------------------+


Purpose

The module record is used to define a source module. It 
is usually used at the beginning of each of the module 
specific CDB files, and will occur several times in the 
final CDB file produced by the linker to represent each 
of the source modules. The location of this record 
within the file does not necessarily indicate the scope 
of the variables that follow. Those variables that have 
module specific scope have an indication encoded within 
their respective symbol entry.

Examples

M:Timer0
M:_bp

4.3 Symbol Records

+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|        

S        |  

Symbol record type indicator                                                                                                                                             |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|        

G        |  

Scope is global                                                                                                                                                          |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|  

F <Filename>   |  

Scope is file                                                                                                                                                            |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|  

L <Function>   |  

Scope is local                                                                                                                                                           |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|     

<Name>      |  

Symbol name                                                                                                                                                              |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|     

<Level>     |  

Scope level (see below)                                                                                                                                                  |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|     

<Block>     |  

Scope block (see below)                                                                                                                                                  |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|   

<TypeChain>   |  

Type chain record (see type record below)                                                                                                                                |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 

<Address Space> |  

Address space code (see table below)                                                                                                                                     |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|   

<On Stack>    |  

Is this symbol on the stack? Indicates if the next 
parameter is valid.                                                                                                  |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|     

<Stack>     |  

The stack Offsetorelative to the "bp" variable. (The 
libraries may have to be recompiled to include the -
-debug option for this variable to appear in the debug file). |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|      

<Reg>      |  

If the address space is 'R', this field indicates the 
register that the symbol is allocated. The register 
name is in its native form: R1, AX, etc.                     |
+-------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+


  <S><:>
{ G | F<Filename> | L { <function> | "--null--" }}
<$><Name>

  <$><Level>
<$><Block>
<(><TypeRecord><)>
<,><AddressSpace>

  <,><OnStack>
<,><Stack>
<,><[><Reg><,>{<Reg><,>}<]>

A symbol record is generated for each named symbol in 
the source file; this includes local, global and 
parameter symbols. 

Blocks and Levels

The level & block are used to further scope local 
variables since C allows unique definitions across 
different scope blocks. When using the symbol records, 
it is always important to include the level and block 
information as part of the identification. It is 
possible to have two symbols that share the same name, 
but have different scope information.

The linker address records contain not only the name of 
the symbol, but the Scope information as well, which is 
instrumental in determining the correct instantiation 
of the symbol.

Linker C line records also contain the Scope 
information (see below).

The following code fragment illustrates a simple scope example:

foo()

{

int c; /* block #1 , level #1 */

   {

      int c; /* block #2, level #2 */

      ...

   }

   {

      int c; /* block #3 , level #2 */

      ...

   }

}

+------+----------------------------------------------------------+
| 

A  | 

External stack                                         |
+------+----------------------------------------------------------+
| 

B  | 

Internal stack                                         |
+------+----------------------------------------------------------+
| 

C  | 

Code                                                   |
+------+----------------------------------------------------------+
| 

D  | 

Code / static segment                                  |
+------+----------------------------------------------------------+
| 

E  | 

Internal ram (lower 128) bytes                         |
+------+----------------------------------------------------------+
| 

F  | 

External ram                                           |
+------+----------------------------------------------------------+
| 

G  | 

Internal ram                                           |
+------+----------------------------------------------------------+
| 

H  | 

Bit addressable                                        |
+------+----------------------------------------------------------+
| 

I  | 

SFR space                                              |
+------+----------------------------------------------------------+
| 

J  | 

SBIT space                                             |
+------+----------------------------------------------------------+
| 

R  | 

Register space                                         |
+------+----------------------------------------------------------+
| 

Z  | 

Used for function records, or any undefined space code |
+------+----------------------------------------------------------+


4.4 Type Chain Record

  <{><Size><}> <DCLType> <,> {<DCLType> <,>} <:> <Sign>

+--------------+------------------------------------------------+
|  

<Size>    | 

The size of the item in decimal.             |
+--------------+------------------------------------------------+
| 

<DCLType>  | 

The type encoded using the table below.      |
+--------------+------------------------------------------------+
|  

<Sign>    | 

The sign of the item. Encoded as 'U' or 'S'. |
+--------------+------------------------------------------------+


Purpose

The C programming language allows arbitrarily complex 
type constructions. Because of this, the CDB file type 
designations are organized as a list of basic primitive types.

+--------------+----------------------------+
|  

DA <n>    | 

Array of n elements      |
+--------------+----------------------------+
|    

DF      | 

Function                 |
+--------------+----------------------------+
|    

DG      | 

Generic pointer          |
+--------------+----------------------------+
|    

DC      | 

Code pointer             |
+--------------+----------------------------+
|    

DX      | 

External ram pointer     |
+--------------+----------------------------+
|    

DD      | 

Internal ram pointer     |
+--------------+----------------------------+
|    

DP      | 

Paged pointer            |
+--------------+----------------------------+
|    

DI      | 

Upper 128 byte pointer   |
+--------------+----------------------------+

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -