be_ppc.c 5.09 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * Debugger Power PC specific functions
 *
 * Copyright 2000-2003 Marcus Meissner
 *                2004 Eric Pouech
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 23 24 25 26
 */

#include "debugger.h"

#if defined(__powerpc__)

static unsigned be_ppc_get_addr(HANDLE hThread, const CONTEXT* ctx, 
27
                                enum be_cpu_addr bca, ADDRESS64* addr)
28 29 30 31 32 33 34 35 36 37 38 39 40
{
    switch (bca)
    {
    case be_cpu_addr_pc:
        return be_cpu_build_addr(hThread, ctx, addr, 0, ctx->Iar);
    default:
    case be_cpu_addr_stack:
    case be_cpu_addr_frame:
        dbg_printf("not done\n");
    }
    return FALSE;
}

41 42 43 44 45 46
static unsigned be_ppc_get_register_info(int regno, enum be_cpu_addr* kind)
{
    dbg_printf("not done\n");
    return FALSE;
}

47 48 49 50 51 52
static void be_ppc_single_step(CONTEXT* ctx, unsigned enable)
{
#ifndef MSR_SE
# define MSR_SE (1<<10)
#endif 
    if (enable) ctx->Msr |= MSR_SE;
53
    else ctx->Msr &= ~MSR_SE;
54 55
}

56
static void be_ppc_print_context(HANDLE hThread, const CONTEXT* ctx, int all_regs)
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
{
    dbg_printf("Context printing for PPC not done yet\n");
}

static void be_ppc_print_segment_info(HANDLE hThread, const CONTEXT* ctx)
{
}

static struct dbg_internal_var be_ppc_ctx[] =
{
    {0,                 NULL,           0,                                      dbg_itype_none}
};

static const struct dbg_internal_var* be_ppc_init_registers(CONTEXT* ctx)
{
    dbg_printf("not done\n");
    return be_ppc_ctx;
}

static unsigned be_ppc_is_step_over_insn(void* insn)
{
    dbg_printf("not done\n");
    return FALSE;
}

static unsigned be_ppc_is_function_return(void* insn)
{
    dbg_printf("not done\n");
    return FALSE;
}

static unsigned be_ppc_is_break_insn(void* insn)
{
    dbg_printf("not done\n");
    return FALSE;
}

static unsigned be_ppc_is_func_call(void* insn, void** insn_callee)
{
    return FALSE;
}

99
static void be_ppc_disasm_one_insn(ADDRESS64* addr, int display)
100 101 102 103
{
    dbg_printf("Disasm NIY\n");
}

104
static unsigned be_ppc_insert_Xpoint(HANDLE hProcess, const struct be_process_io* pio,
105 106
                                     CONTEXT* ctx, enum be_xpoint_type type,
                                     void* addr, unsigned long* val, unsigned size)
107 108
{
    unsigned long       xbp;
109
    SIZE_T              sz;
110 111 112 113 114

    switch (type)
    {
    case be_xpoint_break:
        if (!size) return 0;
115
        if (!pio->read(hProcess, addr, val, 4, &sz) || sz != 4) return 0;
116
        xbp = 0x7d821008; /* 7d 82 10 08 ... in big endian */
117
        if (!pio->write(hProcess, addr, &xbp, 4, &sz) || sz != 4) return 0;
118 119 120 121 122 123 124 125
        break;
    default:
        dbg_printf("Unknown/unsupported bp type %c\n", type);
        return 0;
    }
    return 1;
}

126
static unsigned be_ppc_remove_Xpoint(HANDLE hProcess, const struct be_process_io* pio,
127 128
                                     CONTEXT* ctx, enum be_xpoint_type type,
                                     void* addr, unsigned long val, unsigned size)
129
{
130
    SIZE_T              sz;
131 132 133 134 135

    switch (type)
    {
    case be_xpoint_break:
        if (!size) return 0;
136
        if (!pio->write(hProcess, addr, &val, 4, &sz) || sz == 4) return 0;
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
        break;
    default:
        dbg_printf("Unknown/unsupported bp type %c\n", type);
        return 0;
    }
    return 1;
}

static unsigned be_ppc_is_watchpoint_set(const CONTEXT* ctx, unsigned idx)
{
    dbg_printf("not done\n");
    return FALSE;
}

static void be_ppc_clear_watchpoint(CONTEXT* ctx, unsigned idx)
{
    dbg_printf("not done\n");
}

static int be_ppc_adjust_pc_for_break(CONTEXT* ctx, BOOL way)
{
    dbg_printf("not done\n");
    return 0;
}

static int be_ppc_fetch_integer(const struct dbg_lvalue* lvalue, unsigned size,
163
                                unsigned ext_sign, LONGLONG* ret)
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
{
    dbg_printf("not done\n");
    return FALSE;
}

static int be_ppc_fetch_float(const struct dbg_lvalue* lvalue, unsigned size, 
                              long double* ret)
{
    dbg_printf("not done\n");
    return FALSE;
}

struct backend_cpu be_ppc =
{
    be_cpu_linearize,
    be_cpu_build_addr,
    be_ppc_get_addr,
181
    be_ppc_get_register_info,
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
    be_ppc_single_step,
    be_ppc_print_context,
    be_ppc_print_segment_info,
    be_ppc_init_registers,
    be_ppc_is_step_over_insn,
    be_ppc_is_function_return,
    be_ppc_is_break_insn,
    be_ppc_is_func_call,
    be_ppc_disasm_one_insn,
    be_ppc_insert_Xpoint,
    be_ppc_remove_Xpoint,
    be_ppc_is_watchpoint_set,
    be_ppc_clear_watchpoint,
    be_ppc_adjust_pc_for_break,
    be_ppc_fetch_integer,
    be_ppc_fetch_float,
};
#endif