From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10836 invoked by alias); 20 May 2013 14:43:58 -0000 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 Received: (qmail 10826 invoked by uid 89); 20 May 2013 14:43:58 -0000 X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.1 Received: from hop-nat-141.emc.com (HELO mexforward.lss.emc.com) (168.159.213.141) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 20 May 2013 14:43:57 +0000 Received: from hop04-l1d11-si01.isus.emc.com (HOP04-L1D11-SI01.isus.emc.com [10.254.111.54]) by mexforward.lss.emc.com (Switch-3.4.3/Switch-3.4.3) with ESMTP id r4KEhtnj031687 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 20 May 2013 10:43:55 -0400 Received: from mailhub.lss.emc.com (mailhubhoprd01.lss.emc.com [10.254.221.251]) by hop04-l1d11-si01.isus.emc.com (RSA Interceptor) for ; Mon, 20 May 2013 10:43:32 -0400 Received: from usendtaylorx2l.lss.emc.com (usendtaylorx2l.lss.emc.com [10.243.10.188]) by mailhub.lss.emc.com (Switch-3.4.3/Switch-3.4.3) with ESMTP id r4KEhVx4005156 for ; Mon, 20 May 2013 10:43:31 -0400 Received: by usendtaylorx2l.lss.emc.com (Postfix, from userid 26043) id 11E175B0065; Mon, 20 May 2013 10:43:25 -0400 (EDT) Received: from usendtaylorx2l (localhost [127.0.0.1]) by usendtaylorx2l.lss.emc.com (Postfix) with ESMTP id 8F48F5AFC70 for ; Mon, 20 May 2013 10:43:25 -0400 (EDT) To: gdb@sourceware.org Subject: add-inferior / clone-inferior Date: Mon, 20 May 2013 14:43:00 -0000 Message-ID: <7249.1369061005@usendtaylorx2l> From: David Taylor X-EMM-MHVC: 1 X-SW-Source: 2013-05/txt/msg00082.txt.bz2 The commands add-inferior / clone-inferior and several related commands were added as long ago as gdb 7.1. But, unless I'm missing the obvious, they aren't currently very useful. GDB appears to support multiple "live" inferiors only when the arise as the result of a fork or vfork. Please tell me that I'm wrong and that I'm missing the obvious. . I start up gdb with no arguments . file my-elf-file . clone-inferior . info inferiors I now have two inferiors, numbers 1 and 2, same elf file; 1 is curent. . target remote . inferior 2 . target remote And I get: A program is being debugged already. Kill it? (y or n) I also tried attaching to two pre-existing processes, one each two different inferiors. That failed as well. I've looked more at remote targets than attached / forked targets, as we are more interested in remote targets. Thursday last week I would have loved to have had 10 inferiors, 5 elf files, 2 inferiors per elf file. Looking at remote.c, it stores a global pointer to a structure containing a file descriptor and other state in remote_desc. This variable, and presumably others, are inferior specific. Looking at inferior.h I see: /* Private data used by the target vector implementation. */ struct private_inferior *private; Based on the comment, the structure should probably be called private_target rather than private_inferior. I'm thinking that remote.c should define a struct private_inferior containing, at least, a pointer to 'struct serial *remote_desc' and then *EITHER* changing inferiors needs to save / restore remote_desc (which would mean target_ops entries for { saving / restoring } state when you { switch away from / switch back to } an inferior *OR* all references to remote_desc need to be modified to get to it via current_inferior -> private -> remote_desc -> ... I'm also thinking that target_ops needs to have a couple of additional fields: . a boolean -- does the target support multiple concurrent active instances? . a counter -- how many active instances do we currently have? I'm also guessing that the above is just the tip of the iceberg or someone would have already done this. What else needs to happen for this to work? I'm trying to get a feel for how big a project this would be and whether it would be better for us to pursue other options. Thanks. David p.s. It would also be nice if inferiors could be named, otherwise you'll end up creating a crib sheet telling you which is which. It's trivial, but it makes me think that no one really uses add-inferior / clone-inferior. -- David Taylor dtaylor@emc.com