mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 01:39:30 +00:00
Lazy port of kdbg to AMD64. Kdbg is very x86 specific but thankfully amd64 isn't that diferent. It can query register values, list modules, and dump PCR. Other stuff is broken and needs further debugging such as KdpSafe API, IDT, GDT, LDT offsets and disasm code. Backtraces not available because of missing unwind data. Special thanks to Physicus for making this commit possible.
svn path=/branches/ros-amd64-bringup/; revision=44722
This commit is contained in:
parent
6134ac2619
commit
0cb1aea701
12 changed files with 5361 additions and 286 deletions
217
reactos/ntoskrnl/kd/amd64/kdmemsup.c
Normal file
217
reactos/ntoskrnl/kd/amd64/kdmemsup.c
Normal file
|
@ -0,0 +1,217 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS Kernel
|
||||
* FILE: ntoskrnl/kd/amd64/kdmemsup.c
|
||||
* PURPOSE: Kernel Debugger Safe Memory Support
|
||||
*
|
||||
* PROGRAMMERS: arty
|
||||
*/
|
||||
|
||||
#include <ntoskrnl.h>
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#define HIGH_PHYS_MASK 0x80000000
|
||||
#define PAGE_TABLE_MASK 0x3ff
|
||||
#define BIG_PAGE_SIZE (1<<22)
|
||||
#define CR4_PAGE_SIZE_BIT 0x10
|
||||
#define PDE_PRESENT_BIT 0x01
|
||||
#define PDE_W_BIT 0x02
|
||||
#define PDE_PWT_BIT 0x08
|
||||
#define PDE_PCD_BIT 0x10
|
||||
#define PDE_ACCESSED_BIT 0x20
|
||||
#define PDE_DIRTY_BIT 0x40
|
||||
#define PDE_PS_BIT 0x80
|
||||
|
||||
#define MI_KDBG_TMP_PAGE_1 (HYPER_SPACE + 0x400000 - PAGE_SIZE)
|
||||
#define MI_KDBG_TMP_PAGE_0 (MI_KDBG_TMP_PAGE_1 - PAGE_SIZE)
|
||||
|
||||
/* VARIABLES ***************************************************************/
|
||||
|
||||
static BOOLEAN KdpPhysAccess = FALSE;
|
||||
|
||||
static
|
||||
ULONG_PTR
|
||||
KdpPhysMap(ULONG_PTR PhysAddr, LONG Len)
|
||||
{
|
||||
MMPTE TempPte;
|
||||
PMMPTE PointerPte;
|
||||
ULONG_PTR VirtAddr;
|
||||
|
||||
TempPte.u.Long = PDE_PRESENT_BIT | PDE_W_BIT | PDE_PWT_BIT |
|
||||
PDE_PCD_BIT | PDE_ACCESSED_BIT | PDE_DIRTY_BIT;
|
||||
|
||||
if ((PhysAddr & (PAGE_SIZE - 1)) + Len > PAGE_SIZE)
|
||||
{
|
||||
TempPte.u.Hard.PageFrameNumber = (PhysAddr >> PAGE_SHIFT) + 1;
|
||||
PointerPte = MiAddressToPte((PVOID)MI_KDBG_TMP_PAGE_1);
|
||||
*PointerPte = TempPte;
|
||||
VirtAddr = (ULONG_PTR)PointerPte << 10;
|
||||
KeInvalidateTlbEntry((PVOID)VirtAddr);
|
||||
}
|
||||
|
||||
TempPte.u.Hard.PageFrameNumber = PhysAddr >> PAGE_SHIFT;
|
||||
PointerPte = MiAddressToPte((PVOID)MI_KDBG_TMP_PAGE_0);
|
||||
*PointerPte = TempPte;
|
||||
VirtAddr = (ULONG_PTR)PointerPte << 10;
|
||||
KeInvalidateTlbEntry((PVOID)VirtAddr);
|
||||
|
||||
return VirtAddr + (PhysAddr & (PAGE_SIZE - 1));
|
||||
}
|
||||
|
||||
static
|
||||
ULONGLONG
|
||||
KdpPhysRead(ULONG_PTR PhysAddr, LONG Len)
|
||||
{
|
||||
ULONG_PTR Addr;
|
||||
ULONGLONG Result = 0;
|
||||
|
||||
Addr = KdpPhysMap(PhysAddr, Len);
|
||||
|
||||
switch (Len)
|
||||
{
|
||||
case 8:
|
||||
Result = *((PULONGLONG)Addr);
|
||||
break;
|
||||
case 4:
|
||||
Result = *((PULONG)Addr);
|
||||
break;
|
||||
case 2:
|
||||
Result = *((PUSHORT)Addr);
|
||||
break;
|
||||
case 1:
|
||||
Result = *((PUCHAR)Addr);
|
||||
break;
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
KdpPhysWrite(ULONG_PTR PhysAddr, LONG Len, ULONGLONG Value)
|
||||
{
|
||||
ULONG_PTR Addr;
|
||||
|
||||
Addr = KdpPhysMap(PhysAddr, Len);
|
||||
|
||||
switch (Len)
|
||||
{
|
||||
case 8:
|
||||
*((PULONGLONG)Addr) = Value;
|
||||
break;
|
||||
case 4:
|
||||
*((PULONG)Addr) = Value;
|
||||
break;
|
||||
case 2:
|
||||
*((PUSHORT)Addr) = Value;
|
||||
break;
|
||||
case 1:
|
||||
*((PUCHAR)Addr) = Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
KdpTranslateAddress(ULONG_PTR Addr, PULONG_PTR ResultAddr)
|
||||
{
|
||||
ULONG_PTR CR3Value = __readcr3();
|
||||
ULONG_PTR CR4Value = __readcr4();
|
||||
ULONG_PTR PageDirectory = (CR3Value & ~(PAGE_SIZE-1)) +
|
||||
((Addr >> 22) * sizeof(ULONG));
|
||||
ULONG_PTR PageDirectoryEntry = KdpPhysRead(PageDirectory, sizeof(ULONG));
|
||||
|
||||
/* Not present -> fail */
|
||||
if (!(PageDirectoryEntry & PDE_PRESENT_BIT))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Big Page? */
|
||||
if ((PageDirectoryEntry & PDE_PS_BIT) && (CR4Value & CR4_PAGE_SIZE_BIT))
|
||||
{
|
||||
*ResultAddr = (PageDirectoryEntry & ~(BIG_PAGE_SIZE-1)) +
|
||||
(Addr & (BIG_PAGE_SIZE-1));
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ULONG_PTR PageTableAddr =
|
||||
(PageDirectoryEntry & ~(PAGE_SIZE-1)) +
|
||||
((Addr >> PAGE_SHIFT) & PAGE_TABLE_MASK) * sizeof(ULONG);
|
||||
ULONG_PTR PageTableEntry = KdpPhysRead(PageTableAddr, sizeof(ULONG));
|
||||
if (PageTableEntry & PDE_PRESENT_BIT)
|
||||
{
|
||||
*ResultAddr = (PageTableEntry & ~(PAGE_SIZE-1)) +
|
||||
(Addr & (PAGE_SIZE-1));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
KdpSafeReadMemory(ULONG_PTR Addr, LONG Len, PVOID Value)
|
||||
{
|
||||
ULONG_PTR ResultPhysAddr;
|
||||
|
||||
if (!KdpPhysAccess)
|
||||
{
|
||||
memcpy(Value, (PVOID)Addr, Len);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
memset(Value, 0, Len);
|
||||
|
||||
if (!KdpTranslateAddress(Addr, &ResultPhysAddr))
|
||||
return FALSE;
|
||||
|
||||
switch (Len)
|
||||
{
|
||||
case 8:
|
||||
*((PULONGLONG)Value) = KdpPhysRead(ResultPhysAddr, Len);
|
||||
break;
|
||||
case 4:
|
||||
*((PULONG)Value) = KdpPhysRead(ResultPhysAddr, Len);
|
||||
break;
|
||||
case 2:
|
||||
*((PUSHORT)Value) = KdpPhysRead(ResultPhysAddr, Len);
|
||||
break;
|
||||
case 1:
|
||||
*((PUCHAR)Value) = KdpPhysRead(ResultPhysAddr, Len);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
KdpSafeWriteMemory(ULONG_PTR Addr, LONG Len, ULONGLONG Value)
|
||||
{
|
||||
ULONG_PTR ResultPhysAddr;
|
||||
|
||||
if (!KdpPhysAccess)
|
||||
{
|
||||
memcpy((PVOID)Addr, &Value, Len);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!KdpTranslateAddress(Addr, &ResultPhysAddr))
|
||||
return FALSE;
|
||||
|
||||
KdpPhysWrite(ResultPhysAddr, Len, Value);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
KdpEnableSafeMem(VOID)
|
||||
{
|
||||
KdpPhysAccess = TRUE;
|
||||
}
|
||||
|
||||
/* EOF */
|
330
reactos/ntoskrnl/kdbg/amd64/dis-asm.h
Normal file
330
reactos/ntoskrnl/kdbg/amd64/dis-asm.h
Normal file
|
@ -0,0 +1,330 @@
|
|||
/* Interface between the opcode library and its callers.
|
||||
|
||||
Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Written by Cygnus Support, 1993.
|
||||
|
||||
The opcode library (libopcodes.a) provides instruction decoders for
|
||||
a large variety of instruction sets, callable with an identical
|
||||
interface, for making instruction-processing programs more independent
|
||||
of the instruction set being processed. */
|
||||
|
||||
#ifndef DIS_ASM_H
|
||||
#define DIS_ASM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* #include <stdio.h> */
|
||||
/* #include "bfd.h" */
|
||||
#endif
|
||||
|
||||
typedef int (*fprintf_ftype) PARAMS((PTR, const char*, ...));
|
||||
|
||||
enum dis_insn_type {
|
||||
dis_noninsn, /* Not a valid instruction */
|
||||
dis_nonbranch, /* Not a branch instruction */
|
||||
dis_branch, /* Unconditional branch */
|
||||
dis_condbranch, /* Conditional branch */
|
||||
dis_jsr, /* Jump to subroutine */
|
||||
dis_condjsr, /* Conditional jump to subroutine */
|
||||
dis_dref, /* Data reference instruction */
|
||||
dis_dref2 /* Two data references in instruction */
|
||||
};
|
||||
|
||||
/* This struct is passed into the instruction decoding routine,
|
||||
and is passed back out into each callback. The various fields are used
|
||||
for conveying information from your main routine into your callbacks,
|
||||
for passing information into the instruction decoders (such as the
|
||||
addresses of the callback functions), or for passing information
|
||||
back from the instruction decoders to their callers.
|
||||
|
||||
It must be initialized before it is first passed; this can be done
|
||||
by hand, or using one of the initialization macros below. */
|
||||
|
||||
typedef struct disassemble_info {
|
||||
fprintf_ftype fprintf_func;
|
||||
PTR stream;
|
||||
PTR application_data;
|
||||
|
||||
/* Target description. We could replace this with a pointer to the bfd,
|
||||
but that would require one. There currently isn't any such requirement
|
||||
so to avoid introducing one we record these explicitly. */
|
||||
/* The bfd_flavour. This can be bfd_target_unknown_flavour. */
|
||||
enum bfd_flavour flavour;
|
||||
/* The bfd_arch value. */
|
||||
enum bfd_architecture arch;
|
||||
/* The bfd_mach value. */
|
||||
unsigned long mach;
|
||||
#if 0
|
||||
enum bfd_endian endian;
|
||||
#endif
|
||||
/* An arch/mach-specific bitmask of selected instruction subsets, mainly
|
||||
for processors with run-time-switchable instruction sets. The default,
|
||||
zero, means that there is no constraint. CGEN-based opcodes ports
|
||||
may use ISA_foo masks. */
|
||||
unsigned long insn_sets;
|
||||
|
||||
#if 0
|
||||
/* Some targets need information about the current section to accurately
|
||||
display insns. If this is NULL, the target disassembler function
|
||||
will have to make its best guess. */
|
||||
asection *section;
|
||||
|
||||
/* An array of pointers to symbols either at the location being disassembled
|
||||
or at the start of the function being disassembled. The array is sorted
|
||||
so that the first symbol is intended to be the one used. The others are
|
||||
present for any misc. purposes. This is not set reliably, but if it is
|
||||
not NULL, it is correct. */
|
||||
asymbol **symbols;
|
||||
/* Number of symbols in array. */
|
||||
int num_symbols;
|
||||
#endif
|
||||
/* For use by the disassembler.
|
||||
The top 16 bits are reserved for public use (and are documented here).
|
||||
The bottom 16 bits are for the internal use of the disassembler. */
|
||||
unsigned long flags;
|
||||
#define INSN_HAS_RELOC 0x80000000
|
||||
PTR private_data;
|
||||
|
||||
/* Function used to get bytes to disassemble. MEMADDR is the
|
||||
address of the stuff to be disassembled, MYADDR is the address to
|
||||
put the bytes in, and LENGTH is the number of bytes to read.
|
||||
INFO is a pointer to this struct.
|
||||
Returns an errno value or 0 for success. */
|
||||
int (*read_memory_func)
|
||||
PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, unsigned int length,
|
||||
struct disassemble_info *info));
|
||||
|
||||
/* Function which should be called if we get an error that we can't
|
||||
recover from. STATUS is the errno value from read_memory_func and
|
||||
MEMADDR is the address that we were trying to read. INFO is a
|
||||
pointer to this struct. */
|
||||
void (*memory_error_func)
|
||||
PARAMS ((int status, bfd_vma memaddr, struct disassemble_info *info));
|
||||
|
||||
/* Function called to print ADDR. */
|
||||
void (*print_address_func)
|
||||
PARAMS ((bfd_vma addr, struct disassemble_info *info));
|
||||
|
||||
/* Function called to determine if there is a symbol at the given ADDR.
|
||||
If there is, the function returns 1, otherwise it returns 0.
|
||||
This is used by ports which support an overlay manager where
|
||||
the overlay number is held in the top part of an address. In
|
||||
some circumstances we want to include the overlay number in the
|
||||
address, (normally because there is a symbol associated with
|
||||
that address), but sometimes we want to mask out the overlay bits. */
|
||||
int (* symbol_at_address_func)
|
||||
PARAMS ((bfd_vma addr, struct disassemble_info * info));
|
||||
|
||||
/* These are for buffer_read_memory. */
|
||||
bfd_byte *buffer;
|
||||
bfd_vma buffer_vma;
|
||||
unsigned int buffer_length;
|
||||
|
||||
/* This variable may be set by the instruction decoder. It suggests
|
||||
the number of bytes objdump should display on a single line. If
|
||||
the instruction decoder sets this, it should always set it to
|
||||
the same value in order to get reasonable looking output. */
|
||||
int bytes_per_line;
|
||||
|
||||
/* the next two variables control the way objdump displays the raw data */
|
||||
/* For example, if bytes_per_line is 8 and bytes_per_chunk is 4, the */
|
||||
/* output will look like this:
|
||||
00: 00000000 00000000
|
||||
with the chunks displayed according to "display_endian". */
|
||||
int bytes_per_chunk;
|
||||
enum bfd_endian display_endian;
|
||||
|
||||
/* Number of octets per incremented target address
|
||||
Normally one, but some DSPs have byte sizes of 16 or 32 bits. */
|
||||
unsigned int octets_per_byte;
|
||||
|
||||
/* Results from instruction decoders. Not all decoders yet support
|
||||
this information. This info is set each time an instruction is
|
||||
decoded, and is only valid for the last such instruction.
|
||||
|
||||
To determine whether this decoder supports this information, set
|
||||
insn_info_valid to 0, decode an instruction, then check it. */
|
||||
|
||||
char insn_info_valid; /* Branch info has been set. */
|
||||
char branch_delay_insns; /* How many sequential insn's will run before
|
||||
a branch takes effect. (0 = normal) */
|
||||
char data_size; /* Size of data reference in insn, in bytes */
|
||||
enum dis_insn_type insn_type; /* Type of instruction */
|
||||
bfd_vma target; /* Target address of branch or dref, if known;
|
||||
zero if unknown. */
|
||||
bfd_vma target2; /* Second target address for dref2 */
|
||||
|
||||
/* Command line options specific to the target disassembler. */
|
||||
char * disassembler_options;
|
||||
|
||||
} disassemble_info;
|
||||
|
||||
|
||||
/* Standard disassemblers. Disassemble one instruction at the given
|
||||
target address. Return number of octets processed. */
|
||||
typedef int (*disassembler_ftype)
|
||||
PARAMS((bfd_vma, disassemble_info *));
|
||||
|
||||
extern int print_insn_big_mips PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_little_mips PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_i386 PARAMS ((bfd_vma, disassemble_info *));
|
||||
extern int print_insn_i386_att PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_i386_intel PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_ia64 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_i370 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_m68hc11 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_m68hc12 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_m68k PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_z8001 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_z8002 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_h8300 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_h8300h PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_h8300s PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_h8500 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_alpha PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_big_arm PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_little_arm PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_sparc PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_big_a29k PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_little_a29k PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_avr PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_d10v PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_d30v PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_dlx PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_fr30 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_hppa PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_i860 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_i960 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_ip2k PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_m32r PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_m88k PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_mcore PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_mmix PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_mn10200 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_mn10300 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_msp430 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_ns32k PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_openrisc PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_big_or32 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_little_or32 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_pdp11 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_pj PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_big_powerpc PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_little_powerpc PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_rs6000 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_s390 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_sh PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_tic30 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_tic4x PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_tic54x PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_tic80 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_v850 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_vax PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_w65 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_xstormy16 PARAMS ((bfd_vma, disassemble_info*));
|
||||
extern int print_insn_sh64 PARAMS ((bfd_vma, disassemble_info *));
|
||||
extern int print_insn_sh64x_media PARAMS ((bfd_vma, disassemble_info *));
|
||||
extern int print_insn_frv PARAMS ((bfd_vma, disassemble_info *));
|
||||
extern int print_insn_iq2000 PARAMS ((bfd_vma, disassemble_info *));
|
||||
|
||||
extern disassembler_ftype arc_get_disassembler PARAMS ((void *));
|
||||
extern disassembler_ftype cris_get_disassembler PARAMS ((bfd *));
|
||||
|
||||
extern void print_mips_disassembler_options PARAMS ((FILE *));
|
||||
extern void print_ppc_disassembler_options PARAMS ((FILE *));
|
||||
extern void print_arm_disassembler_options PARAMS ((FILE *));
|
||||
extern void parse_arm_disassembler_option PARAMS ((char *));
|
||||
extern int get_arm_regname_num_options PARAMS ((void));
|
||||
extern int set_arm_regname_option PARAMS ((int));
|
||||
extern int get_arm_regnames PARAMS ((int, const char **, const char **, const char ***));
|
||||
|
||||
/* Fetch the disassembler for a given BFD, if that support is available. */
|
||||
extern disassembler_ftype disassembler PARAMS ((bfd *));
|
||||
|
||||
/* Document any target specific options available from the disassembler. */
|
||||
extern void disassembler_usage PARAMS ((FILE *));
|
||||
|
||||
|
||||
/* This block of definitions is for particular callers who read instructions
|
||||
into a buffer before calling the instruction decoder. */
|
||||
|
||||
/* Here is a function which callers may wish to use for read_memory_func.
|
||||
It gets bytes from a buffer. */
|
||||
extern int buffer_read_memory
|
||||
PARAMS ((bfd_vma, bfd_byte *, unsigned int, struct disassemble_info *));
|
||||
|
||||
/* This function goes with buffer_read_memory.
|
||||
It prints a message using info->fprintf_func and info->stream. */
|
||||
extern void perror_memory PARAMS ((int, bfd_vma, struct disassemble_info *));
|
||||
|
||||
|
||||
/* Just print the address in hex. This is included for completeness even
|
||||
though both GDB and objdump provide their own (to print symbolic
|
||||
addresses). */
|
||||
extern void generic_print_address
|
||||
PARAMS ((bfd_vma, struct disassemble_info *));
|
||||
|
||||
/* Always true. */
|
||||
extern int generic_symbol_at_address
|
||||
PARAMS ((bfd_vma, struct disassemble_info *));
|
||||
|
||||
/* Macro to initialize a disassemble_info struct. This should be called
|
||||
by all applications creating such a struct. */
|
||||
#define INIT_DISASSEMBLE_INFO(INFO, STREAM, FPRINTF_FUNC) \
|
||||
(INFO).flavour = bfd_target_unknown_flavour, \
|
||||
(INFO).arch = bfd_arch_unknown, \
|
||||
(INFO).mach = 0, \
|
||||
(INFO).insn_sets = 0, \
|
||||
(INFO).endian = BFD_ENDIAN_UNKNOWN, \
|
||||
(INFO).octets_per_byte = 1, \
|
||||
INIT_DISASSEMBLE_INFO_NO_ARCH(INFO, STREAM, FPRINTF_FUNC)
|
||||
|
||||
/* Call this macro to initialize only the internal variables for the
|
||||
disassembler. Architecture dependent things such as byte order, or machine
|
||||
variant are not touched by this macro. This makes things much easier for
|
||||
GDB which must initialize these things separately. */
|
||||
|
||||
#define INIT_DISASSEMBLE_INFO_NO_ARCH(INFO, STREAM, FPRINTF_FUNC) \
|
||||
(INFO).fprintf_func = (fprintf_ftype)(FPRINTF_FUNC), \
|
||||
(INFO).stream = (PTR)(STREAM), \
|
||||
(INFO).section = NULL, \
|
||||
(INFO).symbols = NULL, \
|
||||
(INFO).num_symbols = 0, \
|
||||
(INFO).private_data = NULL, \
|
||||
(INFO).buffer = NULL, \
|
||||
(INFO).buffer_vma = 0, \
|
||||
(INFO).buffer_length = 0, \
|
||||
(INFO).read_memory_func = buffer_read_memory, \
|
||||
(INFO).memory_error_func = perror_memory, \
|
||||
(INFO).print_address_func = generic_print_address, \
|
||||
(INFO).symbol_at_address_func = generic_symbol_at_address, \
|
||||
(INFO).flags = 0, \
|
||||
(INFO).bytes_per_line = 0, \
|
||||
(INFO).bytes_per_chunk = 0, \
|
||||
(INFO).display_endian = BFD_ENDIAN_UNKNOWN, \
|
||||
(INFO).disassembler_options = NULL, \
|
||||
(INFO).insn_info_valid = 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ! defined (DIS_ASM_H) */
|
4300
reactos/ntoskrnl/kdbg/amd64/i386-dis.c
Normal file
4300
reactos/ntoskrnl/kdbg/amd64/i386-dis.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -3,200 +3,109 @@
|
|||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/kdbg/amd64/kdb.c
|
||||
* PURPOSE: Kernel Debugger
|
||||
* PROGRAMMERS: Gregor Anich
|
||||
* Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
* PROGRAMMERS:
|
||||
*/
|
||||
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ntoskrnl.h>
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
extern KSPIN_LOCK KdpSerialSpinLock;
|
||||
STRING KdpPromptString = RTL_CONSTANT_STRING("kdb:> ");
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
ULONG KdbDebugState = 0; /* KDBG Settings (NOECHO, KDSERIAL) */
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
ULONG
|
||||
NTAPI
|
||||
KiEspFromTrapFrame(IN PKTRAP_FRAME TrapFrame)
|
||||
{
|
||||
return TrapFrame->Rsp;
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
KdbpGetCommandLineSettings(PCHAR p1)
|
||||
KiEspToTrapFrame(IN PKTRAP_FRAME TrapFrame,
|
||||
IN ULONG_PTR Esp)
|
||||
{
|
||||
PCHAR p2;
|
||||
KIRQL OldIrql;
|
||||
ULONG Previous;
|
||||
|
||||
while (p1 && (p2 = strchr(p1, ' ')))
|
||||
/* Raise to APC_LEVEL if needed */
|
||||
OldIrql = KeGetCurrentIrql();
|
||||
if (OldIrql < APC_LEVEL) KeRaiseIrql(APC_LEVEL, &OldIrql);
|
||||
|
||||
/* Get the old ESP */
|
||||
Previous = KiEspFromTrapFrame(TrapFrame);
|
||||
|
||||
/* Check if this is user-mode */
|
||||
if ((TrapFrame->SegCs & MODE_MASK))
|
||||
{
|
||||
p2++;
|
||||
|
||||
if (!_strnicmp(p2, "KDSERIAL", 8))
|
||||
{
|
||||
p2 += 8;
|
||||
KdbDebugState |= KD_DEBUG_KDSERIAL;
|
||||
KdpDebugMode.Serial = TRUE;
|
||||
}
|
||||
else if (!_strnicmp(p2, "KDNOECHO", 8))
|
||||
{
|
||||
p2 += 8;
|
||||
KdbDebugState |= KD_DEBUG_KDNOECHO;
|
||||
}
|
||||
|
||||
p1 = p2;
|
||||
/* Write it directly */
|
||||
TrapFrame->Rsp = Esp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Don't allow ESP to be lowered, this is illegal */
|
||||
if (Esp < Previous) KeBugCheckEx(SET_OF_INVALID_CONTEXT,
|
||||
Esp,
|
||||
Previous,
|
||||
(ULONG_PTR)TrapFrame,
|
||||
0);
|
||||
|
||||
KD_CONTINUE_TYPE
|
||||
KdbEnterDebuggerException(
|
||||
IN PEXCEPTION_RECORD ExceptionRecord OPTIONAL,
|
||||
IN KPROCESSOR_MODE PreviousMode,
|
||||
IN PCONTEXT Context,
|
||||
IN OUT PKTRAP_FRAME TrapFrame,
|
||||
IN BOOLEAN FirstChance)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return 0;
|
||||
}
|
||||
/* Create an edit frame, check if it was alrady */
|
||||
if (!(TrapFrame->SegCs & FRAME_EDITED))
|
||||
{
|
||||
/* Update the value */
|
||||
TrapFrame->Rsp = Esp;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Check if ESP changed */
|
||||
if (Previous != Esp)
|
||||
{
|
||||
/* Save CS */
|
||||
TrapFrame->SegCs &= ~FRAME_EDITED;
|
||||
|
||||
VOID
|
||||
KdbpCliModuleLoaded(IN PUNICODE_STRING Name)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
/* Save ESP */
|
||||
TrapFrame->Rsp = Esp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore IRQL */
|
||||
if (OldIrql < APC_LEVEL) KeLowerIrql(OldIrql);
|
||||
|
||||
VOID
|
||||
KdbpCliInit()
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
ULONG
|
||||
NTAPI
|
||||
KdpPrompt(IN LPSTR InString,
|
||||
IN USHORT InStringLength,
|
||||
OUT LPSTR OutString,
|
||||
IN USHORT OutStringLength)
|
||||
KiSsFromTrapFrame(IN PKTRAP_FRAME TrapFrame)
|
||||
{
|
||||
USHORT i;
|
||||
CHAR Response;
|
||||
ULONG DummyScanCode;
|
||||
KIRQL OldIrql;
|
||||
|
||||
/* Acquire the printing spinlock without waiting at raised IRQL */
|
||||
while (TRUE)
|
||||
if (TrapFrame->SegCs & MODE_MASK)
|
||||
{
|
||||
/* Wait when the spinlock becomes available */
|
||||
while (!KeTestSpinLock(&KdpSerialSpinLock));
|
||||
|
||||
/* Spinlock was free, raise IRQL */
|
||||
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
|
||||
|
||||
/* Try to get the spinlock */
|
||||
if (KeTryToAcquireSpinLockAtDpcLevel(&KdpSerialSpinLock))
|
||||
break;
|
||||
|
||||
/* Someone else got the spinlock, lower IRQL back */
|
||||
KeLowerIrql(OldIrql);
|
||||
/* User mode, return the User SS */
|
||||
return TrapFrame->SegSs | RPL_MASK;
|
||||
}
|
||||
|
||||
/* Loop the string to send */
|
||||
for (i = 0; i < InStringLength; i++)
|
||||
else
|
||||
{
|
||||
/* Print it to serial */
|
||||
KdPortPutByteEx(&SerialPortInfo, *(PCHAR)(InString + i));
|
||||
/* Kernel mode */
|
||||
return KGDT_64_R0_SS;
|
||||
}
|
||||
|
||||
/* Print a new line for log neatness */
|
||||
KdPortPutByteEx(&SerialPortInfo, '\r');
|
||||
KdPortPutByteEx(&SerialPortInfo, '\n');
|
||||
|
||||
/* Print the kdb prompt */
|
||||
for (i = 0; i < KdpPromptString.Length; i++)
|
||||
{
|
||||
/* Print it to serial */
|
||||
KdPortPutByteEx(&SerialPortInfo,
|
||||
*(KdpPromptString.Buffer + i));
|
||||
}
|
||||
|
||||
/* Loop the whole string */
|
||||
for (i = 0; i < OutStringLength; i++)
|
||||
{
|
||||
/* Check if this is serial debugging mode */
|
||||
if (KdbDebugState & KD_DEBUG_KDSERIAL)
|
||||
{
|
||||
/* Get the character from serial */
|
||||
do
|
||||
{
|
||||
Response = KdbpTryGetCharSerial(MAXULONG);
|
||||
} while (Response == -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the response from the keyboard */
|
||||
do
|
||||
{
|
||||
Response = KdbpTryGetCharKeyboard(&DummyScanCode, MAXULONG);
|
||||
} while (Response == -1);
|
||||
}
|
||||
|
||||
/* Check for return */
|
||||
if (Response == '\r')
|
||||
{
|
||||
/*
|
||||
* We might need to discard the next '\n'.
|
||||
* Wait a bit to make sure we receive it.
|
||||
*/
|
||||
KeStallExecutionProcessor(100000);
|
||||
|
||||
/* Check the mode */
|
||||
if (KdbDebugState & KD_DEBUG_KDSERIAL)
|
||||
{
|
||||
/* Read and discard the next character, if any */
|
||||
KdbpTryGetCharSerial(5);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Read and discard the next character, if any */
|
||||
KdbpTryGetCharKeyboard(&DummyScanCode, 5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Null terminate the output string -- documentation states that
|
||||
* DbgPrompt does not null terminate, but it does
|
||||
*/
|
||||
*(PCHAR)(OutString + i) = 0;
|
||||
|
||||
/* Print a new line */
|
||||
KdPortPutByteEx(&SerialPortInfo, '\r');
|
||||
KdPortPutByteEx(&SerialPortInfo, '\n');
|
||||
|
||||
/* Release spinlock */
|
||||
KiReleaseSpinLock(&KdpSerialSpinLock);
|
||||
|
||||
/* Lower IRQL back */
|
||||
KeLowerIrql(OldIrql);
|
||||
|
||||
/* Return the length */
|
||||
return OutStringLength + 1;
|
||||
}
|
||||
|
||||
/* Write it back and print it to the log */
|
||||
*(PCHAR)(OutString + i) = Response;
|
||||
KdPortPutByteEx(&SerialPortInfo, Response);
|
||||
}
|
||||
|
||||
/* Print a new line */
|
||||
KdPortPutByteEx(&SerialPortInfo, '\r');
|
||||
KdPortPutByteEx(&SerialPortInfo, '\n');
|
||||
|
||||
/* Release spinlock */
|
||||
KiReleaseSpinLock(&KdpSerialSpinLock);
|
||||
|
||||
/* Lower IRQL back */
|
||||
KeLowerIrql(OldIrql);
|
||||
|
||||
/* Return the length */
|
||||
return OutStringLength;
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
KiSsToTrapFrame(IN PKTRAP_FRAME TrapFrame,
|
||||
IN ULONG Ss)
|
||||
{
|
||||
/* Remove the high-bits */
|
||||
Ss &= 0xFFFF;
|
||||
|
||||
if (TrapFrame->SegCs & MODE_MASK)
|
||||
{
|
||||
/* Usermode, save the User SS */
|
||||
TrapFrame->SegSs = Ss | RPL_MASK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <ndk/amd64/asmmacro.S>
|
||||
|
||||
|
@ -7,10 +6,11 @@ _KdbEnter:
|
|||
|
||||
/* save flags */
|
||||
pushfq
|
||||
// .pushreg ?
|
||||
|
||||
/* Make room for a KTRAP_FRAME */
|
||||
sub rsp, SIZE_KTRAP_FRAME
|
||||
.allocstack SIZE_KTRAP_FRAME
|
||||
// .allocstack SIZE_KTRAP_FRAME
|
||||
|
||||
/* Save rbp */
|
||||
mov [rsp + KTRAP_FRAME_Rbp], rbp
|
||||
|
@ -30,12 +30,12 @@ _KdbEnter:
|
|||
mov [rsp + KTRAP_FRAME_R11], r11
|
||||
|
||||
/* Save xmm registers */
|
||||
// movdqa [rbp + KTRAP_FRAME_Xmm0], xmm0
|
||||
// movdqa [rbp + KTRAP_FRAME_Xmm1], xmm1
|
||||
// movdqa [rbp + KTRAP_FRAME_Xmm2], xmm2
|
||||
// movdqa [rbp + KTRAP_FRAME_Xmm3], xmm3
|
||||
// movdqa [rbp + KTRAP_FRAME_Xmm4], xmm4
|
||||
// movdqa [rbp + KTRAP_FRAME_Xmm5], xmm5
|
||||
// movdqa [rsp + KTRAP_FRAME_Xmm0], xmm0
|
||||
// movdqa [rsp + KTRAP_FRAME_Xmm1], xmm1
|
||||
// movdqa [rsp + KTRAP_FRAME_Xmm2], xmm2
|
||||
// movdqa [rsp + KTRAP_FRAME_Xmm3], xmm3
|
||||
// movdqa [rsp + KTRAP_FRAME_Xmm4], xmm4
|
||||
// movdqa [rsp + KTRAP_FRAME_Xmm5], xmm5
|
||||
|
||||
/* Save cs and previous mode */
|
||||
mov ax, cs
|
||||
|
@ -45,13 +45,13 @@ _KdbEnter:
|
|||
|
||||
/* Save segment selectors */
|
||||
mov ax, ds
|
||||
mov [rbp + KTRAP_FRAME_SegDs], ax
|
||||
mov [rsp + KTRAP_FRAME_SegDs], ax
|
||||
mov ax, es
|
||||
mov [rbp + KTRAP_FRAME_SegEs], ax
|
||||
mov [rsp + KTRAP_FRAME_SegEs], ax
|
||||
mov ax, fs
|
||||
mov [rbp + KTRAP_FRAME_SegFs], ax
|
||||
mov [rsp + KTRAP_FRAME_SegFs], ax
|
||||
mov ax, gs
|
||||
mov [rbp + KTRAP_FRAME_SegGs], ax
|
||||
mov [rsp + KTRAP_FRAME_SegGs], ax
|
||||
|
||||
/* Save previous irql */
|
||||
mov rax, cr8
|
||||
|
@ -71,16 +71,16 @@ _KdbEnter:
|
|||
mov rax, dr7
|
||||
mov [rsp + KTRAP_FRAME_Dr7], rax
|
||||
|
||||
/* Point rbp, where rsp was initially */
|
||||
lea rbp, [rsp + SIZE_KTRAP_FRAME + 8]
|
||||
/* Point rbp, where rsp was before */
|
||||
lea rbp, [rsp + SIZE_KTRAP_FRAME]
|
||||
mov [rsp + KTRAP_FRAME_Rsp], rbp
|
||||
|
||||
/* Store the EFLAGS we previously pushed on the stack */
|
||||
mov rax, [rbp]
|
||||
mov rax, [rbp + 8]
|
||||
mov [rsp + KTRAP_FRAME_EFlags], rax
|
||||
|
||||
/* Get RIP from the stack */
|
||||
mov rax, [rbp + 8]
|
||||
mov rax, [rbp + 16]
|
||||
mov [rsp + KTRAP_FRAME_Rip], rax
|
||||
|
||||
/* Make sure the direction flag is cleared */
|
||||
|
@ -124,4 +124,29 @@ _KdbEnter:
|
|||
/* Restore RSP */
|
||||
mov rsp, [rsp + KTRAP_FRAME_Rsp]
|
||||
|
||||
iret
|
||||
/* Restore EFLAGS */
|
||||
popfq
|
||||
|
||||
ret
|
||||
|
||||
.globl _KdbpStackSwitchAndCall
|
||||
_KdbpStackSwitchAndCall:
|
||||
|
||||
/* Save old stack */
|
||||
mov rax, rsp
|
||||
|
||||
/* Set new stack */
|
||||
mov rsp, rcx
|
||||
|
||||
/* Save old stack on new stack */
|
||||
push rax
|
||||
|
||||
/* Call function */
|
||||
call rdx
|
||||
|
||||
/* Restire old stack */
|
||||
pop rax
|
||||
mov rsp, rax
|
||||
|
||||
/* Return */
|
||||
ret
|
118
reactos/ntoskrnl/kdbg/amd64/setjmp.S
Normal file
118
reactos/ntoskrnl/kdbg/amd64/setjmp.S
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* PURPOSE: Implementation of _setjmp/longjmp
|
||||
* FILE: lib/sdk/crt/setjmp/amd64/setjmp.s
|
||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ndk/amd64/asm.h>
|
||||
#include <ndk/amd64/asmmacro.S>
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
#define JUMP_BUFFER_Frame 0x00
|
||||
#define JUMP_BUFFER_Rbx 0x08
|
||||
#define JUMP_BUFFER_Rsp 0x10
|
||||
#define JUMP_BUFFER_Rbp 0x18
|
||||
#define JUMP_BUFFER_Rsi 0x20
|
||||
#define JUMP_BUFFER_Rdi 0x28
|
||||
#define JUMP_BUFFER_R12 0x30
|
||||
#define JUMP_BUFFER_R13 0x38
|
||||
#define JUMP_BUFFER_R14 0x40
|
||||
#define JUMP_BUFFER_R15 0x48
|
||||
#define JUMP_BUFFER_Rip 0x50
|
||||
#define JUMP_BUFFER_Spare 0x58
|
||||
#define JUMP_BUFFER_Xmm6 0x60
|
||||
#define JUMP_BUFFER_Xmm7 0x70
|
||||
#define JUMP_BUFFER_Xmm8 0x80
|
||||
#define JUMP_BUFFER_Xmm9 0x90
|
||||
#define JUMP_BUFFER_Xmm10 0xa0
|
||||
#define JUMP_BUFFER_Xmm11 0xb0
|
||||
#define JUMP_BUFFER_Xmm12 0xc0
|
||||
#define JUMP_BUFFER_Xmm13 0xd0
|
||||
#define JUMP_BUFFER_Xmm14 0xe0
|
||||
#define JUMP_BUFFER_Xmm15 0xf0
|
||||
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
/*
|
||||
* int _setjmp(jmp_buf env);
|
||||
*
|
||||
* Parameters: <rcx> - jmp_buf env
|
||||
* Returns: 0
|
||||
* Notes: Sets up the jmp_buf
|
||||
*/
|
||||
.globl _setjmp
|
||||
_setjmp:
|
||||
/* Load rsp as it was before the call into rax */
|
||||
lea rax, [rsp + 8]
|
||||
/* Load return address into r8 */
|
||||
mov r8, [rsp]
|
||||
mov qword ptr [rcx + JUMP_BUFFER_Frame], 0
|
||||
mov [rcx + JUMP_BUFFER_Rbx], rbx
|
||||
mov [rcx + JUMP_BUFFER_Rbp], rbp
|
||||
mov [rcx + JUMP_BUFFER_Rsi], rsi
|
||||
mov [rcx + JUMP_BUFFER_Rdi], rdi
|
||||
mov [rcx + JUMP_BUFFER_R12], r12
|
||||
mov [rcx + JUMP_BUFFER_R13], r13
|
||||
mov [rcx + JUMP_BUFFER_R14], r14
|
||||
mov [rcx + JUMP_BUFFER_R15], r15
|
||||
mov [rcx + JUMP_BUFFER_Rsp], rax
|
||||
mov [rcx + JUMP_BUFFER_Rip], r8
|
||||
movdqa [rcx + JUMP_BUFFER_Xmm6], xmm6
|
||||
movdqa [rcx + JUMP_BUFFER_Xmm7], xmm7
|
||||
movdqa [rcx + JUMP_BUFFER_Xmm8], xmm8
|
||||
movdqa [rcx + JUMP_BUFFER_Xmm9], xmm9
|
||||
movdqa [rcx + JUMP_BUFFER_Xmm10], xmm10
|
||||
movdqa [rcx + JUMP_BUFFER_Xmm11], xmm11
|
||||
movdqa [rcx + JUMP_BUFFER_Xmm12], xmm12
|
||||
movdqa [rcx + JUMP_BUFFER_Xmm13], xmm13
|
||||
movdqa [rcx + JUMP_BUFFER_Xmm14], xmm14
|
||||
movdqa [rcx + JUMP_BUFFER_Xmm15], xmm15
|
||||
xor rax, rax
|
||||
ret
|
||||
|
||||
/*
|
||||
* void longjmp(jmp_buf env, int value);
|
||||
*
|
||||
* Parameters: <rcx> - jmp_buf setup by _setjmp
|
||||
* <rdx> - int value to return
|
||||
* Returns: Doesn't return
|
||||
* Notes: Non-local goto
|
||||
*/
|
||||
.proc longjmp
|
||||
|
||||
// FIXME: handle frame
|
||||
|
||||
mov rbx, [rcx + JUMP_BUFFER_Rbx]
|
||||
mov rbp, [rcx + JUMP_BUFFER_Rbp]
|
||||
mov rsi, [rcx + JUMP_BUFFER_Rsi]
|
||||
mov rdi, [rcx + JUMP_BUFFER_Rdi]
|
||||
mov r12, [rcx + JUMP_BUFFER_R12]
|
||||
mov r13, [rcx + JUMP_BUFFER_R13]
|
||||
mov r14, [rcx + JUMP_BUFFER_R14]
|
||||
mov r15, [rcx + JUMP_BUFFER_R15]
|
||||
mov rsp, [rcx + JUMP_BUFFER_Rsp]
|
||||
mov r8, [rcx + JUMP_BUFFER_Rip]
|
||||
movdqa xmm6, [rcx + JUMP_BUFFER_Xmm6]
|
||||
movdqa xmm7, [rcx + JUMP_BUFFER_Xmm7]
|
||||
movdqa xmm8, [rcx + JUMP_BUFFER_Xmm8]
|
||||
movdqa xmm9, [rcx + JUMP_BUFFER_Xmm9]
|
||||
movdqa xmm10, [rcx + JUMP_BUFFER_Xmm10]
|
||||
movdqa xmm11, [rcx + JUMP_BUFFER_Xmm11]
|
||||
movdqa xmm12, [rcx + JUMP_BUFFER_Xmm12]
|
||||
movdqa xmm13, [rcx + JUMP_BUFFER_Xmm13]
|
||||
movdqa xmm14, [rcx + JUMP_BUFFER_Xmm14]
|
||||
movdqa xmm15, [rcx + JUMP_BUFFER_Xmm15]
|
||||
|
||||
/* return param2 or 1 if it was 0 */
|
||||
mov rax, rdx
|
||||
test rax, rax
|
||||
jnz 2f
|
||||
inc rax
|
||||
2: jmp r8
|
||||
.endproc
|
|
@ -125,7 +125,7 @@ VOID
|
|||
NTAPI
|
||||
KiEspToTrapFrame(
|
||||
IN PKTRAP_FRAME TrapFrame,
|
||||
IN ULONG Esp);
|
||||
IN ULONG_PTR Esp);
|
||||
|
||||
/* ROS Internal. Please deprecate */
|
||||
NTHALAPI
|
||||
|
@ -140,14 +140,18 @@ KdbpTrapFrameToKdbTrapFrame(
|
|||
PKTRAP_FRAME TrapFrame,
|
||||
PKDB_KTRAP_FRAME KdbTrapFrame)
|
||||
{
|
||||
ULONG TrapCr0, TrapCr2, TrapCr3, TrapCr4;
|
||||
ULONG_PTR TrapCr0, TrapCr2, TrapCr3, TrapCr4;
|
||||
|
||||
#if defined(_M_IX86)
|
||||
/* Copy the TrapFrame only up to Eflags and zero the rest*/
|
||||
RtlCopyMemory(&KdbTrapFrame->Tf, TrapFrame, FIELD_OFFSET(KTRAP_FRAME, HardwareEsp));
|
||||
RtlZeroMemory((PVOID)((ULONG_PTR)&KdbTrapFrame->Tf + FIELD_OFFSET(KTRAP_FRAME, HardwareEsp)),
|
||||
sizeof(KTRAP_FRAME) - FIELD_OFFSET(KTRAP_FRAME, HardwareEsp));
|
||||
#elif defined(_M_AMD64)
|
||||
RtlCopyMemory(&KdbTrapFrame->Tf, TrapFrame, sizeof(KTRAP_FRAME));
|
||||
#endif
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#if defined(__GNUC__) && defined(_M_IX86)
|
||||
asm volatile(
|
||||
"movl %%cr0, %0" "\n\t"
|
||||
"movl %%cr2, %1" "\n\t"
|
||||
|
@ -155,7 +159,7 @@ KdbpTrapFrameToKdbTrapFrame(
|
|||
"movl %%cr4, %3" "\n\t"
|
||||
: "=r"(TrapCr0), "=r"(TrapCr2),
|
||||
"=r"(TrapCr3), "=r"(TrapCr4));
|
||||
#else
|
||||
#elif defined(_MSC_VER) && defined(_M_IX86)
|
||||
__asm
|
||||
{
|
||||
mov eax, cr0;
|
||||
|
@ -170,6 +174,16 @@ KdbpTrapFrameToKdbTrapFrame(
|
|||
//mov eax, cr4;
|
||||
//mov TrapCr4, eax;
|
||||
}
|
||||
#elif defined(__GNUC__) && defined(_M_AMD64)
|
||||
asm volatile(
|
||||
"movq %%cr0, %0" "\n\t"
|
||||
"movq %%cr2, %1" "\n\t"
|
||||
"movq %%cr3, %2" "\n\t"
|
||||
"movq %%cr4, %3" "\n\t"
|
||||
: "=r"(TrapCr0), "=r"(TrapCr2),
|
||||
"=r"(TrapCr3), "=r"(TrapCr4));
|
||||
#else
|
||||
#error UNSUPPORTED ARCHITECTURE
|
||||
#endif
|
||||
|
||||
KdbTrapFrame->Cr0 = TrapCr0;
|
||||
|
@ -177,9 +191,13 @@ KdbpTrapFrameToKdbTrapFrame(
|
|||
KdbTrapFrame->Cr3 = TrapCr3;
|
||||
KdbTrapFrame->Cr4 = TrapCr4;
|
||||
|
||||
#ifdef _M_IX86
|
||||
KdbTrapFrame->Tf.HardwareEsp = KiEspFromTrapFrame(TrapFrame);
|
||||
KdbTrapFrame->Tf.HardwareSegSs = (USHORT)(KiSsFromTrapFrame(TrapFrame) & 0xFFFF);
|
||||
|
||||
#elif defined(_M_AMD64)
|
||||
//KdbTrapFrame->Tf.Rsp = KiEspFromTrapFrame(TrapFrame);
|
||||
//KdbTrapFrame->Tf.SegGs = (USHORT)(KiSsFromTrapFrame(TrapFrame) & 0xFFFF);
|
||||
#endif
|
||||
|
||||
/* FIXME: copy v86 registers if TrapFrame is a V86 trapframe */
|
||||
}
|
||||
|
@ -190,6 +208,7 @@ KdbpKdbTrapFrameToTrapFrame(
|
|||
PKTRAP_FRAME TrapFrame)
|
||||
{
|
||||
/* Copy the TrapFrame only up to Eflags and zero the rest*/
|
||||
#ifdef _M_IX86
|
||||
RtlCopyMemory(TrapFrame, &KdbTrapFrame->Tf, FIELD_OFFSET(KTRAP_FRAME, HardwareEsp));
|
||||
|
||||
/* FIXME: write cr0, cr2, cr3 and cr4 (not needed atm) */
|
||||
|
@ -198,6 +217,13 @@ KdbpKdbTrapFrameToTrapFrame(
|
|||
KiEspToTrapFrame(TrapFrame, KdbTrapFrame->Tf.HardwareEsp);
|
||||
|
||||
/* FIXME: copy v86 registers if TrapFrame is a V86 trapframe */
|
||||
|
||||
#elif defined(_M_AMD64)
|
||||
RtlCopyMemory(TrapFrame, &KdbTrapFrame->Tf, sizeof(KTRAP_FRAME));
|
||||
//KiSsToTrapFrame(TrapFrame, KdbTrapFrame->Tf.SegSs);
|
||||
//KiEspToTrapFrame(TrapFrame, KdbTrapFrame->Tf.Rsp);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
static VOID
|
||||
|
@ -209,7 +235,7 @@ KdbpKdbTrapFrameFromKernelStack(
|
|||
|
||||
RtlZeroMemory(KdbTrapFrame, sizeof(KDB_KTRAP_FRAME));
|
||||
StackPtr = (ULONG_PTR *) KernelStack;
|
||||
#if _M_X86_
|
||||
#ifdef _M_IX86
|
||||
KdbTrapFrame->Tf.Ebp = StackPtr[3];
|
||||
KdbTrapFrame->Tf.Edi = StackPtr[4];
|
||||
KdbTrapFrame->Tf.Esi = StackPtr[5];
|
||||
|
@ -221,6 +247,18 @@ KdbpKdbTrapFrameFromKernelStack(
|
|||
KdbTrapFrame->Tf.SegDs = KGDT_R0_DATA;
|
||||
KdbTrapFrame->Tf.SegEs = KGDT_R0_DATA;
|
||||
KdbTrapFrame->Tf.SegGs = KGDT_R0_DATA;
|
||||
#elif defined(_M_AMD64)
|
||||
KdbTrapFrame->Tf.Rbp = StackPtr[3];
|
||||
KdbTrapFrame->Tf.Rdi = StackPtr[4];
|
||||
KdbTrapFrame->Tf.Rsi = StackPtr[5];
|
||||
KdbTrapFrame->Tf.Rbx = StackPtr[6];
|
||||
KdbTrapFrame->Tf.Rip = StackPtr[7];
|
||||
KdbTrapFrame->Tf.Rsp = (ULONG_PTR) (StackPtr + 16);
|
||||
KdbTrapFrame->Tf.SegSs = KGDT_64_R0_SS;
|
||||
KdbTrapFrame->Tf.SegCs = KGDT_64_R0_CODE;
|
||||
KdbTrapFrame->Tf.SegDs = KGDT_64_DATA;
|
||||
KdbTrapFrame->Tf.SegEs = KGDT_64_DATA;
|
||||
KdbTrapFrame->Tf.SegGs = KGDT_64_DATA;
|
||||
#endif
|
||||
|
||||
/* FIXME: what about the other registers??? */
|
||||
|
@ -423,7 +461,7 @@ KdbpStepIntoInstruction(
|
|||
}
|
||||
|
||||
/* Get the interrupt descriptor */
|
||||
if (!NT_SUCCESS(KdbpSafeReadMemory(IntDesc, (PVOID)(ULONG_PTR)(Idtr.Base + (IntVect * 8)), sizeof (IntDesc))))
|
||||
if (!NT_SUCCESS(KdbpSafeReadMemory(IntDesc, (PVOID)(ULONG_PTR)((ULONG_PTR)Idtr.Base + (IntVect * 8)), sizeof (IntDesc))))
|
||||
{
|
||||
/*KdbpPrint("Couldn't access memory at 0x%p\n", (ULONG_PTR)Idtr.Base + (IntVect * 8));*/
|
||||
return FALSE;
|
||||
|
@ -1244,7 +1282,7 @@ KdbpInternalEnter()
|
|||
{
|
||||
PETHREAD Thread;
|
||||
PVOID SavedInitialStack, SavedStackBase, SavedKernelStack;
|
||||
ULONG SavedStackLimit;
|
||||
ULONG_PTR SavedStackLimit;
|
||||
|
||||
KbdDisableMouse();
|
||||
if (KdpDebugMode.Screen)
|
||||
|
@ -1262,7 +1300,7 @@ KdbpInternalEnter()
|
|||
Thread->Tcb.StackLimit = (ULONG_PTR)KdbStack;
|
||||
Thread->Tcb.KernelStack = (char*)KdbStack + KDB_STACK_SIZE;
|
||||
|
||||
/*KdbpPrint("Switching to KDB stack 0x%08x-0x%08x (Current Stack is 0x%08x)\n", Thread->Tcb.StackLimit, Thread->Tcb.StackBase, Esp);*/
|
||||
//KdbpPrint("Switching to KDB stack 0x%p-0x%p\n", Thread->Tcb.StackLimit, Thread->Tcb.StackBase);
|
||||
|
||||
KdbpStackSwitchAndCall(KdbStack + KDB_STACK_SIZE - sizeof(ULONG), KdbpCallMainLoop);
|
||||
|
||||
|
@ -1351,7 +1389,7 @@ KdbEnterDebuggerException(
|
|||
ULONGLONG ull;
|
||||
BOOLEAN Resume = FALSE;
|
||||
BOOLEAN EnterConditionMet = TRUE;
|
||||
ULONG OldEflags;
|
||||
ULONG_PTR OldEflags;
|
||||
NTSTATUS ExceptionCode;
|
||||
|
||||
ExceptionCode = (ExceptionRecord ? ExceptionRecord->ExceptionCode : STATUS_BREAKPOINT);
|
||||
|
@ -1463,12 +1501,12 @@ KdbEnterDebuggerException(
|
|||
|
||||
if (BreakPoint->Type == KdbBreakPointSoftware)
|
||||
{
|
||||
KdbpPrint("Entered debugger on breakpoint #%d: EXEC 0x%04x:0x%08x\n",
|
||||
KdbpPrint("Entered debugger on breakpoint #%d: EXEC 0x%04x:0x%p\n",
|
||||
KdbLastBreakPointNr, TrapFrame->SegCs & 0xffff, TrapFrame->Eip);
|
||||
}
|
||||
else if (BreakPoint->Type == KdbBreakPointHardware)
|
||||
{
|
||||
KdbpPrint("Entered debugger on breakpoint #%d: %s 0x%08x\n",
|
||||
KdbpPrint("Entered debugger on breakpoint #%d: %s 0x%p\n",
|
||||
KdbLastBreakPointNr,
|
||||
(BreakPoint->Data.Hw.AccessType == KdbAccessRead) ? "READ" :
|
||||
((BreakPoint->Data.Hw.AccessType == KdbAccessWrite) ? "WRITE" :
|
||||
|
@ -1551,7 +1589,7 @@ KdbEnterDebuggerException(
|
|||
return kdHandleException;
|
||||
}
|
||||
|
||||
KdbpPrint("Entered debugger on embedded INT3 at 0x%04x:0x%08x.\n",
|
||||
KdbpPrint("Entered debugger on embedded INT3 at 0x%04x:0x%p.\n",
|
||||
TrapFrame->SegCs & 0xffff, TrapFrame->Eip - 1);
|
||||
}
|
||||
else
|
||||
|
@ -1576,8 +1614,12 @@ KdbEnterDebuggerException(
|
|||
ULONG Err;
|
||||
|
||||
TrapCr2 = __readcr2();
|
||||
|
||||
#ifdef _M_IX86
|
||||
Err = TrapFrame->ErrCode;
|
||||
#elif defined(_M_AMD64)
|
||||
Err = TrapFrame->ErrorCode;
|
||||
#endif
|
||||
|
||||
KdbpPrint("Memory at 0x%p could not be %s: ", TrapCr2, (Err & (1 << 1)) ? "written" : "read");
|
||||
|
||||
if ((Err & (1 << 0)) == 0)
|
||||
|
@ -1760,4 +1802,4 @@ KdbpSafeWriteMemory(
|
|||
Result = FALSE;
|
||||
|
||||
return Result ? STATUS_SUCCESS : STATUS_ACCESS_VIOLATION;
|
||||
}
|
||||
}
|
|
@ -7,17 +7,25 @@
|
|||
# define RTL_NUMBER_OF(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
//hack to avoid a hundred ifdefs
|
||||
#ifdef _M_IX86
|
||||
#define Eip Eip
|
||||
#elif defined(_M_AMD64)
|
||||
#define Eip Rip
|
||||
#endif
|
||||
|
||||
/* TYPES *********************************************************************/
|
||||
|
||||
/* from kdb.c */
|
||||
|
||||
typedef struct _KDB_KTRAP_FRAME
|
||||
{
|
||||
KTRAP_FRAME Tf;
|
||||
ULONG Cr0;
|
||||
ULONG Cr1; /* reserved/unused */
|
||||
ULONG Cr2;
|
||||
ULONG Cr3;
|
||||
ULONG Cr4;
|
||||
ULONG_PTR Cr0;
|
||||
ULONG_PTR Cr1; /* reserved/unused */
|
||||
ULONG_PTR Cr2;
|
||||
ULONG_PTR Cr3;
|
||||
ULONG_PTR Cr4;
|
||||
} KDB_KTRAP_FRAME, *PKDB_KTRAP_FRAME;
|
||||
|
||||
typedef enum _KDB_BREAKPOINT_TYPE
|
||||
|
@ -78,12 +86,12 @@ typedef enum _KDB_OUTPUT_SETTINGS
|
|||
|
||||
LONG
|
||||
KdbpDisassemble(
|
||||
IN ULONG Address,
|
||||
IN ULONG_PTR Address,
|
||||
IN ULONG IntelSyntax);
|
||||
|
||||
LONG
|
||||
KdbpGetInstLength(
|
||||
IN ULONG Address);
|
||||
IN ULONG_PTR Address);
|
||||
|
||||
/* from i386/kdb_help.S */
|
||||
|
||||
|
@ -265,5 +273,4 @@ KbdDisableMouse();
|
|||
VOID
|
||||
KbdEnableMouse();
|
||||
|
||||
#endif /* NTOSKRNL_KDB_H */
|
||||
|
||||
#endif /* NTOSKRNL_KDB_H */
|
|
@ -34,6 +34,9 @@
|
|||
#include <debug.h>
|
||||
|
||||
/* DEFINES *******************************************************************/
|
||||
//hack for amd64
|
||||
#define NPX_STATE_NOT_LOADED 0xA
|
||||
#define NPX_STATE_LOADED 0x0
|
||||
|
||||
#define KEY_BS 8
|
||||
#define KEY_ESC 27
|
||||
|
@ -557,7 +560,7 @@ KdbpCmdDisassembleX(
|
|||
if (!NT_SUCCESS(KdbpSafeReadMemory(&ul, (PVOID)Address, sizeof(ul))))
|
||||
KdbpPrint(" ????????");
|
||||
else
|
||||
KdbpPrint(" %08x", ul);
|
||||
KdbpPrint(" %x", ul);
|
||||
|
||||
Address += sizeof(ul);
|
||||
}
|
||||
|
@ -571,7 +574,7 @@ KdbpCmdDisassembleX(
|
|||
while (Count-- > 0)
|
||||
{
|
||||
if (!KdbSymPrintAddress((PVOID)Address))
|
||||
KdbpPrint("<%08x>: ", Address);
|
||||
KdbpPrint("<%x>: ", Address);
|
||||
else
|
||||
KdbpPrint(": ");
|
||||
|
||||
|
@ -599,16 +602,26 @@ KdbpCmdRegs(
|
|||
{
|
||||
PKTRAP_FRAME Tf = &KdbCurrentTrapFrame->Tf;
|
||||
INT i;
|
||||
static const PCHAR EflagsBits[32] = { " CF", NULL, " PF", " BIT3", " AF", " BIT5",
|
||||
const PCHAR EflagsBits[64] = { " CF", NULL, " PF", " BIT3", " AF", " BIT5",
|
||||
" ZF", " SF", " TF", " IF", " DF", " OF",
|
||||
NULL, NULL, " NT", " BIT15", " RF", " VF",
|
||||
" AC", " VIF", " VIP", " ID", " BIT22",
|
||||
" BIT23", " BIT24", " BIT25", " BIT26",
|
||||
" BIT27", " BIT28", " BIT29", " BIT30",
|
||||
" BIT31" };
|
||||
" BIT31", " BIT32", " BIT33", " BIT34",
|
||||
" BIT35", " BIT36", " BIT37", " BIT38",
|
||||
" BIT39", " BIT40", " BIT41", " BIT42",
|
||||
" BIT43", " BIT44", " BIT45", " BIT46",
|
||||
" BIT47", " BIT48", " BIT49", " BIT50",
|
||||
" BIT51", " BIT52", " BIT53", " BIT54",
|
||||
" BIT55", " BIT56", " BIT57", " BIT58",
|
||||
" BIT59", " BIT60", " BIT61", " BIT62",
|
||||
" BIT63",
|
||||
};
|
||||
|
||||
if (Argv[0][0] == 'r') /* regs */
|
||||
{
|
||||
#ifdef _M_IX86
|
||||
KdbpPrint("CS:EIP 0x%04x:0x%08x\n"
|
||||
"SS:ESP 0x%04x:0x%08x\n"
|
||||
" EAX 0x%08x EBX 0x%08x\n"
|
||||
|
@ -621,9 +634,31 @@ KdbpCmdRegs(
|
|||
Tf->Ecx, Tf->Edx,
|
||||
Tf->Esi, Tf->Edi,
|
||||
Tf->Ebp);
|
||||
#elif defined(_M_AMD64)
|
||||
KdbpPrint("CS:RIP 0x%04x:0x%p\n"
|
||||
"SS:RSP 0x%04x:0x%p\n"
|
||||
" RAX 0x%p RBX 0x%p\n"
|
||||
" RCX 0x%p RDX 0x%p\n"
|
||||
" RSI 0x%p RDI 0x%p\n"
|
||||
" RBP 0x%p R8 0x%p\n"
|
||||
" R9 0x%p R10 0x%p\n"
|
||||
" R11 0x%p\n",
|
||||
Tf->SegCs & 0xFFFF, Tf->Rip,
|
||||
Tf->SegSs, Tf->Rsp,
|
||||
Tf->Rax, Tf->Rbx,
|
||||
Tf->Rcx, Tf->Rdx,
|
||||
Tf->Rsi, Tf->Rdi,
|
||||
Tf->Rbp, Tf->R8,
|
||||
Tf->R9, Tf->R10,
|
||||
Tf->R11);
|
||||
#endif
|
||||
KdbpPrint("EFLAGS 0x%08x ", Tf->EFlags);
|
||||
|
||||
#ifdef _M_IX86
|
||||
for (i = 0; i < 32; i++)
|
||||
#elif defined(_M_AMD64)
|
||||
for (i = 0; i < 64; i++)
|
||||
#endif
|
||||
{
|
||||
if (i == 1)
|
||||
{
|
||||
|
@ -647,9 +682,15 @@ KdbpCmdRegs(
|
|||
}
|
||||
else if (Argv[0][0] == 'c') /* cregs */
|
||||
{
|
||||
ULONG Cr0, Cr2, Cr3, Cr4;
|
||||
ULONG_PTR Cr0, Cr2, Cr3, Cr4;
|
||||
KDESCRIPTOR Gdtr, Idtr;
|
||||
#if defined(_M_IX86)
|
||||
USHORT Ldtr;
|
||||
Ke386GetGlobalDescriptorTable(&Gdtr.Limit);
|
||||
Ldtr = Ke386GetLocalDescriptorTable();
|
||||
#elif defined(_M_AMD64)
|
||||
__sgdt(&Gdtr.Limit);
|
||||
#endif
|
||||
static const PCHAR Cr0Bits[32] = { " PE", " MP", " EM", " TS", " ET", " NE", NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
" WP", NULL, " AM", NULL, NULL, NULL, NULL, NULL,
|
||||
|
@ -664,13 +705,11 @@ KdbpCmdRegs(
|
|||
Cr3 = KdbCurrentTrapFrame->Cr3;
|
||||
Cr4 = KdbCurrentTrapFrame->Cr4;
|
||||
|
||||
/* Get descriptor table regs */
|
||||
Ke386GetGlobalDescriptorTable(&Gdtr.Limit);
|
||||
Ldtr = Ke386GetLocalDescriptorTable();
|
||||
/* Get interrupt descriptor table regs */
|
||||
__sidt(&Idtr.Limit);
|
||||
|
||||
/* Display the control registers */
|
||||
KdbpPrint("CR0 0x%08x ", Cr0);
|
||||
KdbpPrint("CR0 0x%p ", Cr0);
|
||||
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
|
@ -681,10 +720,10 @@ KdbpCmdRegs(
|
|||
KdbpPrint(Cr0Bits[i]);
|
||||
}
|
||||
|
||||
KdbpPrint("\nCR2 0x%08x\n", Cr2);
|
||||
KdbpPrint("CR3 0x%08x Pagedir-Base 0x%08x %s%s\n", Cr3, (Cr3 & 0xfffff000),
|
||||
KdbpPrint("\nCR2 0x%p\n", Cr2);
|
||||
KdbpPrint("CR3 0x%p Pagedir-Base 0x%p %s%s\n", Cr3, (Cr3 & 0xfffff000),
|
||||
(Cr3 & (1 << 3)) ? " PWT" : "", (Cr3 & (1 << 4)) ? " PCD" : "" );
|
||||
KdbpPrint("CR4 0x%08x ", Cr4);
|
||||
KdbpPrint("CR4 0x%p ", Cr4);
|
||||
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
|
@ -696,9 +735,11 @@ KdbpCmdRegs(
|
|||
}
|
||||
|
||||
/* Display the descriptor table regs */
|
||||
KdbpPrint("\nGDTR Base 0x%08x Size 0x%04x\n", Gdtr.Base, Gdtr.Limit);
|
||||
KdbpPrint("LDTR 0x%04x\n", Ldtr);
|
||||
KdbpPrint("IDTR Base 0x%08x Size 0x%04x\n", Idtr.Base, Idtr.Limit);
|
||||
KdbpPrint("\nGDTR Base 0x%p Size 0x%04x\n", Gdtr.Base, Gdtr.Limit);
|
||||
#ifdef _M_IX86
|
||||
KdbpPrint("LDTR 0x%p\n", Ldtr);
|
||||
#endif
|
||||
KdbpPrint("IDTR Base 0x%p Size 0x%04x\n", Idtr.Base, Idtr.Limit);
|
||||
}
|
||||
else if (Argv[0][0] == 's') /* sregs */
|
||||
{
|
||||
|
@ -713,18 +754,24 @@ KdbpCmdRegs(
|
|||
Tf->SegFs, Tf->SegFs >> 3, (Tf->SegFs & (1 << 2)) ? 'L' : 'G', Tf->SegFs & 3);
|
||||
KdbpPrint("GS 0x%04x Index 0x%04x %cDT RPL%d\n",
|
||||
Tf->SegGs, Tf->SegGs >> 3, (Tf->SegGs & (1 << 2)) ? 'L' : 'G', Tf->SegGs & 3);
|
||||
#ifdef _M_IX86
|
||||
KdbpPrint("SS 0x%04x Index 0x%04x %cDT RPL%d\n",
|
||||
Tf->HardwareSegSs, Tf->HardwareSegSs >> 3, (Tf->HardwareSegSs & (1 << 2)) ? 'L' : 'G', Tf->HardwareSegSs & 3);
|
||||
#else
|
||||
KdbpPrint("SS 0x%04x Index 0x%04x %cDT RPL%d\n",
|
||||
Tf->SegSs, Tf->SegSs >> 3, (Tf->SegSs & (1 << 2)) ? 'L' : 'G', Tf->SegSs & 3);
|
||||
#endif
|
||||
|
||||
}
|
||||
else /* dregs */
|
||||
{
|
||||
ASSERT(Argv[0][0] == 'd');
|
||||
KdbpPrint("DR0 0x%08x\n"
|
||||
"DR1 0x%08x\n"
|
||||
"DR2 0x%08x\n"
|
||||
"DR3 0x%08x\n"
|
||||
"DR6 0x%08x\n"
|
||||
"DR7 0x%08x\n",
|
||||
KdbpPrint("DR0 0x%p\n"
|
||||
"DR1 0x%p\n"
|
||||
"DR2 0x%p\n"
|
||||
"DR3 0x%p\n"
|
||||
"DR6 0x%p\n"
|
||||
"DR7 0x%p\n",
|
||||
Tf->Dr0, Tf->Dr1, Tf->Dr2, Tf->Dr3,
|
||||
Tf->Dr6, Tf->Dr7);
|
||||
}
|
||||
|
@ -742,7 +789,11 @@ KdbpCmdBackTrace(
|
|||
ULONG Count;
|
||||
ULONG ul;
|
||||
ULONGLONG Result = 0;
|
||||
#ifdef _M_IX86
|
||||
ULONG_PTR Frame = KdbCurrentTrapFrame->Tf.Ebp;
|
||||
#elif defined(_M_AMD64)
|
||||
ULONG_PTR Frame = KdbCurrentTrapFrame->Tf.Rbp;
|
||||
#endif
|
||||
ULONG_PTR Address;
|
||||
|
||||
if (Argc >= 2)
|
||||
|
@ -806,7 +857,7 @@ KdbpCmdBackTrace(
|
|||
|
||||
/* Try printing the function at EIP */
|
||||
if (!KdbSymPrintAddress((PVOID)KdbCurrentTrapFrame->Tf.Eip))
|
||||
KdbpPrint("<%08x>\n", KdbCurrentTrapFrame->Tf.Eip);
|
||||
KdbpPrint("<%x>\n", KdbCurrentTrapFrame->Tf.Eip);
|
||||
else
|
||||
KdbpPrint("\n");
|
||||
}
|
||||
|
@ -824,7 +875,7 @@ KdbpCmdBackTrace(
|
|||
}
|
||||
|
||||
if (!KdbSymPrintAddress((PVOID)Address))
|
||||
KdbpPrint("<%08x>\n", Address);
|
||||
KdbpPrint("<%x>\n", Address);
|
||||
else
|
||||
KdbpPrint("\n");
|
||||
|
||||
|
@ -936,7 +987,7 @@ KdbpCmdBreakPointList(
|
|||
{
|
||||
GlobalOrLocal = Buffer;
|
||||
sprintf(Buffer, " PID 0x%08lx",
|
||||
(ULONG)(Process ? Process->UniqueProcessId : INVALID_HANDLE_VALUE));
|
||||
(ULONG_PTR)(Process ? Process->UniqueProcessId : INVALID_HANDLE_VALUE));
|
||||
}
|
||||
|
||||
if (Type == KdbBreakPointSoftware || Type == KdbBreakPointTemporary)
|
||||
|
@ -1082,6 +1133,8 @@ KdbpCmdBreakPoint(ULONG Argc, PCHAR Argv[])
|
|||
Size = 2;
|
||||
else if (_stricmp(Argv[2], "dword") == 0)
|
||||
Size = 4;
|
||||
else if (_stricmp(Argv[2], "qword") == 0)
|
||||
Size = 8;
|
||||
else if (AccessType == KdbAccessExec)
|
||||
{
|
||||
Size = 1;
|
||||
|
@ -1155,10 +1208,10 @@ KdbpCmdThread(
|
|||
PETHREAD Thread = NULL;
|
||||
PEPROCESS Process = NULL;
|
||||
BOOLEAN ReferencedThread = FALSE, ReferencedProcess = FALSE;
|
||||
PULONG Esp;
|
||||
PULONG Ebp;
|
||||
ULONG Eip;
|
||||
ULONG ul = 0;
|
||||
PULONG_PTR Esp;
|
||||
PULONG_PTR Ebp;
|
||||
ULONG_PTR Eip;
|
||||
ULONG_PTR ul = 0;
|
||||
PCHAR State, pend, str1, str2;
|
||||
static const PCHAR ThreadStateToString[DeferredReady+1] =
|
||||
{
|
||||
|
@ -1224,6 +1277,7 @@ KdbpCmdThread(
|
|||
|
||||
if (Thread->Tcb.TrapFrame)
|
||||
{
|
||||
#ifdef _M_IX86
|
||||
if (Thread->Tcb.TrapFrame->PreviousPreviousMode == KernelMode)
|
||||
Esp = (PULONG)Thread->Tcb.TrapFrame->TempEsp;
|
||||
else
|
||||
|
@ -1231,11 +1285,18 @@ KdbpCmdThread(
|
|||
|
||||
Ebp = (PULONG)Thread->Tcb.TrapFrame->Ebp;
|
||||
Eip = Thread->Tcb.TrapFrame->Eip;
|
||||
|
||||
#elif defined(_M_AMD64)
|
||||
Esp = (PULONG_PTR)Thread->Tcb.TrapFrame->Rsp;
|
||||
|
||||
Ebp = (PULONG_PTR)Thread->Tcb.TrapFrame->Rbp;
|
||||
Eip = Thread->Tcb.TrapFrame->Eip;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
Esp = (PULONG)Thread->Tcb.KernelStack;
|
||||
Ebp = (PULONG)Esp[4];
|
||||
Esp = (PULONG_PTR)Thread->Tcb.KernelStack;
|
||||
Ebp = (PULONG_PTR)Esp[4];
|
||||
Eip = 0;
|
||||
|
||||
if (Ebp) /* FIXME: Should we attach to the process to read Ebp[1]? */
|
||||
|
@ -1247,7 +1308,7 @@ KdbpCmdThread(
|
|||
else
|
||||
State = "Unknown";
|
||||
|
||||
KdbpPrint(" %s0x%08x %-11s %3d 0x%08x 0x%08x 0x%08x%s\n",
|
||||
KdbpPrint(" %s0x%p %-11s %3d 0x%p 0x%p 0x%p%s\n",
|
||||
str1,
|
||||
Thread->Cid.UniqueThread,
|
||||
State,
|
||||
|
@ -1320,11 +1381,11 @@ KdbpCmdThread(
|
|||
" State: %s (0x%x)\n"
|
||||
" Priority: %d\n"
|
||||
" Affinity: 0x%08x\n"
|
||||
" Initial Stack: 0x%08x\n"
|
||||
" Stack Limit: 0x%08x\n"
|
||||
" Stack Base: 0x%08x\n"
|
||||
" Kernel Stack: 0x%08x\n"
|
||||
" Trap Frame: 0x%08x\n"
|
||||
" Initial Stack: 0x%p\n"
|
||||
" Stack Limit: 0x%p\n"
|
||||
" Stack Base: 0x%p\n"
|
||||
" Kernel Stack: 0x%p\n"
|
||||
" Trap Frame: 0x%p\n"
|
||||
" NPX State: %s (0x%x)\n",
|
||||
(Argc < 2) ? "Current Thread:\n" : "",
|
||||
Thread->Cid.UniqueThread,
|
||||
|
@ -1357,7 +1418,7 @@ KdbpCmdProc(
|
|||
PEPROCESS Process;
|
||||
BOOLEAN ReferencedProcess = FALSE;
|
||||
PCHAR State, pend, str1, str2;
|
||||
ULONG ul;
|
||||
ULONG_PTR ul;
|
||||
extern LIST_ENTRY PsActiveProcessHead;
|
||||
|
||||
if (Argc >= 2 && _stricmp(Argv[1], "list") == 0)
|
||||
|
@ -1419,8 +1480,8 @@ KdbpCmdProc(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
KdbpPrint("Attached to process 0x%08x, thread 0x%08x.\n", (ULONG)ul,
|
||||
(ULONG)KdbCurrentThread->Cid.UniqueThread);
|
||||
KdbpPrint("Attached to process 0x%x, thread 0x%x.\n", ul,
|
||||
(ULONG_PTR)KdbCurrentThread->Cid.UniqueThread);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1509,7 +1570,7 @@ KdbpCmdMod(
|
|||
{
|
||||
ULONG_PTR ntoskrnlBase = ((ULONG_PTR)KdbpCmdMod) & 0xfff00000;
|
||||
KdbpPrint(" Base Size Name\n");
|
||||
KdbpPrint(" %08x %08x %s\n", ntoskrnlBase, 0, "ntoskrnl.exe");
|
||||
KdbpPrint(" %p %x %s\n", ntoskrnlBase, 0, "ntoskrnl.exe");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1519,7 +1580,7 @@ KdbpCmdMod(
|
|||
KdbpPrint(" Base Size Name\n");
|
||||
for (;;)
|
||||
{
|
||||
KdbpPrint(" %08x %08x %wZ\n", LdrEntry->DllBase, LdrEntry->SizeOfImage, &LdrEntry->BaseDllName);
|
||||
KdbpPrint(" %p %x %wZ\n", LdrEntry->DllBase, LdrEntry->SizeOfImage, &LdrEntry->BaseDllName);
|
||||
|
||||
if(DisplayOnlyOneModule || !KdbpSymFindModule(NULL, NULL, i++, &LdrEntry))
|
||||
break;
|
||||
|
@ -1561,9 +1622,9 @@ KdbpCmdGdtLdtIdt(
|
|||
|
||||
for (i = 0; (i + sizeof(SegDesc) - 1) <= Reg.Limit; i += 8)
|
||||
{
|
||||
if (!NT_SUCCESS(KdbpSafeReadMemory(SegDesc, (PVOID)(Reg.Base + i), sizeof(SegDesc))))
|
||||
if (!NT_SUCCESS(KdbpSafeReadMemory(SegDesc, (PVOID)((ULONG_PTR)Reg.Base + i), sizeof(SegDesc))))
|
||||
{
|
||||
KdbpPrint("Couldn't access memory at 0x%08x!\n", Reg.Base + i);
|
||||
KdbpPrint("Couldn't access memory at 0x%08x!\n", (ULONG_PTR)Reg.Base + i);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1608,7 +1669,11 @@ KdbpCmdGdtLdtIdt(
|
|||
if (Argv[0][0] == 'g')
|
||||
{
|
||||
/* Read GDTR */
|
||||
#ifdef _M_IX86
|
||||
Ke386GetGlobalDescriptorTable(&Reg.Limit);
|
||||
#elif defined(_M_AMD64)
|
||||
__sgdt(&Reg.Limit);
|
||||
#endif
|
||||
i = 8;
|
||||
}
|
||||
else
|
||||
|
@ -1616,7 +1681,11 @@ KdbpCmdGdtLdtIdt(
|
|||
ASSERT(Argv[0][0] == 'l');
|
||||
|
||||
/* Read LDTR */
|
||||
#ifdef _M_IX86
|
||||
Reg.Limit = Ke386GetLocalDescriptorTable();
|
||||
#elif defined(_M_AMD64)
|
||||
__sldt(&Reg.Limit);
|
||||
#endif
|
||||
Reg.Base = 0;
|
||||
i = 0;
|
||||
ul = 1 << 2;
|
||||
|
@ -1635,9 +1704,9 @@ KdbpCmdGdtLdtIdt(
|
|||
|
||||
for (; (i + sizeof(SegDesc) - 1) <= Reg.Limit; i += 8)
|
||||
{
|
||||
if (!NT_SUCCESS(KdbpSafeReadMemory(SegDesc, (PVOID)(Reg.Base + i), sizeof(SegDesc))))
|
||||
if (!NT_SUCCESS(KdbpSafeReadMemory(SegDesc, (PVOID)((ULONG_PTR)Reg.Base + i), sizeof(SegDesc))))
|
||||
{
|
||||
KdbpPrint("Couldn't access memory at 0x%08x!\n", Reg.Base + i);
|
||||
KdbpPrint("Couldn't access memory at 0x%08x!\n", (ULONG_PTR)Reg.Base + i);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1756,6 +1825,7 @@ KdbpCmdPcr(
|
|||
{
|
||||
PKIPCR Pcr = (PKIPCR)KeGetPcr();
|
||||
|
||||
#ifdef _M_IX86
|
||||
KdbpPrint("Current PCR is at 0x%08x.\n", (INT)Pcr);
|
||||
KdbpPrint(" Tib.ExceptionList: 0x%08x\n"
|
||||
" Tib.StackBase: 0x%08x\n"
|
||||
|
@ -1790,7 +1860,35 @@ KdbpCmdPcr(
|
|||
Pcr->MajorVersion, Pcr->MinorVersion, Pcr->SetMember, Pcr->StallScaleFactor,
|
||||
Pcr->Number, Pcr->L2CacheAssociativity,
|
||||
Pcr->VdmAlert, Pcr->SecondLevelCacheSize, Pcr->InterruptMode);
|
||||
|
||||
#elif defined(_M_AMD64)
|
||||
KdbpPrint("Current PCR is at 0x%x.\n", (INT_PTR)Pcr);
|
||||
KdbpPrint(" Tib.ExceptionList: 0x%x\n"
|
||||
" Tib.StackBase: 0x%x\n"
|
||||
" Tib.StackLimit: 0x%x\n"
|
||||
" Tib.SubSystemTib: 0x%x\n"
|
||||
" Tib.FiberData/Version: 0x%x\n"
|
||||
" Tib.ArbitraryUserPointer: 0x%x\n"
|
||||
" Tib.Self: 0x%x\n"
|
||||
" Self: 0x%x\n"
|
||||
" PCRCB: 0x%x\n"
|
||||
" Irql: 0x%x\n"
|
||||
" KdVersionBlock: 0x%08x\n"
|
||||
" IDT: 0x%08x\n"
|
||||
" GDT: 0x%08x\n"
|
||||
" TSS: 0x%08x\n"
|
||||
" UserRsp: 0x%08x\n"
|
||||
" MajorVersion: 0x%04x\n"
|
||||
" MinorVersion: 0x%04x\n"
|
||||
" StallScaleFactor: 0x%08x\n"
|
||||
" L2CacheAssociativity: 0x%02x\n"
|
||||
" L2CacheSize: 0x%08x\n",
|
||||
Pcr->NtTib.ExceptionList, Pcr->NtTib.StackBase, Pcr->NtTib.StackLimit,
|
||||
Pcr->NtTib.SubSystemTib, Pcr->NtTib.FiberData, Pcr->NtTib.ArbitraryUserPointer,
|
||||
Pcr->NtTib.Self, Pcr->Self, Pcr->Prcb, Pcr->Irql,
|
||||
Pcr->KdVersionBlock, Pcr->IdtBase, Pcr->GdtBase, Pcr->TssBase,Pcr->UserRsp,
|
||||
Pcr->MajorVersion, Pcr->MinorVersion, Pcr->StallScaleFactor,
|
||||
Pcr->SecondLevelCacheAssociativity, Pcr->SecondLevelCacheSize);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1801,6 +1899,7 @@ KdbpCmdTss(
|
|||
ULONG Argc,
|
||||
PCHAR Argv[])
|
||||
{
|
||||
#ifdef _M_IX86
|
||||
KTSS *Tss = KeGetPcr()->TSS;
|
||||
|
||||
KdbpPrint("Current TSS is at 0x%08x.\n", (INT)Tss);
|
||||
|
@ -1815,6 +1914,8 @@ KdbpCmdTss(
|
|||
Tss->Eip, Tss->Es, Tss->Cs, Tss->Ds, Tss->Fs, Tss->Gs, Tss->IoMapBase);
|
||||
|
||||
return TRUE;
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*!\brief Bugchecks the system.
|
||||
|
@ -2902,7 +3003,7 @@ KdpPrompt(IN LPSTR InString,
|
|||
KdbpTryGetCharKeyboard(&DummyScanCode, 5);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Null terminate the output string -- documentation states that
|
||||
* DbgPrompt does not null terminate, but it does
|
||||
*/
|
||||
|
@ -2910,7 +3011,7 @@ KdpPrompt(IN LPSTR InString,
|
|||
|
||||
/* Print a new line */
|
||||
KdPortPutByteEx(&SerialPortInfo, '\r');
|
||||
KdPortPutByteEx(&SerialPortInfo, '\n');
|
||||
KdPortPutByteEx(&SerialPortInfo, '\n');
|
||||
|
||||
/* Release spinlock */
|
||||
KiReleaseSpinLock(&KdpSerialSpinLock);
|
||||
|
@ -2939,4 +3040,4 @@ KdpPrompt(IN LPSTR InString,
|
|||
|
||||
/* Return the length */
|
||||
return OutStringLength;
|
||||
}
|
||||
}
|
|
@ -72,7 +72,7 @@ RPN_OP, *PRPN_OP;
|
|||
typedef struct _RPN_STACK
|
||||
{
|
||||
ULONG Size; /* Number of RPN_OPs on Ops */
|
||||
ULONG Sp; /* Stack pointer */
|
||||
ULONG_PTR Sp; /* Stack pointer */
|
||||
RPN_OP Ops[1]; /* Array of RPN_OPs */
|
||||
}
|
||||
RPN_STACK, *PRPN_STACK;
|
||||
|
@ -94,7 +94,7 @@ RPN_STACK, *PRPN_STACK;
|
|||
static struct
|
||||
{
|
||||
ULONG Size;
|
||||
ULONG Sp;
|
||||
ULONG_PTR Sp;
|
||||
RPN_OP Ops[RPN_OP_STACK_SIZE];
|
||||
}
|
||||
RpnStack =
|
||||
|
@ -106,11 +106,12 @@ RpnStack =
|
|||
static const struct
|
||||
{
|
||||
PCHAR Name;
|
||||
UCHAR Offset;
|
||||
UCHAR Size;
|
||||
USHORT Offset;
|
||||
USHORT Size;
|
||||
}
|
||||
RegisterToTrapFrame[] =
|
||||
{
|
||||
#ifdef _M_IX86
|
||||
{"eip", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Eip), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Eip)},
|
||||
{"eflags", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.EFlags), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.EFlags)},
|
||||
{"eax", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Eax), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Eax)},
|
||||
|
@ -137,6 +138,36 @@ RegisterToTrapFrame[] =
|
|||
{"cr2", FIELD_OFFSET(KDB_KTRAP_FRAME, Cr2), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Cr2)},
|
||||
{"cr3", FIELD_OFFSET(KDB_KTRAP_FRAME, Cr3), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Cr3)},
|
||||
{"cr4", FIELD_OFFSET(KDB_KTRAP_FRAME, Cr4), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Cr4)}
|
||||
#elif defined(_M_AMD64)
|
||||
{"rip", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Rip), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Rip)},
|
||||
{"rflags", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.EFlags), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.EFlags)},
|
||||
{"rax", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Rax), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Rax)},
|
||||
{"rbx", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Rbx), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Rbx)},
|
||||
{"rcx", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Rcx), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Rcx)},
|
||||
{"rdx", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Rdx), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Rdx)},
|
||||
{"rsi", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Rsi), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Rsi)},
|
||||
{"rdi", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Rdi), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Rdi)},
|
||||
{"r8", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.R8), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.R8)},
|
||||
{"r9", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.R9), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.R9)},
|
||||
{"r10", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.R10), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.R10)},
|
||||
{"r11", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.R11), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.R11)},
|
||||
{"cs", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.SegCs), 2 }, /* Use only the lower 2 bytes */
|
||||
{"ds", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.SegDs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.SegDs)},
|
||||
{"es", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.SegEs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.SegEs)},
|
||||
{"fs", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.SegFs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.SegFs)},
|
||||
{"gs", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.SegGs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.SegGs)},
|
||||
{"ss", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.SegSs), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.SegSs)},
|
||||
{"dr0", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Dr0), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Dr0)},
|
||||
{"dr1", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Dr1), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Dr1)},
|
||||
{"dr2", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Dr2), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Dr2)},
|
||||
{"dr3", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Dr3), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Dr3)},
|
||||
{"dr6", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Dr6), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Dr6)},
|
||||
{"dr7", FIELD_OFFSET(KDB_KTRAP_FRAME, Tf.Dr7), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Tf.Dr7)},
|
||||
{"cr0", FIELD_OFFSET(KDB_KTRAP_FRAME, Cr0), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Cr0)},
|
||||
{"cr2", FIELD_OFFSET(KDB_KTRAP_FRAME, Cr2), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Cr2)},
|
||||
{"cr3", FIELD_OFFSET(KDB_KTRAP_FRAME, Cr3), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Cr3)},
|
||||
{"cr4", FIELD_OFFSET(KDB_KTRAP_FRAME, Cr4), RTL_FIELD_SIZE(KDB_KTRAP_FRAME, Cr4)}
|
||||
#endif
|
||||
};
|
||||
static const INT RegisterToTrapFrameCount = sizeof (RegisterToTrapFrame) / sizeof (RegisterToTrapFrame[0]);
|
||||
|
||||
|
@ -1013,7 +1044,7 @@ RpnpEvaluateStack(
|
|||
|
||||
if (!Ok)
|
||||
{
|
||||
_snprintf(ErrMsg, 128, "Couldn't access memory at 0x%lx", (ULONG)p);
|
||||
_snprintf(ErrMsg, 128, "Couldn't access memory at 0x%p", p);
|
||||
|
||||
if (ErrOffset)
|
||||
*ErrOffset = Op->CharacterOffset;
|
||||
|
@ -1199,4 +1230,3 @@ KdbpRpnEvaluateParsedExpression(
|
|||
/* Evaluate the stack */
|
||||
return RpnpEvaluateStack(Stack, TrapFrame, Result, ErrOffset, ErrMsg);
|
||||
}
|
||||
|
||||
|
|
|
@ -714,23 +714,13 @@ KiSystemStartupReal(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|||
if (KdPollBreakIn()) DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C);
|
||||
|
||||
/* Hack! Wait for the debugger! */
|
||||
while (!KdPollBreakIn());
|
||||
//while (!KdPollBreakIn());
|
||||
|
||||
/* Display separator + ReactOS version at start of the debug log */
|
||||
DPRINT1("-----------------------------------------------------\n");
|
||||
DPRINT1("ReactOS "KERNEL_VERSION_STR" (Build "KERNEL_VERSION_BUILD_STR")\n");
|
||||
DPRINT1("Command Line: %s\n", LoaderBlock->LoadOptions);
|
||||
DPRINT1("ARC Paths: %s %s %s %s\n", LoaderBlock->ArcBootDeviceName,
|
||||
LoaderBlock->NtHalPathName,
|
||||
LoaderBlock->ArcHalDeviceName,
|
||||
LoaderBlock->NtBootPathName);
|
||||
}
|
||||
|
||||
DPRINT("Pcr = %p, Gdt = %p, Idt = %p, Tss = %p\n",
|
||||
Pcr, Pcr->GdtBase, Pcr->IdtBase, Pcr->TssBase);
|
||||
|
||||
DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C);
|
||||
|
||||
/* Initialize the Processor with HAL */
|
||||
HalInitializeProcessor(Cpu, KeLoaderBlock);
|
||||
|
||||
|
|
|
@ -321,19 +321,24 @@
|
|||
</if>
|
||||
</directory>
|
||||
</if>
|
||||
<if property="ARCH" value="amd64">
|
||||
<directory name="amd64">
|
||||
<if property="KDBG" value="1">
|
||||
<group>
|
||||
<file>i386-dis.c</file>
|
||||
<file>kdb_help.S</file>
|
||||
<file>kdb.c</file>
|
||||
<file>setjmp.S</file>
|
||||
</group>
|
||||
</if>
|
||||
</directory>
|
||||
</if>
|
||||
<if property="KDBG" value="1">
|
||||
<ifnot property="ARCH" value="amd64">
|
||||
<file>kdb.c</file>
|
||||
<file>kdb_cli.c</file>
|
||||
<file>kdb_expr.c</file>
|
||||
</ifnot>
|
||||
<file>kdb.c</file>
|
||||
<file>kdb_cli.c</file>
|
||||
<file>kdb_expr.c</file>
|
||||
<file>kdb_keyboard.c</file>
|
||||
<file>kdb_serial.c</file>
|
||||
<if property="ARCH" value="amd64">
|
||||
<directory name="amd64">
|
||||
<file>kdb.c</file>
|
||||
</directory>
|
||||
</if>
|
||||
</if>
|
||||
<if property="DBG_OR_KDBG" value="true">
|
||||
<file>kdb_symbols.c</file>
|
||||
|
@ -353,6 +358,7 @@
|
|||
<if property="ARCH" value="amd64">
|
||||
<directory name="amd64">
|
||||
<file>kd.c</file>
|
||||
<file>kdmemsup.c</file>
|
||||
</directory>
|
||||
</if>
|
||||
<file>kdinit.c</file>
|
||||
|
|
Loading…
Reference in a new issue