issue-#187 adding a run-time debugger to BlackBox

Merged to the master branch

issue-#187 adding a run-time debugger to BlackBox

Postby Josef Templ » Tue May 15, 2018 2:21 pm

I have created https://redmine.blackboxframework.org/issues/187 for adding a run-time debugger to BlackBox.

Technically the debugger is based on a prototype by ominc, which has been ported to BB1.7 by oberoncore+x512+Ivan.
I have tested the prototype but was not very happy with the user interface. The main problem was that it required to start the
debugger first and attach the debugged BlackBox process to it later. In my opinion, the reverse approach would be more natural,
i.e. while working in BlackBox it should be possible to attach a debugger to it and to debug a command very much like
executing a command directly. A first version of this 'reversed' approach is now available.
The main differences over the ominc prototype are:

- improved user interface: debugger is attached to running BB, no flickering when single-stepping, tool dialog, etc.
- internationalized
- relevant DevDebug changes since BB1.6 applied to RTDebug.

A test version is available from http://blackboxframework.org/unstable/issue-%23187/blackbox-1.7.2-a1.1023.zip.
If you want to debug a command M.P then select M.P in a text viewer and execute Dev->Debug Command.
If you want to open a module M in the debugger (e.g. for setting breakpoints) then select M in a text viewer and execute Dev->Debug Module.
Docu is included.

The debugger is a normal BlackBox process which simply uses the startup option /LOAD DevRTDebug.
DevRTDebug is a new module that uses the Windows debug API for attaching a debugger to a running process.
DevRTDebug is only loaded in the debugger process. Normal BlackBox execution does not load this module and is not affected.
There is only a small interface added in DevDebug for attaching (starting) a run-time debugger to the running BlackBox.
A couple of missing Windows debug API functions have been added to WinApi.
A nice side-effect of the reversed approach, and may be an indication that it is the right approach, is the fact
that the Kernel support for starting under the prototype run-time debugger with the magic lines
Code: Select all
S.PUTREG(ML, S.ADR(modList));
WinApi.OutputDebugStringW("BlackBox started");

(or any variation of it) is no longer required. However, it has been left for compatibility reasons.

The changes are https://redmine.blackboxframework.org/projects/blackbox/repository/diff?utf8=%E2%9C%93&rev=66f28131a6d3c0ef2c25bcc5be135c162aa19909&rev_to=a8b5479d55774c467572f100314900a4d9f1453b.

Note: This also fixes an error in DevDebug.ShowArray, where the type of the variable vi has been changed from SHORTINT to INTEGER in issue-#19.
This variable is used for reading 2-byte characters and must be reset to SHORTINT.

I would be glad to get feed-back on this version of debugger.

- Josef
User avatar
Josef Templ
 
Posts: 1954
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#187 adding a run-time debugger to BlackBox

Postby Ivan Denisov » Wed May 16, 2018 3:40 am

It is much easier to use now. Thanks for this new version!

There is still the old problem is if somebody would copy text from application to the debugger, it is hanging forever.
Ivan Denisov
 
Posts: 1690
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#187 adding a run-time debugger to BlackBox

Postby Josef Templ » Wed May 16, 2018 5:58 am

Ivan Denisov wrote:It is much easier to use now. Thanks for this new version!

There is still the old problem is if somebody would copy text from application to the debugger, it is hanging forever.


I see, if the application is stopped it cannot provide the clipboard data.
This applies to all applications that receive clipboard data, i.e. if I try to copy data from a
stopped application to Word, for example, it also hangs forever.
If I copy to Notepad, it also hangs but not forever.
After some time the Paste operation is terminated. So it may be possible to
solve this at the side of the receiver by using something like a timeout.

- Josef
User avatar
Josef Templ
 
Posts: 1954
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#187 adding a run-time debugger to BlackBox

Postby Josef Templ » Tue May 29, 2018 1:54 pm

A small fix regarding Strings resources has been added.
Now there are separate keys SourceCodeBtn for the button label and
and SourceCode for the source code window title.

See diffs at https://redmine.blackboxframework.org/projects/blackbox/repository/diff?utf8=%E2%9C%93&rev=a56090e1ec59efa5c34048d6ffc1bbcf7e21d59d&rev_to=ca5b3448e23316cfd1e3b6b93ca79cb7d8c12d82.

The latest version can be downloaded from http://blackboxframework.org/unstable/issue-%23187/blackbox-1.7.2-a1.1025.zip.

- Josef
User avatar
Josef Templ
 
Posts: 1954
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#187 adding a run-time debugger to BlackBox

Postby Ivan Denisov » Wed May 30, 2018 7:14 am

Josef, can you please make it separate module?
DevDebug was platform independent module without WinApi import. It is distributing with Cross-Platform version well.
Now you put WinApi and it will cause problems for me (hard to sync with Center version).
Ivan Denisov
 
Posts: 1690
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#187 adding a run-time debugger to BlackBox

Postby Josef Templ » Wed May 30, 2018 11:47 am

Ivan Denisov wrote:Josef, can you please make it separate module?
DevDebug was platform independent module without WinApi import. It is distributing with Cross-Platform version well.
Now you put WinApi and it will cause problems for me (hard to sync with Center version).


I am looking into this.

But currently I am working on a problem with the 'Stop' button of the run-time debugger.
It used to work fine and I have not changed anything, but all of a sudden it no longer
works in most cases. The only thing I have done is a Windows version upgrade.
As far as I see also the X512/ominc debugger has the same problem now.

- Josef
User avatar
Josef Templ
 
Posts: 1954
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#187 adding a run-time debugger to BlackBox

Postby Josef Templ » Thu May 31, 2018 9:02 am

Ivan Denisov wrote:Josef, can you please make it separate module?
DevDebug was platform independent module without WinApi import. It is distributing with Cross-Platform version well.
Now you put WinApi and it will cause problems for me (hard to sync with Center version).


I was thinking about moving the debugger start procedures to DevRTDebug but then
a large module is loaded even when only a very small part is needed.

The debugger start procedures could also be moved into a separate small module, e.g. DevDebugCmds.
The trivial guard 'DebugGuard' could remain in DevDebug and then there is nothing loaded at all unless you really
use it, i.e. attach a debugger. I have tried this approach now.

The latest version can be downloaded from http://blackboxframework.org/unstable/issue-%23187/blackbox-1.7.2-a1.1026.zip.

- Josef
User avatar
Josef Templ
 
Posts: 1954
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#187 adding a run-time debugger to BlackBox

Postby Josef Templ » Fri Jun 01, 2018 12:14 pm

I have added a work around for a problem with Stop.

The new version of DevRTDebug.Stop uses a retry loop. It is a work around for a problem probably introduced
by a recent Windows 10 update. It seems that setting the processor's trace flag is ignored when
the process is executing a certain part of the Windows library code. Therefore Stop does not
always work at the first attempt. So we retry until it works or it times out.

The latest version can be downloaded from http://blackboxframework.org/unstable/issue-%23187/blackbox-1.7.2-a1.1027.zip.

- Josef
User avatar
Josef Templ
 
Posts: 1954
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#187 adding a run-time debugger to BlackBox

Postby DGDanforth » Sat Jun 02, 2018 3:43 am

Josef,
I just want to add my two bits by saying thank you for doing this.

Doug
User avatar
DGDanforth
 
Posts: 1060
Joined: Tue Sep 17, 2013 1:16 am
Location: Palo Alto, California, USA

Re: issue-#187 adding a run-time debugger to BlackBox

Postby Josef Templ » Mon Jun 04, 2018 10:59 am

The latest version fixes the problem with 'Stop' in a reliable way
by using the function WinApi.DebugBreakProcess instead of setting the trace flag directly.
It also improves some details in the docu and it includes some cleanups.

The latest version can be downloaded from http://blackboxframework.org/unstable/issue-%23187/blackbox-1.7.2-a1.1030.zip.

- Josef
User avatar
Josef Templ
 
Posts: 1954
Joined: Tue Sep 17, 2013 6:50 am

Next

Return to Resolved (Features)

Who is online

Users browsing this forum: No registered users and 2 guests

cron