[RFC] New function find_target_at_stratum() ?

Joel Brobecker brobecker@adacore.com
Thu Jan 12 06:09:00 GMT 2006


Hello,

While learning a bit more about the target vector and the target
stack, and how it is used, I noticed that two files, sol-thread.c
and uw-thread.c make an explicit reference to the procfs_ops target
vector.

Looking at the code, the idea is to implement one target method at
the thread level by first using the same method at the process level
and then by performing the necessary operations to handle threads.
For instance:

  static void
  sol_thread_attach (char *args, int from_tty)
  {
    procfs_ops.to_attach (args, from_tty);
  
    /* Must get symbols from shared libraries before libthread_db can run!  */
    solib_add (NULL, from_tty, (struct target_ops *) 0, auto_solib_add);
    [...]
  }

This is really nit-picking, but I think we can get rid of these explicit
references and then make procfs_ops static. The way to do this would be
to change the reference to procfs_ops by a function that would return
the target vector at the process level. Ie:

    find_target_ops_at_stratum (process_stratum).to_attach (args, from_tty);

This means adding a new function in target.h/target.c.

To be complete, I think the current public interface already allows us
to find the target vector at any stratum. Just by using current_target
and find_target_beneath(). I just thought that the new proposed function
might be of general interest?

Thoughts?

-- 
Joel



More information about the Gdb-patches mailing list