tid::errno would be handy in mdb

Review Request #2010 — Created June 20, 2019 and submitted

jbk
illumos-gate
11264
general

tid::errno would be handy in mdb

To test, I created a small program:

#define _REENTRANT
#include <stdio.h>
#include <thread.h>
#include <unistd.h>
#include <sys/sysmacros.h>
#include <sys/debug.h>
#include <sys/types.h>
#include <errno.h>

static int vals[] = { 42, 5150, 2112 }; // Hi Dan!

static void *
do_something(void *arg)
{
    int val = (intptr_t)arg;

    errno = val;
    (void) printf("Thread %u; errno = %d; waiting...\n", thr_self(), val);
    pause();
}

int
main(int argc, char **argv)
{
    size_t i;

    (void)printf("pid %u\n\n", getpid());
    for (i = 0; i < ARRAY_SIZE(vals); i++) {
        void *arg = (void*)(intptr_t)vals[i];

        VERIFY0(thr_create(NULL, 0, do_something, arg, 0, NULL));
    }

    (void) do_something((void *)(intptr_t)6768);
    return (0);
}

And then ran it in one window and then ran mdb in another window:

In window 1:

# ./test
pid 40404

Thread 2; errno = 42; waiting...
Thread 3; errno = 5150; waiting...
Thread 4; errno = 2112; waiting...
Thread 1; errno = 6768; waiting...

In window 2:

# mdb -L /tmp -p 40404
> ::load libc
> 1::errno
6768
> 2::errno
42
> 3::errno
5150
> 4::errno
2112
>
tsoome
  1. Ship It!
  2. 
      
citrus
  1. Ship It!
  2. 
      
jbk
Review request changed

Status: Closed (submitted)

Loading...