News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

debugging

Started by jimg, March 15, 2020, 03:59:29 PM

Previous topic - Next topic

jimg

It been ten years since I used a debugger.  My current methods are failing me, so I'm ready to try one.  What's the consensus on the best one to use these days.  It's a 32 bit program.  I tried my ancient copy of olly but it doesn't let me set breakpoints and it's not tracking between the files very well.  I tried to do a search on the forum, but I mispelled it the first time, and it wouldn't let me try again for a frustrating 30 seconds, and then the next one was fruitless, so I gave up.  Unusable.

Anyways, any recommendations?

six_L

Say you, Say me, Say the codes together for ever.

jimg

Thanks six.   Looks interesting, but after half an hour, I still couldn't figure out how to show and follow along in the source code.

jimg

With a fresh head this morning, I finally got Olly working.  I was loading the include files with a for loop.  Even though Olly knew all the files involved (it listed them in the source files list) and I could open them, it wouldn't let me set a breakpoint in an included file, and wouldn't trace into an included file.   After discarding the for loop and hard coding an include for each source file, Olly was happy and let me set break points and follow along.  Yea! 

jj2007

Consider using the deb macro. Olly is great when the problem sits at the level of instructions, but logical bugs are much easier to find with a console. The source code of my editor counts over 600 uses of deb. I know it's painful to install MasmBasic, but once you have finished debugging, you need just two lines to convert your source back to a pure Masm32 application:
deb MACRO arg:vararg
endm

jimg

Thanks jj.  That's going to take a bit of study to figure out, but I'll try it tomorrow when I'm a little fresher.
So far I've found two really dumb errors.  But the real problem is a lot more subtle.  I think somewhere I probably did a comparison and did the wrong type of jump (signed vs. unsigned).  This occurs, of course, only after thousands of iterations, and the problem doesn't become obvious until thousands later.
At least I figured out how to use Olly again :)

jimg

I've become a little frustrated with Olly, it doesn't update the watched items in a timely manner (or at all sometimes).
So I tried WinDbg Preview.  It also has a lot of frustrating attributes, but at least I can see the variables change.
Minus points include:
  It doesn't automatically know all the source files.
  It doesn't let you show some watch variables in decimal and some in hex.  In fact, the only way to see decimal shows Everything in decimal including the registers.
  It installs in a hidden location somewhere controlled by microsoft, the only windbgx.exe is a zero length file in the WindowsApps folder that works by magic.

Otherwise, it's different than Olly, and it works.
I never used the old WinDbg so I can't compare.  It seem the only way to get the old one is download the entire win10sdk and try to get it out of that.

edit:
Nope.  WinDbg Preview is just too frustrating.  It didn't save the setup I so carefully created, even though I told it to save.  At least there doesn't seem to be any way to load the saved setups.  About all it remembers it the locations of the windows.

aw27

VS is the best debugger by far and large. Wincbg is also good but difficult to learn.
This is my opinion.

For VS people need to learn how to use Asm from it. It is easy but most people has no idea. Google is a great friend.

jj2007

Quote from: jimg on March 17, 2020, 05:10:37 AMIt doesn't let you show some watch variables in decimal and some in hex

deb shows variables in decimal, as hex with x:prefix, as binary with b:prefix, as $string, $Utf8$ and as $$unicode string. The xmm regs can be displayed as integers in decimal, as floats in f:decimal, and in 16-byte hex presentation (x:xmm0).

deb 4, "Variables etc", ST(0), ST(1), b:eax, $ecx, $esi, $My$, $$MyWide$, a1, a2, a3, MyDword, MyR8, MyQ, x:xmm0, f:xmm1

Variables etc
ST(0)           1.000000000000000000
ST(1)           3.141592653589793238
b:eax           00000111010110111100110100010101
$ecx            123     <not a pointer>
$esi            Hello World
$My$            Здравствуйте, мир
$$MyWide$       Hello World
a1              111
a2              222
a3              333
MyDword         123456789
MyR8            1234567.890123457
MyQ             1234567890123456789
x:xmm0          00000000 00000000 00000000 075BCD15
f:xmm1          1234567.890123457

K_F

I do most of my debugging on paper... working out the code before I type.

Found most of my errors are syntactical... forgetting to put ADDR or OFFSET directives..etc

Works well, and also gives you time to think about changes and work-arounds.
;)
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

jimg

Quote from: jj2007 on March 17, 2020, 10:44:15 AM
Quote from: jimg on March 17, 2020, 05:10:37 AMIt doesn't let you show some watch variables in decimal and some in hex

deb shows variables in decimal, as hex with x:prefix, as binary with b:prefix, as $string, $Utf8$ and as $$unicode string. The xmm regs can be displayed as integers in decimal, as floats in f:decimal, and in 16-byte hex presentation (x:xmm0).

Sorry, jj, I was talking about Windbg preview.  Your method looks very similar to what I used a few years ago.  I incorrectly thought I could work this out by watching a few registers.  I now think there is some fatal error in the design logic.  My program is considering any single letter to be less than any two letter string, but most routines don't.  Not really sure which is correct.  Is the one byte string "2" less than the two byte string "10"?  Not according to most sorters.

K_F-
That has always been my mode of operation since my first programing class in 1968.  In my old age, I tend to fall asleep doing a long sequence that way, so we adapt :)

hutch--

The first and last thing I programmed on paper was for a HP 11c which I still own somewhere and last time I looked at it, the original batteries were still working.

K_F

Quote from: hutch-- on March 18, 2020, 03:12:20 AM
... and last time I looked at it, the original batteries were still working.
Nahhhh.. You serious ?  :dazzled:

Well, I'm not surprised... old tech is best on quality.  :thumbsup:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

jj2007

Quote from: jimg on March 18, 2020, 02:43:31 AMMy program is considering any single letter to be less than any two letter string, but most routines don't.  Not really sure which is correct.

Normal sort:
Anderson
Johnson
Lee
Ross
Smith
Wilson
Xi

Sort by string len:
Xi
Lee
Ross
Smith
Wilson
Johnson
Anderson


Source attached - I vote for the first version :angelic:

jimg

Yes, that is correct for an implied fixed width list, eg. a list of names in a table.  For zbt words, I'm still thinking about it.