Can't see content of local variables with WinDbg on amd64

Hi All,
I’m trying to debug an amd 64 bit machine.
I’m debugging the amd 64 machine in kernel mode through com port.
The debugger is running on a 32 bit regular machine.
WinDbg version is the latest.
The drivers have been compiled with DDK with flags: checked, wnet and
amd64.
DDK version from may 2003.

The problem is that the local variables in the local window are all
there but pointing to
addresses relative 0. example:

Name Value Type Location
status long 00000000`00000180

When I’m debugging a 32 bit machine all is normal.

I suspect a problem in the compilation or linkage params.

Attached below a log from the compilation of one driver as a sample:

Thanks. Tamir.

BUILD: Examining d:\dvlp\v4r4.01.x64\safilter directory for files to
compile.
Compiling d:\dvlp\v4r4.01.x64\safilter directory
‘nmake.exe /c BUILDMSG=Stop. -i NTTEST= UMTEST= NOLINK=1 AMD64=1’
1>BUILDMSG: Processing d:\dvlp\v4r4.01.x64\safilter

1> rc -l 409 -DSXS_ASSEMBLY_NAME=“”“”“”
-DSXS_ASSEMBLY_VERSION=“”“”“”
-DSXS_ASSEMBLY_LANGUAGE=“”“”“” -DSXS_PROCESSOR_ARCHITECTURE=“”“AMD64"”“

-DSXS_TARGET=”““safilter.sys””"
-DSYSTEM_COMPATIBLE_ASSEMBLY_NAME=“”“Microsoft.Windows.SystemCompatible”
“”
-DLSYSTEM_COMPATIBLE_ASSEMBLY_NAME=L"““Microsoft.Windows.SystemCompatibl
e””"
-z “MS Sans Serif,Helv/MS Shell Dlg” -r
-fo objchk_wnet_AMD64\amd64\diskperf.res -D_WIN64 -D_AMD64_ -DAMD64
-DCONDITION_HANDLING=1 -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 -DWINNT=1
-D_WIN32_WINNT=0x0502 /DWINVER=0x0502 -D_WIN32_IE=0x0600
-DWIN32_LEAN_AND_MEAN=1 -D_AMD64_SIMULATOR_PERF_ -D_SKIP_IF_SIMULATOR_
-D_AMD64_SIMULATOR_ -D_AMD64_WORKAROUND_ -DDEVL=1 -DDBG=1
-D BUILDMACHINE =WinDDK -DNDEBUG -D_DLL=1
-ID:\WINDDK~1\3790\inc\mfc42 -ID:\WINDDK~1\3790\src\storage\class\inc
-ID:\WINDDK~1\3790\src\storage\inc -ID:\WINDDK~1\3790\src\inc
-ID:\WINDDK~1\3790\inc\ddk\wnet -I…\common -I…\SaEventLog
-Iobjchk_wnet_AMD64\amd64 -ID:\WINDDK~1\3790\inc\wnet
-ID:\WINDDK~1\3790\inc\wnet -ID:\WINDDK~1\3790\inc\ddk\wnet
-ID:\WINDDK~1\3790\inc\ddk\wdm\wnet -ID:\WINDDK~1\3790\inc\crt
.\diskperf.rc

1>cl -nologo -Iamd64\ -I. -ID:\WINDDK~1\3790\inc\mfc42
-ID:\WINDDK~1\3790\src\storage\class\inc
-ID:\WINDDK~1\3790\src\storage\inc
-ID:\WINDDK~1\3790\src\inc -ID:\WINDDK~1\3790\inc\ddk\wnet -I…\common
-I…\SaEventLog -Iobjchk_wnet_AMD64\amd64 -ID:\WINDDK~1\3790\inc\wnet
-ID:\WINDDK~1\3790\inc\wnet -ID:\WINDDK~1\3790\inc\ddk\wnet
-ID:\WINDDK~1\3790\inc\ddk\wdm\wnet -ID:\WINDDK~1\3790\inc\crt -D_WIN64
-D_AMD64_ -DAMD64 -DCONDITION_HANDLING=1 -DNT_INST=0 -DWIN32=100
-D_NT1X_=100 -DWINNT=1 -D_WIN32_WINNT=0x0502 /DWINVER=0x0502
-D_WIN32_IE=0x0600 -DWIN32_LEAN_AND_MEAN=1 -D_AMD64_SIMULATOR_PERF_
-D_SKIP_IF_SIMULATOR_ -D_AMD64_SIMULATOR_ -D_AMD64_WORKAROUND_ -DDEVL=1
-DDBG=1 -D BUILDMACHINE =WinDDK -DNDEBUG -D_DLL=1 /c /Zel /Zp8
/Gy /Gi- -cbstring /W3 /Wp64 /WX /GX- /GR- /GF -Z7 /Od
/DWIN2003_DRIVER -d2home -FID:\WINDDK~1\3790\inc\wnet\warning.h
/d1noWchar_t .\filter.c

1>filter.c
1>
1>Stop.
Linking d:\dvlp\v4r4.01.x64\safilter directory

‘nmake.exe /c BUILDMSG=Stop. -i LINKONLY=1 NOPASS0=1 NTTEST= UMTEST=
AMD64=1’
1> link -out:objchk_wnet_AMD64\amd64\safilter.sys -machine:amd64
@C:\DOCUME~1\toffek\LOCALS~1\Temp\nm2BE.tmp
1>Microsoft (R) Incremental Linker Version 8.00.2207
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>
1>-MERGE:_PAGE=PAGE
1>-MERGE:_TEXT=.text
1>-SECTION:INIT,d
1>-OPT:REF
1>-OPT:ICF
1>-IGNORE:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221
1>-INCREMENTAL:NO
1>-FULLBUILD
1>/release
1>-NODEFAULTLIB
1>/WX
1>-debug:FULL
1>-debugtype:cv
1>-version:5.2
1>-osversion:5.2
1>/opt:nowin98
1>-STACK:0x40000,0x1000
1>-driver
1>-base:0x10000
1>-subsystem:native,5.02
1>-entry:DriverEntry
1>-out:objchk_wnet_AMD64\amd64\safilter.sys
1>objchk_wnet_AMD64\amd64\diskperf.res
1>objchk_wnet_AMD64\amd64\filter.obj
1>D:\WINDDK~1\3790\lib\wnet\amd64\ntoskrnl.lib
1>D:\WINDDK~1\3790\lib\wnet\amd64\hal.lib
1>D:\WINDDK~1\3790\lib\wnet\amd64\wmilib.lib
1>D:\WINDDK~1\3790\lib\wnet\amd64\classpnp.lib
1>…\common\objchk_wnet_AMD64\AMD64\common.lib
1> echo Skip Binplace:
1>Skip Binplace:
1>
1>Stop.


This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.

Local variables only appear in WinDbg if they are stored on the stack. If
they are in registers, you are out of luck and you have to work them out by
hand. This can happen on x86 or x64, but it is a much more common scenario
for x64 since there are so many more useful registers.

To force your code to store all values on the stack (for debugging during
development) turn off optimizations. I believe that’s done with “no_opt” as
a parameter to the DDK build environment setup script. It can be done for
either debug or release builds.


Jake Oshins
Windows Kernel Group

The Virtual Machine Team at Microsoft is hiring. Contact
xxxxx@microsoft.com for more information.

This posting is provided “AS IS” with no warranties, and confers no rights.

“Tamir Offek” wrote in message news:xxxxx@ntdev…
Hi All,
I’m trying to debug an amd 64 bit machine.
I’m debugging the amd 64 machine in kernel mode through com port.
The debugger is running on a 32 bit regular machine.
WinDbg version is the latest.
The drivers have been compiled with DDK with flags: checked, wnet and amd64.
DDK version from may 2003.

The problem is that the local variables in the local window are all there
but pointing to
addresses relative 0. example:

Name Value Type Location
status long 00000000`00000180

When I’m debugging a 32 bit machine all is normal.

I suspect a problem in the compilation or linkage params.

Attached below a log from the compilation of one driver as a sample:

Thanks. Tamir.

BUILD: Examining d:\dvlp\v4r4.01.x64\safilter directory for files to
compile.
Compiling d:\dvlp\v4r4.01.x64\safilter directory
‘nmake.exe /c BUILDMSG=Stop. -i NTTEST= UMTEST= NOLINK=1 AMD64=1’
1>BUILDMSG: Processing d:\dvlp\v4r4.01.x64\safilter

1> rc -l 409 -DSXS_ASSEMBLY_NAME=“”“”“” -DSXS_ASSEMBLY_VERSION=“”“”“”
-DSXS_ASSEMBLY_LANGUAGE=“”“”“” -DSXS_PROCESSOR_ARCHITECTURE=“”“AMD64"”“
-DSXS_TARGET=”““safilter.sys””“
-DSYSTEM_COMPATIBLE_ASSEMBLY_NAME=”““Microsoft.Windows.SystemCompatible””“
-DLSYSTEM_COMPATIBLE_ASSEMBLY_NAME=L”““Microsoft.Windows.SystemCompatible””"
-z “MS Sans Serif,Helv/MS Shell Dlg” -r
-fo objchk_wnet_AMD64\amd64\diskperf.res -D_WIN64 -D_AMD64_ -DAMD64
-DCONDITION_HANDLING=1 -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 -DWINNT=1
-D_WIN32_WINNT=0x0502 /DWINVER=0x0502 -D_WIN32_IE=0x0600
-DWIN32_LEAN_AND_MEAN=1 -D_AMD64_SIMULATOR_PERF_ -D_SKIP_IF_SIMULATOR_
-D_AMD64_SIMULATOR_ -D_AMD64_WORKAROUND_ -DDEVL=1 -DDBG=1
-D BUILDMACHINE =WinDDK -DNDEBUG -D_DLL=1
-ID:\WINDDK~1\3790\inc\mfc42 -ID:\WINDDK~1\3790\src\storage\class\inc
-ID:\WINDDK~1\3790\src\storage\inc -ID:\WINDDK~1\3790\src\inc
-ID:\WINDDK~1\3790\inc\ddk\wnet -I…\common -I…\SaEventLog
-Iobjchk_wnet_AMD64\amd64 -ID:\WINDDK~1\3790\inc\wnet
-ID:\WINDDK~1\3790\inc\wnet -ID:\WINDDK~1\3790\inc\ddk\wnet
-ID:\WINDDK~1\3790\inc\ddk\wdm\wnet -ID:\WINDDK~1\3790\inc\crt .\diskperf.rc

1>cl -nologo -Iamd64\ -I. -ID:\WINDDK~1\3790\inc\mfc42
-ID:\WINDDK~1\3790\src\storage\class\inc -ID:\WINDDK~1\3790\src\storage\inc
-ID:\WINDDK~1\3790\src\inc -ID:\WINDDK~1\3790\inc\ddk\wnet -I…\common
-I…\SaEventLog -Iobjchk_wnet_AMD64\amd64 -ID:\WINDDK~1\3790\inc\wnet
-ID:\WINDDK~1\3790\inc\wnet -ID:\WINDDK~1\3790\inc\ddk\wnet
-ID:\WINDDK~1\3790\inc\ddk\wdm\wnet -ID:\WINDDK~1\3790\inc\crt -D_WIN64
-D_AMD64_ -DAMD64 -DCONDITION_HANDLING=1 -DNT_INST=0 -DWIN32=100
-D_NT1X_=100 -DWINNT=1 -D_WIN32_WINNT=0x0502 /DWINVER=0x0502
-D_WIN32_IE=0x0600 -DWIN32_LEAN_AND_MEAN=1 -D_AMD64_SIMULATOR_PERF_
-D_SKIP_IF_SIMULATOR_ -D_AMD64_SIMULATOR_ -D_AMD64_WORKAROUND_ -DDEVL=1
-DDBG=1 -D BUILDMACHINE =WinDDK -DNDEBUG -D_DLL=1 /c /Zel /Zp8
/Gy /Gi- -cbstring /W3 /Wp64 /WX /GX- /GR- /GF -Z7 /Od
/DWIN2003_DRIVER -d2home -FID:\WINDDK~1\3790\inc\wnet\warning.h
/d1noWchar_t .\filter.c

1>filter.c
1>
1>Stop.
Linking d:\dvlp\v4r4.01.x64\safilter directory

‘nmake.exe /c BUILDMSG=Stop. -i LINKONLY=1 NOPASS0=1 NTTEST= UMTEST=
AMD64=1’
1> link -out:objchk_wnet_AMD64\amd64\safilter.sys -machine:amd64
@C:\DOCUME~1\toffek\LOCALS~1\Temp\nm2BE.tmp
1>Microsoft (R) Incremental Linker Version 8.00.2207
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>
1>-MERGE:_PAGE=PAGE
1>-MERGE:_TEXT=.text
1>-SECTION:INIT,d
1>-OPT:REF
1>-OPT:ICF
1>-IGNORE:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221
1>-INCREMENTAL:NO
1>-FULLBUILD
1>/release
1>-NODEFAULTLIB
1>/WX
1>-debug:FULL
1>-debugtype:cv
1>-version:5.2
1>-osversion:5.2
1>/opt:nowin98
1>-STACK:0x40000,0x1000
1>-driver
1>-base:0x10000
1>-subsystem:native,5.02
1>-entry:DriverEntry
1>-out:objchk_wnet_AMD64\amd64\safilter.sys
1>objchk_wnet_AMD64\amd64\diskperf.res
1>objchk_wnet_AMD64\amd64\filter.obj
1>D:\WINDDK~1\3790\lib\wnet\amd64\ntoskrnl.lib
1>D:\WINDDK~1\3790\lib\wnet\amd64\hal.lib
1>D:\WINDDK~1\3790\lib\wnet\amd64\wmilib.lib
1>D:\WINDDK~1\3790\lib\wnet\amd64\classpnp.lib
1>…\common\objchk_wnet_AMD64\AMD64\common.lib
1> echo Skip Binplace:
1>Skip Binplace:
1>
1>Stop.


This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer
viruses.

> To force your code to store all values on the stack (for debugging during

development) turn off optimizations. I believe that’s done with “no_opt” as
a parameter to the DDK build environment setup script.

!IF !$(FREEBUILD)
MSC_OPTIMIZATION=/Od
!ENDIF

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

I’ve compiled the driver with CHECKED option. Which means the driver
should be suitable for debugging.

In the CHECKED option the compiler is being run with /Od option which
disable optimization.
the link optimizing option is /OPT:ICF and /OPT:REF which to my
understanding shouldn’t cause problems.

In the resent versions of my driver the locals addresses in the debugger
are being shown closer to their real
addresses but they are still wrong (which is actually worse). the only
meaningful thing I’ve done is to update
the win2003 with Microsoft updates…

BTW: I didn’t find “no_opt” (or any thing close) in the documentation of
the DDK and MSDN.

Thanks, Tamir Offek.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com
mailto:xxxxx ] On Behalf Of Jake Oshins
Sent: Tuesday, January 03, 2006 18:54
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Can’t see content of local variables with WinDbg on
amd64

Local variables only appear in WinDbg if they are stored on the stack.
If they are in registers, you are out of luck and you have to work them
out by hand. This can happen on x86 or x64, but it is a much more
common scenario for x64 since there are so many more useful registers.

To force your code to store all values on the stack (for debugging
during
development) turn off optimizations. I believe that’s done with
“no_opt” as a parameter to the DDK build environment setup script. It
can be done for either debug or release builds.


Jake Oshins
Windows Kernel Group

The Virtual Machine Team at Microsoft is hiring. Contact
xxxxx@microsoft.com for more information.

This posting is provided “AS IS” with no warranties, and confers no
rights.

“Tamir Offek” wrote in message news:xxxxx@ntdev
news:xxxxx
Hi All,
I’m trying to debug an amd 64 bit machine.
I’m debugging the amd 64 machine in kernel mode through com port.
The debugger is running on a 32 bit regular machine.
WinDbg version is the latest.
The drivers have been compiled with DDK with flags: checked, wnet and
amd64.
DDK version from may 2003.

The problem is that the local variables in the local window are all
there but pointing to addresses relative 0. example:

Name Value Type Location
status long 00000000`00000180

When I’m debugging a 32 bit machine all is normal.

I suspect a problem in the compilation or linkage params.

Attached below a log from the compilation of one driver as a sample:

Thanks. Tamir.

BUILD: Examining d:\dvlp\v4r4.01.x64\safilter directory for files to
compile.
Compiling d:\dvlp\v4r4.01.x64\safilter directory
‘nmake.exe /c BUILDMSG=Stop. -i NTTEST= UMTEST= NOLINK=1 AMD64=1’
1>BUILDMSG: Processing d:\dvlp\v4r4.01.x64\safilter

1> rc -l 409 -DSXS_ASSEMBLY_NAME=“”“”“”
-DSXS_ASSEMBLY_VERSION=“”“”“”
-DSXS_ASSEMBLY_LANGUAGE=“”“”“” -DSXS_PROCESSOR_ARCHITECTURE=“”“AMD64"”“
-DSXS_TARGET=”““safilter.sys””“
-DSYSTEM_COMPATIBLE_ASSEMBLY_NAME=”““Microsoft.Windows.SystemCompatible”
”“
-DLSYSTEM_COMPATIBLE_ASSEMBLY_NAME=L”““Microsoft.Windows.SystemCompatibl
e””"
-z “MS Sans Serif,Helv/MS Shell Dlg” -r
-fo objchk_wnet_AMD64\amd64\diskperf.res -D_WIN64 -D_AMD64_ -DAMD64
-DCONDITION_HANDLING=1 -DNT_INST=0 -DWIN32=100 -D_NT1X_=100 -DWINNT=1
-D_WIN32_WINNT=0x0502 /DWINVER=0x0502 -D_WIN32_IE=0x0600
-DWIN32_LEAN_AND_MEAN=1 -D_AMD64_SIMULATOR_PERF_ -D_SKIP_IF_SIMULATOR_
-D_AMD64_SIMULATOR_ -D_AMD64_WORKAROUND_ -DDEVL=1 -DDBG=1
-D BUILDMACHINE =WinDDK -DNDEBUG -D_DLL=1
-ID:\WINDDK~1\3790\inc\mfc42 -ID:\WINDDK~1\3790\src\storage\class\inc
-ID:\WINDDK~1\3790\src\storage\inc -ID:\WINDDK~1\3790\src\inc
-ID:\WINDDK~1\3790\inc\ddk\wnet -I…\common -I…\SaEventLog
-Iobjchk_wnet_AMD64\amd64 -ID:\WINDDK~1\3790\inc\wnet
-ID:\WINDDK~1\3790\inc\wnet -ID:\WINDDK~1\3790\inc\ddk\wnet
-ID:\WINDDK~1\3790\inc\ddk\wdm\wnet -ID:\WINDDK~1\3790\inc\crt
.\diskperf.rc

1>cl -nologo -Iamd64\ -I. -ID:\WINDDK~1\3790\inc\mfc42
-ID:\WINDDK~1\3790\src\storage\class\inc
-ID:\WINDDK~1\3790\src\storage\inc
-ID:\WINDDK~1\3790\src\inc -ID:\WINDDK~1\3790\inc\ddk\wnet -I…\common
-I…\SaEventLog -Iobjchk_wnet_AMD64\amd64 -ID:\WINDDK~1\3790\inc\wnet
-ID:\WINDDK~1\3790\inc\wnet -ID:\WINDDK~1\3790\inc\ddk\wnet
-ID:\WINDDK~1\3790\inc\ddk\wdm\wnet -ID:\WINDDK~1\3790\inc\crt -D_WIN64
-D_AMD64_ -DAMD64 -DCONDITION_HANDLING=1 -DNT_INST=0 -DWIN32=100
-D_NT1X_=100 -DWINNT=1 -D_WIN32_WINNT=0x0502 /DWINVER=0x0502
-D_WIN32_IE=0x0600 -DWIN32_LEAN_AND_MEAN=1 -D_AMD64_SIMULATOR_PERF_
-D_SKIP_IF_SIMULATOR_ -D_AMD64_SIMULATOR_ -D_AMD64_WORKAROUND_ -DDEVL=1
-DDBG=1 -D BUILDMACHINE =WinDDK -DNDEBUG -D_DLL=1 /c /Zel /Zp8
/Gy /Gi- -cbstring /W3 /Wp64 /WX /GX- /GR- /GF -Z7 /Od
/DWIN2003_DRIVER -d2home -FID:\WINDDK~1\3790\inc\wnet\warning.h
/d1noWchar_t .\filter.c

1>filter.c
1>
1>Stop.
Linking d:\dvlp\v4r4.01.x64\safilter directory

‘nmake.exe /c BUILDMSG=Stop. -i LINKONLY=1 NOPASS0=1 NTTEST= UMTEST=
AMD64=1’
1> link -out:objchk_wnet_AMD64\amd64\safilter.sys -machine:amd64
@C:\DOCUME~1\toffek\LOCALS~1\Temp\nm2BE.tmp
1>Microsoft (R) Incremental Linker Version 8.00.2207
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>
1>-MERGE:_PAGE=PAGE
1>-MERGE:_TEXT=.text
1>-SECTION:INIT,d
1>-OPT:REF
1>-OPT:ICF
1>-IGNORE:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221
1>-INCREMENTAL:NO
1>-FULLBUILD
1>/release
1>-NODEFAULTLIB
1>/WX
1>-debug:FULL
1>-debugtype:cv
1>-version:5.2
1>-osversion:5.2
1>/opt:nowin98
1>-STACK:0x40000,0x1000
1>-driver
1>-base:0x10000
1>-subsystem:native,5.02
1>-entry:DriverEntry
1>-out:objchk_wnet_AMD64\amd64\safilter.sys
1>objchk_wnet_AMD64\amd64\diskperf.res
1>objchk_wnet_AMD64\amd64\filter.obj
1>D:\WINDDK~1\3790\lib\wnet\amd64\ntoskrnl.lib
1>D:\WINDDK~1\3790\lib\wnet\amd64\hal.lib
1>D:\WINDDK~1\3790\lib\wnet\amd64\wmilib.lib
1>D:\WINDDK~1\3790\lib\wnet\amd64\classpnp.lib
1>…\common\objchk_wnet_AMD64\AMD64\common.lib
1> echo Skip Binplace:
1>Skip Binplace:
1>
1>Stop.

************************************************************

This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals &
computer
viruses.
************************************************************



Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
http:

You are currently subscribed to ntdev as: xxxxx@storeage.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
</http:></news:xxxxx></mailto:xxxxx>