Project

General

Profile

Actions

Feature #14103

open

DTrace uregs[] should allow access to FSBASE and GSBASE

Added by Joshua M. Clulow 8 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
DTrace
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

The DTrace errno variable allows access to the error number that is returned by a system call, and is useful in the context of a syscall:::return probe. When tracing library functions with the pid provider, the situation is somewhat more complex; errno is thread-local, so the specific value is somewhat harder to fish out. It's possible, for amd64 programs, to:

pid$target::port_getn:return
{
        /*
         * Get the per-thread errno location for this thread:
         */
        this->fsbase = curthread->t_lwp->lwp_pcb.pcb_fsbase;
        this->ulwp = (userland struct pid`ulwp *)this->fsbase;
        this->errnop = this->ulwp->ul_errnop;

        printf("errnop %p = %d\n", this->errnop, *this->errnop);
}

At a minimum, it seems like we should provide access to the FSBASE value (or, I believe, the GSBASE value for i386) that is needed to find the ulwp structure for the current LWP. It would seem most logical to make these available through additional entries in the uregs[] array (R_FSBASE and R_GSBASE), through they would perhaps be read-only entries at least initially.

No data to display

Actions

Also available in: Atom PDF