Skip to content

Commit 36f4793

Browse files
committed
implement callstack; tooltips in locals; listview event fix
1 parent 1050858 commit 36f4793

13 files changed

+450
-131
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
# 忽略烦人的vbw
2+
*.vbw
13

4+
# 不要理自动备份的文件
5+
Vb_autoBak/

DarkImageButton.ctl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Private Sub labTip_MouseUp(Button As Integer, Shift As Integer, X As Single, Y A
111111
End Sub
112112

113113
Private Sub tmrSetColor_Timer()
114-
Dim pt As Point
114+
Dim pt As POINT
115115
Dim Target As Long
116116

117117
If Not Enabled Then
@@ -136,9 +136,9 @@ Private Sub tmrSetColor_Timer()
136136
BackB = MOUSEIN_B
137137
End If
138138
Else
139-
BackR = BackR - 1
140-
BackG = BackG - 1
141-
BackB = BackB - 1
139+
BackR = BackR - (MOUSEIN_R - NORMAL_R) / 30
140+
BackG = BackG - (MOUSEIN_G - NORMAL_G) / 30
141+
BackB = BackB - (MOUSEIN_B - NORMAL_B) / 30
142142
If BackR < NORMAL_R Or BackG < NORMAL_G Or BackB < NORMAL_B Then
143143
BackR = NORMAL_R
144144
BackG = NORMAL_G
@@ -211,7 +211,7 @@ End Sub
211211

212212
Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
213213
If Button = vbLeftButton Then
214-
Dim pt As Point
214+
Dim pt As POINT
215215
Dim Target As Long
216216

217217
GetCursorPos pt

DarkListView.ctl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ Public Sub RaiseClick(iItem As Long, iSubItem As Long, X As Long, Y As Long)
9393
RaiseEvent Click(iItem, iSubItem, X, Y)
9494
End Sub
9595

96+
'Please note that this function is for internal usage only and is NOT suggested to call directly
9697
Public Sub RaiseDoubleClick(iItem As Long, iSubItem As Long, X As Long, Y As Long)
9798
RaiseEvent DoubleClick(iItem, iSubItem, X, Y)
9899
End Sub
99100

100101
Public Function AddColumnHeader(Text As String, Optional Width As Integer = 75, Optional Index As Long = -1) As Long
101-
102102
Dim lvCol As LVCOLUMN
103103
Dim tmpStr() As Byte
104104

@@ -317,7 +317,7 @@ Private Sub UserControl_Initialize()
317317
0, 0, UserControl.ScaleWidth / Screen.TwipsPerPixelX, _
318318
UserControl.ScaleHeight / Screen.TwipsPerPixelY, UserControl.hWnd, 0, App.hInstance, 0) 'Or WS_BORDER
319319

320-
SetPropA lvHwnd, "ID", CtlListPushBack(Me)
320+
SetPropA lvHwnd, "ID", ByVal CtlListPushBack(Me)
321321
SetPropA lvHwnd, "PARENT_CTL", UserControl.hWnd
322322

323323
SendMessageA lvHwnd, LVM_SETBKCOLOR, ByVal 0, ByVal RGB(51, 51, 55)
@@ -415,6 +415,10 @@ Public Property Get ListViewHwnd() As Long
415415
ListViewHwnd = lvHwnd
416416
End Property
417417

418+
Public Property Get hWnd() As Long
419+
hWnd = UserControl.hWnd
420+
End Property
421+
418422
'Initialize Properties for User Control
419423
Private Sub UserControl_InitProperties()
420424
m_FullRowSelect = m_def_FullRowSelect

DragControlsIDE.exe

4 KB
Binary file not shown.

DragControlsIDE.vbp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Module=modTreeViewProc; modTreeViewProc.bas
5353
UserControl=DarkTreeView.ctl
5454
Form=frmCreateOptions.frm
5555
Form=frmSaveBox.frm
56+
Module=modTooltips; modTooltips.bas
5657
ResFile32="DragControlsIDE.res"
5758
IconForm="frmMain"
5859
Startup="frmMain"

DragControlsIDE.vbw

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ propMenuItems = 111, 43, 1512, 799, C, 295, 129, 1296, 754, C
1515
frmPopupMenu = 83, 74, 1476, 830, C, 52, 83, 1287, 756, C
1616
DarkListBox = 146, 197, 1389, 850, C, 67, 159, 1319, 832, C
1717
modListBoxRedrawProc = 24, 153, 1454, 732, C
18-
DarkListView = 80, 115, 1336, 853, C, 541, 254, 1328, 746, C
18+
DarkListView = 120, 64, 1376, 633, C, 541, 254, 1328, 746, C
1919
modListViewProc = 93, 200, 1393, 809, C
2020
DarkHScrollBar = 275, 223, 1527, 876, C, 76, 206, 1328, 879, C
21-
frmMain = 82, 98, 1486, 716, , 10, 9, 1250, 629, C
21+
frmMain = -118, 18, 1350, 629, , 10, 9, 1250, 629, C
2222
modMain = 62, 84, 1463, 735, C
2323
frmCodeWindow = 17, 39, 1358, 762, C, 115, 152, 1397, 714, C
24-
modConfig = 98, 125, 1446, 922, C
24+
modConfig = 98, 125, 1446, 922,
2525
frmStartupLogo = 132, 195, 1414, 750, C, 96, 96, 849, 426, C
2626
frmControlBox = 737, 289, 1945, 949, C, 125, 95, 1407, 650, C
2727
frmWindowContainer = 0, 0, 0, 0, C, 75, 75, 1357, 630, C
28-
frmBreakpoints = 9, 59, 1345, 719, C, 103, 319, 1385, 874, C
28+
frmBreakpoints = 124, 124, 1460, 784, C, 103, 319, 1385, 874, C
2929
frmWatch = 234, 234, 1442, 894, C, 75, 75, 1357, 630, C
30-
frmLocals = 3, 12, 1485, 801, Z, 196, 190, 1478, 745, C
30+
frmLocals = 19, 18, 1491, 786, C, 196, 189, 1478, 745, C
3131
frmImmediate = 26, 26, 1234, 686, C, 125, 125, 1407, 680, C
32-
frmCallStack = 51, 307, 1259, 967, C, 150, 150, 1432, 705, C
32+
frmCallStack = 69, 60, 1525, 876, , 150, 150, 1432, 705, C
3333
frmThreads = 130, 130, 1338, 790, C, 175, 175, 1457, 730, C
3434
frmModules = 156, 156, 1364, 816, C, 200, 200, 1482, 755, C
3535
frmMemory = 104, 104, 1312, 764, C, 225, 225, 1507, 780, C
@@ -41,8 +41,9 @@ frmErrorList = 312, 312, 1520, 972, C, 100, 100, 1382, 655, C
4141
frmOutput = 264, 120, 1521, 670, C, 125, 125, 1407, 680, C
4242
TabBar = 7, 146, 1396, 834, C, 0, 0, 1282, 555, C
4343
frmCreate = 407, 123, 1486, 768, C, 21, 176, 1348, 732, C
44-
clsPipe = 72, 47, 1421, 899, C
44+
clsPipe = 72, 48, 1421, 899, C
4545
modTreeViewProc = 632, 197, 2116, 1018, C
4646
DarkTreeView = -43, 181, 1449, 779, C, 210, 193, 1452, 743, C
4747
frmCreateOptions = -239, 310, 1256, 1061, C, -6, 46, 1236, 596, C
4848
frmSaveBox = 83, 162, 1449, 839, C, 205, 263, 1410, 923, C
49+
modTooltips = 81, 90, 1439, 883, C

frmBreakpoints.frm

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ Begin VB.Form frmBreakpoints
1919
TabIndex = 0
2020
Top = 0
2121
Width = 6855
22-
_ExtentX = 8281
23-
_ExtentY = 5318
24-
CheckBoxes = -1 'True
22+
_extentx = 8281
23+
_extenty = 5318
24+
checkboxes = -1
2525
End
2626
End
2727
Attribute VB_Name = "frmBreakpoints"
@@ -37,6 +37,15 @@ Attribute VB_Exposed = False
3737

3838
Option Explicit
3939

40+
'描述: 清空所有东西,为下一次调试做准备
41+
Public Sub ClearEverything()
42+
Dim i As Long
43+
44+
For i = 0 To Me.lvBreakpoints.GetItemCount '清空断点对应的地址
45+
Me.lvBreakpoints.SetItemText "", i, 2
46+
Next i
47+
End Sub
48+
4049
Private Sub Form_Load()
4150
Me.Caption = Lang_Breakpoints_Caption
4251

frmCallStack.frm

Lines changed: 161 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,180 @@ Begin VB.Form frmCallStack
33
BackColor = &H00302D2D&
44
BorderStyle = 0 'None
55
Caption = "调用堆栈"
6-
ClientHeight = 3030
6+
ClientHeight = 3645
77
ClientLeft = 0
88
ClientTop = 0
9-
ClientWidth = 4560
9+
ClientWidth = 5775
1010
LinkTopic = "Form1"
11-
ScaleHeight = 3030
12-
ScaleWidth = 4560
11+
ScaleHeight = 3645
12+
ScaleWidth = 5775
1313
ShowInTaskbar = 0 'False
1414
StartUpPosition = 3 'Windows Default
15+
Begin DragControlsIDE.DarkListView lvCallStack
16+
Height = 2655
17+
Left = 480
18+
TabIndex = 0
19+
Top = 240
20+
Width = 3615
21+
_extentx = 6376
22+
_extenty = 4683
23+
End
1524
End
1625
Attribute VB_Name = "frmCallStack"
1726
Attribute VB_GlobalNameSpace = False
1827
Attribute VB_Creatable = False
1928
Attribute VB_PredeclaredId = True
2029
Attribute VB_Exposed = False
30+
'====================================================
31+
'描述: 调用堆栈窗口,在中断状态下显示调用堆栈
32+
'作者: 冰棍
33+
'文件: frmCallStack.frm
34+
'====================================================
35+
2136
Option Explicit
2237

38+
'定义调用堆栈信息结构
39+
Private Type CallStackInfoStruct
40+
Address As String '地址
41+
Args As String '参数
42+
File As String '文件
43+
Line As Long '行号
44+
End Type
45+
46+
Dim CallStackInfo() As CallStackInfoStruct '所有调用堆栈信息
47+
48+
'描述: 清空所有东西,为下一次调试做准备
49+
Public Sub ClearEverything()
50+
Me.lvCallStack.Clear
51+
ReDim CallStackInfo(0)
52+
End Sub
53+
54+
'描述: 获取调用堆栈列表
55+
Public Sub GetCallStack()
56+
'On Error Resume Next 'todo
57+
Dim PipeOutput As String '管道的输出
58+
Dim OutputLines() As String '输出的每一行
59+
Dim StrPos As Long '查找到的字符串的位置
60+
Dim BracketLevel As Long '括号匹配计数,一开始是0,遇到“(”加1, 遇到“)”减1
61+
Dim NewListItem As Long '新添加的ListView列表项索引
62+
Dim i As Long
63+
64+
Me.lvCallStack.Clear
65+
frmMain.DockingPane.Panes(10).Title = Lang_CallStack_Retrieving_Caption
66+
67+
frmMain.GdbPipe.ClearPipe '清空管道里的内容
68+
frmMain.GdbPipe.DosInput "info stack" & vbCrLf '向gdb发送获取调用堆栈命令
69+
frmMain.GdbPipe.DosOutput PipeOutput, "(gdb) " '获取gdb输出
70+
71+
OutputLines = Split(PipeOutput, vbCrLf) '逐行分割开输出
72+
ReDim CallStackInfo(UBound(OutputLines) - 1) '分配信息列表元素
73+
For i = 0 To UBound(OutputLines) '逐行进行分析
74+
If Trim(OutputLines(i)) <> "(gdb)" Then '去掉无用输出“(gdb) ”
75+
If OutputLines(i) Like "[#]* * in *(*)" Then '输出中不带文件名
76+
OutputLines(i) = Right(OutputLines(i), Len(OutputLines(i)) - Len(Split(OutputLines(i), " ")(0)) - 1) '(#n func(arg types) (args))
77+
CallStackInfo(i).Address = OutputLines(i)
78+
Else '输出中带有文件名
79+
StrPos = InStrRev(OutputLines(i), ":") '(#n func(arg types) (args) at file:line)
80+
CallStackInfo(i).Line = CLng(Right(OutputLines(i), Len(OutputLines(i)) - StrPos)) '(#n func(arg types) (args) at file:[line])
81+
OutputLines(i) = Left(OutputLines(i), StrPos - 1) '([#n func(arg types) (args) at file]:line)
82+
StrPos = InStrRev(OutputLines(i), ":/") '向前查找“:/”
83+
StrPos = InStrRev(OutputLines(i), " at ", StrPos) '从“:/”的位置继续向前查找“ at ”
84+
CallStackInfo(i).File = Replace(Right(OutputLines(i), Len(OutputLines(i)) - StrPos - 3), "/", "\") '(#n func(arg types) (args) at [file])
85+
OutputLines(i) = Left(OutputLines(i), StrPos - 1) '([#n func(arg types) (args)] at file)
86+
OutputLines(i) = Right(OutputLines(i), Len(OutputLines(i)) - InStr(OutputLines(i), " ") - 1) '(#n [func(arg types) (args)])
87+
StrPos = InStr(OutputLines(i), "(") '查找字符串里的第一个“(”
88+
BracketLevel = 0
89+
For StrPos = StrPos + 1 To Len(OutputLines(i)) '往后面查找匹配的“)”(这部分代码与frmLocals的ArrayParser中的代码相似)
90+
If Mid(OutputLines(i), StrPos, 1) = "(" Then '遇到开括号: 计数+1
91+
BracketLevel = BracketLevel + 1
92+
ElseIf Mid(OutputLines(i), StrPos, 1) = ")" Then '遇到关括号
93+
If BracketLevel <= 0 Then '括号计数为0,即括号已经匹配。此时StrPos是下一个匹配的“)”的位置
94+
CallStackInfo(i).Address = Left(OutputLines(i), StrPos) '([func(arg types)] (args))
95+
Exit For '别继续往后找了
96+
Else '括号仍未匹配,计数减1,继续往后查找
97+
BracketLevel = BracketLevel - 1
98+
End If
99+
ElseIf Mid(OutputLines(i), StrPos, 1) = """" Then '遇到“"”,查找到下一个匹配的”"“,确保不会分析到字符串中间去
100+
Do '一直向后查找“"”,直到不处于字符串中间
101+
StrPos = StrPos + 1
102+
Loop Until (Mid(OutputLines(i), StrPos, 1) = """" And Mid(OutputLines(i), StrPos - 1, 1) <> "\") Or StrPos > Len(OutputLines(i))
103+
End If
104+
Next StrPos
105+
If StrPos = Len(OutputLines(i)) Then '输出里面没有参数
106+
CallStackInfo(i).Args = "" '设置参数为空
107+
Else '输出里面有参数
108+
CallStackInfo(i).Args = Right(OutputLines(i), Len(OutputLines(i)) - StrPos - 1) '(func(arg types) [(args)])
109+
End If
110+
111+
NewListItem = Me.lvCallStack.AddItem(CallStackInfo(i).Address) '添加新列表项
112+
Me.lvCallStack.SetItemText CallStackInfo(i).Args, NewListItem, 1
113+
Me.lvCallStack.SetItemText CallStackInfo(i).File, NewListItem, 2
114+
Me.lvCallStack.SetItemText CStr(CallStackInfo(i).Line), NewListItem, 3
115+
End If
116+
End If
117+
Next i
118+
119+
frmMain.DockingPane.Panes(10).Title = Lang_CallStack_Caption
120+
End Sub
121+
23122
Private Sub Form_Load()
24123
Me.Caption = Lang_CallStack_Caption
124+
125+
Me.lvCallStack.Move 0, 0
126+
127+
Me.lvCallStack.AddColumnHeader Lang_Breakpoints_ListViewHeader_Address, 300
128+
Me.lvCallStack.AddColumnHeader Lang_CallStack_Args, 300
129+
Me.lvCallStack.AddColumnHeader Lang_Breakpoints_ListViewHeader_File, 150
130+
Me.lvCallStack.AddColumnHeader Lang_Breakpoints_ListViewHeader_Line
131+
132+
ReDim CallStackInfo(0) '初始化调用堆栈信息列表
133+
End Sub
134+
135+
Private Sub Form_Resize()
136+
On Error Resume Next
137+
138+
Me.lvCallStack.Width = Me.ScaleWidth
139+
Me.lvCallStack.Height = Me.ScaleHeight
25140
End Sub
141+
142+
Private Sub lvCallStack_DoubleClick(iItem As Long, iSubItem As Long, X As Long, Y As Long)
143+
On Error Resume Next
144+
Dim i As Long
145+
146+
If CallStackInfo(iItem).File <> "" Then '如果有对应的文件
147+
For i = 0 To UBound(CurrentProject.Files) '尝试在工程的文件中查找对应的文件
148+
If CurrentProject.Files(i).FilePath = CallStackInfo(iItem).File Then '查找到对应的文件
149+
If CurrentProject.Files(i).TargetWindow Is Nothing Then '如果有对应的代码窗口就切换过去
150+
Dim NewCodeWindow As frmCodeWindow
151+
Dim FileData As String
152+
Dim tmpData As String
153+
154+
Set NewCodeWindow = CreateNewCodeWindow(i) '创建新的代码窗体并设置绑定的文件序号
155+
NewCodeWindow.Caption = GetFileName(CallStackInfo(iItem).File)
156+
157+
Err.Clear
158+
Open CallStackInfo(iItem).File For Input As #1 '尝试打开对应的代码文件
159+
If Err.Number <> 0 Then
160+
Close #1
161+
NoSkinMsgBox Lang_Main_Debug_OpenSourceFailure & CallStackInfo(iItem).File, vbExclamation, Lang_Msgbox_Error
162+
Else
163+
Do While Not EOF(1)
164+
Line Input #1, tmpData
165+
FileData = FileData & tmpData & vbCrLf
166+
Loop
167+
End If
168+
Close #1
169+
170+
frmMain.TabBar.AddForm NewCodeWindow
171+
Else '没有的话就创建一个新的代码窗口
172+
frmMain.TabBar.SwitchToByForm CurrentProject.Files(i).TargetWindow
173+
End If
174+
175+
CurrentProject.Files(i).TargetWindow.SyntaxEdit.CurrPos.Row = CallStackInfo(iItem).Line
176+
CurrentProject.Files(i).TargetWindow.SyntaxEdit.SetFocus
177+
Exit Sub
178+
End If
179+
Next i
180+
End If
181+
End Sub
182+

0 commit comments

Comments
 (0)