Best way of debugging Win16 programs on 64-bit Windows?

Emulation of old PCs, PC hardware, or PC peripherals.

Best way of debugging Win16 programs on 64-bit Windows?

Postby marzsyndrome » 2019-4-14 @ 02:55

I already have experience with the DOSBox debugger, but it's proving really difficult to do effective debugging with it on Windows 3.x programs - and DOS programs for that matter - simply because of the lack of support for on-read breakpoints (it can only do on-write breakpoints). I probably inquired about this before a long time ago but I forget the reason for it. Anyhow...

I attempted to try attaching DOSBox.exe (and DOSBox_debug.exe) through Ollydbg but although it can find messages and code in memory specific to a Win 3.x environment through the Memory Map, any on-read breakpoints made there will only take me to see whatever DOSBox's code is doing, rather than the program being run through it (guess I should have figured that 16-bit and 32-bit codebases are practically worlds apart), so not that great for finding out where I need to be for stuff.

Are there any other real ways of debugging a Win16 program that still involves a GUI of sorts? Something similar to Ollydbg since that's what I'm already familiar with. Thanks!
marzsyndrome
Newbie
 
Posts: 58
Joined: 2007-3-28 @ 14:33

Re: Best way of debugging Win16 programs on 64-bit Windows?

Postby Dominus » 2019-4-14 @ 03:48

A VM?
User avatar
Dominus
DOSBox Moderator
 
Posts: 7968
Joined: 2002-10-03 @ 09:54
Location: Ludwigsburg

Re: Best way of debugging Win16 programs on 64-bit Windows?

Postby marzsyndrome » 2019-4-14 @ 09:14

Which VM emulators/simulators provide a debugger though?
marzsyndrome
Newbie
 
Posts: 58
Joined: 2007-3-28 @ 14:33

Re: Best way of debugging Win16 programs on 64-bit Windows?

Postby Dominus » 2019-4-14 @ 09:16

You run a 32bit Windows in a VM and a debugger inside that?
User avatar
Dominus
DOSBox Moderator
 
Posts: 7968
Joined: 2002-10-03 @ 09:54
Location: Ludwigsburg

Re: Best way of debugging Win16 programs on 64-bit Windows?

Postby marzsyndrome » 2019-4-14 @ 14:00

Okay but which are the best debuggers that support Win16 (or NewExecutable) exes?
marzsyndrome
Newbie
 
Posts: 58
Joined: 2007-3-28 @ 14:33

Re: Best way of debugging Win16 programs on 64-bit Windows?

Postby crazyc » 2019-4-14 @ 14:30

Are you trying to debug code you've compiled yourself or not? If so it depends on the compiler, if not your options are limited to really just one of the text mode debuggers (softice, codeview, tdw) but only with win3.1/95. If you are using ntvdm (which is recommended because if it crashes you can just kill ntvdm rather than having to restart the whole vm) there's windbg and the watcom debugger.
crazyc
Member
 
Posts: 143
Joined: 2013-2-02 @ 16:17

Re: Best way of debugging Win16 programs on 64-bit Windows?

Postby Jo22 » 2019-4-14 @ 18:30

crazyc wrote:If you are using ntvdm (which is recommended because if it crashes you can just kill ntvdm rather than having to restart the whole vm) there's windbg and the watcom debugger.

I wonder, why is OS/2's VDM never mentioned anywhere in this respect? Was there no debugger of this kind available at the time? :confused:
Sorry if I ask. It's perhaps not the right spot. It's just.. When it was new, the OS/2 VDM used to be much more flexible than NT's VDM.
And according to the readme files of DOS/Win16 PD+Freeware programs that I came across in the past years, the authors often mentioned OS/2.
"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//
User avatar
Jo22
l33t
 
Posts: 3884
Joined: 2009-12-13 @ 07:06
Location: Europe

Re: Best way of debugging Win16 programs on 64-bit Windows?

Postby crazyc » 2019-4-14 @ 20:19

I'd expect NTVDM to be better for win16 programs but if you want to use OS/2 go ahead.
crazyc
Member
 
Posts: 143
Joined: 2013-2-02 @ 16:17

Re: Best way of debugging Win16 programs on 64-bit Windows?

Postby kjliew » 2019-4-15 @ 00:33

If you have access to SoftICE Win9x (from a now defunct company called Numega), it can debug Win16 program from Win9x OS. Last I checked, it even worked within recent version of QEMU running Win98SE as guest OS.
kjliew
Member
 
Posts: 479
Joined: 2004-1-08 @ 03:03

Re: Best way of debugging Win16 programs on 64-bit Windows?

Postby ssokolow » 2019-5-11 @ 06:41

I had a long reply but I forgot that Firefox neglects to preserve un-submitted form contents if you have an extension which unloads idle tabs.

The gist of it was that you should check the options for NE-format executables that I dug up a few months ago.

I haven't tried debugging Win16 executables yet but, in theory, you can use any of these options:
  • Run a Win32 debugger on NTVDM under 32-bit Windows inside a VM (eg. the "OllyDbg on NTVDM" option used in the blog post linked under "Reference Materials")
  • Check if Boxedwine has Wine's built-in debugger backend enabled and, if so, use something like gdbgui to connect to it.
  • Install a lightweight Linux distro like Lubuntu into a VM and run regular Wine on that, then connect to it using gdbgui.
  • Run the Open Watcom C/C++ debugger in Windows 3.x inside DOSBox or in a 32-bit Windows in a VM. (I'm not sure how far back in time you'll have to go to find a Win16 build of the installer, but you can install the Win16 tools using the DOS installer and then manually set up the relevant bits of config.)
Internet Archive: My Uploads
My Blog: DOS & Win16 programming resources, Free Installer Creators for All Eras
My Rose-Coloured-Glasses Builds

I also try to announce anything retro-relevant on on Twitter.
User avatar
ssokolow
Newbie
 
Posts: 57
Joined: 2018-6-14 @ 19:59
Location: Canada

Re: Best way of debugging Win16 programs on 64-bit Windows?

Postby Jo22 » 2019-5-11 @ 23:49

Interesting, thanks for mentioning it. Also saw your blog - Btw, there also was a WinMem32 API in Windows 3.1 which could be used for writing flat-memory apps (thus dropping 286 support).
I haven't found much information of it, but you can check its presence in Byte Magazine May/92, p.24, if you like. Anyway, just saying. Now have to stop going slightly off-topic..
"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//
User avatar
Jo22
l33t
 
Posts: 3884
Joined: 2009-12-13 @ 07:06
Location: Europe

Re: Best way of debugging Win16 programs on 64-bit Windows?

Postby ssokolow » 2019-5-13 @ 10:41

Jo22 wrote:Interesting, thanks for mentioning it. Also saw your blog - Btw, there also was a WinMem32 API in Windows 3.1 which could be used for writing flat-memory apps (thus dropping 286 support).
I haven't found much information of it, but you can check its presence in Byte Magazine May/92, p.24, if you like. Anyway, just saying. Now have to stop going slightly off-topic..


Sorry to keep things slightly off-topic, but I just have to respond to that.

According to this Wikipedia Talk page entry...

Unlike win23s which was installed separately, winmem32 was included with Window 3.11, and it also provided a 32 bit flat address space (for systems with 80386 or later processors). However, only Watcom C/C++ 10.0 fully supported winmem32 as one of it's standard memory models with a 32 bit flat address space, hiding all of the 16/32 bit interface stuff from the programmer. All Microsoft had at the time was an example assembly "thunk" program for using one function provided by winmem32. This resulted in the Watcom C/C++ 10.0 compiler being relatively popular until Windows 95 was released and became the mainstream Windows OS.

Also, given that none of my references for Windows 3.1 APIs mention it, I think it may be specific to Windows 3.11, which limits its utility.

That aside, Watcom's Win386 doesn't just allow protected mode applications (a la a DPMI host), it also provides a bunch of helper functionality (like a DPMI extender) to make writing 32-bit applications on a 16-bit platform more comfortable.

(Mainly customized Windows API headers and a bi-directional thunking layer that's as automatic as they could make it... so it's similar to Win32s, but built into your application. It also offers a redistributable FPU emulation driver for Windows in case you want to use the inlined floating point optimization that prevents your program from switching in emulated versions internally.)

Win386 is also fairly obscure on the web but Open Watcom's C/C++ Programmer's Guide (pguide.pdf) spends just over a quarter of its length on it, right after spending about the same number of pages on how to write DOS applications using DOS/4GW.
Internet Archive: My Uploads
My Blog: DOS & Win16 programming resources, Free Installer Creators for All Eras
My Rose-Coloured-Glasses Builds

I also try to announce anything retro-relevant on on Twitter.
User avatar
ssokolow
Newbie
 
Posts: 57
Joined: 2018-6-14 @ 19:59
Location: Canada


Return to PC Emulation

Who is online

Users browsing this forum: No registered users and 1 guest