Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
95526c82
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
95526c82
编写于
1月 16, 2018
作者:
A
Alexander Fedorov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#2556 add DBGEvent
上级
c66c46a6
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
125 addition
and
25 deletion
+125
-25
plugins/org.jkiss.dbeaver.debug.core/src/org/jkiss/dbeaver/debug/DBGBaseController.java
...g.core/src/org/jkiss/dbeaver/debug/DBGBaseController.java
+23
-0
plugins/org.jkiss.dbeaver.debug.core/src/org/jkiss/dbeaver/debug/DBGBaseSession.java
...ebug.core/src/org/jkiss/dbeaver/debug/DBGBaseSession.java
+15
-0
plugins/org.jkiss.dbeaver.debug.core/src/org/jkiss/dbeaver/debug/DBGController.java
...debug.core/src/org/jkiss/dbeaver/debug/DBGController.java
+7
-0
plugins/org.jkiss.dbeaver.debug.core/src/org/jkiss/dbeaver/debug/DBGEvent.java
...aver.debug.core/src/org/jkiss/dbeaver/debug/DBGEvent.java
+30
-2
plugins/org.jkiss.dbeaver.debug.core/src/org/jkiss/dbeaver/debug/DBGEventHandler.java
...bug.core/src/org/jkiss/dbeaver/debug/DBGEventHandler.java
+7
-0
plugins/org.jkiss.dbeaver.debug.core/src/org/jkiss/dbeaver/debug/core/model/DatabaseDebugTarget.java
...g/jkiss/dbeaver/debug/core/model/DatabaseDebugTarget.java
+12
-2
plugins/org.jkiss.dbeaver.ext.postgresql.debug.core/src/org/jkiss/dbeaver/ext/postgresql/debug/internal/impl/PostgreDebugController.java
...ostgresql/debug/internal/impl/PostgreDebugController.java
+1
-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
+22
-16
plugins/org.jkiss.dbeaver.ext.postgresql.debug.core/src/org/jkiss/dbeaver/ext/postgresql/debug/internal/impl/PostgreDebugSessionWorker.java
...gresql/debug/internal/impl/PostgreDebugSessionWorker.java
+8
-4
未找到文件。
plugins/org.jkiss.dbeaver.debug.core/src/org/jkiss/dbeaver/debug/DBGBaseController.java
浏览文件 @
95526c82
...
...
@@ -23,6 +23,7 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
org.eclipse.core.runtime.ListenerList
;
import
org.eclipse.osgi.util.NLS
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
...
...
@@ -41,6 +42,8 @@ public abstract class DBGBaseController implements DBGController {
private
final
Map
<
String
,
Object
>
configuration
=
new
HashMap
<
String
,
Object
>();
private
final
Map
<
Object
,
DBGSession
>
sessions
=
new
HashMap
<
Object
,
DBGSession
>(
1
);
private
ListenerList
<
DBGEventHandler
>
eventHandlers
=
new
ListenerList
<>();
private
DBCExecutionContext
executionContext
;
public
DBGBaseController
(
DBPDataSourceContainer
dataSourceContainer
)
{
...
...
@@ -112,6 +115,10 @@ public abstract class DBGBaseController implements DBGController {
for
(
DBGSession
session
:
values
)
{
session
.
close
();
}
Object
[]
listeners
=
eventHandlers
.
getListeners
();
for
(
Object
listener
:
listeners
)
{
unregisterEventHandler
((
DBGEventHandler
)
listener
);
}
}
@Override
...
...
@@ -180,4 +187,20 @@ public abstract class DBGBaseController implements DBGController {
//throw DBGException?
}
@Override
public
void
registerEventHandler
(
DBGEventHandler
eventHandler
)
{
eventHandlers
.
add
(
eventHandler
);
}
@Override
public
void
unregisterEventHandler
(
DBGEventHandler
eventHandler
)
{
eventHandlers
.
remove
(
eventHandler
);
}
public
void
fireEvent
(
DBGEvent
event
)
{
for
(
DBGEventHandler
eventHandler
:
eventHandlers
)
{
eventHandler
.
handleDebugEvent
(
event
);
}
}
}
plugins/org.jkiss.dbeaver.debug.core/src/org/jkiss/dbeaver/debug/DBGBaseSession.java
0 → 100644
浏览文件 @
95526c82
package
org.jkiss.dbeaver.debug
;
public
abstract
class
DBGBaseSession
implements
DBGSession
{
private
final
DBGBaseController
controller
;
public
DBGBaseSession
(
DBGBaseController
controller
)
{
this
.
controller
=
controller
;
}
public
DBGBaseController
getController
()
{
return
controller
;
}
}
plugins/org.jkiss.dbeaver.debug.core/src/org/jkiss/dbeaver/debug/DBGController.java
浏览文件 @
95526c82
...
...
@@ -86,5 +86,12 @@ public interface DBGController {
void
stepInto
(
Object
sessionKey
)
throws
DBGException
;
void
stepOver
(
Object
sessionKey
)
throws
DBGException
;
void
stepReturn
(
Object
sessionKey
)
throws
DBGException
;
/*
* Events
*/
void
registerEventHandler
(
DBGEventHandler
eventHandler
);
void
unregisterEventHandler
(
DBGEventHandler
eventHandler
);
}
plugins/org.jkiss.dbeaver.debug.core/src/org/jkiss/dbeaver/debug/DBGEvent.java
浏览文件 @
95526c82
...
...
@@ -6,9 +6,37 @@ public class DBGEvent extends EventObject {
private
static
final
long
serialVersionUID
=
1L
;
public
DBGEvent
(
Object
source
)
{
super
(
source
);
public
static
final
int
ATTACH
=
0x0001
;
public
static
final
int
SUSPEND
=
0x0002
;
public
static
final
int
RESUME
=
0x0004
;
public
static
final
int
DETACH
=
0x0008
;
public
static
final
int
UNSPECIFIED
=
0
;
public
static
final
int
STEP_INTO
=
0x0001
;
public
static
final
int
STEP_OVER
=
0x0002
;
public
static
final
int
STEP_RETURN
=
0x0004
;
public
static
final
int
STEP_END
=
0x0008
;
private
int
kind
;
private
int
details
;
public
DBGEvent
(
Object
source
,
int
kind
)
{
this
(
source
,
kind
,
UNSPECIFIED
);
}
public
DBGEvent
(
Object
source
,
int
kind
,
int
details
)
{
super
(
source
);
this
.
kind
=
kind
;
this
.
details
=
details
;
}
public
int
getKind
()
{
return
kind
;
}
public
int
getDetails
()
{
return
details
;
}
}
plugins/org.jkiss.dbeaver.debug.core/src/org/jkiss/dbeaver/debug/DBGEventHandler.java
0 → 100644
浏览文件 @
95526c82
package
org.jkiss.dbeaver.debug
;
public
interface
DBGEventHandler
{
void
handleDebugEvent
(
DBGEvent
event
);
}
plugins/org.jkiss.dbeaver.debug.core/src/org/jkiss/dbeaver/debug/core/model/DatabaseDebugTarget.java
浏览文件 @
95526c82
...
...
@@ -36,12 +36,14 @@ import org.eclipse.debug.core.model.IThread;
import
org.eclipse.osgi.util.NLS
;
import
org.jkiss.dbeaver.debug.DBGController
;
import
org.jkiss.dbeaver.debug.DBGEvent
;
import
org.jkiss.dbeaver.debug.DBGEventHandler
;
import
org.jkiss.dbeaver.debug.DBGException
;
import
org.jkiss.dbeaver.debug.core.DebugCore
;
import
org.jkiss.dbeaver.debug.core.DebugEvents
;
import
org.jkiss.dbeaver.model.runtime.DefaultProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
public
abstract
class
DatabaseDebugTarget
extends
DatabaseDebugElement
implements
IDatabaseDebugTarget
{
public
abstract
class
DatabaseDebugTarget
extends
DatabaseDebugElement
implements
IDatabaseDebugTarget
,
DBGEventHandler
{
private
final
String
modelIdentifier
;
...
...
@@ -64,6 +66,7 @@ public abstract class DatabaseDebugTarget extends DatabaseDebugElement implement
this
.
launch
=
launch
;
this
.
process
=
process
;
this
.
controller
=
controller
;
this
.
controller
.
registerEventHandler
(
this
);
this
.
threads
=
new
ArrayList
<
IThread
>();
}
...
...
@@ -174,6 +177,7 @@ public abstract class DatabaseDebugTarget extends DatabaseDebugElement implement
suspended
=
false
;
try
{
controller
.
detach
(
sessionKey
,
getProgressMonitor
());
controller
.
unregisterEventHandler
(
this
);
}
catch
(
DBGException
e
)
{
String
message
=
NLS
.
bind
(
"Error terminating {0}"
,
getName
());
IStatus
status
=
DebugCore
.
newErrorStatus
(
message
,
e
);
...
...
@@ -285,7 +289,7 @@ public abstract class DatabaseDebugTarget extends DatabaseDebugElement implement
@Override
public
DebugEvent
toDebugEvent
(
DBGEvent
event
)
{
return
new
DebugEvent
(
event
.
getSource
(),
DebugEvent
.
MODEL_SPECIFIC
);
return
new
DebugEvent
(
event
.
getSource
(),
event
.
getKind
(),
event
.
getDetails
()
);
}
@Override
...
...
@@ -297,5 +301,11 @@ public abstract class DatabaseDebugTarget extends DatabaseDebugElement implement
public
IMemoryBlock
getMemoryBlock
(
long
startAddress
,
long
length
)
throws
DebugException
{
return
null
;
}
@Override
public
void
handleDebugEvent
(
DBGEvent
event
)
{
DebugEvent
debugEvent
=
toDebugEvent
(
event
);
DebugEvents
.
fireEvent
(
debugEvent
);
}
}
plugins/org.jkiss.dbeaver.ext.postgresql.debug.core/src/org/jkiss/dbeaver/ext/postgresql/debug/internal/impl/PostgreDebugController.java
浏览文件 @
95526c82
...
...
@@ -155,7 +155,7 @@ public class PostgreDebugController extends DBGBaseController {
@Override
public
PostgreDebugSession
createSession
(
DBGSessionInfo
targetInfo
,
DBCExecutionContext
sessionContext
)
throws
DBGException
{
PostgreDebugSessionInfo
sessionInfo
=
getSessionDescriptor
(
sessionContext
);
PostgreDebugSession
debugSession
=
new
PostgreDebugSession
(
sessionInfo
,
targetInfo
.
getID
());
PostgreDebugSession
debugSession
=
new
PostgreDebugSession
(
this
,
sessionInfo
,
targetInfo
.
getID
());
return
debugSession
;
...
...
plugins/org.jkiss.dbeaver.ext.postgresql.debug.core/src/org/jkiss/dbeaver/ext/postgresql/debug/internal/impl/PostgreDebugSession.java
浏览文件 @
95526c82
...
...
@@ -30,8 +30,11 @@ import java.util.concurrent.FutureTask;
import
java.util.concurrent.locks.ReentrantReadWriteLock
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.debug.DBGBaseController
;
import
org.jkiss.dbeaver.debug.DBGBaseSession
;
import
org.jkiss.dbeaver.debug.DBGBreakpointDescriptor
;
import
org.jkiss.dbeaver.debug.DBGBreakpointProperties
;
import
org.jkiss.dbeaver.debug.DBGEvent
;
import
org.jkiss.dbeaver.debug.DBGException
;
import
org.jkiss.dbeaver.debug.DBGObjectDescriptor
;
import
org.jkiss.dbeaver.debug.DBGSession
;
...
...
@@ -57,7 +60,7 @@ import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
* procedure will be reached <br/>
*
*/
public
class
PostgreDebugSession
implements
DBG
Session
{
public
class
PostgreDebugSession
extends
DBGBase
Session
{
private
static
final
Log
log
=
Log
.
getLog
(
PostgreDebugSession
.
class
);
...
...
@@ -96,7 +99,7 @@ public class PostgreDebugSession implements DBGSession {
private
List
<
PostgreDebugBreakpointDescriptor
>
breakpoints
=
new
ArrayList
<
PostgreDebugBreakpointDescriptor
>(
1
);
private
FutureTask
<
Void
>
task
;
private
FutureTask
<
DBGEvent
>
task
;
private
Thread
workerThread
=
null
;
...
...
@@ -108,7 +111,8 @@ public class PostgreDebugSession implements DBGSession {
* @param sessionDebugInfo - session (debugger client connection) description
* @throws DBGException
*/
public
PostgreDebugSession
(
PostgreDebugSessionInfo
sessionInfo
,
Object
targetId
)
throws
DBGException
{
public
PostgreDebugSession
(
DBGBaseController
controller
,
PostgreDebugSessionInfo
sessionInfo
,
Object
targetId
)
throws
DBGException
{
super
(
controller
);
this
.
sessionInfo
=
sessionInfo
;
this
.
targetId
=
targetId
;
}
...
...
@@ -148,8 +152,9 @@ public class PostgreDebugSession implements DBGSession {
PostgreDebugObjectDescriptor
obj
=
new
PostgreDebugObjectDescriptor
(
OID
,
"ENTRY"
,
"SESSION"
,
"THIS"
,
"PG"
);
addBreakpoint
(
obj
,
properties
);
runAsync
(
SQL_ATTACH
.
replaceAll
(
"\\?sessionid"
,
String
.
valueOf
(
sessionId
)),
String
.
valueOf
(
sessionId
)
+
" global attached to "
+
String
.
valueOf
(
targetId
));
String
sessionParam
=
String
.
valueOf
(
getSessionId
());
String
taskName
=
sessionParam
+
" global attached to "
+
String
.
valueOf
(
targetId
);
runAsync
(
SQL_ATTACH
.
replaceAll
(
"\\?sessionid"
,
sessionParam
),
taskName
,
new
DBGEvent
(
this
,
DBGEvent
.
ATTACH
));
/*if (breakpoint) {
runAsync(SQL_ATTACH_BREAKPOINT.replaceAll("\\?sessionid", String.valueOf(sessionId)),
...
...
@@ -246,19 +251,18 @@ public class PostgreDebugSession implements DBGSession {
@Override
public
void
execContinue
()
throws
DBGException
{
execStep
(
SQL_CONTINUE
,
" continue for "
);
execStep
(
SQL_CONTINUE
,
" continue for "
,
DBGEvent
.
RESUME
);
}
@Override
public
void
execStepInto
()
throws
DBGException
{
execStep
(
SQL_STEP_INTO
,
" step into for "
);
execStep
(
SQL_STEP_INTO
,
" step into for "
,
DBGEvent
.
STEP_INTO
);
}
@Override
public
void
execStepOver
()
throws
DBGException
{
execStep
(
SQL_STEP_OVER
,
" step over for "
);
execStep
(
SQL_STEP_OVER
,
" step over for "
,
DBGEvent
.
STEP_OVER
);
}
...
...
@@ -270,14 +274,15 @@ public class PostgreDebugSession implements DBGSession {
* @param name - session 'name' part
* @throws DBGException
*/
public
void
execStep
(
String
commandSQL
,
String
name
)
throws
DBGException
{
public
void
execStep
(
String
commandSQL
,
String
name
,
int
eventDetail
)
throws
DBGException
{
acquireWriteLock
();
try
{
DBGEvent
event
=
new
DBGEvent
(
this
,
DBGEvent
.
RESUME
,
eventDetail
);
runAsync
(
commandSQL
.
replaceAll
(
"\\?sessionid"
,
String
.
valueOf
(
sessionId
)),
String
.
valueOf
(
sessionId
)
+
name
+
String
.
valueOf
(
targetId
));
String
.
valueOf
(
sessionId
)
+
name
+
String
.
valueOf
(
targetId
)
,
event
);
}
finally
{
lock
.
writeLock
().
unlock
();
...
...
@@ -401,7 +406,7 @@ public class PostgreDebugSession implements DBGSession {
List
<
DBGStackFrame
>
stack
=
new
ArrayList
<
DBGStackFrame
>(
1
);
String
sql
=
SQL_GET_STACK
.
replaceAll
(
"\\?sessionid"
,
String
.
valueOf
(
sessionId
));
String
sql
=
SQL_GET_STACK
.
replaceAll
(
"\\?sessionid"
,
String
.
valueOf
(
getSessionId
()
));
try
(
Statement
stmt
=
getConnection
(
connection
).
createStatement
();
ResultSet
rs
=
stmt
.
executeQuery
(
sql
))
{
while
(
rs
.
next
())
{
int
level
=
rs
.
getInt
(
"level"
);
...
...
@@ -467,7 +472,8 @@ public class PostgreDebugSession implements DBGSession {
if
(
task
.
isDone
())
{
try
{
task
.
get
();
DBGEvent
dbgEvent
=
task
.
get
();
getController
().
fireEvent
(
dbgEvent
);
}
catch
(
InterruptedException
e
)
{
log
.
error
(
"DEBUG INTERRUPT ERROR "
,
e
);
return
false
;
...
...
@@ -499,16 +505,16 @@ public class PostgreDebugSession implements DBGSession {
* @param name
* @throws DBGException
*/
private
void
runAsync
(
String
commandSQL
,
String
name
)
throws
DBGException
{
private
void
runAsync
(
String
commandSQL
,
String
name
,
DBGEvent
event
)
throws
DBGException
{
Connection
connection
=
getConnection
();
try
(
Statement
stmt
=
connection
.
createStatement
())
{
connection
.
setAutoCommit
(
false
);
PostgreDebugSessionWorker
worker
=
new
PostgreDebugSessionWorker
(
connection
,
commandSQL
);
PostgreDebugSessionWorker
worker
=
new
PostgreDebugSessionWorker
(
connection
,
commandSQL
,
event
);
task
=
new
FutureTask
<
Void
>(
worker
);
task
=
new
FutureTask
<
DBGEvent
>(
worker
);
workerThread
=
new
Thread
(
task
);
...
...
plugins/org.jkiss.dbeaver.ext.postgresql.debug.core/src/org/jkiss/dbeaver/ext/postgresql/debug/internal/impl/PostgreDebugSessionWorker.java
浏览文件 @
95526c82
...
...
@@ -23,24 +23,28 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.util.concurrent.Callable
;
public
class
PostgreDebugSessionWorker
implements
Callable
<
Void
>
{
import
org.jkiss.dbeaver.debug.DBGEvent
;
public
class
PostgreDebugSessionWorker
implements
Callable
<
DBGEvent
>
{
private
final
Connection
conn
;
private
final
String
sql
;
private
final
DBGEvent
event
;
public
PostgreDebugSessionWorker
(
Connection
conn
,
String
sqlCommand
)
public
PostgreDebugSessionWorker
(
Connection
conn
,
String
sqlCommand
,
DBGEvent
event
)
{
this
.
conn
=
conn
;
this
.
sql
=
sqlCommand
;
this
.
event
=
event
;
}
@Override
public
Void
call
()
throws
Exception
public
DBGEvent
call
()
throws
Exception
{
try
(
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
executeQuery
(
sql
);
return
null
;
return
event
;
}
catch
(
SQLException
e
)
{
String
message
=
String
.
format
(
"Failed to execute %s"
,
sql
);
throw
new
Exception
(
message
,
e
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录