Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
6292027d
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,发现更多精彩内容 >>
提交
6292027d
编写于
1月 07, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/devel' into devel
上级
d1f86e15
bad913c9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
63 addition
and
40 deletion
+63
-40
plugins/org.jkiss.dbeaver.ext.postgresql.debug.core/src/org/jkiss/dbeaver/ext/postgresql/debug/internal/console/Debugger.java
...eaver/ext/postgresql/debug/internal/console/Debugger.java
+3
-1
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
+54
-37
plugins/org.jkiss.dbeaver.ext.postgresql.debug.core/src/org/jkiss/dbeaver/ext/postgresql/debug/internal/impl/PostgreDebugSessionManager.java
...resql/debug/internal/impl/PostgreDebugSessionManager.java
+6
-2
未找到文件。
plugins/org.jkiss.dbeaver.ext.postgresql.debug.core/src/org/jkiss/dbeaver/ext/postgresql/debug/internal/console/Debugger.java
浏览文件 @
6292027d
...
...
@@ -28,6 +28,7 @@ import org.jkiss.dbeaver.debug.DBGSession;
import
org.jkiss.dbeaver.debug.DBGStackFrame
;
import
org.jkiss.dbeaver.debug.DBGVariable
;
import
org.jkiss.dbeaver.ext.postgresql.debug.internal.impl.*
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext
;
@SuppressWarnings
(
"nls"
)
public
class
Debugger
{
...
...
@@ -726,7 +727,8 @@ public class Debugger {
System
.
out
.
println
(
"Waiting for target session ..."
);
debugSessionA
.
attach
(
false
);
//FIXME:AF: Andrew, please migrate to attach(JDBCExecutionContext connection,int OID,int targetPID) API
// debugSessionA.attach(false);
break
;
...
...
plugins/org.jkiss.dbeaver.ext.postgresql.debug.core/src/org/jkiss/dbeaver/ext/postgresql/debug/internal/impl/PostgreDebugSession.java
浏览文件 @
6292027d
...
...
@@ -18,6 +18,7 @@
package
org.jkiss.dbeaver.ext.postgresql.debug.internal.impl
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.debug.*
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContext
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext
;
...
...
@@ -33,15 +34,17 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
@SuppressWarnings
(
"nls"
)
public
class
PostgreDebugSession
implements
DBGSession
<
PostgreDebugSessionInfo
,
PostgreDebugObject
,
Integer
,
Integer
>
{
private
static
final
Log
log
=
Log
.
getLog
(
PostgreDebugSession
.
class
);
private
final
PostgreDebugSessionInfo
sessionManagerInfo
;
private
final
PostgreDebugSessionInfo
sessionDebugInfo
;
private
final
JDBCExecutionContext
connection
;
private
JDBCExecutionContext
connection
=
null
;
private
final
String
title
;
private
final
int
sessionId
;
private
int
sessionId
=
-
1
;
private
static
final
String
SQL_ATTACH
=
"select pldbg_wait_for_target(?sessionid)"
;
...
...
@@ -66,45 +69,50 @@ public class PostgreDebugSession implements DBGSession<PostgreDebugSessionInfo,
private
final
ReentrantReadWriteLock
lock
=
new
ReentrantReadWriteLock
(
true
);
private
List
<
PostgreDebugBreakpoint
>
breakpoints
=
new
ArrayList
<
PostgreDebugBreakpoint
>(
1
);
private
PostgreDebugBreakpoint
entry
;
private
FutureTask
<
Void
>
task
;
private
Thread
workerThread
=
null
;
private
int
listen
()
throws
DBGException
{
acquireWriteLock
();
try
(
Statement
stmt
=
getConnection
(
connection
).
createStatement
())
{
public
void
attach
(
JDBCExecutionContext
connection
,
int
OID
,
int
targetPID
)
throws
DBGException
{
ResultSet
rs
=
stmt
.
executeQuery
(
SQL_LISTEN
);
lock
.
writeLock
().
lock
(
);
if
(
rs
.
next
())
{
try
{
this
.
connection
=
connection
;
try
(
Statement
stmt
=
getConnection
(
connection
).
createStatement
())
{
getConnection
(
connection
).
setClientInfo
(
"ApplicationName"
,
"Debug Mode : "
+
String
.
valueOf
(
sessionId
));
return
rs
.
getInt
(
"sessionid"
);
ResultSet
rs
=
stmt
.
executeQuery
(
SQL_LISTEN
);
}
else
{
if
(
rs
.
next
())
{
throw
new
DBGException
(
"Unable to create debug instance"
);
getConnection
(
connection
).
setClientInfo
(
"ApplicationName"
,
"Debug Mode : "
+
String
.
valueOf
(
sessionId
));
sessionId
=
rs
.
getInt
(
"sessionid"
);
}
}
catch
(
SQLException
e
)
{
throw
new
DBGException
(
"SQL error"
,
e
);
}
finally
{
lock
.
writeLock
().
unlock
();
}
}
else
{
}
throw
new
DBGException
(
"Unable to create debug instance"
);
public
void
attach
(
boolean
breakpoint
)
throws
DBGException
{
}
acquireWriteLock
();
}
catch
(
SQLException
e
)
{
throw
new
DBGException
(
"SQL error"
,
e
);
}
try
{
PostgreDebugBreakpointProperties
properties
=
new
PostgreDebugBreakpointProperties
(
true
);
PostgreDebugObject
obj
=
new
PostgreDebugObject
(
OID
,
"ENTRY"
,
"SESSION"
,
"THIS"
,
"PG"
);
entry
=
new
PostgreDebugBreakpoint
(
this
,
obj
,
properties
);
runAsync
(
SQL_ATTACH
.
replaceAll
(
"\\?sessionid"
,
String
.
valueOf
(
sessionId
)),
String
.
valueOf
(
sessionId
)
+
" global attached to "
+
String
.
valueOf
(
sessionManagerInfo
.
pid
));
if
(
breakpoint
)
{
/*
if (breakpoint) {
runAsync(SQL_ATTACH_BREAKPOINT.replaceAll("\\?sessionid", String.valueOf(sessionId)),
String.valueOf(sessionId) + " breakpoint attached to "
+ String.valueOf(sessionManagerInfo.pid));
...
...
@@ -112,7 +120,7 @@ public class PostgreDebugSession implements DBGSession<PostgreDebugSessionInfo,
} else {
runAsync(SQL_ATTACH.replaceAll("\\?sessionid", String.valueOf(sessionId)),
String.valueOf(sessionId) + " global attached to " + String.valueOf(sessionManagerInfo.pid));
}
}
*/
}
finally
{
lock
.
writeLock
().
unlock
();
...
...
@@ -120,13 +128,11 @@ public class PostgreDebugSession implements DBGSession<PostgreDebugSessionInfo,
}
public
PostgreDebugSession
(
PostgreDebugSessionInfo
sessionManagerInfo
,
PostgreDebugSessionInfo
sessionDebugInfo
,
JDBCExecutionContext
connection
)
throws
DBGException
{
public
PostgreDebugSession
(
PostgreDebugSessionInfo
sessionManagerInfo
,
PostgreDebugSessionInfo
sessionDebugInfo
)
throws
DBGException
{
this
.
sessionManagerInfo
=
sessionManagerInfo
;
this
.
sessionDebugInfo
=
sessionDebugInfo
;
this
.
connection
=
connection
;
this
.
title
=
sessionManagerInfo
.
application
;
sessionId
=
listen
();
}
private
static
Connection
getConnection
(
DBCExecutionContext
connectionTarget
)
throws
SQLException
{
...
...
@@ -243,15 +249,11 @@ public class PostgreDebugSession implements DBGSession<PostgreDebugSessionInfo,
try
{
try
{
if
(!
isDone
())
{
task
.
cancel
(
true
);
}
}
catch
(
DBGException
e1
)
{
e1
.
printStackTrace
();
}
connection
.
close
();
connection
.
close
();
}
finally
{
lock
.
writeLock
().
unlock
();
...
...
@@ -376,7 +378,7 @@ public class PostgreDebugSession implements DBGSession<PostgreDebugSessionInfo,
return
(
task
==
null
?
false
:
!
task
.
isDone
())
&&
(
workerThread
==
null
?
false
:
workerThread
.
isAlive
());
}
public
boolean
isDone
()
throws
DBGException
{
public
boolean
isDone
(){
if
(
task
==
null
)
return
true
;
...
...
@@ -385,9 +387,10 @@ public class PostgreDebugSession implements DBGSession<PostgreDebugSessionInfo,
try
{
task
.
get
();
}
catch
(
InterruptedException
e
)
{
throw
new
DBGException
(
"SQL error"
,
e
);
log
.
error
(
"DEBUG INTERRUPT ERROR "
,
e
);
return
false
;
}
catch
(
ExecutionException
e
)
{
System
.
out
.
println
(
"WARNING "
+
e
.
getMessage
()
);
log
.
error
(
"DEBUG WARNING "
,
e
);
return
false
;
}
return
true
;
...
...
@@ -397,6 +400,10 @@ public class PostgreDebugSession implements DBGSession<PostgreDebugSessionInfo,
return
false
;
}
public
boolean
isAttached
()
{
return
(
connection
!=
null
&&
sessionId
>
0
);
}
private
void
runAsync
(
String
commandSQL
,
String
name
)
throws
DBGException
{
...
...
@@ -433,6 +440,11 @@ public class PostgreDebugSession implements DBGSession<PostgreDebugSessionInfo,
}
if
(!
isAttached
())
{
lock
.
readLock
().
unlock
();
throw
new
DBGException
(
"Debug session not attached"
);
}
if
(
isWaiting
())
{
lock
.
readLock
().
unlock
();
throw
new
DBGException
(
"Debug session in waiting state"
);
...
...
@@ -454,6 +466,11 @@ public class PostgreDebugSession implements DBGSession<PostgreDebugSessionInfo,
}
catch
(
InterruptedException
e1
)
{
throw
new
DBGException
(
e1
.
getMessage
());
}
if
(!
isAttached
())
{
lock
.
writeLock
().
unlock
();
throw
new
DBGException
(
"Debug session not attached"
);
}
if
(
isWaiting
())
{
lock
.
writeLock
().
unlock
();
...
...
plugins/org.jkiss.dbeaver.ext.postgresql.debug.core/src/org/jkiss/dbeaver/ext/postgresql/debug/internal/impl/PostgreDebugSessionManager.java
浏览文件 @
6292027d
...
...
@@ -141,8 +141,12 @@ public class PostgreDebugSessionManager implements DBGSessionManager<Integer, In
PostgreDebugSessionInfo
targetInfo
=
getSessionInfo
(
connectionTarget
);
PostgreDebugSession
debugSession
=
new
PostgreDebugSession
(
getSessionInfo
(
this
.
context
),
targetInfo
,
(
JDBCExecutionContext
)
connectionTarget
);
PostgreDebugSession
debugSession
=
new
PostgreDebugSession
(
getSessionInfo
(
this
.
context
),
targetInfo
);
debugSession
.
attach
((
JDBCExecutionContext
)
connectionTarget
,
16749
,
-
1
);
//FIXME 16749 - OID for debug proc
//FIXME -1 - target PID (-1 for ANY PID)
sessions
.
put
(
targetInfo
.
getPid
(),
debugSession
);
return
debugSession
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录