[Lldb-commits] [lldb] r156994 - /lldb/trunk/source/Host/common/Host.cpp

Filipe Cabecinhas filcab at gmail.com
Fri May 18 16:22:40 PDT 2012


But the default architecture is a static variable for the Target class (in the back-end), so you wouldn't be able to do that (without some code juggling). If you call SetDefaultArchitecture on one SBDebugger, it will call Target::SetDefaultArchitecure and will change it for every (SB)Debugger. 

If we decide to change the default arch from the target to the debugger, we will also have to deal with the one other client of GetDefaultArchitecture: Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO
This one has no pointer to a debugger (but I have no idea if we can remove that check for a valid arch or not).

In the meantime, I can commit this patch, which will add a IsValid() method to Target (when it gets destroyed, it becomes invalid), and test the dummy target. If the dummy target is not valid, it will create a new one.

I don't think this is the best way (being able to have two debuggers with different default architectures would be better), but it works now and is a minimal change from what we had (and makes the test suite happy :-) ).

Is this OK?

Regards, 

  Filipe


On Friday, May 18, 2012 at 8:57 PM, Jim Ingham wrote:

> You pretty much have to attach the Dummy Target to its Debugger, because I might (in Python) create two Debuggers, set the Default Architecture on one to i386, and on the other to x86_64, but give them no files, then:
> 
> i386_debugger.HandleCommand("expr (int) 0xffffffff + 1")
> x86_64_debugger.HandleCommand ("expr (int) 0xffffffff + 1")
> 
> should both do the right thing without losing persistent variables in either of the interpreters, etc...
> 
> Jim
> 
> 
> On May 18, 2012, at 12:51 PM, Jim Ingham <jingham at apple.com (mailto:jingham at apple.com)> wrote:
> 
> > Targets belong to debuggers so I think it makes sense for the dummy target to belong to the Debugger passed into GetDummyTarget. So when you start a new debug session (i.e. make a new Debugger) then you'll get a new DummyTarget appropriate to that Debugger. And if you call "SetDefaultArchitecture" on the debugger, it should dump the dummy target if it exists, so that the next request for it will make it with the correct architecture.
> > 
> > Jim
> > 
> > 
> > 
> > On May 18, 2012, at 10:31 AM, Filipe Cabecinhas <filcab at filcab.net (mailto:filcab at filcab.net)> wrote:
> > 
> > > But how would that avoid using the cached dummy target after it's destroyed?
> > > 
> > > The problem is this: (lldbtest.py:TestBase.tearDown()):
> > > # Delete the target(s) from the debugger as a general cleanup step.
> > > # This includes terminating the process for each target, if any.
> > > # We'd like to reuse the debugger for our next test without incurring
> > > # the initialization overhead.
> > > targets = []
> > > for target in self.dbg:
> > > if target:
> > > targets.append(target)
> > > process = target.GetProcess()
> > > if process:
> > > rc = self.invoke(process, "Kill")
> > > self.assertTrue(rc.Success(), PROCESS_KILLED)
> > > for target in targets:
> > > self.dbg.DeleteTarget(target)
> > > 
> > > 
> > > 
> > > 
> > > What we can do is:
> > > Restore the method as it was before, but add a check for g_dummy_target_sp->IsValid()
> > > Implement the Target::IsValid() method that would, for example, check a m_valid boolean that would be set to false on Destroy().
> > > 
> > > What do you think?
> > > 
> > > Regards, 
> > > 
> > > Filipe
> > > 
> > > 
> > > On Friday, May 18, 2012 at 6:11 PM, Greg Clayton wrote:
> > > 
> > > 
> > > 
> > > 
> > > _______________________________________________
> > > lldb-commits mailing list
> > > lldb-commits at cs.uiuc.edu (mailto:lldb-commits at cs.uiuc.edu)
> > > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
> > 
> > 
> > 
> > _______________________________________________
> > lldb-commits mailing list
> > lldb-commits at cs.uiuc.edu (mailto:lldb-commits at cs.uiuc.edu)
> > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
> 
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu (mailto:lldb-commits at cs.uiuc.edu)
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits


-------------- next part --------------
A non-text attachment was scrubbed...
Name: lldb-dummy-target-fix.patch
Type: application/octet-stream
Size: 2173 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20120519/89f67c29/attachment.obj>


More information about the lldb-commits mailing list