11541Srgrimes/*
21541Srgrimes * Copyright (c) 2006 Marcel Moolenaar
31541Srgrimes * All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes *
141541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
151541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
161541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
171541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
181541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
191541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
201541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
211541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
221541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
231541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
241541Srgrimes * SUCH DAMAGE.
251541Srgrimes */
261541Srgrimes
271541Srgrimes#include <sys/cdefs.h>
281541Srgrimes__FBSDID("$FreeBSD$");
291541Srgrimes
301541Srgrimes#include <sys/types.h>
311541Srgrimes#include <string.h>
321541Srgrimes#include <thread_db.h>
331541Srgrimes
341541Srgrimes#include "libpthread_db.h"
351541Srgrimes
361541Srgrimesvoid
371541Srgrimespt_reg_to_ucontext(const struct reg *r, ucontext_t *uc)
3814508Shsu{
3950477Speter	mcontext_t *mc = &uc->uc_mcontext;
401541Srgrimes
411541Srgrimes	memcpy(mc->mc_frame, r, MIN(sizeof(mc->mc_frame), sizeof(*r)));
422165Spaul}
432865Sbde
442165Spaulvoid
4549043Salcpt_ucontext_to_reg(const ucontext_t *uc, struct reg *r)
461549Srgrimes{
4729683Sgibbs	const mcontext_t *mc = &uc->uc_mcontext;
481549Srgrimes
4918883Sbde	memcpy(r, mc->mc_frame, MIN(sizeof(mc->mc_frame), sizeof(*r)));
5082693Srwatson}
517090Sbde
527090Sbdevoid
531541Srgrimespt_fpreg_to_ucontext(const struct fpreg *r, ucontext_t *uc)
5467093Sps{
551541Srgrimes	mcontext_t *mc = &uc->uc_mcontext;
561541Srgrimes
571541Srgrimes	memcpy(mc->mc_fpreg, r, MIN(sizeof(mc->mc_fpreg), sizeof(*r)));
581541Srgrimes	mc->mc_flags |= _MC_FP_VALID;
591541Srgrimes}
6076564Stanimura
611541Srgrimesvoid
621541Srgrimespt_ucontext_to_fpreg(const ucontext_t *uc, struct fpreg *r)
631541Srgrimes{
641541Srgrimes	const mcontext_t *mc = &uc->uc_mcontext;
651541Srgrimes
661541Srgrimes	if (mc->mc_flags & _MC_FP_VALID)
671541Srgrimes		memcpy(r, mc->mc_fpreg, MIN(sizeof(mc->mc_fpreg), sizeof(*r)));
6836809Sbde	else
6936809Sbde		memset(r, 0, sizeof(*r));
701541Srgrimes}
711541Srgrimes
721541Srgrimesvoid
7315113Sbdept_md_init(void)
741541Srgrimes{
7580418Speter}
7680418Speter
7742453Seivindint
7842453Seivindpt_reg_sstep(struct reg *reg __unused, int step __unused)
7942408Seivind{
8042453Seivind
8142408Seivind	/* XXX */
8242408Seivind	return (0);
831541Srgrimes}
8483595Speter