flat assembler
Message board for the users of flat assembler.

Index > IDE Development > FASMW::Multi-Debug (patch)

Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 4020
Location: vpcmpistri
bitRAKE 06 Aug 2013, 22:29
Some time back comrade created a patch to add features to FASMW. Among them was basic F8 Debug functionality. Problem being that FASM works for many different environments, and if one wants to also debug in multiple environments then separate versions of FASM are needed. I've attempted to eliminate part of that need with this patch.

How does it work? Almost transparently.

FASM stores information about the output format of each compile, that information is used to create the INI keys. So, a different tool can be assigned to every output format. The key also includes the file extension to support binary file differentiation. With this patch it becomes easy to program in DOS/Win32/Win64 all at the same time and execute the correct debugging tool.

How to configure? The file type one wishes to configure must be compiled, and then select the "Debugger setup..." option from the menu. Normally, the command line needs to be preceded with "%s" which gets replaced by the debugger program. The second %s is the name of the file generated by FASM.

Let's look at an example:
Code:
format binary as 'txt'

db 'This is a test.'    
...here we want to execute Notepad after assembling this file. So, the debugger is C:\Windows\System32\Notepad.exe and the command line is "%s" %s
(quotes included)

Some other use cases:

A) execute your make tool for COFF files.

B) start an emulator to debug OS development



Only known bug is when there isn't an extension on the compiled file - which I just noticed. Diff was created against 1.71.11 sources (really IDE 0.96.0), but easy enough to patch manually.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 06 Aug 2013, 22:29
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4020
Location: vpcmpistri
bitRAKE 17 Aug 2013, 08:46
Fixed the silly bug which would use the current settings as default. Now, it correctly does nothing when debug settings do not exist for the current file type.
Code:
diff -Narb -X EXCLUDE.TXT R:\FASM17112\SOURCE\IDE\FASMW\FASMW.ASM R:\!FASM\SOURCE\IDE\FASMW\FASMW.ASM
15c15
< IDE_VERSION_STRING equ "0.96.0"
---
> IDE_VERSION_STRING equ "0.96.0a"
80a81
>   _pick_debugger db 'Select debugger program',0
124a126,129
>   debugger_type     db '%s_%X_%X_%s',0
>   debugger_program  db 'Program',0
>   debugger_params   db 'Params',0
>   _section_debugger db 'Debugger',0
230a236,239
>   debuggerprogram rb 200h
>   debuggerparams rb 200h
>   debugcmdline rb 1000h
> 
1199a1209,1210
>       cmp     eax,IDM_DEBUG
>       je      debug
1207a1219,1220
>       cmp     eax,IDM_DEBUGGERSETUP
>       je      debugger_setup
1580a1594,1603
>   debug:
>       and     [command_flags],0
>       invoke  SendMessage,[hwnd],FM_COMPILE,0,FALSE
>       or      eax,eax
>       jnz     finish
>       stc ; debug mode
>       call    Debugger
>       jmp     finish
1600a1624,1628
>   debugger_setup:
>       mov     eax,[hwnd]
>       clc ; setup mode
>       call    Debugger
>       jmp     finish
3056a3085,3196
> proc DebuggerSetup hwnd_dlg,msg,wparam,lparam
>       push    ebx esi edi
>       cmp     [msg],WM_INITDIALOG
>       je      .initdialog
>       cmp     [msg],WM_COMMAND
>       je      .command
>       cmp     [msg],WM_CLOSE
>       je      .close
>   .notprocessed:
>       xor     eax,eax
>       jmp     .finish
>   .pick:
>       mov     [ofn.lpstrFile],debuggerprogram
>       mov     [ofn.lpstrFilter],0
>       mov     [ofn.Flags],OFN_EXPLORER+OFN_FILEMUSTEXIST
>       mov     [ofn.lpstrTitle],_pick_debugger
>       invoke  GetOpenFileName,ofn
>   .initdialog:
>       invoke  SetDlgItemText,[hwnd_dlg],ID_DEBUGGERPROGRAM,debuggerprogram
>       invoke  SetDlgItemText,[hwnd_dlg],ID_DEBUGGERPARAMS,debuggerparams
>       jmp     .processed
>   .command:
>       cmp     [wparam],IDCANCEL
>       je      .close
>       cmp     [wparam],ID_DEBUGGERPICK
>       je      .pick
>       cmp     [wparam],IDOK
>       jne     .finish
>       invoke  GetDlgItemText,[hwnd_dlg],ID_DEBUGGERPROGRAM,debuggerprogram,200h
>       invoke  GetDlgItemText,[hwnd_dlg],ID_DEBUGGERPARAMS,debuggerparams,200h
>       invoke  EndDialog,[hwnd_dlg],TRUE
>       jmp     finish
>   .close:
>       invoke  EndDialog,[hwnd_dlg],FALSE
>   .processed:
>       mov     eax,1
>   .finish:
>       pop     edi esi ebx
>       ret
> endp
> 
> Debugger:
>       push ebx esi edi
>       virtual at ebp-.FRAME
>         .key_program rb $80
>         .key_params  rb $80
> 
>         .hwnd rd 1
>         .CF rb 1
>         .FRAME = ($-$$+3)AND-4
>       end virtual
>       enter .FRAME,0
>       setc [.CF]
>       mov [.hwnd],eax
> 
>       cmp     [output_format],1
>       adc     [output_format],0
> 
>       lea edi,[path_buffer]
>       cmp byte[edi],0
>       jz .finish
>       mov esi,edi
> 
>       xor ebx,ebx
>   .ext: inc edi
>       cmp byte[edi-1],'.'
>       cmovz ebx,edi
>       cmp byte[edi-1],0
>       jnz .ext
>       ; convert extension to uppercase?
>       movzx eax,[output_format]
>       mov edx,[format_flags]
>       and edx,$030C ; what bits?
>       mov [param_buffer+0],ebx
>       mov [param_buffer+4],eax
>       mov [param_buffer+8],edx
> 
>       mov [param_buffer+12],debugger_params
>       lea ebx,[.key_params]
>       invoke wvsprintf,ebx,debugger_type,param_buffer
>       invoke  GetPrivateProfileString,_section_debugger,ebx,0,debuggerparams,200h,ini_path
> 
>       mov [param_buffer+12],debugger_program
>       lea edi,[.key_program]
>       invoke wvsprintf,edi,debugger_type,param_buffer
>       invoke  GetPrivateProfileString,_section_debugger,edi,0,debuggerprogram,200h,ini_path
>       test [.CF],1
>       jnz .debug
>   .settings:
>       invoke  DialogBoxParam,[hinstance],IDD_DEBUGGERSETUP,[.hwnd],DebuggerSetup,edi
>       test eax,eax
>       jz .finish
>       invoke  WritePrivateProfileString,_section_debugger,ebx,debuggerparams,ini_path
>       invoke  WritePrivateProfileString,_section_debugger,edi,debuggerprogram,ini_path
>       jmp .finish
>   .debug:
>       test eax,eax
>       jz .finish
>       mov     [param_buffer+0],debuggerprogram
>       mov     [param_buffer+4],path_buffer
>       invoke  wvsprintf,debugcmdline,debuggerparams,param_buffer
> 
>       mov     [sinfo.cb],sizeof.STARTUPINFO
>       mov     [sinfo.dwFlags],0
>       invoke  CreateProcess,debuggerprogram,debugcmdline,0,0,0,NORMAL_PRIORITY_CLASS,0,0,sinfo,pinfo
>       invoke  CloseHandle,[pinfo.hThread]
>       invoke  CloseHandle,[pinfo.hProcess]
>   .finish:
>       leave
>       pop edi esi ebx
>       retn
> 
> 
3254a3395
>          IDD_DEBUGGERSETUP,LANG_ENGLISH+SUBLANG_DEFAULT,debugger_setup_dialog,\
3281,3282c3422,3424
<   IDD_ABOUT       = 309
<   IDD_CALCULATOR    = 310
---
>   IDD_DEBUGGERSETUP = 309
>   IDD_ABOUT       = 310
>   IDD_CALCULATOR    = 311
3314a3457
>   IDM_DEBUGGERSETUP  = 1503
3357a3501,3503
>   ID_DEBUGGERPROGRAM=3000
>   ID_DEBUGGERPARAMS= 3001
>   ID_DEBUGGERPICK  = 3002
3390c3536,3537
<               ;menuitem '&Debug' _ 'F8',IDM_DEBUG
---
>               menuitem '&Debug' _ 'F8',IDM_DEBUG
>               menuseparator
3394a3542
>               menuitem '&Debugger setup...',IDM_DEBUGGERSETUP
3535a3684,3693
>   enddialog
> 
>   dialog debugger_setup_dialog,'Debugger Setup',54,28,186,44,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME
>     dialogitem 'STATIC','&Debugger:',-1,4,8,40,8,WS_VISIBLE+SS_RIGHT
>     dialogitem 'EDIT','',ID_DEBUGGERPROGRAM,48,6,74,12,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL
>     dialogitem 'BUTTON','...',ID_DEBUGGERPICK,122,6,8,12,WS_VISIBLE+WS_TABSTOP
>     dialogitem 'STATIC','&Parameters:',-1,4,26,40,8,WS_VISIBLE+SS_RIGHT
>     dialogitem 'EDIT','',ID_DEBUGGERPARAMS,48,24,82,12,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL
>     dialogitem 'BUTTON','OK',IDOK,138,6,42,14,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
>     dialogitem 'BUTTON','C&ancel',IDCANCEL,138,22,42,14,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON    
Post 17 Aug 2013, 08:46
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.