Linux Perf
genelf_debug.c File Reference
#include <linux/compiler.h>
#include <sys/types.h>
#include <stdio.h>
#include <getopt.h>
#include <stddef.h>
#include <libelf.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include <limits.h>
#include <fcntl.h>
#include <err.h>
#include <dwarf.h>
#include "perf.h"
#include "genelf.h"
#include "../util/jitdump.h"
Include dependency graph for genelf_debug.c:

Go to the source code of this file.

Classes

struct  buffer_ext
 
struct  debug_line_header
 
struct  compilation_unit_header
 

Macros

#define BUFFER_EXT_DFL_SIZE   (4 * 1024)
 
#define DW_LNS_num_opcode   (DW_LNS_set_isa + 1)
 

Typedefs

typedef uint32_t uword
 
typedef uint16_t uhalf
 
typedef int32_t sword
 
typedef int16_t shalf
 
typedef uint8_t ubyte
 
typedef int8_t sbyte
 

Functions

static void buffer_ext_dump (struct buffer_ext *be, const char *msg)
 
static int buffer_ext_add (struct buffer_ext *be, void *addr, size_t sz)
 
static void buffer_ext_init (struct buffer_ext *be)
 
static size_t buffer_ext_size (struct buffer_ext *be)
 
static void * buffer_ext_addr (struct buffer_ext *be)
 
static void emit_uword (struct buffer_ext *be, uword data)
 
static void emit_string (struct buffer_ext *be, const char *s)
 
static void emit_unsigned_LEB128 (struct buffer_ext *be, unsigned long data)
 
static void emit_signed_LEB128 (struct buffer_ext *be, long data)
 
static void emit_extended_opcode (struct buffer_ext *be, ubyte opcode, void *data, size_t data_len)
 
static void emit_opcode (struct buffer_ext *be, ubyte opcode)
 
static void emit_opcode_signed (struct buffer_ext *be, ubyte opcode, long data)
 
static void emit_opcode_unsigned (struct buffer_ext *be, ubyte opcode, unsigned long data)
 
static void emit_advance_pc (struct buffer_ext *be, unsigned long delta_pc)
 
static void emit_advance_lineno (struct buffer_ext *be, long delta_lineno)
 
static void emit_lne_end_of_sequence (struct buffer_ext *be)
 
static void emit_set_file (struct buffer_ext *be, unsigned long idx)
 
static void emit_lne_define_filename (struct buffer_ext *be, const char *filename)
 
static void emit_lne_set_address (struct buffer_ext *be, void *address)
 
static ubyte get_special_opcode (struct debug_entry *ent, unsigned int last_line, unsigned long last_vma)
 
static void emit_lineno_info (struct buffer_ext *be, struct debug_entry *ent, size_t nr_entry, unsigned long code_addr)
 
static void add_debug_line (struct buffer_ext *be, struct debug_entry *ent, size_t nr_entry, unsigned long code_addr)
 
static void add_debug_abbrev (struct buffer_ext *be)
 
static void add_compilation_unit (struct buffer_ext *be, size_t offset_debug_line)
 
static int jit_process_debug_info (uint64_t code_addr, void *debug, int nr_debug_entries, struct buffer_ext *dl, struct buffer_ext *da, struct buffer_ext *di)
 
int jit_add_debug_info (Elf *e, uint64_t code_addr, void *debug, int nr_debug_entries)
 

Variables

struct debug_line_header __packed
 
static struct debug_line_header const default_debug_line_header
 
static ubyte standard_opcode_length []
 
static struct compilation_unit_header default_comp_unit_header
 

Macro Definition Documentation

◆ BUFFER_EXT_DFL_SIZE

#define BUFFER_EXT_DFL_SIZE   (4 * 1024)

Definition at line 32 of file genelf_debug.c.

◆ DW_LNS_num_opcode

#define DW_LNS_num_opcode   (DW_LNS_set_isa + 1)

Definition at line 144 of file genelf_debug.c.

Typedef Documentation

◆ sbyte

typedef int8_t sbyte

Definition at line 39 of file genelf_debug.c.

◆ shalf

typedef int16_t shalf

Definition at line 37 of file genelf_debug.c.

◆ sword

typedef int32_t sword

Definition at line 36 of file genelf_debug.c.

◆ ubyte

typedef uint8_t ubyte

Definition at line 38 of file genelf_debug.c.

◆ uhalf

typedef uint16_t uhalf

Definition at line 35 of file genelf_debug.c.

◆ uword

typedef uint32_t uword

Definition at line 34 of file genelf_debug.c.

Function Documentation

◆ add_compilation_unit()

static void add_compilation_unit ( struct buffer_ext be,
size_t  offset_debug_line 
)
static

Definition at line 446 of file genelf_debug.c.

Here is the call graph for this function:

◆ add_debug_abbrev()

static void add_debug_abbrev ( struct buffer_ext be)
static

Definition at line 433 of file genelf_debug.c.

Here is the call graph for this function:

◆ add_debug_line()

static void add_debug_line ( struct buffer_ext be,
struct debug_entry ent,
size_t  nr_entry,
unsigned long  code_addr 
)
static

Definition at line 399 of file genelf_debug.c.

Here is the call graph for this function:

◆ buffer_ext_add()

static int buffer_ext_add ( struct buffer_ext be,
void *  addr,
size_t  sz 
)
inlinestatic

Definition at line 57 of file genelf_debug.c.

Here is the call graph for this function:

◆ buffer_ext_addr()

static void* buffer_ext_addr ( struct buffer_ext be)
inlinestatic

Definition at line 99 of file genelf_debug.c.

◆ buffer_ext_dump()

static void buffer_ext_dump ( struct buffer_ext be,
const char *  msg 
)
static

Definition at line 48 of file genelf_debug.c.

◆ buffer_ext_init()

static void buffer_ext_init ( struct buffer_ext be)
static

Definition at line 85 of file genelf_debug.c.

◆ buffer_ext_size()

static size_t buffer_ext_size ( struct buffer_ext be)
inlinestatic

Definition at line 93 of file genelf_debug.c.

◆ emit_advance_lineno()

static void emit_advance_lineno ( struct buffer_ext be,
long  delta_lineno 
)
static

Definition at line 257 of file genelf_debug.c.

Here is the call graph for this function:

◆ emit_advance_pc()

static void emit_advance_pc ( struct buffer_ext be,
unsigned long  delta_pc 
)
static

Definition at line 252 of file genelf_debug.c.

Here is the call graph for this function:

◆ emit_extended_opcode()

static void emit_extended_opcode ( struct buffer_ext be,
ubyte  opcode,
void *  data,
size_t  data_len 
)
static

Definition at line 222 of file genelf_debug.c.

Here is the call graph for this function:

◆ emit_lineno_info()

static void emit_lineno_info ( struct buffer_ext be,
struct debug_entry ent,
size_t  nr_entry,
unsigned long  code_addr 
)
static

Definition at line 329 of file genelf_debug.c.

Here is the call graph for this function:

◆ emit_lne_define_filename()

static void emit_lne_define_filename ( struct buffer_ext be,
const char *  filename 
)
static

Definition at line 272 of file genelf_debug.c.

Here is the call graph for this function:

◆ emit_lne_end_of_sequence()

static void emit_lne_end_of_sequence ( struct buffer_ext be)
static

Definition at line 262 of file genelf_debug.c.

Here is the call graph for this function:

◆ emit_lne_set_address()

static void emit_lne_set_address ( struct buffer_ext be,
void *  address 
)
static

Definition at line 289 of file genelf_debug.c.

Here is the call graph for this function:

◆ emit_opcode()

static void emit_opcode ( struct buffer_ext be,
ubyte  opcode 
)
static

Definition at line 233 of file genelf_debug.c.

Here is the call graph for this function:

◆ emit_opcode_signed()

static void emit_opcode_signed ( struct buffer_ext be,
ubyte  opcode,
long  data 
)
static

Definition at line 238 of file genelf_debug.c.

Here is the call graph for this function:

◆ emit_opcode_unsigned()

static void emit_opcode_unsigned ( struct buffer_ext be,
ubyte  opcode,
unsigned long  data 
)
static

Definition at line 245 of file genelf_debug.c.

Here is the call graph for this function:

◆ emit_set_file()

static void emit_set_file ( struct buffer_ext be,
unsigned long  idx 
)
static

Definition at line 267 of file genelf_debug.c.

Here is the call graph for this function:

◆ emit_signed_LEB128()

static void emit_signed_LEB128 ( struct buffer_ext be,
long  data 
)
static

Definition at line 203 of file genelf_debug.c.

Here is the call graph for this function:

◆ emit_string()

static void emit_string ( struct buffer_ext be,
const char *  s 
)
static

Definition at line 186 of file genelf_debug.c.

Here is the call graph for this function:

◆ emit_unsigned_LEB128()

static void emit_unsigned_LEB128 ( struct buffer_ext be,
unsigned long  data 
)
static

Definition at line 191 of file genelf_debug.c.

Here is the call graph for this function:

◆ emit_uword()

static void emit_uword ( struct buffer_ext be,
uword  data 
)
static

Definition at line 181 of file genelf_debug.c.

Here is the call graph for this function:

◆ get_special_opcode()

static ubyte get_special_opcode ( struct debug_entry ent,
unsigned int  last_line,
unsigned long  last_vma 
)
static

Definition at line 295 of file genelf_debug.c.

Here is the call graph for this function:

◆ jit_add_debug_info()

int jit_add_debug_info ( Elf *  e,
uint64_t  code_addr,
void *  debug,
int  nr_debug_entries 
)

Definition at line 486 of file genelf_debug.c.

Here is the call graph for this function:

◆ jit_process_debug_info()

static int jit_process_debug_info ( uint64_t  code_addr,
void *  debug,
int  nr_debug_entries,
struct buffer_ext dl,
struct buffer_ext da,
struct buffer_ext di 
)
static

Definition at line 464 of file genelf_debug.c.

Here is the call graph for this function:

Variable Documentation

◆ __packed

struct compilation_unit_header __packed

◆ default_comp_unit_header

struct compilation_unit_header default_comp_unit_header
static
Initial value:
= {
.total_length = -1,
.version = 2,
.debug_abbrev_offset = 0,
.pointer_size = sizeof(void *)
}

Definition at line 174 of file genelf_debug.c.

◆ default_debug_line_header

struct debug_line_header const default_debug_line_header
static
Initial value:
= {
.total_length = -1,
.version = 2,
.prolog_length = -1,
.minimum_instruction_length = 1,
.default_is_stmt = 1,
.line_base = -5,
.line_range = -14,
.opcode_base = DW_LNS_num_opcode
}
#define DW_LNS_num_opcode
Definition: genelf_debug.c:144

Definition at line 147 of file genelf_debug.c.

◆ standard_opcode_length

ubyte standard_opcode_length[]
static
Initial value:
=
{
0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1
}

Definition at line 158 of file genelf_debug.c.