From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14752 invoked by alias); 5 Jun 2009 18:55:25 -0000 Received: (qmail 14741 invoked by uid 22791); 5 Jun 2009 18:55:23 -0000 X-SWARE-Spam-Status: No, hits=-3.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 05 Jun 2009 18:55:13 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MCeZI-0003MN-Sr for gdb@sources.redhat.com; Fri, 05 Jun 2009 18:55:08 +0000 Received: from enigma.qnx.com ([209.226.137.106]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 05 Jun 2009 18:55:08 +0000 Received: from aristovski by enigma.qnx.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 05 Jun 2009 18:55:08 +0000 To: gdb@sources.redhat.com From: Aleksandar Ristovski Subject: corelow and threads question Date: Fri, 05 Jun 2009 18:55:00 -0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080207020800050405070706" User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-06/txt/msg00051.txt.bz2 This is a multi-part message in MIME format. --------------080207020800050405070706 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1435 Hello, Since: http://sourceware.org/ml/gdb-patches/2009-06/msg00101.html diverged from original intention, I would like to ask a question regarding core_ops and possible solution to my problem. Right now, we are treating core_ops somewhat specially since we add threads before calling target_find_new_threads in core_open; but why don't we let target_find_new_threads add the threads instead of adding them in core_open? Wouldn't that actually be the right solution? (attached is diff for corelow.c that illustrates what I am talking about). With corelow.c patched as proposed, on Neutrino I could do this: For NTO, I "hijack" core_ops: static void init_nto_core_ops () { struct target_ops *core_ops; core_ops = find_core_target (); gdb_assert (core_ops && core_ops->to_shortname != NULL && !!"core_ops must be initialized first!"); original_core_ops = *core_ops; core_ops->to_extra_thread_info = nto_target_extra_thread_info; core_ops->to_open = nto_core_open; core_ops->to_xfer_partial = nto_core_xfer_partial; core_ops->to_pid_to_str = nto_pid_to_str; } I can provide to_find_new_threads there: static void nto_find_new_threads_in_core (void) { if (core_bfd) bfd_map_over_sections (core_bfd, nto_core_add_thread_private_data, NULL); } where I add_thread and also add thread private data. All works well. Thoughts? -- Aleksandar Ristovski QNX Software Systems --------------080207020800050405070706 Content-Type: text/x-patch; name="corelow.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="corelow.c.diff" Content-length: 1322 Index: gdb/corelow.c =================================================================== RCS file: /cvs/src/src/gdb/corelow.c,v retrieving revision 1.86 diff -u -p -r1.86 corelow.c --- gdb/corelow.c 5 Jun 2009 18:08:53 -0000 1.86 +++ gdb/corelow.c 5 Jun 2009 18:51:03 -0000 @@ -395,12 +395,6 @@ core_open (char *filename, int from_tty) previous session, and the frame cache being stale. */ registers_changed (); - /* Build up thread list from BFD sections, and possibly set the - current thread to the .reg/NN section matching the .reg - section. */ - bfd_map_over_sections (core_bfd, add_to_thread_list, - bfd_get_section_by_name (core_bfd, ".reg")); - post_create_inferior (&core_ops, from_tty); /* Now go through the target stack looking for threads since there @@ -748,6 +742,13 @@ core_pid_to_str (struct target_ops *ops, return buf; } +static void +core_find_new_threads (struct target_ops *ops) +{ + if (core_bfd) + bfd_map_over_sections (core_bfd, add_to_thread_list, NULL); +} + /* Fill in core_ops with its defined operations and properties. */ static void @@ -775,6 +776,7 @@ init_core_ops (void) core_ops.to_has_stack = 1; core_ops.to_has_registers = 1; core_ops.to_magic = OPS_MAGIC; + core_ops.to_find_new_threads = core_find_new_threads; } void --------------080207020800050405070706--