Skip to content

Commit 1d046bf

Browse files
committed
beginning debugger integration
1 parent bae7aff commit 1d046bf

File tree

25 files changed

+1504
-231
lines changed

25 files changed

+1504
-231
lines changed

Module1.bas

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
Attribute VB_Name = "Module1"
22
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, Source As Any, ByVal Length As Long)
33

4+
Enum cb_type
5+
cb_output = 0
6+
cb_dbgout = 1
7+
cb_dbgmsg = 2
8+
End Enum
49

510

6-
Public Sub vb_stdout(ByVal lpMsg As Long, ByVal sz As Long)
11+
Public Sub vb_stdout(ByVal t As cb_type, ByVal lpMsg As Long, ByVal sz As Long)
12+
713
Dim b() As Byte
814
Dim msg As String
15+
916
ReDim b(sz)
1017
CopyMemory b(0), ByVal lpMsg, sz
1118
msg = StrConv(b, vbUnicode)
19+
If Right(msg, 1) = Chr(0) Then msg = Left(msg, Len(msg) - 1)
20+
21+
If t = cb_dbgmsg Then msg = "DBG> " & msg
22+
1223
With Form1.txtOut
1324
.Text = .Text & Replace(msg, vbLf, vbCrLf)
25+
.Refresh
26+
DoEvents
1427
End With
28+
1529
End Sub

engine/dll.vcproj

Lines changed: 16 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
Name="VCCLCompilerTool"
4343
Optimization="0"
4444
AdditionalIncludeDirectories="$(ProjectDir)\sb\include"
45-
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
45+
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
4646
MinimalRebuild="true"
4747
ExceptionHandling="2"
4848
BasicRuntimeChecks="3"
@@ -186,16 +186,8 @@
186186
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
187187
>
188188
<File
189-
RelativePath=".\dllmain.cpp"
189+
RelativePath=".\dllmain.c"
190190
>
191-
<FileConfiguration
192-
Name="Debug|Win32"
193-
>
194-
<Tool
195-
Name="VCCLCompilerTool"
196-
CompileAs="2"
197-
/>
198-
</FileConfiguration>
199191
</File>
200192
<Filter
201193
Name="Commands"
@@ -450,6 +442,10 @@
450442
RelativePath=".\sb\include\ftpd.h"
451443
>
452444
</File>
445+
<File
446+
RelativePath=".\sb\include\global.h"
447+
>
448+
</File>
453449
<File
454450
RelativePath=".\sb\include\hndlptr.h"
455451
>
@@ -546,6 +542,10 @@
546542
RelativePath=".\sb\include\uniqfnam.h"
547543
>
548544
</File>
545+
<File
546+
RelativePath=".\sb\include\vb.h"
547+
>
548+
</File>
549549
</Filter>
550550
<Filter
551551
Name="extensions"
@@ -562,28 +562,12 @@
562562
/>
563563
</FileConfiguration>
564564
</File>
565-
<File
566-
RelativePath=".\extensions\trial.c"
567-
>
568-
</File>
569565
</Filter>
570566
<Filter
571567
Name="scripts"
572568
>
573569
<File
574-
RelativePath=".\scripts\com_test.sb"
575-
>
576-
<FileConfiguration
577-
Name="Debug|Win32"
578-
ExcludedFromBuild="true"
579-
>
580-
<Tool
581-
Name="VCCustomBuildTool"
582-
/>
583-
</FileConfiguration>
584-
</File>
585-
<File
586-
RelativePath=".\scripts\com_voice_test.sb"
570+
RelativePath="..\scripts\com_voice_test.sb"
587571
>
588572
<FileConfiguration
589573
Name="Debug|Win32"
@@ -606,59 +590,27 @@
606590
/>
607591
</FileConfiguration>
608592
</File>
609-
<File
610-
RelativePath=".\scripts\hello.sb"
611-
>
612-
<FileConfiguration
613-
Name="Debug|Win32"
614-
ExcludedFromBuild="true"
615-
>
616-
<Tool
617-
Name="VCCustomBuildTool"
618-
/>
619-
</FileConfiguration>
620-
</File>
621593
</Filter>
622594
<Filter
623595
Name="preprocessors"
624596
>
625597
<Filter
626-
Name="sdbg"
627-
>
628-
<File
629-
RelativePath=".\sb\sdbg\sdbg.h"
630-
>
631-
</File>
632-
<File
633-
RelativePath=".\sb\sdbg\sdbg_comm.h"
634-
>
635-
</File>
636-
<File
637-
RelativePath=".\sb\sdbg\sdbg_con.c"
638-
>
639-
</File>
640-
<File
641-
RelativePath=".\sb\sdbg\sdbg_interface.c"
642-
>
643-
</File>
644-
</Filter>
645-
<Filter
646-
Name="dbg"
598+
Name="vb_dbg"
647599
>
648600
<File
649-
RelativePath=".\sb\dbg\dbg.h"
601+
RelativePath=".\preprocessors\vb_dbg\vb_dbg.h"
650602
>
651603
</File>
652604
<File
653-
RelativePath=".\sb\dbg\dbg_comm.h"
605+
RelativePath=".\preprocessors\vb_dbg\vb_dbg_comm.h"
654606
>
655607
</File>
656608
<File
657-
RelativePath=".\sb\dbg\dbg_con.c"
609+
RelativePath=".\preprocessors\vb_dbg\vb_dbg_con.c"
658610
>
659611
</File>
660612
<File
661-
RelativePath=".\sb\dbg\interface.c"
613+
RelativePath=".\preprocessors\vb_dbg\vb_dbg_interface.c"
662614
>
663615
</File>
664616
</Filter>
Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11

2-
#define _CRT_SECURE_NO_WARNINGS
3-
42
#include <windows.h>
53
#include <stdio.h>
64
#include <stdlib.h>
@@ -9,33 +7,25 @@
97
#include "basext.h"
108
#include "scriba.h"
119
#include "errcodes.h"
10+
#include "vb.h"
1211

13-
extern void* dbg_preproc; //for console based debugger preprocessor
14-
extern void* sdbg_preproc; //for the socket based debugger preprocessor
15-
extern LPWSTR __C2W(char *szString);
16-
17-
#define EXPORT comment(linker, "/EXPORT:"__FUNCTION__"="__FUNCDNAME__)
1812

19-
void* vb_stdout = 0;
13+
extern void* vb_dbg_preproc;
2014

21-
/*
22-
enum error_codes{
23-
ec_load_source_failed = 1,
24-
ec_run_failed = 2
15+
#define EXPORT comment(linker, "/EXPORT:"__FUNCTION__"="__FUNCDNAME__)
16+
extern LPWSTR __C2W(char *szString);
2517

26-
};
27-
*/
2818

2919
void __stdcall SetVBStdout(void* lpfnHandler){
3020
#pragma EXPORT
31-
vb_stdout = lpfnHandler;
21+
vbStdOut = (vbCallback)lpfnHandler;
3222
}
3323

3424
int __stdcall GetErrorString(int iErrorCode, char* buf, int bufSz){
3525
#pragma EXPORT
36-
26+
int sz = 0;
3727
if( iErrorCode >= MAX_ERROR_CODE ) iErrorCode = COMMAND_ERROR_EXTENSION_SPECIFIC;
38-
int sz = strlen(en_error_messages[iErrorCode]);
28+
sz = strlen(en_error_messages[iErrorCode]);
3929
if(sz < bufSz) strcpy(buf,en_error_messages[iErrorCode]);
4030
return sz;
4131

@@ -46,19 +36,14 @@ int __stdcall run_script(char* fPath, int use_debugger)
4636
#pragma EXPORT
4737

4838
int iError;
49-
int iErrorCounter;
50-
unsigned long fErrorFlags;
5139
char* cmdline = "";
5240
pSbProgram pProgram;
5341

5442
pProgram = scriba_new(NULL,NULL);
5543
scriba_SetFileName(pProgram, fPath);
5644

57-
if(vb_stdout != NULL) pProgram->fpVbStdOutFunction = vb_stdout;
58-
59-
6045
if(use_debugger){
61-
//iError = scriba_LoadInternalPreprocessorByFunction(pProgram, "sdbg", &sdbg_preproc);
46+
//iError = scriba_LoadInternalPreprocessorByFunction(pProgram, "vb_dbg", &vb_dbg_preproc);
6247
}
6348

6449
if( iError = scriba_LoadSourceProgram(pProgram) ) goto cleanup;

engine/extensions/COM.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939
#include <string>
4040

4141
#include "basext.h"
42+
#include "vb.h"
4243

43-
int com_dbg = 1;
44+
int com_dbg = 0;
4445
int initilized=0;
4546

4647
//vbCallType aligns with DISPATCH_XX values for Invoke
@@ -111,9 +112,13 @@ void color_printf(colors c, const char *format, ...)
111112
va_start(args,format);
112113
try{
113114
_vsnprintf(buf,1024,format,args);
114-
SetConsoleTextAttribute(hConOut, c);
115-
printf("%s",buf);
116-
SetConsoleTextAttribute(hConOut,7);
115+
if(vbStdOut){
116+
vbStdOut(cb_dbgout, buf, strlen(buf));
117+
}else{
118+
SetConsoleTextAttribute(hConOut, c);
119+
printf("%s",buf);
120+
SetConsoleTextAttribute(hConOut,7);
121+
}
117122
}
118123
catch(...){}
119124
}

engine/main.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
extern dbg_preproc; //for console based debugger preprocessor
1212
extern sdbg_preproc; //for the socket based debugger preprocessor
1313

14-
MODLIST StaticallyLinkedModules[] ={
15-
{ NULL, NULL },
16-
};
17-
18-
1914
void main(int argc, char *argv[]){
2015

2116
int iError;

0 commit comments

Comments
 (0)