!6638 支持高级包gms_debug

Merge pull request !6638 from james/gms_debug
This commit is contained in:
opengauss_bot
2024-11-22 01:57:00 +00:00
committed by Gitee
82 changed files with 7378 additions and 32 deletions

View File

@ -1147,6 +1147,8 @@ typedef struct PlDebuggerComm {
volatile bool hasClientErrorOccured;
/* true during debug procedure is running */
volatile bool isProcdeureRunning;
/* true if pacakge gms_debug used */
volatile bool isGmsDebug;
volatile uint32 lock; /* 1 means locked, 0 means unlock */
volatile uint64 serverId;
volatile uint64 clientId;
@ -1168,6 +1170,11 @@ typedef struct PlDebuggerComm {
pg_memory_barrier();
return isProcdeureRunning;
}
inline bool isGmsRunning()
{
pg_memory_barrier();
return isGmsDebug;
}
} PlDebuggerComm;
typedef struct knl_g_pldebug_context {

View File

@ -1651,6 +1651,11 @@ typedef struct knl_u_plpgsql_context {
bool has_step_into;
/*This is a temporary comm_id, because when gms_debug is enabled,
it does not immediately bind to a specific function,
so a temporary id is needed as a transition.*/
int gms_debug_idx;
/* dbe.output buffer limit */
uint32 dbe_output_buffer_limit;
Oid running_pkg_oid;

View File

@ -74,6 +74,7 @@ extern RegProcedure get_oprrest(Oid opno);
extern RegProcedure get_oprjoin(Oid opno);
extern char* get_func_name(Oid funcid);
extern Oid get_func_namespace(Oid funcid);
extern Oid get_func_owner(Oid funcid);
extern Oid get_func_rettype(Oid funcid);
extern int get_func_nargs(Oid funcid);
extern Oid get_func_signature(Oid funcid, Oid** argtypes, int* nargs);

View File

@ -0,0 +1,53 @@
/* ---------------------------------------------------------------------------------------
*
* pl_debug.h
* Declarations for operations on log sequence numbers (LSNs) of
* PostgreSQL.
*
* Portions Copyright (c) 2020 Huawei Technologies Co.,Ltd.
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* src/include/utils/pl_debug.h
*
* ---------------------------------------------------------------------------------------
*/
#ifndef PL_DEBUG_H
#define PL_DEBUG_H
#include "utils/plpgsql.h"
#define DEBUG_REASON_NONE 0
#define DEBUG_REASON_INTERPRETER_STARTING 1
#define DEBUG_REASON_BREAKPOINT 2
#define DEBUG_REASON_ENTER 3
#define DEBUG_REASON_RETURN 4
#define DEBUG_REASON_FINISH 5
#define DEBUG_REASON_LINE 6
#define DEBUG_REASON_INTERRUPT 7
#define DEBUG_REASON_EXCEPTION 8
#define DEBUG_REASON_EXIT 9
#define DEBUG_REASON_KNL_EXIT 10
#define DEBUG_REASON_HANDLER 11
#define DEBUG_REASON_TIMEOUT 12
#define DEBUG_REASON_INSTANTIATE 13
#define DEBUG_REASON_ABORT 14
typedef struct {
char* nodename;
int port;
Oid funcoid;
} DebuggerServerInfo;
extern void debug_server_rec_msg(DebugInfo* debug, char* firstChar);
extern void debug_server_send_msg(DebugInfo* debug, const char* msg, int msg_len);
extern void debug_client_rec_msg(DebugClientInfo* client);
extern void debug_client_send_msg(DebugClientInfo* client, char first_char, char* msg, int msg_len);
extern void init_pldebug_htcl();
extern bool AcquireDebugCommIdx(int commIdx);
extern void check_debugger_valid(int commidx);
extern void attach_session(int commidx, uint64 sid);
extern bool CheckPlpgsqlFunc(Oid funcoid, bool report_error = true);
extern DebugClientInfo* InitDebugClient(int comm_idx);
#endif /* PL_DEBUG_H */

View File

@ -1685,6 +1685,18 @@ const char DEBUG_STEP_INTO_HEADER_AFTER = 'S';
const char DEBUG_BACKTRACE_HEADER = 't';
const char DEBUG_SET_VARIABLE_HEADER = 'h';
const char DEBUG_INFOCODE_HEADER = 'i';
const char GMS_DEBUG_NEXT_HEADER = 'd';
const char GMS_DEBUG_NEXT_HEADER_AFTER = 'D';
const char GMS_DEBUG_STEP_INTO_HEADER = 'j';
const char GMS_DEBUG_STEP_INTO_HEADER_AFTER = 'J';
const char GMS_DEBUG_FINISH_HEADER = 'k';
const char GMS_DEBUG_FINISH_HEADER_AFTER = 'K';
const char GMS_DEBUG_ABORT_HEADER = 'l';
const char GMS_DEBUG_ABORT_HEADER_AFTER = 'L';
const char GMS_DEBUG_CONTINUE_HEADER = 'o';
const char GMS_DEBUG_CONTINUE_HEADER_AFTER = 'O';
const char GMS_DEBUG_RUNTIMEINFO_HEADER = 'm';
const char GMS_DEBUG_ADDBREAKPOINT_HEADER = 'x';
/* server return message */
const int DEBUG_SERVER_SUCCESS = 0;
@ -1778,6 +1790,7 @@ void server_pass_upper_debug_opt(DebugInfo* debug);
void clean_up_debug_client(bool hasError = false);
void clean_up_debug_server(DebugInfo* debug, bool sessClose, bool hasError);
void server_send_end_msg(DebugInfo* debug);
void server_send_gms_end_msg(DebugInfo* debug);
int GetValidDebugCommIdx();
void WaitSendMsg(int commIdx, bool isClient, char** destBuffer, int* destLen);
bool WakeUpReceiver(int commIdx, bool isClient);
@ -1786,11 +1799,13 @@ extern void ReportInvalidMsg(const char* buf);
extern char* AssignStr(char* src, bool copy = true);
extern PlDebugEntry* has_debug_func(Oid key, bool* found);
extern bool delete_debug_func(Oid key);
extern void add_gms_debug_func(Oid funcOid, int commIdx);
extern void RecvUnixMsg(const char* buf, int bufLen, char* destBuf, int destLen);
extern char* ResizeDebugBufferIfNecessary(char* buffer, int* oldSize, int needSize);
extern void ReleaseDebugCommIdx(int idx);
extern void SendUnixMsg(int socket, const char* val, int len, bool is_client);
extern List* collect_breakable_line(PLpgSQL_function* func);
extern bool SetDebugCommGmsUsed(int commIdx, bool flag);
/**********************************************************************
* Function declarations