satyr 0.43
Loading...
Searching...
No Matches
thread.h File Reference

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

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

Go to the source code of this file.

Data Structures

struct  sr_gdb_thread
 A thread of execution of a GDB-produced stack trace. More...

Functions

struct sr_gdb_threadsr_gdb_thread_new (void)
void sr_gdb_thread_init (struct sr_gdb_thread *thread)
void sr_gdb_thread_free (struct sr_gdb_thread *thread)
struct sr_gdb_threadsr_gdb_thread_dup (struct sr_gdb_thread *thread, bool siblings)
int sr_gdb_thread_cmp (struct sr_gdb_thread *thread1, struct sr_gdb_thread *thread2)
struct sr_gdb_threadsr_gdb_thread_append (struct sr_gdb_thread *dest, struct sr_gdb_thread *item)
void sr_gdb_thread_quality_counts (struct sr_gdb_thread *thread, int *ok_count, int *all_count)
float sr_gdb_thread_quality (struct sr_gdb_thread *thread)
bool sr_gdb_thread_remove_frame (struct sr_gdb_thread *thread, struct sr_gdb_frame *frame)
bool sr_gdb_thread_remove_frames_above (struct sr_gdb_thread *thread, struct sr_gdb_frame *frame)
void sr_gdb_thread_remove_frames_below_n (struct sr_gdb_thread *thread, int n)
void sr_gdb_thread_append_to_str (struct sr_gdb_thread *thread, GString *dest, bool verbose)
struct sr_gdb_threadsr_gdb_thread_parse (const char **input, struct sr_location *location)
int sr_gdb_thread_parse_lwp (const char **input, uint32_t *tid)
int sr_gdb_thread_skip_lwp (const char **input)
struct sr_gdb_threadsr_gdb_thread_parse_funs (const char *input)
char * sr_gdb_thread_format_funs (struct sr_gdb_thread *thread)
void sr_gdb_thread_set_libnames (struct sr_gdb_thread *thread, struct sr_gdb_sharedlib *libs)
struct sr_gdb_threadsr_gdb_thread_get_optimized (struct sr_gdb_thread *thread, struct sr_gdb_sharedlib *libs, int max_frames)

Detailed Description

Single thread of execution of GDB stack trace.

Definition in file gdb/thread.h.

Function Documentation

◆ sr_gdb_thread_append()

struct sr_gdb_thread * sr_gdb_thread_append ( struct sr_gdb_thread * dest,
struct sr_gdb_thread * item )

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

Returns
This function returns the 'dest' thread.

◆ sr_gdb_thread_append_to_str()

void sr_gdb_thread_append_to_str ( struct sr_gdb_thread * thread,
GString * dest,
bool verbose )

Appends a textual representation of 'thread' to the 'str'.

◆ sr_gdb_thread_cmp()

int sr_gdb_thread_cmp ( struct sr_gdb_thread * thread1,
struct sr_gdb_thread * thread2 )

Compares two threads. When comparing the threads, it compares also their frames, including the frame numbers.

Returns
Returns 0 if the threads are same. Returns negative number if t1 is found to be 'less' than t2. Returns positive number if t1 is found to be 'greater' than t2.

◆ sr_gdb_thread_dup()

struct sr_gdb_thread * sr_gdb_thread_dup ( struct sr_gdb_thread * thread,
bool siblings )

Creates a duplicate of the thread.

Parameters
threadIt must be non-NULL pointer. The thread is not modified by calling this function.
siblingsWhether to duplicate also siblings referenced by thread->next. If false, thread->next is not duplicated for the new frame, but it is set to NULL.

◆ sr_gdb_thread_format_funs()

char * sr_gdb_thread_format_funs ( struct sr_gdb_thread * thread)

Prepare a string representing thread which contains just the function and library names. This can be used to store only data necessary for comparison.

Returns
Newly allocated string, which should be released by calling g_free(). The string can be parsed by sr_gdb_thread_parse_funs().

◆ sr_gdb_thread_free()

void sr_gdb_thread_free ( struct sr_gdb_thread * thread)

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

Parameters
threadIf thread is NULL, no operation is performed.

◆ sr_gdb_thread_get_optimized()

struct sr_gdb_thread * sr_gdb_thread_get_optimized ( struct sr_gdb_thread * thread,
struct sr_gdb_sharedlib * libs,
int max_frames )

Return copy of the thread optimized for comparison.

◆ sr_gdb_thread_init()

void sr_gdb_thread_init ( struct sr_gdb_thread * thread)

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

◆ sr_gdb_thread_new()

struct sr_gdb_thread * sr_gdb_thread_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_thread_free().

◆ sr_gdb_thread_parse()

struct sr_gdb_thread * sr_gdb_thread_parse ( const char ** input,
struct sr_location * location )

If the input contains proper thread with frames, parse the thread, move the input pointer after the thread, and return a structure representing the thread. Otherwise to not modify the input pointer and return NULL.

Parameters
locationThe caller must provide a pointer to struct sr_location here. The line and column members are gradually increased as the parser handles the input, keep this in mind to get reasonable values. When this function returns NULL (an error occurred), the structure will contain the error line, column, and message.
Returns
NULL or newly allocated structure, which should be released by calling sr_gdb_thread_free().

◆ sr_gdb_thread_parse_funs()

struct sr_gdb_thread * sr_gdb_thread_parse_funs ( const char * input)

Create a thread from function and library names.

Parameters
inputString containing function names and library names separated by space, one frame per line.
Returns
Newly allocated structure, which should be released by calling sr_gdb_thread_free().

◆ sr_gdb_thread_parse_lwp()

int sr_gdb_thread_parse_lwp ( const char ** input,
uint32_t * tid )

If the input contains a LWP section in form of "(LWP [0-9]+), move the input pointer after this section. Otherwise do not modify input.

Parameters
tidCan be NULL. If not NULL, the parsed [0-9]+ value is stored there.
Returns
The number of characters parsed from input. 0 if the input does not contain a LWP section.

◆ sr_gdb_thread_quality()

float sr_gdb_thread_quality ( struct sr_gdb_thread * thread)

Returns the quality of the thread. The quality is the ratio of the number of frames with function name fully known to the number of all frames. This function does not take into account that some frames are more important than others.

Parameters
threadMust be a non-NULL pointer. It's not modified in this function.
Returns
A number between 0 and 1. 0 means the lowest quality, 1 means full thread stacktrace is known. If the thread contains no frames, this function returns 1.

◆ sr_gdb_thread_quality_counts()

void sr_gdb_thread_quality_counts ( struct sr_gdb_thread * thread,
int * ok_count,
int * all_count )

Counts the number of 'good' frames and the number of all frames in a thread. Good means that the function name is known (so it's not just '??').

Parameters
ok_count
all_countNot zeroed. This function just adds the numbers to ok_count and all_count.

◆ sr_gdb_thread_remove_frame()

bool sr_gdb_thread_remove_frame ( struct sr_gdb_thread * thread,
struct sr_gdb_frame * frame )

Removes the frame from the thread and then deletes it.

Returns
True if the frame was found in the thread and removed and deleted. False if the frame was not found in the thread.

◆ sr_gdb_thread_remove_frames_above()

bool sr_gdb_thread_remove_frames_above ( struct sr_gdb_thread * thread,
struct sr_gdb_frame * frame )

Removes all the frames from the thread that are above certain frame.

Returns
True if the frame was found, and all the frames that were above the frame in the thread were removed from the thread and then deleted. False if the frame was not found in the thread.

◆ sr_gdb_thread_remove_frames_below_n()

void sr_gdb_thread_remove_frames_below_n ( struct sr_gdb_thread * thread,
int n )

Keeps only the top n frames in the thread.

◆ sr_gdb_thread_set_libnames()

void sr_gdb_thread_set_libnames ( struct sr_gdb_thread * thread,
struct sr_gdb_sharedlib * libs )

Set library names in all frames in the thread according to the the sharedlib data.

◆ sr_gdb_thread_skip_lwp()

int sr_gdb_thread_skip_lwp ( const char ** input)

This functions is an alias to sr_gdb_thread_parse_lwp(input, NULL);