## rb-debug

rb-debug — debugging support functions

## Functions

#define | rb_debug()
void | rb_debug_init ()
void | rb_debug_init_match ()
gboolean | rb_debug_matches ()
char ** | rb_debug_get_args ()
void | rb_debug_stop_in_debugger ()
RBProfiler * | rb_profiler_new ()
void | rb_profiler_dump ()
void | rb_profiler_reset ()
void | rb_profiler_free ()
#define | rb_profile_start()
#define | rb_profile_end()

## Types and Values

typedef | RBProfiler

## Description

In addition to a simple debug output system, we have two distinct profiling mechanisms for timing sections of code.

## Functions

### rb_debug()

    #define rb_debug(...) rb_debug_realf (__func__, __FILE__, __LINE__, TRUE, __VA_ARGS__)

If the call site function or file name matches the current debug output settings, the message will be formatted and printed to standard error, including a timestamp, the thread ID, the file and function names, and the line number. A newline will be appended, so the format string shouldn't include one.

#### Parameters

... | printf-style format string followed by any substitution values |

### rb_debug_init ()

    void
    rb_debug_init (gboolean debug);

Sets up debug output, with either all debug enabled or none.

#### Parameters

debug | if TRUE, enable all debug output |

### rb_debug_init_match ()

    void
    rb_debug_init_match (const char *match);

Sets up debug output, enabling debug output from file and function names that contain the specified match string.

Also sets up a GLib log handler that will trigger a debugger break for critical or warning level output if any debug output at all is enabled.

#### Parameters

match | string to match functions and filenames against |

### rb_debug_matches ()

    gboolean
    rb_debug_matches (const char *func,
                      const char *file);

Checks if `file` or `func` matches the current debug output settings.

#### Parameters

func | function to check |
file | filename to check |

#### Returns

`TRUE` if matched

### rb_debug_get_args ()

    char **
    rb_debug_get_args (void);

Constructs arguments to pass to another process using this debug output code that will produce the same debug output settings.

#### Returns

debug output arguments, must be freed with ``g_strfreev()``.

[transfer full]

### rb_debug_stop_in_debugger ()

    void
    rb_debug_stop_in_debugger (void);

Raises a SIGINT signal to get the attention of the debugger. When not running under the debugger, we don't want to stop, so we ignore the signal for just the moment that we raise it.

### rb_profiler_new ()

    RBProfiler *
    rb_profiler_new (const char *name);

Creates a new profiler instance. This can be used to time certain sections of code.

[skip]

#### Parameters

name | profiler name |

#### Returns

profiler instance

### rb_profiler_dump ()

    void
    rb_profiler_dump (RBProfiler *profiler);

Produces debug output for the profiler instance, showing the elapsed time.

[skip]

#### Parameters

profiler | profiler instance |

### rb_profiler_reset ()

    void
    rb_profiler_reset (RBProfiler *profiler);

Resets the elapsed time for the profiler

[skip]

#### Parameters

profiler | profiler instance |

### rb_profiler_free ()

    void
    rb_profiler_free (RBProfiler *profiler);

Frees the memory associated with a profiler instance.

[skip]

#### Parameters

profiler | profiler instance to destroy |

### rb_profile_start()

    #define rb_profile_start(msg) _rb_profile_log (__func__, __FILE__, __LINE__, RB_PROFILE_INDENTATION, "START", msg)

Records a start point for profiling. This profile mechanism operates by issuing file access requests with filenames indicating the profile points. Use 'strace -e access' to gather this information.

#### Parameters

msg | profile point message |

### rb_profile_end()

    #define rb_profile_end(msg)   _rb_profile_log (__func__, __FILE__, __LINE__, -RB_PROFILE_INDENTATION, "END", msg)

Records an end point for profiling. See `rb_profile_start` .

#### Parameters

msg | profile point message |

## Types and Values

### RBProfiler

    typedef struct RBProfiler RBProfiler;