netstat: Initial implementation.
[wine] / dlls / dbghelp / cpu_sparc.c
1 /*
2  * File cpu_sparc.c
3  *
4  * Copyright (C) 2009-2009, Eric Pouech
5  * Copyright (C) 2010, Austin English
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #include <assert.h>
23
24 #include "ntstatus.h"
25 #define WIN32_NO_STATUS
26 #include "dbghelp_private.h"
27 #include "winternl.h"
28 #include "wine/debug.h"
29
30 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
31
32 static unsigned sparc_get_addr(HANDLE hThread, const CONTEXT* ctx,
33                              enum cpu_addr ca, ADDRESS64* addr)
34 {
35     addr->Mode    = AddrModeFlat;
36     addr->Segment = 0; /* don't need segment */
37     switch (ca)
38     {
39 #ifdef __sparc__
40     case cpu_addr_pc:    addr->Offset = ctx->pc; return TRUE;
41     case cpu_addr_stack: addr->Offset = ctx->o6; return TRUE;
42     case cpu_addr_frame: addr->Offset = ctx->i6; return TRUE;
43 #endif
44     default: addr->Mode = -1;
45         return FALSE;
46     }
47 }
48
49 static BOOL sparc_stack_walk(struct cpu_stack_walk* csw, LPSTACKFRAME64 frame, CONTEXT* context)
50 {
51     FIXME("not done for Sparc\n");
52     return FALSE;
53 }
54
55 static unsigned sparc_map_dwarf_register(unsigned regno)
56 {
57     if (regno <= 7)
58         return CV_SPARC_G0 + regno;
59     else if (regno >= 8 && regno <= 15)
60         return CV_SPARC_O0 + regno - 8;
61     else if (regno >= 16 && regno <= 23)
62         return CV_SPARC_L0 + regno - 16;
63     else if (regno >= 24 && regno <= 31)
64         return CV_SPARC_I0 + regno - 24;
65
66     FIXME("Don't know how to map register %d\n", regno);
67     return CV_SPARC_NOREG;
68 }
69
70 static void* sparc_fetch_context_reg(CONTEXT* ctx, unsigned regno, unsigned* size)
71 {
72     FIXME("not done for Sparc\n");
73     return NULL;
74 }
75
76 static const char* sparc_fetch_regname(unsigned regno)
77 {
78     FIXME("Unknown register %x\n", regno);
79     return NULL;
80 }
81
82 static BOOL sparc_fetch_minidump_thread(struct dump_context* dc, unsigned index, unsigned flags, const CONTEXT* ctx)
83 {
84     FIXME("NIY\n");
85     return FALSE;
86 }
87
88 static BOOL sparc_fetch_minidump_module(struct dump_context* dc, unsigned index, unsigned flags)
89 {
90     FIXME("NIY\n");
91     return FALSE;
92 }
93
94 DECLSPEC_HIDDEN struct cpu cpu_sparc = {
95     IMAGE_FILE_MACHINE_SPARC,
96     4,
97     CV_REG_NONE, /* FIXME */
98     sparc_get_addr,
99     sparc_stack_walk,
100     NULL,
101     sparc_map_dwarf_register,
102     sparc_fetch_context_reg,
103     sparc_fetch_regname,
104     sparc_fetch_minidump_thread,
105     sparc_fetch_minidump_module,
106 };