libpthread_md.c revision 181341
16059Samurai/*
26059Samurai * Copyright (c) 2006 Marcel Moolenaar
36059Samurai * All rights reserved.
46059Samurai *
56059Samurai * Redistribution and use in source and binary forms, with or without
66059Samurai * modification, are permitted provided that the following conditions
76059Samurai * are met:
86059Samurai * 1. Redistributions of source code must retain the above copyright
96059Samurai *    notice, this list of conditions and the following disclaimer.
106059Samurai * 2. Redistributions in binary form must reproduce the above copyright
116059Samurai *    notice, this list of conditions and the following disclaimer in the
126059Samurai *    documentation and/or other materials provided with the distribution.
136059Samurai *
146059Samurai * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
156059Samurai * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
166059Samurai * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
176059Samurai * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
186059Samurai * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
196059Samurai * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2026098Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
218857Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
226059Samurai * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
236059Samurai * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
246059Samurai * SUCH DAMAGE.
256059Samurai */
266059Samurai
276059Samurai#include <sys/cdefs.h>
2811336Samurai__FBSDID("$FreeBSD: head/lib/libthread_db/arch/powerpc/libpthread_md.c 181341 2008-08-06 03:14:18Z marcel $");
296059Samurai
306059Samurai#include <sys/types.h>
3123114Sbrian#include <string.h>
326059Samurai#include <thread_db.h>
336059Samurai
346059Samurai#include "libpthread_db.h"
3518786Sjkh
366059Samuraivoid
376059Samuraipt_reg_to_ucontext(const struct reg *r, ucontext_t *uc)
3820365Sjkh{
3920365Sjkh	mcontext_t *mc = &uc->uc_mcontext;
4026031Sbrian
416059Samurai	memcpy(mc->mc_frame, r, MIN(sizeof(mc->mc_frame), sizeof(*r)));
426059Samurai}
436059Samurai
4413389Sphkvoid
456059Samuraipt_ucontext_to_reg(const ucontext_t *uc, struct reg *r)
466059Samurai{
476059Samurai	const mcontext_t *mc = &uc->uc_mcontext;
486735Samurai
497001Samurai	memcpy(r, mc->mc_frame, MIN(sizeof(mc->mc_frame), sizeof(*r)));
5013389Sphk}
5113389Sphk
5223840Sbrianvoid
536059Samuraipt_fpreg_to_ucontext(const struct fpreg *r, ucontext_t *uc)
546764Samurai{
559410Sasami	mcontext_t *mc = &uc->uc_mcontext;
566764Samurai
576735Samurai	memcpy(mc->mc_fpreg, r, MIN(sizeof(mc->mc_fpreg), sizeof(*r)));
586735Samurai	mc->mc_flags |= _MC_FP_VALID;
596735Samurai}
606735Samurai
616735Samuraivoid
626735Samuraipt_ucontext_to_fpreg(const ucontext_t *uc, struct fpreg *r)
636059Samurai{
6425630Sbrian	const mcontext_t *mc = &uc->uc_mcontext;
656059Samurai
666059Samurai	if (mc->mc_flags & _MC_FP_VALID)
676059Samurai		memcpy(r, mc->mc_fpreg, MIN(sizeof(mc->mc_fpreg), sizeof(*r)));
6818885Sjkh	else
696059Samurai		memset(r, 0, sizeof(*r));
706059Samurai}
7110528Samurai
7225908Sbrianvoid
736059Samuraipt_md_init(void)
746059Samurai{
756059Samurai}
7614418Sache
7713379Sphkint
7820813Sjkhpt_reg_sstep(struct reg *reg __unused, int step __unused)
796059Samurai{
8025634Sbrian
8125634Sbrian	/* XXX */
8225445Sache	return (0);
836059Samurai}
846059Samurai