Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
133fa72c
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
133fa72c
编写于
1月 08, 2018
作者:
A
Andrew Khitrin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Typical scenario for PostreDebugSession
上级
1d225f58
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
102 addition
and
9 deletion
+102
-9
plugins/org.jkiss.dbeaver.ext.postgresql.debug.core/src/org/jkiss/dbeaver/ext/postgresql/debug/internal/impl/PostgreDebugSession.java
...t/postgresql/debug/internal/impl/PostgreDebugSession.java
+87
-3
plugins/org.jkiss.dbeaver.ext.postgresql.debug.core/src/org/jkiss/dbeaver/ext/postgresql/debug/internal/impl/PostgreDebugSessionInfo.java
...stgresql/debug/internal/impl/PostgreDebugSessionInfo.java
+15
-6
未找到文件。
plugins/org.jkiss.dbeaver.ext.postgresql.debug.core/src/org/jkiss/dbeaver/ext/postgresql/debug/internal/impl/PostgreDebugSession.java
浏览文件 @
133fa72c
...
...
@@ -42,6 +42,21 @@ import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
/**
* Typical scenario for debug session <br/>
* <br/>
* 0. create session (now it can only attached to target Procedure)<br/><br/>
* 1. attach to target this method attaches to a debugging target and listening on the given port -
* waiting for run procedure in other session(s) debugger client should invoke this function after creation
* also created implicit breakpoint for target procedure, after this call debug session in <b>WAITING</b> state -
* isDone returns false and is isWaiting returns true<br/><br/>
* 2. when target procedure will called debug session implicit breakpoint will be reached
* and session goes in state <b>READY</b> (isDone - true, isWaiting - true) in this state possible to call
* getStack, getVariables, setVariables, setBreakpoint or execStepXXX\continue<br/><br/>
* 3. when execStepXXX or continue will called session goes in <b>WAITING</b> state until next breakpoint or end of
* procedure will be reached <br/>
*
*/
@SuppressWarnings
(
"nls"
)
public
class
PostgreDebugSession
implements
DBGSession
{
...
...
@@ -81,12 +96,21 @@ public class PostgreDebugSession implements DBGSession {
private
List
<
PostgreDebugBreakpoint
>
breakpoints
=
new
ArrayList
<
PostgreDebugBreakpoint
>(
1
);
private
PostgreDebugBreakpoint
entry
;
private
PostgreDebugBreakpoint
entry
=
null
;
private
FutureTask
<
Void
>
task
;
private
Thread
workerThread
=
null
;
/**
* This method attach debug session to debug object (procedure)
* and wait forever while target or any (depend on targetPID) session will run target procedure
*
* @param connection - connection for debug session after attach this connection will forever belong to debug
* @param OID - OID for target procedure
* @param targetPID - target session PID (-1 for any target)
* @throws DBGException
*/
public
void
attach
(
JDBCExecutionContext
connection
,
int
OID
,
int
targetPID
)
throws
DBGException
{
lock
.
writeLock
().
lock
();
...
...
@@ -112,7 +136,7 @@ public class PostgreDebugSession implements DBGSession {
PostgreDebugBreakpointProperties
properties
=
new
PostgreDebugBreakpointProperties
(
true
);
PostgreDebugObject
obj
=
new
PostgreDebugObject
(
OID
,
"ENTRY"
,
"SESSION"
,
"THIS"
,
"PG"
);
entry
=
new
PostgreDebugBreakpoint
(
this
,
obj
,
properties
);
this
.
entry
=
new
PostgreDebugBreakpoint
(
this
,
obj
,
properties
);
runAsync
(
SQL_ATTACH
.
replaceAll
(
"\\?sessionid"
,
String
.
valueOf
(
sessionId
)),
String
.
valueOf
(
sessionId
)
+
" global attached to "
+
String
.
valueOf
(
sessionManagerInfo
.
pid
));
...
...
@@ -133,6 +157,14 @@ public class PostgreDebugSession implements DBGSession {
}
/**
* Create session with two description
* after creation session need to be attached to postgres procedure by attach method
*
* @param sessionManagerInfo - manager (caller connection) description
* @param sessionDebugInfo - session (debugger client connection) description
* @throws DBGException
*/
public
PostgreDebugSession
(
PostgreDebugSessionInfo
sessionManagerInfo
,
PostgreDebugSessionInfo
sessionDebugInfo
)
throws
DBGException
{
this
.
sessionManagerInfo
=
sessionManagerInfo
;
this
.
sessionDebugInfo
=
sessionDebugInfo
;
...
...
@@ -140,10 +172,16 @@ public class PostgreDebugSession implements DBGSession {
}
/**
* @param connectionTarget - DBCExecutionContext of debug client (will be used in debug process)
* @return Connection - java.sql.Connection
* @throws SQLException
*/
private
static
Connection
getConnection
(
DBCExecutionContext
connectionTarget
)
throws
SQLException
{
return
((
JDBCExecutionContext
)
connectionTarget
).
getConnection
(
new
VoidProgressMonitor
());
}
@Override
public
DBGSessionInfo
getSessionInfo
()
{
return
sessionDebugInfo
;
...
...
@@ -212,6 +250,14 @@ public class PostgreDebugSession implements DBGSession {
}
/**
* Execute step SQL command asynchronously, set debug session name to
* [sessionID] name [managerPID]
*
* @param commandSQL - SQL command for execute step
* @param name - session 'name' part
* @throws DBGException
*/
public
void
execStep
(
String
commandSQL
,
String
name
)
throws
DBGException
{
acquireWriteLock
();
...
...
@@ -363,6 +409,12 @@ public class PostgreDebugSession implements DBGSession {
return
stack
;
}
/**
* Return connection used in debug session
*
* @return java.sql.Connection
* @throws DBGException
*/
public
Connection
getConnection
()
throws
DBGException
{
try
{
return
getConnection
(
connection
);
...
...
@@ -382,11 +434,21 @@ public class PostgreDebugSession implements DBGSession {
public
Integer
getSessionId
()
{
return
sessionId
;
}
/**
* Return true if session up and running debug thread
*
* @return boolean
*/
public
boolean
isWaiting
()
{
return
(
task
==
null
?
false
:
!
task
.
isDone
())
&&
(
workerThread
==
null
?
false
:
workerThread
.
isAlive
());
}
/**
* Return true if session waiting target connection (on breakpoint, after step or continue) in debug thread
*
* @return boolean
*/
public
boolean
isDone
(){
if
(
task
==
null
)
...
...
@@ -410,10 +472,22 @@ public class PostgreDebugSession implements DBGSession {
}
/**
* Return true if debug session up and running on server
*
* @return boolean
*/
public
boolean
isAttached
()
{
return
(
connection
!=
null
&&
sessionId
>
0
);
}
/**
* Start thread for SQL command
*
* @param commandSQL
* @param name
* @throws DBGException
*/
private
void
runAsync
(
String
commandSQL
,
String
name
)
throws
DBGException
{
Connection
connection
=
getConnection
();
...
...
@@ -437,6 +511,11 @@ public class PostgreDebugSession implements DBGSession {
}
}
/**
* Try to acquire shared lock
*
* @throws DBGException
*/
private
void
acquireReadLock
()
throws
DBGException
{
try
{
...
...
@@ -466,6 +545,11 @@ public class PostgreDebugSession implements DBGSession {
}
/**
* Try to acquire exclusive lock
*
* @throws DBGException
*/
private
void
acquireWriteLock
()
throws
DBGException
{
try
{
...
...
plugins/org.jkiss.dbeaver.ext.postgresql.debug.core/src/org/jkiss/dbeaver/ext/postgresql/debug/internal/impl/PostgreDebugSessionInfo.java
浏览文件 @
133fa72c
...
...
@@ -26,6 +26,16 @@ import org.jkiss.dbeaver.debug.DBGSessionInfo;
@SuppressWarnings
(
"nls"
)
public
class
PostgreDebugSessionInfo
implements
DBGSessionInfo
{
public
static
final
String
QUERY_PROP
=
"query"
;
public
static
final
String
STATE_PROP
=
"state"
;
public
static
final
String
APP_PROP
=
"application"
;
public
static
final
String
USER_PROP
=
"user"
;
public
static
final
String
PID
=
"pid"
;
public
static
final
String
CREATE_LISTEN
=
"CREATE LISTEN"
;
final
int
pid
;
...
...
@@ -69,13 +79,12 @@ public class PostgreDebugSessionInfo implements DBGSessionInfo {
}
public
Map
<
String
,
Object
>
toMap
()
{
//FIXME: declare constants elsewhere, it is the part of metadata
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"pid"
,
pid
);
map
.
put
(
"user"
,
user
);
map
.
put
(
"application"
,
application
);
map
.
put
(
"state"
,
state
);
map
.
put
(
"query"
,
query
);
map
.
put
(
PID
,
pid
);
map
.
put
(
USER_PROP
,
user
);
map
.
put
(
APP_PROP
,
application
);
map
.
put
(
STATE_PROP
,
state
);
map
.
put
(
QUERY_PROP
,
query
);
return
map
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录