This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: GDB internals: thread infos


   From: Fabrice Gautier <Fabrice_Gautier@sdesigns.com>
   Date: Tue, 29 Aug 2000 15:36:35 -0700

   Hi,

   I'm trying to understand how gdb retrieve thread information, thread frame
   and thread pc.

   I started in the info_threads_command  function.

Good point to start :-).

   So there in order to retrieve thread $pc it call the
   functionswitch_to_thread which I presume do only a frame switch.

   So here is this function:

   static void
   switch_to_thread (pid)
	int pid;
   {
     if (pid == inferior_pid)
       return;

     inferior_pid = pid;
     flush_cached_frames ();
     registers_changed ();
     stop_pc = read_pc ();
     select_frame (get_current_frame (), 0);
   }

   I assume that inferior_pid should contain the thread id of the current
   selected thread.

Correct.

   Then I have a few questions:

   What does the registers_changed() should do and where is it
   defined?

Trouble using grep :-).

It tells GDB that any registers it has cached are invalid now.  You
can find the stuff in regcache.c.

   Which pc does the read_pc command should return? The one of the inferior_pid
   thread ?

The one for inferior_pid.

   Then in the get_current_frame function, it ends up calling:
	   current_frame = create_new_frame (read_fp (), read_pc ());

   What frame pointer should read_fp() return? I presume this is the one of the
   thread we are switching too. right?

Indeed.

   idem for read_pc(). But at what point is there an interaction with the
   target to get effectively those values.

If the registers aren't cached by GDB (and they aren't since we just
called registers_changed()) these functions will fetch the registers.
There is a chain of function calls, which ultimately ends with a call
for the target's fetch_inferior_registers().

Mark

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]