News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

PDB Explore

Started by KetilO, May 27, 2009, 01:46:21 PM

Previous topic - Next topic

KetilO

I am playing with the idea to create a source code debugger for RadASM as an addin.

Unfortunatly the pdb format is undocumented and a search on the internet gave little information.
I managed to create a pdb explorer to read and save the pdb streams for version 2.00 pdb files.
If you know anything or find any useful info on the pdb format, give me a hint.

You can download the PDB Explore project here.

KetilO

[attachment deleted by admin]

akane

KetilO,
to read info (like symbols) from pdb files use the interfaces from \Program Files\Microsoft Visual Studio <version>\DIA SDK\.
I saw it in VS8 and VS9.

BTW, PDB Explore crashed while loading %windir%\Symbols\ax\vbisurf.pdb

Ficko


ToutEnMasm


Reading the pdb format can be done with the functions of dbghelp.dll (debugging tools).
The except.asm in my ide can read the symbols and find the the souce file and the line when an error occured.

drizz

I had the same idea myself :)

Toutenmasm is right, dbghelp is the way to go. Here is an example from Matt Pietrek :  http://www.wheaty.net/downloads.htm, you can also download the useful PEDUMP with source.
Also check out YASM source code, afaik YASM is the only assembler that can generate ms debug information beside MASM.

I have some knowledge on writting a debugger so i can offer you my help if you want. I would love to see this project realised.
The truth cannot be learned ... it can only be recognized.

UtillMasm

#5
 :U
thanks guys.
DIA SDK on Microsoft Windows Software Development Kit Update for Windows Vista is ok:
\DIA SDK\Samples\DIA2Dump>msbuild dia2dump.vcproj
\DIA SDK\bin>regsvr32.exe /c msdia100.dll
\DIA SDK\Samples\DIA2Dump\Release>Dia2Dump.exe Dia2Dump.exe
\DIA SDK\bin>regsvr32.exe /u msdia100.dll

UtillMasm

 :U
DbgHelpDemo is ok!

KetilO

Thanks for your help!

Here is RADebug addin version 1.0.0.0

RadASM debug addin.

NOTE!
The addin uses dbghelp,dll version 6.4 or higher.

How to install:
-----------------------------------------------------------------------------
o Copy RADebug.dll to C:\RadASM\Addins
o Copy RADebug.txt to C:\RadASM\Addins\Help
o Start RadASM and use Options/Addin Manager to activate addin.
  - There is an option to show DbgHelp output.

How to make (masm):
-----------------------------------------------------------------------------
o Assemble with the /Zd option.
o Link with the /DEBUG option.

How to debug:
-----------------------------------------------------------------------------
o Set a breakpoint in your source using Make/Debug/Toggle Breakpoint
0 Select Make/Debug/Run
  - You will get a warning on unhandled breakpoints if you set a breakpoint
    on a line that does not produce any code.
  - You will get an error if there are unsaved source files.
  - You will get an error if any source files are newer than the exe.
  - Execution will stop when a breakpoint is reached.
    Output window #1 will show some debug info.
    Output window #2 will show registers.
  - Use Step Into, Step Over, Run To Caret or Run to continue execution.
  - Use Toggle Breakpoint to set a new breakpoint or Clear Breakpoints to
    clear all breakpoints.
  - Use Stop to stop execution.
  - Multithreading is supported. Each thread gets to execute one line
    at a time, very confusing.

Whats new:
-----------------------------------------------------------------------------
o Uploaded version 1.0.0.0
  - Step Over is disabled (Needs size of proc).
  - Do Not Debug is disabled (Needs size of proc).


To do:
-----------------------------------------------------------------------------
o Find size of procs and enable Step Over and Do Not Debug.
o Speed optimize. Sort lines using Address to an array of pointers.
  Use successive approximation to find a line.
o Immediate window to inspect variables, proc parameters and locals.
o Tooltip on mouse over a variable, proc parameter or local.

KetilO

EDIT:
New upload.

[attachment deleted by admin]

KetilO

Hi all

To do:
-----------------------------------------------------------------------------
o Find size of procs and enable Step Over and Do Not Debug.
o Speed optimize. Sort lines using Address to an array of pointers.
  Use successive approximation to find a line.
o Immediate window to inspect variables, proc parameters and locals.
o Tooltip on mouse over a variable, proc parameter or local.

Here is the to do list. Help is needed to implement it. The sources is included so just sign up and start coding.

Also help is needed to test other assemblers / compilers.

KetilO

UtillMasm

 :U
great!

btw: text position bug report in my atachment.

[attachment deleted by admin]

KetilO

Thanks UtillMasm

New upload.

KetilO

drizz

Hi Ketil,

I've been writting a little demo debugger for you, it not really complete as i want it to be, but since you already posted RADebug i'm going to post it anyway. I hope it will be of some help, atleast the use of dbghelp.

"Step Over"/"Step Into" can be implemented using Software Breakpoints (Int3), but Hardware Breakpoints (via Debug Registers) are a better option imho.

I have no more thoughts since I didn't install RADebug yet; I replyed as soon as I noticed your post.

P.S.:  Demo is using japheth's includes and msvcrt funcs.
P.S.2: Split this topic so RADebug has its own Thread?

[attachment deleted by admin]
The truth cannot be learned ... it can only be recognized.

drizz

Here is the same demo modified to show how to use "Trace Flag" to single step instructions, i've added my ia32 decoder that i use to find instruction length and check for "call".

[attachment deleted by admin]
The truth cannot be learned ... it can only be recognized.

drizz

I'm thinking about this system for step over/into:

If user presses StepInto Hotkey - Debugger traces (with trace flag) "under the hood" until displacement (from line information retrieved by SymGetLineFromAddr) is 0

If user presses StepOver Hotkey - Debugger traces "under the hood" until displacement is 0 AND skipping "Call" instructions by placing Hardware breakpoint after the call.

by "under the hood" i mean not showing anything visually
The truth cannot be learned ... it can only be recognized.

UtillMasm

 :U
cool!
but for me (debug beginer):
include stdio.inc
include stdlib.INC
include commctrl.inc

what are they?