satyr  0.28
Data Structures | Typedefs | Functions
gdb/frame.h File Reference

Single frame of GDB stack trace thread. More...

#include "../report_type.h"
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  sr_gdb_frame
 A function call of a GDB-produced stack trace. More...
 

Typedefs

typedef uint64_t sr_gdb_frame_address_t
 

Functions

struct sr_gdb_framesr_gdb_frame_new (void)
 
void sr_gdb_frame_init (struct sr_gdb_frame *frame)
 
void sr_gdb_frame_free (struct sr_gdb_frame *frame)
 
struct sr_gdb_framesr_gdb_frame_dup (struct sr_gdb_frame *frame, bool siblings)
 
bool sr_gdb_frame_calls_func (struct sr_gdb_frame *frame, const char *function_name,...)
 
int sr_gdb_frame_cmp (struct sr_gdb_frame *frame1, struct sr_gdb_frame *frame2, bool compare_number)
 
int sr_gdb_frame_cmp_distance (struct sr_gdb_frame *frame1, struct sr_gdb_frame *frame2)
 
struct sr_gdb_framesr_gdb_frame_append (struct sr_gdb_frame *dest, struct sr_gdb_frame *item)
 
void sr_gdb_frame_append_to_str (struct sr_gdb_frame *frame, struct sr_strbuf *dest, bool verbose)
 
struct sr_gdb_framesr_gdb_frame_parse (const char **input, struct sr_location *location)
 
int sr_gdb_frame_parse_frame_start (const char **input, uint32_t *number)
 
int sr_gdb_frame_parseadd_operator (const char **input, struct sr_strbuf *target)
 
int sr_gdb_frame_parse_function_name_chunk (const char **input, bool space_allowed, char **target)
 
int sr_gdb_frame_parse_function_name_braces (const char **input, char **target)
 
int sr_gdb_frame_parse_function_name_template (const char **input, char **target)
 
int sr_gdb_frame_parse_function_name_template_args (const char **input, char **target)
 
bool sr_gdb_frame_parse_function_name (const char **input, char **function_name, char **function_type, struct sr_location *location)
 
bool sr_gdb_frame_skip_function_args (const char **input, struct sr_location *location)
 
bool sr_gdb_frame_parse_function_call (const char **input, char **function_name, char **function_type, struct sr_location *location)
 
bool sr_gdb_frame_parse_address_in_function (const char **input, uint64_t *address, char **function_name, char **function_type, struct sr_location *location)
 
bool sr_gdb_frame_parse_file_location (const char **input, char **file, uint32_t *file_line, struct sr_location *location)
 
struct sr_gdb_framesr_gdb_frame_parse_header (const char **input, struct sr_location *location)
 

Detailed Description

Single frame of GDB stack trace thread.

Definition in file gdb/frame.h.

Function Documentation

◆ sr_gdb_frame_append()

struct sr_gdb_frame* sr_gdb_frame_append ( struct sr_gdb_frame dest,
struct sr_gdb_frame item 
)

Appends 'item' at the end of the list 'dest'.

Returns
This function returns the 'dest' frame. If 'dest' is NULL, it returns the 'item' frame.

◆ sr_gdb_frame_append_to_str()

void sr_gdb_frame_append_to_str ( struct sr_gdb_frame frame,
struct sr_strbuf dest,
bool  verbose 
)

Appends the textual representation of the frame to the string buffer.

Parameters
frameIt must be a non-NULL pointer. It's not modified by calling this function.

◆ sr_gdb_frame_calls_func()

bool sr_gdb_frame_calls_func ( struct sr_gdb_frame frame,
const char *  function_name,
  ... 
)

Checks whether the frame represents a call of function with certain function name.

Parameters
frameA stack trace frame.
...Names of source files or shared libaries that should contain the function name. The list needs to be terminated by NULL. Just NULL can be provided, and source file cannot be present in order to succeed. An empty string will cause ANY source file to match and succeed. The name of source file is searched as a substring.
Returns
True if the frame corresponds to a function with function_name, residing in a source file.

◆ sr_gdb_frame_cmp()

int sr_gdb_frame_cmp ( struct sr_gdb_frame frame1,
struct sr_gdb_frame frame2,
bool  compare_number 
)

Compares two frames.

Parameters
frame1It must be non-NULL pointer. It's not modified by calling this function.
frame2It must be non-NULL pointer. It's not modified by calling this function.
compare_numberIndicates whether to include the frame numbers in the comparsion. If set to false, the frame numbers are ignored.
Returns
Returns 0 if the frames are same. Returns negative number if frame1 is found to be 'less' than frame2. Returns positive number if frame1 is found to be 'greater' than frame2.

◆ sr_gdb_frame_cmp_distance()

int sr_gdb_frame_cmp_distance ( struct sr_gdb_frame frame1,
struct sr_gdb_frame frame2 
)

Compares two frames, but only by their function and library names. Two unknown functions ("??") are assumed to be different and unknown library names to be the same.

Parameters
frame1It must be non-NULL pointer. It's not modified by calling this function.
frame2It must be non-NULL pointer. It's not modified by calling this function.
Returns
Returns 0 if the frames are same. Returns negative number if frame1 is found to be 'less' than frame2. Returns positive number if frame1 is found to be 'greater' than frame2.

◆ sr_gdb_frame_dup()

struct sr_gdb_frame* sr_gdb_frame_dup ( struct sr_gdb_frame frame,
bool  siblings 
)

Creates a duplicate of the frame.

Parameters
frameIt must be non-NULL pointer. The frame is not modified by calling this function.
siblingsWhether to duplicate also siblings referenced by frame->next. If false, frame->next is not duplicated for the new frame, but it is set to NULL.
Returns
This function never returns NULL. The returned duplicate frame must be released by calling the function sr_gdb_frame_free().

◆ sr_gdb_frame_free()

void sr_gdb_frame_free ( struct sr_gdb_frame frame)

Releases the memory held by the frame. The frame siblings are not released.

Parameters
frameIf the frame is NULL, no operation is performed.

◆ sr_gdb_frame_init()

void sr_gdb_frame_init ( struct sr_gdb_frame frame)

Initializes all members of the frame structure to their default values. No memory is released, members are simply overwritten. This is useful for initializing a frame structure placed on the stack.

◆ sr_gdb_frame_new()

struct sr_gdb_frame* sr_gdb_frame_new ( void  )

Creates and initializes a new frame structure.

Returns
It never returns NULL. The returned pointer must be released by calling the function sr_gdb_frame_free().

◆ sr_gdb_frame_parse()

struct sr_gdb_frame* sr_gdb_frame_parse ( const char **  input,
struct sr_location location 
)

If the input contains a complete frame, this function parses the frame text, returns it in a structure, and moves the input pointer after the frame. If the input does not contain proper, complete frame, the function does not modify input and returns NULL.

Returns
Allocated pointer with a frame structure. The pointer should be released by sr_gdb_frame_free().
Parameters
locationThe caller must provide a pointer to an instance of sr_location here. When this function returns NULL, the structure will contain the error line, column, and message. The line and column members of the location are gradually increased as the parser handles the input, so the location should be initialized before calling this function to get reasonable values.

◆ sr_gdb_frame_parse_address_in_function()

bool sr_gdb_frame_parse_address_in_function ( const char **  input,
uint64_t *  address,
char **  function_name,
char **  function_type,
struct sr_location location 
)

If the input contains address and function call, parse them, move the input pointer after this sequence, and return true. Otherwise do not modify the input and return false.

If this function returns true, the caller is responsible to free the parameter function.

0x000000322160e7fd in fsync ()
0x000000322222987a in write_to_temp_file (
filename=0x18971b0 "/home/jfclere/.recently-used.xbel",
contents=<value optimized out>, length=29917, error=0x7fff3cbe4110)
Parameters
locationThe caller must provide a pointer to an instance of sr_location here. The line and column members of the location are gradually increased as the parser handles the input, so the location should be initialized before calling this function to get reasonable values. When this function returns false (an error occurred), the structure will contain the error line, column, and message.

◆ sr_gdb_frame_parse_file_location()

bool sr_gdb_frame_parse_file_location ( const char **  input,
char **  file,
uint32_t *  file_line,
struct sr_location location 
)

If the input contains sequence "from path/to/file:fileline" or "at path/to/file:fileline", parse it, move the input pointer after this sequence and return true. Otherwise do not modify the input and return false.

The ':' followed by line number is optional. If it is not present, the fileline is set to -1.

Parameters
locationThe caller must provide a pointer to an instance of sr_location here. The line and column members of the location are gradually increased as the parser handles the input, so the location should be initialized before calling this function to get reasonable values. When this function returns false (an error occurred), the structure will contain the error line, column, and message.

◆ sr_gdb_frame_parse_frame_start()

int sr_gdb_frame_parse_frame_start ( const char **  input,
uint32_t *  number 
)

If the input contains a proper frame start section, parse the frame number, and move the input pointer after this section. Otherwise do not modify input.

Returns
The number of characters parsed from input. 0 if the input does not contain a frame start.
"#1 "
"#255 "

◆ sr_gdb_frame_parse_function_call()

bool sr_gdb_frame_parse_function_call ( const char **  input,
char **  function_name,
char **  function_type,
struct sr_location location 
)

If the input contains proper function call, parse the function name and store it to result, move the input pointer after whole function call, and return true. Otherwise do not modify the input and return false.

If this function returns true, the caller is responsible to free the the function_name.

Parameters
locationThe caller must provide a pointer to an instance of sr_location here. The line and column members of the location are gradually increased as the parser handles the input, so the location should be initialized before calling this function to get reasonable values. When this function returns false (an error occurred), the structure will contain the error line, column, and message.

◆ sr_gdb_frame_parse_function_name()

bool sr_gdb_frame_parse_function_name ( const char **  input,
char **  function_name,
char **  function_type,
struct sr_location location 
)

Parses the function name, which is a part of the frame header, from the input. If the frame header contains also the function type, it's also parsed.

Parameters
function_nameA pointer pointing to an uninitialized pointer. This function allocates a string and sets the pointer to it if it parses the function name from the input successfully. The memory returned this way must be released by the caller using the function free(). If this function returns true, this pointer is guaranteed to be non-NULL.
locationThe caller must provide a pointer to an instance of sr_location here. The line and column members of the location are gradually increased as the parser handles the input, so the location should be initialized before calling this function to get reasonable values. When this function returns false (an error occurred), the structure will contain the error line, column, and message.
Returns
True if the input stream contained a function name, which has been parsed. False otherwise.

◆ sr_gdb_frame_parse_function_name_braces()

int sr_gdb_frame_parse_function_name_braces ( const char **  input,
char **  target 
)

If the input buffer contains part of function name containing braces, for example "(anonymous namespace)", parse it, append the contents to target and move input after the braces. Otherwise do not modify the input and the target.

Returns
The number of characters parsed from input. 0 if the input does not contain a braced part of function name.

◆ sr_gdb_frame_parse_function_name_chunk()

int sr_gdb_frame_parse_function_name_chunk ( const char **  input,
bool  space_allowed,
char **  target 
)

Parses a part of function name from the input.

Parameters
targetPointer to a non-allocated pointer. This function will set the pointer to newly allocated memory containing the name chunk, if it returns positive, nonzero value.
Returns
The number of characters parsed from input. 0 if the input does not contain a part of function name.

◆ sr_gdb_frame_parse_function_name_template()

int sr_gdb_frame_parse_function_name_template ( const char **  input,
char **  target 
)
Returns
The number of characters parsed from input. 0 if the input does not contain a template part of function name.

◆ sr_gdb_frame_parse_function_name_template_args()

int sr_gdb_frame_parse_function_name_template_args ( const char **  input,
char **  target 
)

If the input buffer contains part of function name containing template args, for example " [with Object = bmalloc::Heap; Function = void (bmalloc::Heap::*)()]", parse it, append the contents to the target and move the input after the trailing square brace. Otherwise do not modify the input and the target.

Returns
The number of characters parsed from input. 0 if the input does not contain a template args part of function name.

◆ sr_gdb_frame_parse_header()

struct sr_gdb_frame* sr_gdb_frame_parse_header ( const char **  input,
struct sr_location location 
)

If the input contains proper frame header, this function parses the frame header text, moves the input pointer after the frame header, and returns a frame struct. If the input does not contain proper frame header, this function returns NULL and does not modify input.

Parameters
locationThe caller must provide a pointer to an instance of sr_location here. The line and column members of the location are gradually increased as the parser handles the input, so the location should be initialized before calling this function to get reasonable values. When this function returns false (an error occurred), the structure will contain the error line, column, and message.
Returns
Newly created frame struct or NULL. The returned frame struct should be released by sr_gdb_frame_free().

◆ sr_gdb_frame_parseadd_operator()

int sr_gdb_frame_parseadd_operator ( const char **  input,
struct sr_strbuf target 
)

Parses C++ operator on input. Supports even 'operator new[]' and 'operator delete[]'.

Parameters
targetThe parsed operator name is appened to the string buffer provided, if an operator is found. Otherwise the string buffer is not changed.
Returns
The number of characters parsed from input. 0 if the input does not contain operator.

◆ sr_gdb_frame_skip_function_args()

bool sr_gdb_frame_skip_function_args ( const char **  input,
struct sr_location location 
)

Skips function arguments which are a part of the frame header, in the input stream.

Parameters
locationThe caller must provide a pointer to an instance of sr_location here. The line and column members of the location are gradually increased as the parser handles the input, so the location should be initialized before calling this function to get reasonable values. When this function returns false (an error occurred), the structure will contain the error line, column, and message.