bsd-kvm target, always a thread

Pedro Alves pedro@codesourcery.com
Sat Aug 9 11:28:00 GMT 2008


On Saturday 09 August 2008 09:32:57, Mark Kettenis wrote:
> > From: Pedro Alves <pedro@codesourcery.com>

> Hmm, it is unfortunate that a process ID of 0 is "verboten", since
> that's what you are really looking at with "target kvm".  And it
> should be possible for me to actually make all the running processes
> visible as kernel "threads".
>

> I guess your diff is right, although I'd prefer a less arbitrary ptid
> to be used.  Would something like ptid_build(0, 1, 0) work?

I'd prefer to get away without pid == 0.  I'm going to
introduce later a "struct inferior" which holds an "int pid", and
we will match a ptid to a struct inferior by its ptid.pid.
I'd rather avoid having an inferior with pid == 0.

Does something like this work for you?

    ptid(42000, 0, 0)    ->  for use when we pass around a      
                             ptid representing the whole inferior.

    ptid(42000, 1, 0)    ->  in kernel

    ptid(42000, 1, 1)  ->  process 1.
    ptid(42000, 1, 2)  ->  process 2
    ptid(42000, 1, 3)  ->  process 3
    ...

Or, does it make sense to have one or more threads for the kernel,
distinct from user visible processes?

    ptid(42000, 0, 0)    ->  for use when we pass around a      
                             ptid representing the whole inferior.

    ptid(42000, 1, 1)    ->  kernel thread/context 1
    ptid(42000, 1, 2)    ->  kernel thread/context 2
    ...
    ptid(42000, 0, 1)  ->  user process 1.
    ptid(42000, 0, 2)  ->  user process 2
    ptid(42000, 0, 3)  ->  user process 3
    ...

These are internal ids, of course.  We only show them what we
want in target_pid_to_str and target_extra_thread_info.  The user
doesn't need to know anything about these ids.

-- 
Pedro Alves



More information about the Gdb-patches mailing list