Blame nptl_db/td_thr_getfpregs.c

Packit Service 82fcde
/* Get a thread's floating-point register set.
Packit Service 82fcde
   Copyright (C) 1999-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
   Contributed by Ulrich Drepper <drepper@redhat.com>, 1999.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library; if not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
#include "thread_dbP.h"
Packit Service 82fcde
Packit Service 82fcde
Packit Service 82fcde
td_err_e
Packit Service 82fcde
td_thr_getfpregs (const td_thrhandle_t *th, prfpregset_t *regset)
Packit Service 82fcde
{
Packit Service 82fcde
  psaddr_t cancelhandling, tid;
Packit Service 82fcde
  td_err_e err;
Packit Service 82fcde
Packit Service 82fcde
  LOG ("td_thr_getfpregs");
Packit Service 82fcde
Packit Service 82fcde
  if (th->th_unique == 0)
Packit Service 82fcde
    /* Special case for the main thread before initialization.  */
Packit Service 82fcde
    return ps_lgetfpregs (th->th_ta_p->ph, ps_getpid (th->th_ta_p->ph),
Packit Service 82fcde
			  regset) != PS_OK ? TD_ERR : TD_OK;
Packit Service 82fcde
Packit Service 82fcde
  /* We have to get the state and the PID for this thread.  */
Packit Service 82fcde
  err = DB_GET_FIELD (cancelhandling, th->th_ta_p, th->th_unique, pthread,
Packit Service 82fcde
		      cancelhandling, 0);
Packit Service 82fcde
  if (err != TD_OK)
Packit Service 82fcde
    return err;
Packit Service 82fcde
Packit Service 82fcde
  /* If the thread already terminated we return all zeroes.  */
Packit Service 82fcde
  if (((int) (uintptr_t) cancelhandling) & TERMINATED_BITMASK)
Packit Service 82fcde
    memset (regset, '\0', sizeof (*regset));
Packit Service 82fcde
  /* Otherwise get the register content through the callback.  */
Packit Service 82fcde
  else
Packit Service 82fcde
    {
Packit Service 82fcde
      err = DB_GET_FIELD (tid, th->th_ta_p, th->th_unique, pthread, tid, 0);
Packit Service 82fcde
      if (err != TD_OK)
Packit Service 82fcde
	return err;
Packit Service 82fcde
Packit Service 82fcde
      if (ps_lgetfpregs (th->th_ta_p->ph, (uintptr_t) tid, regset) != PS_OK)
Packit Service 82fcde
	return TD_ERR;
Packit Service 82fcde
    }
Packit Service 82fcde
Packit Service 82fcde
  return TD_OK;
Packit Service 82fcde
}