313
314 return (PS_OK);
315 }
316
317 ps_err_e
318 ps_lgetregs(struct ps_prochandle *ph, lwpid_t lid, prgregset_t gregset)
319 {
320 char procname[MAXPATHLEN];
321 int lwpfd;
322 lwpstatus_t lwpstatus;
323
324 (void) snprintf(procname, MAXPATHLEN - 1,
325 "/proc/%d/lwp/%d/lwpstatus", EC_SWORD(ph->pp_pid), EC_SWORD(lid));
326
327 if ((lwpfd = open(procname, O_RDONLY)) == -1)
328 return (PS_ERR);
329
330 if (read(lwpfd, &lwpstatus, sizeof (lwpstatus)) == -1)
331 return (PS_ERR);
332
333 gregset = lwpstatus.pr_reg;
334
335 (void) close(lwpfd);
336 return (PS_OK);
337 }
338
339 void
340 ps_plog(const char *fmt, ...)
341 {
342 va_list args;
343 static FILE *log_fp = NULL;
344
345 if (log_fp == NULL) {
346 char log_fname[256];
347 (void) sprintf(log_fname, "/tmp/tdlog.%d", EC_SWORD(getpid()));
348 if ((log_fp = fopen(log_fname, "w")) == NULL) {
349 /*
350 * Unable to open log file - default to stderr.
351 */
352 (void) fprintf(stderr, "unable to open %s, logging "
353 "redirected to stderr", log_fname);
|
313
314 return (PS_OK);
315 }
316
317 ps_err_e
318 ps_lgetregs(struct ps_prochandle *ph, lwpid_t lid, prgregset_t gregset)
319 {
320 char procname[MAXPATHLEN];
321 int lwpfd;
322 lwpstatus_t lwpstatus;
323
324 (void) snprintf(procname, MAXPATHLEN - 1,
325 "/proc/%d/lwp/%d/lwpstatus", EC_SWORD(ph->pp_pid), EC_SWORD(lid));
326
327 if ((lwpfd = open(procname, O_RDONLY)) == -1)
328 return (PS_ERR);
329
330 if (read(lwpfd, &lwpstatus, sizeof (lwpstatus)) == -1)
331 return (PS_ERR);
332
333 memcpy(gregset, lwpstatus.pr_reg, sizeof (*gregset));
334
335 (void) close(lwpfd);
336 return (PS_OK);
337 }
338
339 void
340 ps_plog(const char *fmt, ...)
341 {
342 va_list args;
343 static FILE *log_fp = NULL;
344
345 if (log_fp == NULL) {
346 char log_fname[256];
347 (void) sprintf(log_fname, "/tmp/tdlog.%d", EC_SWORD(getpid()));
348 if ((log_fp = fopen(log_fname, "w")) == NULL) {
349 /*
350 * Unable to open log file - default to stderr.
351 */
352 (void) fprintf(stderr, "unable to open %s, logging "
353 "redirected to stderr", log_fname);
|