2004-06-04 02:59:16 +02:00
|
|
|
/*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-06-04 02:59:16 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "debugger.h"
|
|
|
|
|
|
|
|
#if defined(__powerpc__)
|
|
|
|
|
|
|
|
static unsigned be_ppc_get_addr(HANDLE hThread, const CONTEXT* ctx,
|
2006-07-26 11:57:27 +02:00
|
|
|
enum be_cpu_addr bca, ADDRESS64* addr)
|
2004-06-04 02:59:16 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-12-02 17:43:08 +01:00
|
|
|
static unsigned be_ppc_get_register_info(int regno, enum be_cpu_addr* kind)
|
|
|
|
{
|
|
|
|
dbg_printf("not done\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-06-04 02:59:16 +02:00
|
|
|
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;
|
2005-05-24 13:46:25 +02:00
|
|
|
else ctx->Msr &= ~MSR_SE;
|
2004-06-04 02:59:16 +02:00
|
|
|
}
|
|
|
|
|
2006-03-21 13:54:41 +01:00
|
|
|
static void be_ppc_print_context(HANDLE hThread, const CONTEXT* ctx, int all_regs)
|
2004-06-04 02:59:16 +02:00
|
|
|
{
|
|
|
|
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}
|
|
|
|
};
|
|
|
|
|
2009-09-01 22:23:43 +02:00
|
|
|
static unsigned be_ppc_is_step_over_insn(const void* insn)
|
2004-06-04 02:59:16 +02:00
|
|
|
{
|
|
|
|
dbg_printf("not done\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-09-01 22:23:43 +02:00
|
|
|
static unsigned be_ppc_is_function_return(const void* insn)
|
2004-06-04 02:59:16 +02:00
|
|
|
{
|
|
|
|
dbg_printf("not done\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-09-01 22:23:43 +02:00
|
|
|
static unsigned be_ppc_is_break_insn(const void* insn)
|
2004-06-04 02:59:16 +02:00
|
|
|
{
|
|
|
|
dbg_printf("not done\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-09-01 22:23:43 +02:00
|
|
|
static unsigned be_ppc_is_func_call(const void* insn, ADDRESS64* callee)
|
2004-06-04 02:59:16 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-01-08 14:08:56 +01:00
|
|
|
static unsigned be_ppc_is_jump(const void* insn, ADDRESS64* jumpee)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-07-26 11:57:27 +02:00
|
|
|
static void be_ppc_disasm_one_insn(ADDRESS64* addr, int display)
|
2011-01-08 14:08:56 +01:00
|
|
|
|
2004-06-04 02:59:16 +02:00
|
|
|
{
|
|
|
|
dbg_printf("Disasm NIY\n");
|
|
|
|
}
|
|
|
|
|
2006-02-24 22:13:34 +01:00
|
|
|
static unsigned be_ppc_insert_Xpoint(HANDLE hProcess, const struct be_process_io* pio,
|
2005-05-24 13:46:25 +02:00
|
|
|
CONTEXT* ctx, enum be_xpoint_type type,
|
|
|
|
void* addr, unsigned long* val, unsigned size)
|
2004-06-04 02:59:16 +02:00
|
|
|
{
|
|
|
|
unsigned long xbp;
|
2006-06-30 21:37:38 +02:00
|
|
|
SIZE_T sz;
|
2004-06-04 02:59:16 +02:00
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case be_xpoint_break:
|
|
|
|
if (!size) return 0;
|
2005-05-24 13:46:25 +02:00
|
|
|
if (!pio->read(hProcess, addr, val, 4, &sz) || sz != 4) return 0;
|
2004-06-04 02:59:16 +02:00
|
|
|
xbp = 0x7d821008; /* 7d 82 10 08 ... in big endian */
|
2005-05-24 13:46:25 +02:00
|
|
|
if (!pio->write(hProcess, addr, &xbp, 4, &sz) || sz != 4) return 0;
|
2004-06-04 02:59:16 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dbg_printf("Unknown/unsupported bp type %c\n", type);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-02-24 22:13:34 +01:00
|
|
|
static unsigned be_ppc_remove_Xpoint(HANDLE hProcess, const struct be_process_io* pio,
|
2005-05-24 13:46:25 +02:00
|
|
|
CONTEXT* ctx, enum be_xpoint_type type,
|
|
|
|
void* addr, unsigned long val, unsigned size)
|
2004-06-04 02:59:16 +02:00
|
|
|
{
|
2006-06-30 21:37:38 +02:00
|
|
|
SIZE_T sz;
|
2004-06-04 02:59:16 +02:00
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case be_xpoint_break:
|
|
|
|
if (!size) return 0;
|
2005-05-24 13:46:25 +02:00
|
|
|
if (!pio->write(hProcess, addr, &val, 4, &sz) || sz == 4) return 0;
|
2004-06-04 02:59:16 +02:00
|
|
|
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,
|
2006-01-23 16:47:07 +01:00
|
|
|
unsigned ext_sign, LONGLONG* ret)
|
2004-06-04 02:59:16 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-04-04 22:30:38 +02:00
|
|
|
static int be_ppc_store_integer(const struct dbg_lvalue* lvalue, unsigned size,
|
|
|
|
unsigned is_signed, LONGLONG val)
|
|
|
|
{
|
|
|
|
dbg_printf("be_ppc_store_integer: not done\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-06-04 02:59:16 +02:00
|
|
|
struct backend_cpu be_ppc =
|
|
|
|
{
|
2009-12-22 14:20:16 +01:00
|
|
|
IMAGE_FILE_MACHINE_POWERPC,
|
2010-04-12 21:18:18 +02:00
|
|
|
4,
|
2004-06-04 02:59:16 +02:00
|
|
|
be_cpu_linearize,
|
|
|
|
be_cpu_build_addr,
|
|
|
|
be_ppc_get_addr,
|
2006-12-02 17:43:08 +01:00
|
|
|
be_ppc_get_register_info,
|
2004-06-04 02:59:16 +02:00
|
|
|
be_ppc_single_step,
|
|
|
|
be_ppc_print_context,
|
|
|
|
be_ppc_print_segment_info,
|
2010-03-27 09:08:20 +01:00
|
|
|
be_ppc_ctx,
|
2004-06-04 02:59:16 +02:00
|
|
|
be_ppc_is_step_over_insn,
|
|
|
|
be_ppc_is_function_return,
|
|
|
|
be_ppc_is_break_insn,
|
|
|
|
be_ppc_is_func_call,
|
2011-01-08 14:08:56 +01:00
|
|
|
be_ppc_is_jump,
|
2004-06-04 02:59:16 +02:00
|
|
|
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,
|
2012-04-04 22:30:38 +02:00
|
|
|
be_ppc_store_integer,
|
2004-06-04 02:59:16 +02:00
|
|
|
};
|
|
|
|
#endif
|