diff --git a/plugin_debugger.c b/plugin_debugger.c
index 6620021..1bd2057 100644
--- a/plugin_debugger.c
+++ b/plugin_debugger.c
@@ -114,6 +114,8 @@ static debugger_language_t *debugger_languages[] = {
 	NULL
 };
 
+static shmem_request_hook_type prev_shmem_request_hook = NULL;
+
 /**********************************************************************
  * Function declarations
  **********************************************************************/
@@ -124,6 +126,7 @@ void _PG_init( void );				/* initialize this module when we are dynamically load
  * Local (hidden) function prototypes
  **********************************************************************/
 
+static void			 pldebugger_shmem_request( void );
 //static char       ** fetchArgNames( PLpgSQL_function * func, int * nameCount );
 static void        * writen( int peer, void * src, size_t len );
 static bool 		 connectAsServer( void );
@@ -154,6 +157,15 @@ void _PG_init( void )
 	for (i = 0; debugger_languages[i] != NULL; i++)
 		debugger_languages[i]->initialize();
 
+	prev_shmem_request_hook = shmem_request_hook;
+	shmem_request_hook = pldebugger_shmem_request;
+}
+
+static void pldebugger_shmem_request( void )
+{
+	if (prev_shmem_request_hook)
+		prev_shmem_request_hook();
+
 	reserveBreakpoints();
 	dbgcomm_reserve();
 }
