From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3561 invoked by alias); 16 Apr 2010 07:53:17 -0000 Received: (qmail 3548 invoked by uid 22791); 16 Apr 2010 07:53:16 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00,MIME_QP_LONG_LINE,MSGID_MULTIPLE_AT X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.153) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Apr 2010 07:53:09 +0000 Received: from baal.u-strasbg.fr (baal.u-strasbg.fr [IPv6:2001:660:2402::41]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o3G7qsC6070941 ; Fri, 16 Apr 2010 09:52:54 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms3.u-strasbg.fr [IPv6:2001:660:2402:d::12]) by baal.u-strasbg.fr (8.14.0/jtpda-5.5pre1) with ESMTP id o3G7qsb6059004 ; Fri, 16 Apr 2010 09:52:54 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from d620muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o3G7qr1j043538 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) ; Fri, 16 Apr 2010 09:52:53 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'Eli Zaretskii'" Cc: , References: <000901c9f5ef$4ee06f10$eca14d30$@u-strasbg.fr> <201004131214.00652.pedro@codesourcery.com> <004b01cadb0c$2f21b870$8d652950$%muller@ics-cnrs.unistra.fr> <201004131606.35452.pedro@codesourcery.com> <000c01cadcee$7ffcedd0$7ff6c970$%muller@ics-cnrs.unistra.fr> <83wrw7x66u.fsf@gnu.org> In-Reply-To: <83wrw7x66u.fsf@gnu.org> Subject: RE: [RFA-v9] Add Windows OS Thread Information Block Date: Fri, 16 Apr 2010 07:53:00 -0000 Message-ID: <000301cadd39$d632ac80$82980580$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0004_01CADD4A.99BB7C80" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-04/txt/msg00503.txt.bz2 This is a multi-part message in MIME format. ------=_NextPart_000_0004_01CADD4A.99BB7C80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-length: 963 Thanks to Pedro, Christopher and Eli for the patience and advices. I committed the patch. For the record I attached what I committed. (I added two lines to the ChangeLogs that were missing). Pierre Muller > -----Message d'origine----- > De=A0: gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de Eli Zaretskii > Envoy=E9=A0: Friday, April 16, 2010 8:28 AM > =C0=A0: Pierre Muller > Cc=A0: pedro@codesourcery.com; gdb-patches@sourceware.org > Objet=A0: Re: [RFA-v9] Add Windows OS Thread Information Block >=20 > > From: "Pierre Muller" > > Cc: "'Pedro Alves'" , patches@sourceware.org> > > Date: Fri, 16 Apr 2010 00:53:42 +0200 > > > > I still need the approval from Eli for the documentation part. >=20 > You've got it. Pedro did such an excellent job reviewing the > documentation part that I simply had no reasons to chime in. >=20 > Thanks. ------=_NextPart_000_0004_01CADD4A.99BB7C80 Content-Type: application/octet-stream; name="windows-tlb-final.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="windows-tlb-final.patch" Content-length: 46522 ? .swp=0A= ? ChangeLog.mmx=0A= ? added.lst=0A= ? mydiffs=0A= ? mydiffs2=0A= ? mydiffs3=0A= ? p-exp.y.new=0A= ? p-lang.c.new=0A= ? p-typeprint.c.new=0A= ? remove.lst=0A= ? features/i386/i386-go32v2-hidden.c=0A= ? gdbtk/commit.txt=0A= ? testsuite/gdb.pascal/gdb11492.pas=0A= Index: ChangeLog=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/ChangeLog,v=0A= retrieving revision 1.11627=0A= diff -u -p -r1.11627 ChangeLog=0A= --- ChangeLog 16 Apr 2010 04:34:30 -0000 1.11627=0A= +++ ChangeLog 16 Apr 2010 07:47:04 -0000=0A= @@ -1,3 +1,51 @@=0A= +2010-04-16 Pierre Muller =0A= +=0A= + Support for Windows OS Thread Information Block.=0A= + * NEWS: Document new feature.=0A= + * remote.c (PACKET_qGetTIBAddr): New enum element.=0A= + (remote_get_tib_address): New function.=0A= + (init_remote_ops): Set to_get_tib_address field=0A= + to remote_get_tib_address.=0A= + (_initialize_remote): Add add_packet_config_cmd=0A= + for PACKET_qGetTIBAddr.=0A= + * target.c (update_current_target): Set default value for=0A= + new to_get_tib_address field.=0A= + * target.h (target_ops): New field to_get_tib_address.=0A= + (target_get_tib_address): New macro.=0A= + * windows-nat.c (thread_info): Add thread_local_base field.=0A= + (windows_add_thread): Add tlb argument of type 'void *'.=0A= + (fake_create_process): Adapt windows_add_thread call.=0A= + (get_windows_debug_event): Idem.=0A= + (windows_get_tib_address): New function.=0A= + (init_windows_ops): Set to_get_tib_address field=0A= + to remote_get_tib_address.=0A= + (_initialize_windows_nat): Replace info_w32_cmdlist=0A= + initialization by a call to init_w32_command_list.=0A= + (info_w32_command, info_w32_cmdlist): Removed from here...=0A= + to windows-tdep.c file.=0A= + * windows-tdep.h (info_w32_cmdlist): Declare.=0A= + (init_w32_command_list): New external function=20=0A= + declaration.=0A= + * windows-tdep.c: Add several headers.=0A= + (info_w32_cmdlist): to here, made global.=0A= + (thread_information_32): New struct.=0A= + (thread_information_64): New struct.=0A= + (TIB_NAME): New char array.=0A= + (MAX_TIB32, MAX_TIB64, FULL_TIB_SIZE): New constants.=0A= + (maint_display_all_tib): New static variable.=0A= + (windows_get_tlb_type): New function.=0A= + (tlb_value_read, tlb_value_write): New functions.=0A= + (tlb_value_funcs): New static struct.=0A= + (tlb_make_value): New function.=0A= + (display_one_tib): New function.=0A= + (display_tib): New function.=0A= + (show_maint_show_all_tib):New function.=0A= + (info_w32_command): Moved from windows-nat.c.=0A= + (init_w32_command_list): New function.=0A= + (_initialize_windows_tdep): New function.=0A= + New "maint set/show show-all-tib" command=0A= + New "$_tlb" internal variable.=0A= +=0A= 2010-04-16 Joel Brobecker =0A= =20=0A= * tui/tui-regs.c (tui_display_register): Add comment about=0A= Index: NEWS=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/NEWS,v=0A= retrieving revision 1.371=0A= diff -u -p -r1.371 NEWS=0A= --- NEWS 15 Apr 2010 19:54:12 -0000 1.371=0A= +++ NEWS 16 Apr 2010 07:47:04 -0000=0A= @@ -3,6 +3,21 @@=0A= =20=0A= *** Changes since GDB 7.1=0A= =20=0A= +* Windows Thread Information Block access.=0A= +=0A= + On Windows targets, GDB now supports displaying the Windows Thread=0A= + Information Block (TIB) structure. This structure is visible either=0A= + by using the new command `info w32 thread-information-block' or, by=0A= + dereferencing the new convenience variable named `$_tlb', a=0A= + thread-specific pointer to the TIB. This feature is also supported=0A= + when remote debugging using GDBserver.=0A= +=0A= +* New remote packets=0A= +=0A= +qGetTIBAddr=0A= +=0A= + Return the address of the Windows Thread Information Block of a given th= read.=0A= +=0A= * The source command now accepts a -s option to force searching for the=0A= script in the source search path even if the script name specifies=0A= a directory.=0A= Index: remote.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/remote.c,v=0A= retrieving revision 1.401=0A= diff -u -p -r1.401 remote.c=0A= --- remote.c 13 Apr 2010 16:08:28 -0000 1.401=0A= +++ remote.c 16 Apr 2010 07:47:06 -0000=0A= @@ -1136,6 +1136,7 @@ enum {=0A= PACKET_qXfer_spu_write,=0A= PACKET_qXfer_osdata,=0A= PACKET_qXfer_threads,=0A= + PACKET_qGetTIBAddr,=0A= PACKET_qGetTLSAddr,=0A= PACKET_qSupported,=0A= PACKET_QPassSignals,=0A= @@ -8437,6 +8438,48 @@ remote_get_thread_local_address (struct=20=0A= return 0;=0A= }=0A= =20=0A= +/* Provide thread local base, i.e. Thread Information Block address.=0A= + Returns 1 if ptid is found and thread_local_base is non zero. */=0A= +=0A= +int=0A= +remote_get_tib_address (ptid_t ptid, CORE_ADDR *addr)=0A= +{=0A= + if (remote_protocol_packets[PACKET_qGetTIBAddr].support !=3D PACKET_DISA= BLE)=0A= + {=0A= + struct remote_state *rs =3D get_remote_state ();=0A= + char *p =3D rs->buf;=0A= + char *endp =3D rs->buf + get_remote_packet_size ();=0A= + enum packet_result result;=0A= +=0A= + strcpy (p, "qGetTIBAddr:");=0A= + p +=3D strlen (p);=0A= + p =3D write_ptid (p, endp, ptid);=0A= + *p++ =3D '\0';=0A= +=0A= + putpkt (rs->buf);=0A= + getpkt (&rs->buf, &rs->buf_size, 0);=0A= + result =3D packet_ok (rs->buf,=0A= + &remote_protocol_packets[PACKET_qGetTIBAddr]);=0A= + if (result =3D=3D PACKET_OK)=0A= + {=0A= + ULONGEST result;=0A= +=0A= + unpack_varlen_hex (rs->buf, &result);=0A= + if (addr)=0A= + *addr =3D (CORE_ADDR) result;=0A= + return 1;=0A= + }=0A= + else if (result =3D=3D PACKET_UNKNOWN)=0A= + error (_("Remote target doesn't support qGetTIBAddr packet"));=0A= + else=0A= + error (_("Remote target failed to process qGetTIBAddr request"));=0A= + }=0A= + else=0A= + error (_("qGetTIBAddr not supported or disabled on this target"));=0A= + /* Not reached. */=0A= + return 0;=0A= +}=0A= +=0A= /* Support for inferring a target description based on the current=0A= architecture and the size of a 'g' packet. While the 'g' packet=0A= can have any size (since optional registers can be left off the=0A= @@ -9904,6 +9947,7 @@ Specify the serial device it is connecte=0A= remote_ops.to_set_circular_trace_buffer =3D remote_set_circular_trace_bu= ffer;=0A= remote_ops.to_core_of_thread =3D remote_core_of_thread;=0A= remote_ops.to_verify_memory =3D remote_verify_memory;=0A= + remote_ops.to_get_tib_address =3D remote_get_tib_address;=0A= }=0A= =20=0A= /* Set up the extended remote vector by making a copy of the standard=0A= @@ -10323,6 +10367,10 @@ Show the maximum size of the address (in=0A= "qGetTLSAddr", "get-thread-local-storage-address",=0A= 0);=0A= =20=0A= + add_packet_config_cmd (&remote_protocol_packets[PACKET_qGetTIBAddr],=0A= + "qGetTIBAddr", "get-thread-information-block-address",=0A= + 0);=0A= +=0A= add_packet_config_cmd (&remote_protocol_packets[PACKET_bc],=0A= "bc", "reverse-continue", 0);=0A= =20=0A= Index: target.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/target.c,v=0A= retrieving revision 1.245=0A= diff -u -p -r1.245 target.c=0A= --- target.c 24 Mar 2010 01:12:13 -0000 1.245=0A= +++ target.c 16 Apr 2010 07:47:07 -0000=0A= @@ -660,6 +660,7 @@ update_current_target (void)=0A= INHERIT (to_get_raw_trace_data, t);=0A= INHERIT (to_set_disconnected_tracing, t);=0A= INHERIT (to_set_circular_trace_buffer, t);=0A= + INHERIT (to_get_tib_address, t);=0A= INHERIT (to_magic, t);=0A= /* Do not inherit to_memory_map. */=0A= /* Do not inherit to_flash_erase. */=0A= @@ -853,6 +854,9 @@ update_current_target (void)=0A= de_fault (to_set_circular_trace_buffer,=0A= (void (*) (int))=0A= target_ignore);=0A= + de_fault (to_get_tib_address,=0A= + (int (*) (ptid_t, CORE_ADDR *))=0A= + tcomplain);=0A= #undef de_fault=0A= =20=0A= /* Finally, position the target-stack beneath the squashed=0A= Index: target.h=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/target.h,v=0A= retrieving revision 1.177=0A= diff -u -p -r1.177 target.h=0A= --- target.h 24 Mar 2010 01:12:13 -0000 1.177=0A= +++ target.h 16 Apr 2010 07:47:08 -0000=0A= @@ -682,6 +682,10 @@ struct target_ops=0A= int (*to_verify_memory) (struct target_ops *, const gdb_byte *data,=0A= CORE_ADDR memaddr, ULONGEST size);=0A= =20=0A= + /* Return the address of the start of the Thread Information Block=0A= + a Windows OS specific feature. */=0A= + int (*to_get_tib_address) (ptid_t ptid, CORE_ADDR *addr);=0A= +=0A= int to_magic;=0A= /* Need sub-structure for target machine related rather than comm rela= ted?=0A= */=0A= @@ -1371,6 +1375,9 @@ extern int target_search_memory (CORE_AD=0A= #define target_set_circular_trace_buffer(val) \=0A= (*current_target.to_set_circular_trace_buffer) (val)=0A= =20=0A= +#define target_get_tib_address(ptid, addr) \=0A= + (*current_target.to_get_tib_address) ((ptid), (addr))=0A= +=0A= /* Command logging facility. */=0A= =20=0A= #define target_log_command(p) \=0A= Index: windows-nat.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/windows-nat.c,v=0A= retrieving revision 1.207=0A= diff -u -p -r1.207 windows-nat.c=0A= --- windows-nat.c 10 Mar 2010 15:57:07 -0000 1.207=0A= +++ windows-nat.c 16 Apr 2010 07:47:08 -0000=0A= @@ -191,6 +191,7 @@ typedef struct thread_info_struct=0A= struct thread_info_struct *next;=0A= DWORD id;=0A= HANDLE h;=0A= + CORE_ADDR thread_local_base;=0A= char *name;=0A= int suspended;=0A= int reload_context;=0A= @@ -320,7 +321,7 @@ thread_rec (DWORD id, int get_context)=0A= =20=0A= /* Add a thread to the thread list. */=0A= static thread_info *=0A= -windows_add_thread (ptid_t ptid, HANDLE h)=0A= +windows_add_thread (ptid_t ptid, HANDLE h, void *tlb)=0A= {=0A= thread_info *th;=0A= DWORD id;=0A= @@ -335,6 +336,7 @@ windows_add_thread (ptid_t ptid, HANDLE=20=0A= th =3D XZALLOC (thread_info);=0A= th->id =3D id;=0A= th->h =3D h;=0A= + th->thread_local_base =3D (CORE_ADDR) (uintptr_t) tlb;=0A= th->next =3D thread_head.next;=0A= thread_head.next =3D th;=0A= add_thread (ptid);=0A= @@ -1074,15 +1076,6 @@ display_selectors (char * args, int from=0A= }=0A= }=0A= =20=0A= -static struct cmd_list_element *info_w32_cmdlist =3D NULL;=0A= -=0A= -static void=0A= -info_w32_command (char *args, int from_tty)=0A= -{=0A= - help_list (info_w32_cmdlist, "info w32 ", class_info, gdb_stdout);=0A= -}=0A= -=0A= -=0A= #define DEBUG_EXCEPTION_SIMPLE(x) if (debug_exceptions) \=0A= printf_unfiltered ("gdb: Target exception %s at %s\n", x, \=0A= host_address_to_string (\=0A= @@ -1271,9 +1264,11 @@ fake_create_process (void)=0A= /* We can not debug anything in that case. */=0A= }=0A= main_thread_id =3D current_event.dwThreadId;=0A= - current_thread =3D windows_add_thread (ptid_build (current_event.dwProce= ssId, 0,=0A= - current_event.dwThreadId),=0A= - current_event.u.CreateThread.hThread);=0A= + current_thread =3D windows_add_thread (=0A= + ptid_build (current_event.dwProcessId, 0,=0A= + current_event.dwThreadId),=0A= + current_event.u.CreateThread.hThread,=0A= + current_event.u.CreateThread.lpThreadLocalBase);=0A= return main_thread_id;=0A= }=0A= =20=0A= @@ -1447,7 +1442,9 @@ get_windows_debug_event (struct target_o=0A= retval =3D current_event.dwThreadId;=0A= th =3D windows_add_thread (ptid_build (current_event.dwProcessId, 0,= =0A= current_event.dwThreadId),=0A= - current_event.u.CreateThread.hThread);=0A= + current_event.u.CreateThread.hThread,=0A= + current_event.u.CreateThread.lpThreadLocalBase);=0A= +=0A= break;=0A= =20=0A= case EXIT_THREAD_DEBUG_EVENT:=0A= @@ -1481,7 +1478,8 @@ get_windows_debug_event (struct target_o=0A= /* Add the main thread */=0A= th =3D windows_add_thread (ptid_build (current_event.dwProcessId, 0,= =0A= current_event.dwThreadId),=0A= - current_event.u.CreateProcessInfo.hThread);=0A= + current_event.u.CreateProcessInfo.hThread,=0A= + current_event.u.CreateProcessInfo.lpThreadLocalBase);=0A= retval =3D current_event.dwThreadId;=0A= break;=0A= =20=0A= @@ -2266,6 +2264,24 @@ windows_xfer_partial (struct target_ops=20=0A= }=0A= }=0A= =20=0A= +/* Provide thread local base, i.e. Thread Information Block address.=0A= + Returns 1 if ptid is found and sets *ADDR to thread_local_base. */=0A= +=0A= +static int=0A= +windows_get_tib_address (ptid_t ptid, CORE_ADDR *addr)=0A= +{=0A= + thread_info *th;=0A= +=0A= + th =3D thread_rec (ptid_get_tid (ptid), 0);=0A= + if (th =3D=3D NULL)=0A= + return 0;=0A= +=0A= + if (addr !=3D NULL)=0A= + *addr =3D th->thread_local_base;=0A= +=0A= + return 1;=0A= +}=0A= +=0A= static ptid_t=0A= windows_get_ada_task_ptid (long lwp, long thread)=0A= {=0A= @@ -2314,6 +2330,7 @@ init_windows_ops (void)=0A= windows_ops.to_has_execution =3D default_child_has_execution;=0A= windows_ops.to_pid_to_exec_file =3D windows_pid_to_exec_file;=0A= windows_ops.to_get_ada_task_ptid =3D windows_get_ada_task_ptid;=0A= + windows_ops.to_get_tib_address =3D windows_get_tib_address;=0A= =20=0A= i386_use_watchpoints (&windows_ops);=0A= =20=0A= @@ -2415,9 +2432,7 @@ Show whether to display kernel exception=0A= NULL, /* FIXME: i18n: */=0A= &setlist, &showlist);=0A= =20=0A= - add_prefix_cmd ("w32", class_info, info_w32_command,=0A= - _("Print information specific to Win32 debugging."),=0A= - &info_w32_cmdlist, "info w32 ", 0, &infolist);=0A= + init_w32_command_list ();=0A= =20=0A= add_cmd ("selector", class_info, display_selectors,=0A= _("Display selectors infos."),=0A= Index: windows-tdep.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/windows-tdep.c,v=0A= retrieving revision 1.5=0A= diff -u -p -r1.5 windows-tdep.c=0A= --- windows-tdep.c 1 Jan 2010 07:31:46 -0000 1.5=0A= +++ windows-tdep.c 16 Apr 2010 07:47:08 -0000=0A= @@ -19,6 +19,352 @@=0A= #include "windows-tdep.h"=0A= #include "gdb_obstack.h"=0A= #include "xml-support.h"=0A= +#include "gdbarch.h"=0A= +#include "target.h"=0A= +#include "value.h"=0A= +#include "inferior.h"=0A= +#include "command.h"=0A= +#include "gdbcmd.h"=0A= +#include "gdbthread.h"=0A= +=0A= +struct cmd_list_element *info_w32_cmdlist;=0A= +=0A= +typedef struct thread_information_block_32=0A= + {=0A= + uint32_t current_seh; /* %fs:0x0000 */=0A= + uint32_t current_top_of_stack; /* %fs:0x0004 */=0A= + uint32_t current_bottom_of_stack; /* %fs:0x0008 */=0A= + uint32_t sub_system_tib; /* %fs:0x000c */=0A= + uint32_t fiber_data; /* %fs:0x0010 */=0A= + uint32_t arbitrary_data_slot; /* %fs:0x0014 */=0A= + uint32_t linear_address_tib; /* %fs:0x0018 */=0A= + uint32_t environment_pointer; /* %fs:0x001c */=0A= + uint32_t process_id; /* %fs:0x0020 */=0A= + uint32_t current_thread_id; /* %fs:0x0024 */=0A= + uint32_t active_rpc_handle; /* %fs:0x0028 */=0A= + uint32_t thread_local_storage; /* %fs:0x002c */=0A= + uint32_t process_environment_block; /* %fs:0x0030 */=0A= + uint32_t last_error_number; /* %fs:0x0034 */=0A= + }=0A= +thread_information_32;=0A= +=0A= +typedef struct thread_information_block_64=0A= + {=0A= + uint64_t current_seh; /* %gs:0x0000 */=0A= + uint64_t current_top_of_stack; /* %gs:0x0008 */=0A= + uint64_t current_bottom_of_stack; /* %gs:0x0010 */=0A= + uint64_t sub_system_tib; /* %gs:0x0018 */=0A= + uint64_t fiber_data; /* %gs:0x0020 */=0A= + uint64_t arbitrary_data_slot; /* %gs:0x0028 */=0A= + uint64_t linear_address_tib; /* %gs:0x0030 */=0A= + uint64_t environment_pointer; /* %gs:0x0038 */=0A= + uint64_t process_id; /* %gs:0x0040 */=0A= + uint64_t current_thread_id; /* %gs:0x0048 */=0A= + uint64_t active_rpc_handle; /* %gs:0x0050 */=0A= + uint64_t thread_local_storage; /* %gs:0x0058 */=0A= + uint64_t process_environment_block; /* %gs:0x0060 */=0A= + uint64_t last_error_number; /* %gs:0x0068 */=0A= + }=0A= +thread_information_64;=0A= +=0A= +=0A= +static const char* TIB_NAME[] =3D=0A= + {=0A= + " current_seh ", /* %fs:0x0000 */=0A= + " current_top_of_stack ", /* %fs:0x0004 */=0A= + " current_bottom_of_stack ", /* %fs:0x0008 */=0A= + " sub_system_tib ", /* %fs:0x000c */=0A= + " fiber_data ", /* %fs:0x0010 */=0A= + " arbitrary_data_slot ", /* %fs:0x0014 */=0A= + " linear_address_tib ", /* %fs:0x0018 */=0A= + " environment_pointer ", /* %fs:0x001c */=0A= + " process_id ", /* %fs:0x0020 */=0A= + " current_thread_id ", /* %fs:0x0024 */=0A= + " active_rpc_handle ", /* %fs:0x0028 */=0A= + " thread_local_storage ", /* %fs:0x002c */=0A= + " process_environment_block ", /* %fs:0x0030 */=0A= + " last_error_number " /* %fs:0x0034 */=0A= + };=0A= +=0A= +static const int MAX_TIB32 =3D sizeof (thread_information_32) / sizeof (ui= nt32_t);=0A= +static const int MAX_TIB64 =3D sizeof (thread_information_64) / sizeof (ui= nt64_t);=0A= +static const int FULL_TIB_SIZE =3D 0x1000;=0A= +=0A= +static int maint_display_all_tib =3D 0;=0A= +=0A= +/* Define Thread Local Base pointer type. */=0A= +=0A= +static struct type *=0A= +windows_get_tlb_type (struct gdbarch *gdbarch)=0A= +{=0A= + struct type *dword_ptr_type, *dword32_type, *void_ptr_type;=0A= + struct type *peb_ldr_type, *peb_ldr_ptr_type;=0A= + struct type *peb_type, *peb_ptr_type, *list_type, *list_ptr_type;=0A= + struct type *module_list_ptr_type;=0A= + struct type *tib_type, *seh_type, *tib_ptr_type, *seh_ptr_type;=0A= +=0A= + dword_ptr_type =3D arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch)= ,=0A= + 1, "DWORD_PTR");=0A= + dword32_type =3D arch_integer_type (gdbarch, 32,=0A= + 1, "DWORD32");=0A= + void_ptr_type =3D lookup_pointer_type (builtin_type (gdbarch)->builtin_v= oid);=0A= +=0A= + /* list entry */=0A= +=0A= + list_type =3D arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);=0A= + TYPE_NAME (list_type) =3D xstrdup ("list");=0A= +=0A= + list_ptr_type =3D arch_type (gdbarch, TYPE_CODE_PTR,=0A= + TYPE_LENGTH (void_ptr_type), NULL);=0A= +=0A= + module_list_ptr_type =3D void_ptr_type;=0A= +=0A= + append_composite_type_field (list_type, "forward_list", module_list_ptr_= type);=0A= + append_composite_type_field (list_type, "backward_list",=0A= + module_list_ptr_type);=0A= +=0A= + /* Structured Exception Handler */=0A= +=0A= + seh_type =3D arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);=0A= + TYPE_NAME (seh_type) =3D xstrdup ("seh");=0A= +=0A= + seh_ptr_type =3D arch_type (gdbarch, TYPE_CODE_PTR,=0A= + TYPE_LENGTH (void_ptr_type), NULL);=0A= + TYPE_TARGET_TYPE (seh_ptr_type) =3D seh_type;=0A= +=0A= + append_composite_type_field (seh_type, "next_seh", seh_ptr_type);=0A= + append_composite_type_field (seh_type, "handler", void_ptr_type);=0A= +=0A= + /* struct _PEB_LDR_DATA */=0A= + peb_ldr_type =3D arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);= =0A= + TYPE_NAME (peb_ldr_type) =3D xstrdup ("peb_ldr_data");=0A= +=0A= + append_composite_type_field (peb_ldr_type, "length", dword32_type);=0A= + append_composite_type_field (peb_ldr_type, "initialized", dword32_type);= =0A= + append_composite_type_field (peb_ldr_type, "ss_handle", void_ptr_type);= =0A= + append_composite_type_field (peb_ldr_type, "in_load_order", list_type);= =0A= + append_composite_type_field (peb_ldr_type, "in_memory_order", list_type)= ;=0A= + append_composite_type_field (peb_ldr_type, "in_init_order", list_type);= =0A= + append_composite_type_field (peb_ldr_type, "entry_in_progress",=0A= + void_ptr_type);=0A= + peb_ldr_ptr_type =3D arch_type (gdbarch, TYPE_CODE_PTR,=0A= + TYPE_LENGTH (void_ptr_type), NULL);=0A= + TYPE_TARGET_TYPE (peb_ldr_ptr_type) =3D peb_ldr_type;=0A= +=0A= +=0A= + /* struct process environment block */=0A= + peb_type =3D arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);=0A= + TYPE_NAME (peb_type) =3D xstrdup ("peb");=0A= +=0A= + /* First bytes contain several flags. */=0A= + append_composite_type_field (peb_type, "flags", dword_ptr_type);=0A= + append_composite_type_field (peb_type, "mutant", void_ptr_type);=0A= + append_composite_type_field (peb_type, "image_base_address", void_ptr_ty= pe);=0A= + append_composite_type_field (peb_type, "ldr", peb_ldr_ptr_type);=0A= + append_composite_type_field (peb_type, "process_parameters", void_ptr_ty= pe);=0A= + append_composite_type_field (peb_type, "sub_system_data", void_ptr_type)= ;=0A= + append_composite_type_field (peb_type, "process_heap", void_ptr_type);= =0A= + append_composite_type_field (peb_type, "fast_peb_lock", void_ptr_type);= =0A= + peb_ptr_type =3D arch_type (gdbarch, TYPE_CODE_PTR,=0A= + TYPE_LENGTH (void_ptr_type), NULL);=0A= + TYPE_TARGET_TYPE (peb_ptr_type) =3D peb_type;=0A= +=0A= +=0A= + /* struct thread information block */=0A= + tib_type =3D arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);=0A= + TYPE_NAME (tib_type) =3D xstrdup ("tib");=0A= +=0A= + /* uint32_t current_seh; %fs:0x0000 */=0A= + append_composite_type_field (tib_type, "current_seh", seh_ptr_type);=0A= + /* uint32_t current_top_of_stack; %fs:0x0004 */=0A= + append_composite_type_field (tib_type, "current_top_of_stack", void_ptr_= type);=0A= + /* uint32_t current_bottom_of_stack; %fs:0x0008 */=0A= + append_composite_type_field (tib_type, "current_bottom_of_stack",=0A= + void_ptr_type);=0A= + /* uint32_t sub_system_tib; %fs:0x000c */=0A= + append_composite_type_field (tib_type, "sub_system_tib", void_ptr_type);= =0A= +=0A= + /* uint32_t fiber_data; %fs:0x0010 */=0A= + append_composite_type_field (tib_type, "fiber_data", void_ptr_type);=0A= + /* uint32_t arbitrary_data_slot; %fs:0x0014 */=0A= + append_composite_type_field (tib_type, "arbitrary_data_slot", void_ptr_t= ype);=0A= + /* uint32_t linear_address_tib; %fs:0x0018 */=0A= + append_composite_type_field (tib_type, "linear_address_tib", void_ptr_ty= pe);=0A= + /* uint32_t environment_pointer; %fs:0x001c */=0A= + append_composite_type_field (tib_type, "environment_pointer", void_ptr_t= ype);=0A= + /* uint32_t process_id; %fs:0x0020 */=0A= + append_composite_type_field (tib_type, "process_id", dword_ptr_type);=0A= + /* uint32_t current_thread_id; %fs:0x0024 */=0A= + append_composite_type_field (tib_type, "thread_id", dword_ptr_type);=0A= + /* uint32_t active_rpc_handle; %fs:0x0028 */=0A= + append_composite_type_field (tib_type, "active_rpc_handle", dword_ptr_ty= pe);=0A= + /* uint32_t thread_local_storage; %fs:0x002c */=0A= + append_composite_type_field (tib_type, "thread_local_storage", void_ptr_= type);=0A= + /* uint32_t process_environment_block; %fs:0x0030 */=0A= + append_composite_type_field (tib_type, "process_environment_block",=0A= + peb_ptr_type);=0A= + /* uint32_t last_error_number; %fs:0x0034 */=0A= + append_composite_type_field (tib_type, "last_error_number", dword_ptr_ty= pe);=0A= +=0A= + tib_ptr_type =3D arch_type (gdbarch, TYPE_CODE_PTR,=0A= + TYPE_LENGTH (void_ptr_type), NULL);=0A= + TYPE_TARGET_TYPE (tib_ptr_type) =3D tib_type;=0A= +=0A= + return tib_ptr_type;=0A= +}=0A= +=0A= +/* The $_tlb convenience variable is a bit special. We don't know=0A= + for sure the type of the value until we actually have a chance to=0A= + fetch the data. The type can change depending on gdbarch, so it is=0A= + also dependent on which thread you have selected. */=0A= +=0A= +/* This function implements the lval_computed support for reading a=0A= + $_tlb value. */=0A= +=0A= +static void=0A= +tlb_value_read (struct value *val)=0A= +{=0A= + CORE_ADDR tlb;=0A= + struct type *type =3D check_typedef (value_type (val));=0A= +=0A= + if (!target_get_tib_address (inferior_ptid, &tlb))=0A= + error (_("Unable to read tlb"));=0A= + store_typed_address (value_contents_raw (val), type, tlb);=0A= +}=0A= +=0A= +/* This function implements the lval_computed support for writing a=0A= + $_tlb value. */=0A= +=0A= +static void=0A= +tlb_value_write (struct value *v, struct value *fromval)=0A= +{=0A= + error (_("Impossible to change the Thread Local Base"));=0A= +}=0A= +=0A= +static struct lval_funcs tlb_value_funcs =3D=0A= + {=0A= + tlb_value_read,=0A= + tlb_value_write=0A= + };=0A= +=0A= +=0A= +/* Return a new value with the correct type for the tlb object of=0A= + the current thread using architecture GDBARCH. Return a void value=0A= + if there's no object available. */=0A= +=0A= +static struct value *=0A= +tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var)=0A= +{=0A= + if (target_has_stack && !ptid_equal (inferior_ptid, null_ptid))=0A= + {=0A= + struct type *type =3D windows_get_tlb_type (gdbarch);=0A= + return allocate_computed_value (type, &tlb_value_funcs, NULL);=0A= + }=0A= +=0A= + return allocate_value (builtin_type (gdbarch)->builtin_void);=0A= +}=0A= +=0A= +=0A= +/* Display thread information block of a given thread. */=0A= +=0A= +static int=0A= +display_one_tib (ptid_t ptid)=0A= +{=0A= + gdb_byte *tib =3D NULL;=0A= + gdb_byte *index;=0A= + CORE_ADDR thread_local_base;=0A= + ULONGEST i, val, max, max_name, size, tib_size;=0A= + ULONGEST sizeof_ptr =3D gdbarch_ptr_bit (target_gdbarch);=0A= + enum bfd_endian byte_order =3D gdbarch_byte_order (target_gdbarch);=0A= +=0A= + if (sizeof_ptr =3D=3D 64)=0A= + {=0A= + size =3D sizeof (uint64_t);=0A= + tib_size =3D sizeof (thread_information_64);=0A= + max =3D MAX_TIB64;=0A= + }=0A= + else=0A= + {=0A= + size =3D sizeof (uint32_t);=0A= + tib_size =3D sizeof (thread_information_32);=0A= + max =3D MAX_TIB32;=0A= + }=0A= +=0A= + max_name =3D max;=0A= +=0A= + if (maint_display_all_tib)=0A= + {=0A= + tib_size =3D FULL_TIB_SIZE;=0A= + max =3D tib_size / size;=0A= + }=0A= +=20=20=0A= + tib =3D alloca (tib_size);=0A= +=0A= + if (target_get_tib_address (ptid, &thread_local_base) =3D=3D 0)=0A= + {=0A= + printf_filtered (_("Unable to get thread local base for %s\n"),=0A= + target_pid_to_str (ptid));=0A= + return -1;=0A= + }=0A= +=0A= + if (target_read (¤t_target, TARGET_OBJECT_MEMORY,=0A= + NULL, tib, thread_local_base, tib_size) !=3D tib_size)=0A= + {=0A= + printf_filtered (_("Unable to read thread information block for %s a= t \=0A= +address %s\n"),=0A= + target_pid_to_str (ptid),=20=0A= + paddress (target_gdbarch, thread_local_base));=0A= + return -1;=0A= + }=0A= +=0A= + printf_filtered (_("Thread Information Block %s at %s\n"),=0A= + target_pid_to_str (ptid),=0A= + paddress (target_gdbarch, thread_local_base));=0A= +=0A= + index =3D (gdb_byte *) tib;=0A= +=0A= + /* All fields have the size of a pointer, this allows to iterate=20=0A= + using the same for loop for both layouts. */=0A= + for (i =3D 0; i < max; i++)=0A= + {=0A= + val =3D extract_unsigned_integer (index, size, byte_order);=0A= + if (i < max_name)=0A= + printf_filtered (_("%s is 0x%s\n"), TIB_NAME[i], phex (val, size));=0A= + else if (val !=3D 0)=0A= + printf_filtered (_("TIB[0x%s] is 0x%s\n"), phex (i * size, 2),=0A= + phex (val, size));=0A= + index +=3D size;=0A= + }=20=0A= + return 1;=20=20=0A= +}=0A= +=0A= +/* Display thread information block of a thread specified by ARGS.=0A= + If ARGS is empty, display thread information block of current_thread=0A= + if current_thread is non NULL.=0A= + Otherwise ARGS is parsed and converted to a integer that should=0A= + be the windows ThreadID (not the internal GDB thread ID). */=0A= +=0A= +static void=0A= +display_tib (char * args, int from_tty)=0A= +{=0A= + if (args)=0A= + {=0A= + struct thread_info *tp;=0A= + int gdb_id =3D value_as_long (parse_and_eval (args));=0A= +=0A= + tp =3D find_thread_id (gdb_id);=0A= +=0A= + if (!tp)=0A= + error (_("Thread ID %d not known."), gdb_id);=0A= +=0A= + if (!target_thread_alive (tp->ptid))=0A= + error (_("Thread ID %d has terminated."), gdb_id);=0A= +=0A= + display_one_tib (tp->ptid);=0A= + }=0A= + else if (!ptid_equal (inferior_ptid, null_ptid))=0A= + display_one_tib (inferior_ptid);=0A= +}=0A= =20=0A= void=0A= windows_xfer_shared_library (const char* so_name, CORE_ADDR load_addr,=0A= @@ -36,3 +382,59 @@ windows_xfer_shared_library (const char*=0A= obstack_grow_str (obstack, paddress (gdbarch, load_addr + 0x1000));=0A= obstack_grow_str (obstack, "\"/>");=0A= }=0A= +=0A= +static void=0A= +show_maint_show_all_tib (struct ui_file *file, int from_tty,=0A= + struct cmd_list_element *c, const char *value)=0A= +{=0A= + fprintf_filtered (file, _("Show all non-zero elements of Thread Informat= ion \=0A= +Block is %s.\n"), value);=0A= +}=0A= +=0A= +static void=0A= +info_w32_command (char *args, int from_tty)=0A= +{=0A= + help_list (info_w32_cmdlist, "info w32 ", class_info, gdb_stdout);=0A= +}=0A= +=0A= +static int w32_prefix_command_valid =3D 0;=0A= +void=0A= +init_w32_command_list (void)=0A= +{=0A= + if (!w32_prefix_command_valid)=0A= + {=0A= + add_prefix_cmd ("w32", class_info, info_w32_command,=0A= + _("Print information specific to Win32 debugging."),=0A= + &info_w32_cmdlist, "info w32 ", 0, &infolist);=0A= + w32_prefix_command_valid =3D 1;=0A= + }=0A= +}=0A= +=0A= +void=0A= +_initialize_windows_tdep (void)=0A= +{=0A= + init_w32_command_list ();=0A= + add_cmd ("thread-information-block", class_info, display_tib,=0A= + _("Display thread information block."),=0A= + &info_w32_cmdlist);=0A= + add_alias_cmd ("tib", "thread-information-block", class_info, 1,=0A= + &info_w32_cmdlist);=0A= +=0A= + add_setshow_boolean_cmd ("show-all-tib", class_maintenance,=0A= + &maint_display_all_tib, _("\=0A= +Set whether to display all non-zero fields of thread information block."),= _("\=0A= +Show whether to display all non-zero fields of thread information block.")= , _("\=0A= +Use \"on\" to enable, \"off\" to disable.\n\=0A= +If enabled, all non-zero fields of thread information block are displayed,= \n\=0A= +even if their meaning is unknown."),=0A= + NULL,=0A= + show_maint_show_all_tib,=0A= + &maintenance_set_cmdlist,=0A= + &maintenance_show_cmdlist);=0A= +=0A= + /* Explicitly create without lookup, since that tries to create a=0A= + value with a void typed value, and when we get here, gdbarch=0A= + isn't initialized yet. At this point, we're quite sure there=0A= + isn't another convenience variable of the same name. */=0A= + create_internalvar_type_lazy ("_tlb", tlb_make_value);=0A= +}=0A= Index: windows-tdep.h=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/windows-tdep.h,v=0A= retrieving revision 1.4=0A= diff -u -p -r1.4 windows-tdep.h=0A= --- windows-tdep.h 1 Jan 2010 07:31:46 -0000 1.4=0A= +++ windows-tdep.h 16 Apr 2010 07:47:08 -0000=0A= @@ -21,6 +21,10 @@=0A= struct obstack;=0A= struct gdbarch;=0A= =20=0A= +extern struct cmd_list_element *info_w32_cmdlist;=0A= +=0A= +extern void init_w32_command_list (void);=0A= +=0A= extern void windows_xfer_shared_library (const char* so_name,=0A= CORE_ADDR load_addr,=0A= struct gdbarch *gdbarch,=0A= Index: doc/ChangeLog=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/doc/ChangeLog,v=0A= retrieving revision 1.1048=0A= diff -u -p -r1.1048 ChangeLog=0A= --- doc/ChangeLog 15 Apr 2010 19:54:13 -0000 1.1048=0A= +++ doc/ChangeLog 16 Apr 2010 07:47:10 -0000=0A= @@ -1,3 +1,10 @@=0A= +2010-04-16 Pierre Muller =0A= +=0A= + gdb.texinfo ($_tlb): Document new automatic convinience variable.=0A= + (info w32 thread-information-block): Document new command.=0A= + (qGetTIBAddress): Document new gdbserver query.=0A= + (maint set/show show-all-tib): Document new command.=0A= +=0A= 2010-04-15 Doug Evans =0A= =20=0A= * gdb.texinfo (Python API): Add progspaces section.=0A= Index: doc/gdb.texinfo=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v=0A= retrieving revision 1.706=0A= diff -u -p -r1.706 gdb.texinfo=0A= --- doc/gdb.texinfo 15 Apr 2010 19:54:13 -0000 1.706=0A= +++ doc/gdb.texinfo 16 Apr 2010 07:47:18 -0000=0A= @@ -8054,6 +8054,15 @@ The variable @code{$_siginfo} contains e=0A= (@pxref{extra signal information}). Note that @code{$_siginfo}=0A= could be empty, if the application has not yet received any signals.=0A= For example, it will be empty before you execute the @code{run} command.= =0A= +=0A= +@item $_tlb=0A= +@vindex $_tlb@r{, convenience variable}=0A= +The variable @code{$_tlb} is automatically set when debugging=0A= +applications running on MS-Windows in native mode or connected to=0A= +gdbserver that supports the @code{qGetTIBAddr} request.=20=0A= +@xref{General Query Packets}.=0A= +This variable contains the address of the thread information block.=0A= +=0A= @end table=0A= =20=0A= On HP-UX systems, if you refer to a function or variable name that=0A= @@ -15755,6 +15764,10 @@ are:=0A= @tab @code{qGetTLSAddr}=0A= @tab Displaying @code{__thread} variables=0A= =20=0A= +@item @code{get-thread-information-block-address}=0A= +@tab @code{qGetTIBAddr}=0A= +@tab Display MS-Windows Thread Information Block.=0A= +=0A= @item @code{search-memory}=0A= @tab @code{qSearch:memory}=0A= @tab @code{find}=0A= @@ -16534,6 +16547,11 @@ a long value to give the information abo=0A= Without argument, this command displays information=0A= about the six segment registers.=0A= =20=0A= +@item info w32 thread-information-block=0A= +This command displays thread specific information stored in the=0A= +Thread Information Block (readable on the X86 CPU family using @code{$fs}= =0A= +selector for 32-bit programs and @code{$gs} for 64-bit programs).=0A= +=0A= @kindex info dll=0A= @item info dll=0A= This is a Cygwin-specific alias of @code{info shared}.=0A= @@ -29449,6 +29467,14 @@ enabled, the debug registers values are=20=0A= removes a hardware breakpoint or watchpoint, and when the inferior=0A= triggers a hardware-assisted breakpoint or watchpoint.=0A= =20=0A= +@kindex maint set show-all-tib=0A= +@kindex maint show show-all-tib=0A= +@item maint set show-all-tib=0A= +@itemx maint show show-all-tib=0A= +Control whether to show all non zero areas within a 1k block starting=0A= +at thread local base, when using the @samp{info w32 thread-information-blo= ck}=0A= +command.=0A= +=0A= @kindex maint space=0A= @cindex memory used by commands=0A= @item maint space=0A= @@ -30662,6 +30688,27 @@ An error occurred. @var{nn} are hex dig=0A= An empty reply indicates that @samp{qGetTLSAddr} is not supported by the s= tub.=0A= @end table=0A= =20=0A= +@item qGetTIBAddr:@var{thread-id}=0A= +@cindex get thread information block address=0A= +@cindex @samp{qGetTIBAddr} packet=0A= +Fetch address of the Windows OS specific Thread Information Block.=0A= +=0A= +@var{thread-id} is the thread ID associated with the thread.=0A= +=0A= +Reply:=0A= +@table @samp=0A= +@item @var{XX}@dots{}=0A= +Hex encoded (big endian) bytes representing the linear address of the=0A= +thread information block.=0A= +=0A= +@item E @var{nn}=0A= +An error occured. This means that either the thread was not found, or the= =0A= +address could not be retrieved.=0A= +=0A= +@item=0A= +An empty reply indicates that @samp{qGetTIBAddr} is not supported by the s= tub.=0A= +@end table=0A= +=0A= @item qL @var{startflag} @var{threadcount} @var{nextthread}=0A= Obtain thread information from RTOS. Where: @var{startflag} (one hex=0A= digit) is one to indicate the first query and zero to indicate a=0A= Index: gdbserver/ChangeLog=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/gdbserver/ChangeLog,v=0A= retrieving revision 1.361=0A= diff -u -p -r1.361 ChangeLog=0A= --- gdbserver/ChangeLog 12 Apr 2010 17:46:05 -0000 1.361=0A= +++ gdbserver/ChangeLog 16 Apr 2010 07:47:19 -0000=0A= @@ -1,3 +1,16 @@=0A= +2010-04-16 Pierre Muller =0A= +=0A= + * server.c (handle_query): Handle 'qGetTIBAddr' query.=0A= + * target.h (target_ops): New get_tib_address field.=0A= + * win32-low.h (win32_thread_info): Add thread_local_base field.=0A= + * win32-low.c (child_add_thread): Add tlb argument.=0A= + Set thread_local_base field to TLB.=0A= + (get_child_debug_event): Adapt to child_add_thread change.=0A= + (win32_get_tib_address): New function.=0A= + (win32_target_ops): Set get_tib_address field to=0A= + win32_get_tib_address.=0A= + * linux-low.c (linux_target_ops): Set get_tib_address field to NULL.=0A= +=0A= 2010-04-12 Pedro Alves =0A= =20=0A= * linux-low.c (linux_mourn): Also remove the process.=0A= Index: gdbserver/linux-low.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v=0A= retrieving revision 1.142=0A= diff -u -p -r1.142 linux-low.c=0A= --- gdbserver/linux-low.c 12 Apr 2010 17:39:42 -0000 1.142=0A= +++ gdbserver/linux-low.c 16 Apr 2010 07:47:20 -0000=0A= @@ -4334,7 +4334,8 @@ static struct target_ops linux_target_op=0A= linux_read_pc,=0A= linux_write_pc,=0A= linux_thread_stopped,=0A= - linux_pause_all=0A= + linux_pause_all,=0A= + NULL, /* get_tib_address (Windows OS specific). */=0A= };=0A= =20=0A= static void=0A= Index: gdbserver/server.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/gdbserver/server.c,v=0A= retrieving revision 1.115=0A= diff -u -p -r1.115 server.c=0A= --- gdbserver/server.c 12 Apr 2010 17:39:42 -0000 1.115=0A= +++ gdbserver/server.c 16 Apr 2010 07:47:20 -0000=0A= @@ -1463,6 +1463,29 @@ handle_query (char *own_buf, int packet_=0A= /* Otherwise, pretend we do not understand this packet. */=0A= }=0A= =20=0A= + /* Windows OS Thread Information Block address support. */=0A= + if (the_target->get_tib_address !=3D NULL=0A= + && strncmp ("qGetTIBAddr:", own_buf, 12) =3D=3D 0)=0A= + {=0A= + char *annex;=0A= + int n;=0A= + CORE_ADDR tlb;=0A= + ptid_t ptid =3D read_ptid (own_buf + 12, &annex);=0A= +=0A= + n =3D (*the_target->get_tib_address) (ptid, &tlb);=0A= + if (n =3D=3D 1)=0A= + {=0A= + sprintf (own_buf, "%llx", tlb);=0A= + return;=0A= + }=0A= + else if (n =3D=3D 0)=0A= + {=0A= + write_enn (own_buf);=0A= + return;=0A= + }=0A= + return;=0A= + }=0A= +=0A= /* Handle "monitor" commands. */=0A= if (strncmp ("qRcmd,", own_buf, 6) =3D=3D 0)=0A= {=0A= Index: gdbserver/target.h=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/gdbserver/target.h,v=0A= retrieving revision 1.46=0A= diff -u -p -r1.46 target.h=0A= --- gdbserver/target.h 11 Apr 2010 16:33:56 -0000 1.46=0A= +++ gdbserver/target.h 16 Apr 2010 07:47:21 -0000=0A= @@ -309,6 +309,9 @@ struct target_ops=0A= =20=0A= /* Pause all threads. */=0A= void (*pause_all) (void);=0A= +=0A= + /* Read Thread Information Block address. */=0A= + int (*get_tib_address) (ptid_t ptid, CORE_ADDR *address);=0A= };=0A= =20=0A= extern struct target_ops *the_target;=0A= Index: gdbserver/win32-low.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/gdbserver/win32-low.c,v=0A= retrieving revision 1.45=0A= diff -u -p -r1.45 win32-low.c=0A= --- gdbserver/win32-low.c 12 Apr 2010 17:39:42 -0000 1.45=0A= +++ gdbserver/win32-low.c 16 Apr 2010 07:47:21 -0000=0A= @@ -178,7 +178,7 @@ thread_rec (ptid_t ptid, int get_context=0A= =20=0A= /* Add a thread to the thread list. */=0A= static win32_thread_info *=0A= -child_add_thread (DWORD pid, DWORD tid, HANDLE h)=0A= +child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb)=0A= {=0A= win32_thread_info *th;=0A= ptid_t ptid =3D ptid_build (pid, tid, 0);=0A= @@ -189,6 +189,7 @@ child_add_thread (DWORD pid, DWORD tid,=20=0A= th =3D xcalloc (1, sizeof (*th));=0A= th->tid =3D tid;=0A= th->h =3D h;=0A= + th->thread_local_base =3D (CORE_ADDR) (uintptr_t) tlb;=0A= =20=0A= add_thread (ptid, th);=0A= set_inferior_regcache_data ((struct thread_info *)=0A= @@ -1455,7 +1456,8 @@ get_child_debug_event (struct target_wai=0A= /* Record the existence of this thread. */=0A= child_add_thread (current_event.dwProcessId,=0A= current_event.dwThreadId,=0A= - current_event.u.CreateThread.hThread);=0A= + current_event.u.CreateThread.hThread,=0A= + current_event.u.CreateThread.lpThreadLocalBase);=0A= break;=0A= =20=0A= case EXIT_THREAD_DEBUG_EVENT:=0A= @@ -1485,7 +1487,8 @@ get_child_debug_event (struct target_wai=0A= /* Add the main thread. */=0A= child_add_thread (current_event.dwProcessId,=0A= main_thread_id,=0A= - current_event.u.CreateProcessInfo.hThread);=0A= + current_event.u.CreateProcessInfo.hThread,=0A= + current_event.u.CreateProcessInfo.lpThreadLocalBase);=0A= =20=0A= ourstatus->value.related_pid =3D debug_event_ptid (¤t_event);= =0A= #ifdef _WIN32_WCE=0A= @@ -1753,6 +1756,20 @@ wince_hostio_last_error (char *buf)=0A= }=0A= #endif=0A= =20=0A= +/* Write Windows OS Thread Information Block address. */=0A= +=0A= +static int=0A= +win32_get_tib_address (ptid_t ptid, CORE_ADDR *addr)=0A= +{=0A= + win32_thread_info *th;=0A= + th =3D thread_rec (ptid, 0);=0A= + if (th =3D=3D NULL)=0A= + return 0;=0A= + if (addr !=3D NULL)=0A= + *addr =3D th->thread_local_base;=0A= + return 1;=0A= +}=0A= +=0A= static struct target_ops win32_target_ops =3D {=0A= win32_create_inferior,=0A= win32_attach,=0A= @@ -1767,21 +1784,36 @@ static struct target_ops win32_target_op=0A= win32_store_inferior_registers,=0A= win32_read_inferior_memory,=0A= win32_write_inferior_memory,=0A= - NULL,=0A= + NULL, /* lookup_symbols */=0A= win32_request_interrupt,=0A= - NULL,=0A= + NULL, /* read_auxv */=0A= win32_insert_point,=0A= win32_remove_point,=0A= win32_stopped_by_watchpoint,=0A= win32_stopped_data_address,=0A= - NULL,=0A= - NULL,=0A= - NULL,=0A= + NULL, /* read_offsets */=0A= + NULL, /* get_tls_address */=0A= + NULL, /* qxfer_spu */=0A= #ifdef _WIN32_WCE=0A= wince_hostio_last_error,=0A= #else=0A= hostio_last_error_from_errno,=0A= #endif=0A= + NULL, /* qxfer_osdata */=0A= + NULL, /* qxfer_siginfo */=0A= + NULL, /* supports_non_stop */=0A= + NULL, /* async */=0A= + NULL, /* start_non_stop */=0A= + NULL, /* supports_multi_process */=0A= + NULL, /* handle_monitor_command */=0A= + NULL, /* core_of_thread */=0A= + NULL, /* process_qsupported */=0A= + NULL, /* supports_tracepoints */=0A= + NULL, /* read_pc */=0A= + NULL, /* write_pc */=0A= + NULL, /* thread_stopped */=0A= + NULL, /* pause_all */=0A= + win32_get_tib_address,=0A= };=0A= =20=0A= /* Initialize the Win32 backend. */=0A= Index: gdbserver/win32-low.h=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/gdbserver/win32-low.h,v=0A= retrieving revision 1.12=0A= diff -u -p -r1.12 win32-low.h=0A= --- gdbserver/win32-low.h 20 Jan 2010 22:55:38 -0000 1.12=0A= +++ gdbserver/win32-low.h 16 Apr 2010 07:47:21 -0000=0A= @@ -28,6 +28,9 @@ typedef struct win32_thread_info=0A= /* The handle to the thread. */=0A= HANDLE h;=0A= =20=0A= + /* Thread Information Block address. */=0A= + CORE_ADDR thread_local_base;=0A= +=0A= /* Non zero if SuspendThread was called on this thread. */=0A= int suspended;=0A= =20=0A= ------=_NextPart_000_0004_01CADD4A.99BB7C80--