1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
/*
* pldebugger.h -
*
* Main debugger header
*
* Copyright (c) 2004-2024 EnterpriseDB Corporation. All Rights Reserved.
*
* Licensed under the Artistic License v2.0, see
* https://opensource.org/licenses/artistic-license-2.0
* for full details
*/
#ifndef PLDEBUGGER_H
#define PLDEBUGGER_H
#include "globalbp.h"
#include "storage/lwlock.h"
/*
* We keep one per_session_ctx structure per backend. This structure holds all
* of the stuff that we need to track from one function call to the next.
*/
typedef struct
{
bool step_into_next_func; /* Should we step into the next function? */
int client_r; /* Read stream connected to client */
int client_w; /* Write stream connected to client */
} per_session_ctx_t;
extern per_session_ctx_t per_session_ctx;
/*
* errorHandlerCtx
*
* We use setjmp() and longjmp() to handle network errors. Because we want to
* be able to stack setjmp()/longjmp() savepoints, we define a structure to
* wrap sigjmp_buf's - we have to do that because sigjmp_buf is defined as an
* array on some platforms (like Win32).
*/
typedef struct
{
sigjmp_buf m_savepoint;
} errorHandlerCtx;
extern errorHandlerCtx client_lost;
#define PLDBG_HELP '?'
#define PLDBG_CONTINUE 'c'
#define PLDBG_SET_BREAKPOINT 'b'
#define PLDBG_CLEAR_BREAKPOINT 'f'
#define PLDBG_PRINT_VAR 'p'
#define PLDBG_PRINT_STACK '$'
#define PLDBG_LIST_BREAKPOINTS 'l'
#define PLDBG_STEP_INTO 's'
#define PLDBG_STEP_OVER 'o'
#define PLDBG_LIST '#'
#define PLDBG_INFO_VARS 'i'
#define PLDBG_SELECT_FRAME '^'
#define PLDBG_DEPOSIT 'd'
#define PLDBG_RESTART 'r'
#define PLDBG_STOP 'x'
typedef struct
{
void (* initialize)(void);
bool (* frame_belongs_to_me)(ErrorContextCallback *frame);
void (* send_stack_frame)(ErrorContextCallback *frame);
void (* send_vars)(ErrorContextCallback *frame);
void (* select_frame)(ErrorContextCallback *frame);
void (* print_var)(ErrorContextCallback *frame, const char *var_name, int lineno);
bool (* do_deposit)(ErrorContextCallback *frame, const char *var_name,
int line_number, const char *value);
Oid (* get_func_oid)(ErrorContextCallback *frame);
void (* send_cur_line)(ErrorContextCallback *frame);
} debugger_language_t;
/* in plugin_debugger.c */
extern void initGlobalBreakpoints(void);
extern bool plugin_debugger_main_loop(void);
extern bool breakAtThisLine( Breakpoint ** dst, eBreakpointScope * scope, Oid funcOid, int lineNumber );
extern bool attach_to_proxy( Breakpoint * breakpoint );
extern void setBreakpoint( char * command );
extern void clearBreakpoint( char * command );
extern bool breakpointsForFunction( Oid funcOid );
extern void dbg_send( const char *fmt, ... )
#ifdef PG_PRINTF_ATTRIBUTE
/* This extension allows gcc to check the format string for consistency with
the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)))
#endif
;
extern char * dbg_read_str(void);
extern LWLockId getPLDebuggerLock(void);
/* in plpgsql_debugger.c */
extern void plpgsql_debugger_fini(void);
extern debugger_language_t plpgsql_debugger_lang;
#ifdef INCLUDE_PACKAGE_SUPPORT
extern debugger_language_t spl_debugger_lang;
#endif
#if PG_VERSION_NUM >= 110000
#ifndef TRUE
#define TRUE true
#endif
#ifndef FALSE
#define FALSE false
#endif
#endif
#endif
|