The MASM Forum

Projects => Rarely Used Projects => Archival JWASM postings => Topic started by: ToutEnMasm on August 15, 2015, 08:26:09 PM

Title: Jwasm 13 debugging source mode in 64 bits
Post by: ToutEnMasm on August 15, 2015, 08:26:09 PM
Hello,
I used those options

Quote
jwasm /c /win64 /Zi /Zd /nologo /Zp8
LINK /NOLOGO /DEBUG:FASTLINK /debugtype:cv
And i try to debug in source mode,following the source lines.
Visual studio say me there is missed informations,What happen ?.
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on August 16, 2015, 06:08:07 AM
I am aware that JWasm has a problem with debugging but it works if you use small source file like this:

Code: [Select]
  option casemap : none
option win64 : 11
option frame : auto
option STACKBASE : RSP
.code
     
main PROC  FRAME
  vaddpd zmm30,zmm29,[rdx+400h]{1to8}
  vaddpd zmm21{z}{k3}, zmm23, zmm31
  vaddpd zmm21{k1}{z}, zmm23, zmm31
  vaddpd zmm21{k1}, zmm23, zmm31
  vaddpd zmm21{z}, zmm23, zmm31
ret 
main ENDP

END main
I use this for the compiler:
Code: [Select]
/OUT:"C:\JWasm.exe" /MANIFEST /NXCOMPAT /PDB:"C:\Users\Brane\Desktop\JWasm\x64\Debug\JWasm.pdb"
/DYNAMICBASE /FIXED:NO /DEBUG /MACHINE:X64/INCREMENTAL:NO /PGD:"C:\JWasm\x64\Debug\JWasm.pgd"
/MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Debug\JWasm.exe.intermediate.manifest"
/ERRORREPORT:PROMPT /NOLOGO /ASSEMBLYDEBUG /TLBID:1

and this for the linker:
Code: [Select]
/OUT:"C:\Users\Brane\Desktop\HJWasm\x64\Debug\HJWasm.exe" /MANIFEST /NXCOMPAT /PDB:"C:JWasm\x64\Debug\JWasm.pdb"
/DYNAMICBASE /FIXED:NO /DEBUG /MACHINE:X64 /INCREMENTAL:NO /PGD:"C:\Users\Brane\Desktop\HJWasm\x64\Debug\HJWasm.pgd"
/MANIFESTUAC:"level='asInvoker' uiAccess='false'"
/ManifestFile:"x64\Debug\HJWasm.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /ASSEMBLYDEBUG /TLBID:1
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: ToutEnMasm on May 07, 2016, 08:43:05 PM
I have downloaded  the last version,but no more progress.
Is there no hope for debugging in source mode in 64 bits ?.
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: fearless on May 07, 2016, 09:34:49 PM
Seems to work fine with RadASM v2.x and x64dbg

(http://s32.postimg.org/y4na5xda9/x64dbgjwasm.jpg) (http://postimg.org/image/y4na5xda9/)

(http://s32.postimg.org/3wibq5pxd/jwasmsrcdebugging.jpg) (http://postimg.org/image/3wibq5pxd/)
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: ToutEnMasm on May 08, 2016, 01:36:32 AM
With windbg,i have only jwasm who can debug in source mode for 32 bits.
I have also a problem with align 16,don't work.

Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 08, 2016, 08:22:34 AM
Hi ToutEnMasm, I am aware of that and I am investigating the cause of that,
however, it is very hard to find where is the actual problem because it works fine in 64 bit
It will take some time to fix it.
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 08, 2016, 09:04:15 PM
Actually, the last version of HJWasm32.exe from Terraspace can debug on source level.
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: ToutEnMasm on May 08, 2016, 11:41:13 PM
Win 10 don't seem to agree with that,but there is other things who don't work as expected with win 10.
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 08, 2016, 11:57:09 PM
I have Windows 8.1,
I installed Windows 10 and I realized it was a bad decision, so I reverted to Windows 8.1 while I still could
Sooner or later I will have to accept Windows 10, most probably when I get forced to upgrade my laptop.
For now I don't have possibility to experiment with Windows 10 simply because I don't have access to it.
You are left with two choices:
 1) wait until I upgrade to Windows 10
 2) try to figure it out yourself
People have a saying: "If you want a job done properly do it yourself"
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: nidud on May 09, 2016, 12:00:38 AM
 :biggrin:

There is no 32-bit version of HJWasm and there has never been any 32-bit version of HJWasm.

Having a 64-bit version labelled as 32-bit at the download site is not a good idea: people may download it and get rather disappointed.

So here’s a 32-bit version build with VC v6.0
Code: [Select]
HJWasm v2.14, May  8 2016, Masm-compatible assembler.
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 06:23:25 AM
Hi nidud,
Your build is fine if you are assembling 32 bit source, but has general failure if you try to assemble 64 bit.
To be acurate:
    vgatherdpd zmm15{k1}, [r14+ymm13*8+7bh]    ;works
    but:
    vgatherdpd zmm15{k1}, [r14+ymm31*8+7bh]   ;general failure
   
    and:
    real8  2.22e-308 ;rejected by ml + jwasm ( since v2.11 )
    error A2076: Initializer magnitude too large for specified size

I think that 32 bit HJWasm should be still able to assemble 64 bit without general failure.
I am not ungrateful and I appreciate you from the start of your ASMC, I just want to make HJWasm work fine in both x68 and x64.
I have build one x68 version with the Code:Blocks and would like you and other people to test if it can assemble both
 
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: HSE on May 09, 2016, 07:11:41 AM
habran:
 in your compilation echo is not working (any message to console)



          I forget to say: win 7 -32
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: jj2007 on May 09, 2016, 08:06:51 AM
Slow but messages to console are working:
Code: [Select]
*** Assemble using HJWasm /c /coff  /Fl /Sn /Fo "MasmBasic" ***
HJWasm v2.14, May  9 2016, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

*** using MasmBasic version 06.05.2016 ***
Tmp_File.asm: 761 lines, 4 passes, 796 ms, 0 warnings, 0 errors
*** Link using link with sub Console    "MasmBasic.obj" /OUT:TestMasmBasic.exe - no resources ***

Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

*** Assembling and linking took 8237 milliseconds ***

AsmC does it in 2 seconds. There seems to be a considerable overhead:

\Masm32\MasmBasic\libtmpAA.asm: 15065 lines, 2 passes, 312 ms, 0 warnings, 0 errors
\Masm32\MasmBasic\libtmpAD.asm: 94 lines, 2 passes, 219 ms, 0 warnings, 0 errors
\Masm32\MasmBasic\libtmpAE.asm: 36 lines, 2 passes, 234 ms, 0 warnings, 0 errors
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 08:14:32 AM
Hi HSE,
It is built with GNU GCC compiler with Code:Blocks
I am curious if you run it on 32 bit machine.
If it works fine on 32 bit computers I can see if I can tweak Code:Blocks to force the echo.

Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 08:19:59 AM
Hi jj2007, thanks for testing :biggrin:
However, AFAIK, you have 64 bit computer.
If you have a 32 bit machine try to run it there please
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 08:25:11 AM
I think we should actually create 3 kind of HJWasm:
1) HJWasm32.exe              ;for 32 bit computers
2) HJWasmx86.exe            ;for 64 bit computers
3) HJWasmx64                  ;for 64 bit computers
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: nidud on May 09, 2016, 08:49:16 AM
It works in debug mode but generate an error without:
Code: [Select]
        .x64
        .model flat

        .code
        OPTION EVEX:1

        vgatherdpd zmm15{k1}, [r14+ymm31*8+7bh]
 Error A2168: General Failure
end

Well that is at least a clue.
So, lets remove the exception handler: it doesn’t tell much.
Code: [Select]
#ifndef DEBUG_OUT
// signal(SIGSEGV, genfailure);
#endif

Now we have a crash point with some info:
Code: [Select]
0041904F   je          00419097
00419051   xor         edx,edx
00419053   mov         dl,byte ptr [eax+1]
00419056   push        edx
00419057   call        00402890
0041905C   add         esp,4
0041905F   test        eax,eax
00419061   je          00419097
00419063   cmp        dword ptr [eax+14h],0C4h <<<< eax = 1
0041906A   jne         00419074
0041906C   mov         eax,dword ptr [eax+34h]
0041906F   mov         dword ptr [esi+40h],eax
00419072   pop         esi
00419073   ret
00419074   cmp         byte ptr [eax+1Dh],1
00419078   jne         00419097
0041907A   mov         ecx,dword ptr [eax+20h]
0041907D   mov         dword ptr [esi+40h],ecx
00419080   mov         ecx,dword ptr [eax+20h]
00419083   test        ecx,ecx
00419085   je          0041908F
00419087   mov         edx,dword ptr [ecx+14h]
0041908A   mov         dword ptr [esi+2Ch],edx
0041908D   pop         esi
0041908E   ret

0C4h is MT_TYPE, so we looking for:
Code: [Select]
if (struct.[eax+14h] == MT_TYPE)
return ?
else if (struct.[eax+1Dh] == 1)

Some clues from the build process:
Code: [Select]
\HJWASM\SRC\expreval.c(2465) : warning C4047: '!=' : 'struct asym *' differs in levels of indirection from 'const int '

Leads to this code:
Code: [Select]
/* v2.07: moved out from get_operand, case T_REG
 * this function is now called from calculate() only.
 */
static void CheckAssume( struct expr *opnd )
...
    if ( opnd->base_reg ) {
        sym = GetStdAssumeEx( opnd->base_reg->bytval ); <<<<<< ?
    }
    if (!sym && opnd->idx_reg ) {
sym = GetStdAssumeEx( opnd->idx_reg->bytval ); <<<<<< ?
    }
      if ((opnd->type != 0x7b)&&(opnd->type != NULL)){//this is temporary fix for VGATHER instructions in DEBUG mode
        DebugMsg1(( "CheckAssume(%s, type=>%s<, mbr=>%s<): assume=%s [memtype=%X isptr=%u type=%s target_type=%s ptr_memt=%X]\n",
                   GetResWName( ( opnd->idx_reg ? opnd->idx_reg->tokval : opnd->base_reg->tokval ), NULL ),
                   opnd->type ? opnd->type->name : "NULL",
                   opnd->mbr ? opnd->mbr->name : "NULL",
                   sym->name, sym->mem_type, sym->is_ptr,
                   sym->type ? sym->type->name : "NULL",
                   sym->target_type ? sym->target_type->name : "NULL",
                   sym->ptr_memtype ));
      }
        /* v2.08: skip ASSUMEd type if type or mbr is set */
        //if ( opnd->type || opnd->mbr )
        //    return;
        /* skip "alias" types */
        /* v2.05: obsolete */
        //for ( ; sym->type; sym = sym->type );
        /* v2.05: new */
if ( sym->mem_type == MT_TYPE ) <<<<<< sym = 1
            opnd->type = sym->type;
        else if ( sym->is_ptr == 1 ) { /* v2.10: only dereference if indirection is 1 */
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 08:53:41 AM
Hi nidud,
I know that you had to tweak HJWasm source to be able to build it with VC v6.0
Can you please upload that project to your The Doszip Commander page so that I can download that project.
I would like to keep it separated from x64 project on Terraspae and when I make change to HJWasm I would be able to do the same to that project as well. It will be there available to you so that you can build binaries for 32 bit folks.
I think that Johnsa will be glad to include you as well on Terraspae as a developer of HJWasm 
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: nidud on May 09, 2016, 09:20:30 AM
Habran, I downloaded the source a few hours ago:
Code: [Select]
HJWasm-master.zip              21674K    8.05.16 15:30
So I have not done any tweaking at all. I just copied the src directory to \hjwasm and run a batch file to build it:
Code: [Select]
SET SRC=\HJWASM\SRC
SET INC=%SRC%\h

\VC\bin\cl -c -nologo -O2 -Ot -Zm200 -DNDEBUG -I%INC% -I\VC\include %SRC%\*.c
\vc\bin\link /out:hjwasm.exe /subsystem:console /libpath:\vc\lib *.obj
@del *.obj

That's it.
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 09:27:12 AM
That is good :t
So you will need to build for 32 bit computers because I don't have that VC v6.0
We will include your binaries to Terraspace if you agree with it.
I will see if I can find a better solution for :
      if ((opnd->type != 0x7b)&&(opnd->type != NULL)){ //this is temporary fix for VGATHER instructions in DEBUG mode

Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 09:29:05 AM
nidud, what about the version I posted, did you try it?
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: HSE on May 09, 2016, 09:39:27 AM
Yes, 32 bit machine. No evident problem (except no messages).

I post my modified compilation for ObjAsm32 in http://masm32.com/board/index.php?topic=5244.msg57297#msg57297
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 09:43:46 AM
Thanks HSE  :t
I will see if I can fix that
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: nidud on May 09, 2016, 09:44:46 AM
 :biggrin:

Think it would be best if you just install VC 6.0 on your machine.

Or even better to install the build tools that currently holds the copyright to HJWasm: http://www.openwatcom.org/ (http://www.openwatcom.org/)
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 10:02:15 AM
I don't have VC 6.0
I have installed WATCOM on my machine, I will try to build with it.
For now here is one build with speed option build with C:B:
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 10:25:23 AM
OK, line : if ((opnd->type != 0x7b)&&(opnd->type != NULL)){ //this is temporary fix for VGATHER instructions in DEBUG mode
can be replaced wit
  if ( opnd->type != NULL ){

and it works fine :biggrin:
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: nidud on May 09, 2016, 10:29:15 AM
Here's the batch for Open Watcom:
Code: [Select]
SET SRC=\HJWASM\SRC

for %%q in (%SRC%\*.c) do \WATCOM\binnt\wcc386 -q -bt=nt -bc -zc -I\WATCOM\h;%SRC%\h -3r -obmilrt -s -DNDEBUG %%q
\WATCOM\binnt\wlink N hjwasm.exe OP q, m System nt file { *.obj }
@del *.obj
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: nidud on May 09, 2016, 10:41:20 AM
OK, line : if ((opnd->type != 0x7b)&&(opnd->type != NULL)){ //this is temporary fix for VGATHER instructions in DEBUG mode
can be replaced wit
  if ( opnd->type != NULL ){

and it works fine :biggrin:

Well, the problem with the symbol is still there, so it still crashes if you remove (or fix) the debug code.

Code: [Select]
/* v2.05: new, used by
 * expression evaluator if a register is used for indirect addressing
 */

struct asym *GetStdAssumeEx( int reg )
/************************************/
{
    return( StdAssumeTable[reg].symbol );
}

Code: [Select]
/* table StdAssume is for the standard registers;
 * order does match regno in special.h:
 * (R|E)AX=0, (R|E)CX=1, (R|E)DX=2, (R|E)BX=3
 * (R|E)SP=4, (R|E)BP=5, (R|E)SI=6, (R|E)DI=7
 * R8 .. R15.
 */
struct assume_info StdAssumeTable[NUM_STDREGS];

Code: [Select]
    x = opnd->base_reg->bytval;
    if ( opnd->base_reg ) {
        sym = GetStdAssumeEx( opnd->base_reg->bytval );
    }
    sym->is_ptr = x;

Code: [Select]
EBX = 0000000E = opnd->base_reg->bytval --> sym = 0
EBX = 0000001F = opnd->idx_reg->bytval  --> sym = 1 <<<< crash
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: nidud on May 09, 2016, 10:50:40 AM
Code: [Select]
#if AMD64_SUPPORT
#define NUM_STDREGS 16
#else
#define NUM_STDREGS 8
#endif

So..
Code: [Select]
struct asym *GetStdAssumeEx( int reg )
/************************************/
{
    if ( reg >= NUM_STDREGS )
return NULL;
    return( StdAssumeTable[reg].symbol );
}
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 12:38:03 PM
OK, thanks nidud, it will be fixed in next release :t
and thanks for the batch for Open Watcom, I will try to build it now.
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 01:23:56 PM
I succeeded to build 32 bit with OpenWatcom.
I used again Code:Blocks but chose  OpenWatcom 32 compiler
As far as I tested it works fine in both 32 and 64 bit
The only problem in 64 is it rejects: real8  2.22e-308 ;rejected by ml + jwasm ( since v2.11 )
I could have changed it in watcom headers but I don't want to do that because for x64 build we will still use MSVS
I really have to mention that the Code:Blocks is an excellent tool :t
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: TWell on May 09, 2016, 04:35:01 PM
Here is hjwasm.exe build with MSVC 2013 and WinDDK 7600 headers and libraries, -subsystem:console,5.1
Should run in WindowsXP too.
Can we have here some test files for testing?
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: ToutEnMasm on May 09, 2016, 05:40:05 PM
:biggrin:

The Hjwasm32 posted by Habran and compiled with openWatcom mark one point on 32 bits.
Under Windows 10 he allow to debug 32 bit sources codes in source mode with windbg.
He couldn't do the same thing for 64 bits sources.
 
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 07:28:03 PM
Hi ToutEnMasm,
Nice to see a smile ones on your face :biggrin:

He couldn't do the same thing for 64 bits sources.
Please explain ;)
Hi TWell, here is attached one 32 bit example 8)
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: TWell on May 09, 2016, 08:02:26 PM
after chancing in example source rcx to ecx in lines 124 and 125 and comment out invoke subproc1
i was able debug with source with WinDbg 6.1 and Visual Studio in Windows 10.
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 08:05:35 PM
Sorry I borrowed some example from x64
I uploaded fixed version.
But good thing is that it works fine :t
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: habran on May 09, 2016, 09:14:07 PM
TWell, I tested your HJWasm build and it works fine on my laptop, however, it is 64 bit machine,we need to test 32 bit
Title: Re: Jwasm 13 debugging source mode in 64 bits
Post by: HSE on May 09, 2016, 10:01:12 PM
Perfect now  :t