The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: herge on April 12, 2007, 01:58:56 PM

Title: Problems wirh pdb
Post by: herge on April 12, 2007, 01:58:56 PM
Hi All:

I seem to be having problems with building pdb files
and writing to Console[crt].

; REM SHOWTIME.ASM 2:12 PM 7/28/2006
; From MASM32 http://www.masm32.com/board/index.php
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
.data
LOCALE_SYSTEM_DEFAULT   equ   0
hStdOut dd 0; Standard Console output
written dd 0;
stm  SYSTEMTIME<>
    org stm; Must be eight words
wYear dw 0
wMonth dw 0
wToDay dw 0 ; Sunday 0 to Saturday 6
wDay    dw 0
wHour   dw 0
wMinute dw 0
wSecond dw 0
wKsecond dw 0
       
date_buf   db   40 dup (?)
time_buf   db   20 dup (?)
pzCaption  db "Show Time",0
dateformat  db " dddd, MMMM, dd, yyyy", 0
timeformat db "hh:mm:ss tt",0
.code
start:
invTime:
     invoke   GetLocalTime, addr stm
; Print Date
  public invFor
invFor:
   invoke   GetDateFormat, LOCALE_SYSTEM_DEFAULT, NULL, \
       ADDR stm, ADDR dateformat, ADDR date_buf, 40
   mov   ecx, offset date_buf
   add   ecx, eax; add length returned by GetDateFormat
   dec   ecx
   mov   byte ptr [ecx], ' ';replace null with space
   inc   ecx
; Print Time!
  public invPrt
invPrt:
   invoke   GetTimeFormat, LOCALE_SYSTEM_DEFAULT, NULL, \
                  ADDR stm, ADDR timeformat, ecx, 20
  public invMess
invMess:
   invoke   MessageBox, NULL, addr date_buf, addr pzCaption, MB_OK
  public invS
invS:
    invoke GetStdHandle, STD_OUTPUT_HANDLE
    mov hStdOut, eax
    invoke WriteFile,
           eax,
           ADDR date_buf,
           LENGTHOF date_buf,
           ADDR written,
            0         
    invoke      ExitProcess,NULL
end start

REM MAKPDB.BAT 5:15 AM 6/3/2006
REM From Masm Forum
ml /c /coff /Zi /Zd /Fl %1.asm
\masm32\bin\link /SUBSYSTEM:WINDOWS /OPT:NOREF /RELEASE /DEBUG /DEBUGTYPE:CV "%1.obj"
dir %1.*
pause




When I build my pdb[debug info] the WriteFile at end of program
don't work.

Any Suggestions:

Title: Re: Problems wirh pdb
Post by: ToutEnMasm on April 12, 2007, 03:46:23 PM
Hello,
try this
Quote
\masm32\bin\Link /NOLOGO /SUBSYSTEM:WINDOWS /DEBUG /PDB:%1.pdb %1.obj
ToutEnMasm
Title: Re: Problems wirh pdb
Post by: P1 on April 12, 2007, 06:01:10 PM
Here is my BLDALLD.BAT BuildAll Debug batch file from my MASM32.
Of course you need to edit your menu to add it as an option.

You may or may not like the Listing file output.

Regards,  P1  :8)

@echo off

if not exist rsrc.rc goto over1
\masm32\bin\rc /v rsrc.rc
\masm32\bin\cvtres /machine:ix86 rsrc.res
:over1

if exist "%1.obj" del "%1.obj"
if exist "%1.exe" del "%1.exe"

\masm32\bin\ml /c /coff /Fl"%1.lst" /FR"%1.pdb" /Sa /Zd /Zf /Zi  "%1.asm" > "%1.txt"
if errorlevel 1 goto errasm

if not exist rsrc.obj goto nores

rem \masm32\bin\Link /SUBSYSTEM:WINDOWS /DEBUG /OPT:REF /DEBUGTYPE:CV /PDB:"%1" "%1.obj" rsrc.obj
\masm32\bin\Link /SUBSYSTEM:WINDOWS /DEBUG /DEBUGTYPE:CV /PDB:"%1" "%1.obj" rsrc.obj
if errorlevel 1 goto errlink

dir "%1.*"
goto TheEnd

:nores
rem \masm32\bin\Link /SUBSYSTEM:WINDOWS /DEBUG /DEBUGTYPE:CV /PDB:"%1" "%1.obj"
\masm32\bin\Link /SUBSYSTEM:WINDOWS /DEBUG /OPT:REF /DEBUGTYPE:CV /PDB:"%1" "%1.obj"
if errorlevel 1 goto errlink
dir "%1.*"
goto TheEnd

:errlink
echo _
echo Link error
goto TheEnd

:errasm
echo _
echo Assembly Error
goto TheEnd

:TheEnd

pause
Title: Re: Problems wirh pdb
Post by: herge on April 13, 2007, 10:41:43 AM
 Hi ALL:
It would appear that the
     invoke GetStdHandle, STD_OUTPUT_HANDLE
is not working. The carry is set and eax = 10001

You are right the listing file is Huge!
Title: Re: Problems wirh pdb
Post by: sinsi on April 13, 2007, 10:54:25 AM
Don't check the carry flag for any Windows API call - the return value is usually in EAX. In the case of GetStdHandle, if it fails EAX will be INVALID_HANDLE_VALUE (ffffffff), so 10001 is a valid handle.