summaryrefslogtreecommitdiff
path: root/overlay/mgdb/gdb/amd64-winnt-regcache.c
blob: 6ed35cbe60ca03f31ac2ce96804a7a7f00859f36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/***************************************************************/
/*  mgdb: midipix-specific bits for gdb                        */
/*  Copyright (C) 2019  Z. Gilboa                              */
/*  Released under GPLv2 and GPLv3; see COPYING.MGDB.          */
/***************************************************************/

#include "defs.h"
#include "osabi.h"
#include "regcache.h"
#include "amd64-tdep.h"

#include <signal.h>
#include <sys/debug.h>

struct regcache;

static void amd64_winnt_supply_reg(
	struct regcache * rcache,
	int regnum, uintptr_t regval)
{
	regcache_raw_supply(rcache,regnum,&regval);
}

static void amd64_winnt_supply_pc_regs(
	struct regcache * rcache,
	mcontext_t * regctx)
{
	amd64_winnt_supply_reg(rcache,AMD64_RIP_REGNUM,regctx->uc_rip);
}

int amd64_winnt_fetch_registers(
	int pfd, struct regcache * rcache,
	int regnum, pid_t tid)
{
	int ret;
	mcontext_t regctx;

	if ((ret = __dbg_regs_fetch(pfd,tid,&regctx)) < 0)
		return ret;

	if (regnum == AMD64_RIP_REGNUM)
		amd64_winnt_supply_pc_regs(rcache,&regctx);

	return 0;
}