From baldrick at free.fr Mon Nov 28 02:33:09 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 28 Nov 2011 09:33:09 +0100 Subject: [Lldb-commits] [PATCH] fix debugging on linux In-Reply-To: <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> References: <20111124073122.GA13244@bloodbath.burble.org> <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> Message-ID: <4ED34745.7090201@free.fr> The linux lldb buildbot http://lab.llvm.org:8011/builders/lldb-x86_64-linux is still failing, now with: Collected 442 tests 1: test_with_dsym (TestLogging.LogTestCase) ... skipped 'requires Darwin' 2: test_with_dwarf (TestLogging.LogTestCase) ... FAIL 3: test_with_dsym (TestFormatters.ExprFormattersTestCase) Test expr + formatters for good interoperability. ... skipped 'requires Darwin' 4: test_with_dwarf_ (TestFormatters.ExprFormattersTestCase) Test expr + formatters for good interoperability. ... ERROR 5: test_expr_commands (TestPrintfAfterUp.Radar9531204TestCase) The evaluating printf(...) after break stop and then up a stack frame. ... python: LinuxThread.cpp:239: void LinuxThread::BreakNotify(const ProcessMessage&): Assertion `bp_site' failed. make: *** [check-local] Aborted program finished with exit code 2 Ciao, Duncan. On 28/11/11 03:03, Greg Clayton wrote: > > On Nov 23, 2011, at 11:31 PM, dawn at burble.org wrote: > >> This patch was created using clang/llvm rev 144569, lldb rev 144919 but has >> been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on >> Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. >> >> Debugging on Linux broke when the assumption was made that a process could be >> launched by spawning it in a suspended state and then attaching to it. That >> support does not exist on Linux. To work around this, I added a new method >> "CanLaunchViaAttach" which tests whether the platform supports being launched >> in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find >> an easy way to set it from within the Linux plugins. >> >> Commit message: >> >> Fix debugging on Linux. >> Implement remote vs. host platform code as was done with PlatformDarwin. >> Platform::CanLaunchViaAttach(): new: return true if the process can be launched >> via spawn and attach. Default is true. Override in PlatformLinux to false. >> Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) >> then launch the process via CreateProcess and Launch. >> >> Please review and commit if acceptable. > > I checked in an alternate fix: > > % svn commit > Sending include/lldb/Core/Module.h > Sending include/lldb/Symbol/SymbolFile.h > Sending include/lldb/Target/Platform.h > Sending source/Commands/CommandObjectProcess.cpp > Sending source/Core/Module.cpp > Sending source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp > Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp > Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h > Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp > Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h > Sending source/Symbol/SymbolFile.cpp > Transmitting file data ........... > Committed revision 145219. > > % svn commit > Sending Platform/Linux/PlatformLinux.h > Transmitting file data . > Committed revision 145221. > > > The first one contains the necessary changes to CommandObjectProcess.cpp and to include/lldb/Target/Platform.h that allow a platform to say: > > > virtual bool > CanDebugProcess () > { > return true; > } > > This keeps the code out of the platform since when a platform launches a process, it shouldn't be tied to a process plug-in as in the patch you submitted. > > Here is the vision of platforms: > > - They should be able to list all of the processes on the platform. This way you can connect to your local machine and list the processes, or connect to a remote platform, and if the remote platform supports it, it can list the processes that are there. > - Platforms should support launching processes. Not always for debugging, but sometimes just to spawn a child process. On the localhost, this means just using the Host::LaunchProcess() functionality. This way, we just need to implement a single copy of the process launching code. When you create a remote platform, you should be able to link against the native linux or darwin launching code and then we don't end up with multiple copies of the launching code like we have now. You make a good point in that not all platforms will be able to support launching with a program stopped for debugging, so we now ask the platform up in the CommandObjectProcessLaunch class before we launch the process. This keeps the platform clean, yet also lets us fall back to just launching the process through the built in process plug-in. > - Platforms should support attaching to a remote process. Combined with being able to launch for debug, this allows debugging as we have it on MacOSX. If we do this while remotely connected to a remote darwin machine, we now have the ability to talk to a remote computer and launch, attach, list and do a lot more > - Platforms should know if there are files locally on the current machine in an SDK or PDK or some over developer kit/cross compiling sysroot, etc to allow locating files in terms of the path you would us on the remote machine. For example when debugging on a remote device, if the are asked to find the file for "/bin/ls", this might locally be located in developer kit directory such as > "/path/to/old/linux/sysroot/bin/ls". This allows you to debug remote machines, or event mount the root file system on a mountpoint so you have access to the files so you can debug. > - Platforms should be able to upload/download files so you could install a new binary and run it, or upload a shared library so we can locally cache it for faster debugging. > > We are in the process of slowly makine these Platforms a reality, so keep the questions coming if anyone has any. > > So in short: I made the fix you requested, but in a different way. If you can rework your patch around what is in top of tree, then we can get the rest of it submitted. > > Greg Clayton > >> Thanks! >> -Dawn >> _______________________________________________ >> lldb-commits mailing list >> 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 > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From johnny.chen at apple.com Mon Nov 28 13:12:25 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 28 Nov 2011 19:12:25 -0000 Subject: [Lldb-commits] [lldb] r145260 - /lldb/trunk/scripts/Python/interface/SBProcess.i Message-ID: <20111128191225.E5ABD2A6C12D@llvm.org> Author: johnny Date: Mon Nov 28 13:12:25 2011 New Revision: 145260 URL: http://llvm.org/viewvc/llvm-project?rev=145260&view=rev Log: Clarify the SBProcess Python API GetSTDOUT()/GetSTDERR(). They look different from the C++ API due to swig typemapping. Modified: lldb/trunk/scripts/Python/interface/SBProcess.i Modified: lldb/trunk/scripts/Python/interface/SBProcess.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBProcess.i?rev=145260&r1=145259&r2=145260&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBProcess.i (original) +++ lldb/trunk/scripts/Python/interface/SBProcess.i Mon Nov 28 13:12:25 2011 @@ -67,9 +67,19 @@ size_t PutSTDIN (const char *src, size_t src_len); + %feature("autodoc", " + Reads data from the current process's stdout stream. API client specifies + the size of the buffer to read data into. It returns the byte buffer in a + Python string. + ") GetSTDOUT; size_t GetSTDOUT (char *dst, size_t dst_len) const; + %feature("autodoc", " + Reads data from the current process's stderr stream. API client specifies + the size of the buffer to read data into. It returns the byte buffer in a + Python string. + ") GetSTDERR; size_t GetSTDERR (char *dst, size_t dst_len) const; From dawn at burble.org Mon Nov 28 13:59:49 2011 From: dawn at burble.org (dawn at burble.org) Date: Mon, 28 Nov 2011 11:59:49 -0800 Subject: [Lldb-commits] [PATCH] fix debugging on linux In-Reply-To: <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> References: <20111124073122.GA13244@bloodbath.burble.org> <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> Message-ID: <20111128195949.GA24208@bloodbath.burble.org> I find the name "CanDebugProcess" to be misleading. The issue isn't whether a process can be debugged on Linux (because it obviously can), it's that it can't be spawned in a suspended state and then attached to. AFAIK, Linux doesn't have anything like the MacOSX "POSIX_SPAWN_START_SUSPENDED" flag for posix_spawnattr_setflags() that MacOSX has. I chose the name "CanLaunchViaAttach" for this, which I think better describes the problem. Ok to rename "CanDebugProcess" to "CanLaunchViaAttach"? Likewise, since you moved the fixes I had made to DebugProcess() into CommandObjectProcessLaunch(), please also rename "DebugProcess" to "LaunchViaAttach". Thank you! -Dawn On Sun, Nov 27, 2011 at 06:03:03PM -0800, Greg Clayton wrote: > > On Nov 23, 2011, at 11:31 PM, dawn at burble.org wrote: > > > This patch was created using clang/llvm rev 144569, lldb rev 144919 but has > > been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on > > Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. > > > > Debugging on Linux broke when the assumption was made that a process could be > > launched by spawning it in a suspended state and then attaching to it. That > > support does not exist on Linux. To work around this, I added a new method > > "CanLaunchViaAttach" which tests whether the platform supports being launched > > in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find > > an easy way to set it from within the Linux plugins. > > > > Commit message: > > > > Fix debugging on Linux. > > Implement remote vs. host platform code as was done with PlatformDarwin. > > Platform::CanLaunchViaAttach(): new: return true if the process can be launched > > via spawn and attach. Default is true. Override in PlatformLinux to false. > > Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) > > then launch the process via CreateProcess and Launch. > > > > Please review and commit if acceptable. > > I checked in an alternate fix: > > % svn commit > Sending include/lldb/Core/Module.h > Sending include/lldb/Symbol/SymbolFile.h > Sending include/lldb/Target/Platform.h > Sending source/Commands/CommandObjectProcess.cpp > Sending source/Core/Module.cpp > Sending source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp > Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp > Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h > Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp > Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h > Sending source/Symbol/SymbolFile.cpp > Transmitting file data ........... > Committed revision 145219. > > % svn commit > Sending Platform/Linux/PlatformLinux.h > Transmitting file data . > Committed revision 145221. > > > The first one contains the necessary changes to CommandObjectProcess.cpp and to include/lldb/Target/Platform.h that allow a platform to say: > > > virtual bool > CanDebugProcess () > { > return true; > } > > This keeps the code out of the platform since when a platform launches a process, it shouldn't be tied to a process plug-in as in the patch you submitted. > > Here is the vision of platforms: > > - They should be able to list all of the processes on the platform. This way you can connect to your local machine and list the processes, or connect to a remote platform, and if the remote platform supports it, it can list the processes that are there. > - Platforms should support launching processes. Not always for debugging, but sometimes just to spawn a child process. On the localhost, this means just using the Host::LaunchProcess() functionality. This way, we just need to implement a single copy of the process launching code. When you create a remote platform, you should be able to link against the native linux or darwin launching code and then we don't end up with multiple copies of the launching code like we have now. You make a good point in that not all platforms will be able to support launching with a program stopped for debugging, so we now ask the platform up in the CommandObjectProcessLaunch class before we launch the process. This keeps the platform clean, yet also lets us fall back to just launching the process through the built in process plug-in. > - Platforms should support attaching to a remote process. Combined with being able to launch for debug, this allows debugging as we have it on MacOSX. If we do this while remotely connected to a remote darwin machine, we now have the ability to talk to a remote computer and launch, attach, list and do a lot more > - Platforms should know if there are files locally on the current machine in an SDK or PDK or some over developer kit/cross compiling sysroot, etc to allow locating files in terms of the path you would us on the remote machine. For example when debugging on a remote device, if the are asked to find the file for "/bin/ls", this might locally be located in developer kit directory such as > "/path/to/old/linux/sysroot/bin/ls". This allows you to debug remote machines, or event mount the root file system on a mountpoint so you have access to the files so you can debug. > - Platforms should be able to upload/download files so you could install a new binary and run it, or upload a shared library so we can locally cache it for faster debugging. > > We are in the process of slowly makine these Platforms a reality, so keep the questions coming if anyone has any. > > So in short: I made the fix you requested, but in a different way. If you can rework your patch around what is in top of tree, then we can get the rest of it submitted. > > Greg Clayton > > > Thanks! > > -Dawn > > _______________________________________________ > > lldb-commits mailing list > > lldb-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From johnny.chen at apple.com Mon Nov 28 15:39:07 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 28 Nov 2011 21:39:07 -0000 Subject: [Lldb-commits] [lldb] r145282 - in /lldb/trunk: scripts/Python/interface/SBCommandInterpreter.i scripts/Python/interface/SBProcess.i scripts/Python/python-typemaps.swig test/python_api/default-constructor/sb_process.py test/python_api/process/io/ test/python_api/process/io/Makefile test/python_api/process/io/TestProcessIO.py test/python_api/process/io/main.c Message-ID: <20111128213907.ED1A92A6C12E@llvm.org> Author: johnny Date: Mon Nov 28 15:39:07 2011 New Revision: 145282 URL: http://llvm.org/viewvc/llvm-project?rev=145282&view=rev Log: SBProcess.PutSTDIN() needs to be properly typemapped when swigging, so that we can do Python scripting like this: target = self.dbg.CreateTarget(self.exe) self.dbg.SetAsync(True) process = target.LaunchSimple(None, None, os.getcwd()) process.PutSTDIN("Line 1 Entered.\n") process.PutSTDIN("Line 2 Entered.\n") process.PutSTDIN("Line 3 Entered.\n") Add TestProcessIO.py to exercise the process IO API: PutSTDIN()/GetSTDOUT()/GetSTDERR(). Added: lldb/trunk/test/python_api/process/io/ lldb/trunk/test/python_api/process/io/Makefile lldb/trunk/test/python_api/process/io/TestProcessIO.py lldb/trunk/test/python_api/process/io/main.c Modified: lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i lldb/trunk/scripts/Python/interface/SBProcess.i lldb/trunk/scripts/Python/python-typemaps.swig lldb/trunk/test/python_api/default-constructor/sb_process.py Modified: lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i?rev=145282&r1=145281&r2=145282&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i (original) +++ lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i Mon Nov 28 15:39:07 2011 @@ -99,8 +99,10 @@ lldb::SBProcess GetProcess (); +#if 0 ssize_t WriteToScriptInterpreter (const char *src); +#endif ssize_t WriteToScriptInterpreter (const char *src, size_t src_len); Modified: lldb/trunk/scripts/Python/interface/SBProcess.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBProcess.i?rev=145282&r1=145281&r2=145282&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBProcess.i (original) +++ lldb/trunk/scripts/Python/interface/SBProcess.i Mon Nov 28 15:39:07 2011 @@ -64,6 +64,10 @@ lldb::ByteOrder GetByteOrder() const; + %feature("autodoc", " + Writes data into the current process's stdin. API client specifies a Python + string as the only argument. + ") PutSTDIN; size_t PutSTDIN (const char *src, size_t src_len); Modified: lldb/trunk/scripts/Python/python-typemaps.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-typemaps.swig?rev=145282&r1=145281&r2=145282&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-typemaps.swig (original) +++ lldb/trunk/scripts/Python/python-typemaps.swig Mon Nov 28 15:39:07 2011 @@ -76,6 +76,15 @@ $1 = (char *) PyString_AsString($input); $2 = PyString_Size($input); } +// Ditto for SBProcess::PutSTDIN(const char *src, size_t src_len). +%typemap(in) (const char *src, size_t src_len) { + if (!PyString_Check($input)) { + PyErr_SetString(PyExc_ValueError, "Expecting a string"); + return NULL; + } + $1 = (char *) PyString_AsString($input); + $2 = PyString_Size($input); +} // And SBProcess::WriteMemory. %typemap(in) (const void *buf, size_t size) { if (!PyString_Check($input)) { Modified: lldb/trunk/test/python_api/default-constructor/sb_process.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_process.py?rev=145282&r1=145281&r2=145282&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_process.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_process.py Mon Nov 28 15:39:07 2011 @@ -8,7 +8,7 @@ def fuzz_obj(obj): obj.GetTarget() obj.GetByteOrder() - obj.PutSTDIN("my data", 7) + obj.PutSTDIN("my data") obj.GetSTDOUT(6) obj.GetSTDERR(6) event = lldb.SBEvent() Added: lldb/trunk/test/python_api/process/io/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/io/Makefile?rev=145282&view=auto ============================================================================== --- lldb/trunk/test/python_api/process/io/Makefile (added) +++ lldb/trunk/test/python_api/process/io/Makefile Mon Nov 28 15:39:07 2011 @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +C_SOURCES := main.c +EXE := process_io + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/python_api/process/io/TestProcessIO.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/io/TestProcessIO.py?rev=145282&view=auto ============================================================================== --- lldb/trunk/test/python_api/process/io/TestProcessIO.py (added) +++ lldb/trunk/test/python_api/process/io/TestProcessIO.py Mon Nov 28 15:39:07 2011 @@ -0,0 +1,66 @@ +"""Test Python APIs for process IO.""" + +import os, sys, time +import unittest2 +import lldb +from lldbtest import * + +class ProcessIOTestCase(TestBase): + + mydir = os.path.join("python_api", "process", "io") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_put_stdin_with_dsym(self): + """Exercise SBProcess.PutSTDIN().""" + self.buildDsym() + self.put_stdin() + + @python_api_test + def test_put_stdin_with_dwarf(self): + """Exercise SBProcess.PutSTDIN().""" + self.buildDwarf() + self.put_stdin() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Get the full path to our executable to be debugged. + self.exe = os.path.join(os.getcwd(), "process_io") + + def put_stdin(self): + """Launch a process and use SBProcess.PutSTDIN() to write data to it.""" + + target = self.dbg.CreateTarget(self.exe) + + self.dbg.SetAsync(True) + process = target.LaunchSimple(None, None, os.getcwd()) + if self.TraceOn(): + print "process launched." + + self.assertTrue(process, PROCESS_IS_VALID) + + process.PutSTDIN("Line 1 Entered.\n") + process.PutSTDIN("Line 2 Entered.\n") + process.PutSTDIN("Line 3 Entered.\n") + + for i in range(5): + output = process.GetSTDOUT(500) + error = process.GetSTDERR(500) + if self.TraceOn(): + print "output->|%s|" % output + print "error->|%s|" % error + # We are satisfied once "input line=>1" appears in stderr. + # See also main.c. + #if "input line=>1" in error: + if "input line=>1" in output: + return + time.sleep(5) + + self.fail("Expected output form launched process did not appear?") + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/python_api/process/io/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/io/main.c?rev=145282&view=auto ============================================================================== --- lldb/trunk/test/python_api/process/io/main.c (added) +++ lldb/trunk/test/python_api/process/io/main.c Mon Nov 28 15:39:07 2011 @@ -0,0 +1,12 @@ +#include + +int main(int argc, char const *argv[]) { + printf("Hello world.\n"); + char line[100]; + int count = 1; + while (fgets(line, sizeof(line), stdin)) { // Reading from stdin... + fprintf(stderr, "input line=>%d\n", count++); + } + + printf("Exiting now\n"); +} From gclayton at apple.com Mon Nov 28 15:48:35 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 28 Nov 2011 13:48:35 -0800 Subject: [Lldb-commits] [PATCH] fix debugging on linux In-Reply-To: <20111128195949.GA24208@bloodbath.burble.org> References: <20111124073122.GA13244@bloodbath.burble.org> <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> <20111128195949.GA24208@bloodbath.burble.org> Message-ID: <06D1CC93-A433-42D5-9332-BEE9142802CA@apple.com> On Nov 28, 2011, at 11:59 AM, dawn at burble.org wrote: > I find the name "CanDebugProcess" to be misleading. The issue isn't > whether a process can be debugged on Linux (because it obviously can), > it's that it can't be spawned in a suspended state and then attached > to. AFAIK, Linux doesn't have anything like the MacOSX > "POSIX_SPAWN_START_SUSPENDED" flag for posix_spawnattr_setflags() that > MacOSX has. Yes, this flag is darwin only. > I chose the name "CanLaunchViaAttach" for this, which I think better > describes the problem. Ok to rename "CanDebugProcess" to > "CanLaunchViaAttach"? I am not too fond of the CanLaunchViaAttach because launching a program using a platform doesn't imply that you want to debug or attach to it. Also it doesn't make sense how do you launch via attach? First you launch, then you attach. The attach doesn't have anything to do with launching. You might just want to spawn a server program on the remote platform which you don't want to debug. We are asking the platform (not the process plug-in, but the platform) if it can do something, in this case: can the platform launch a process that can be stopped for debugging. Currently the linux platform can't (though I am sure we can make it work somehow), only the native linux _process_ plug-in can. You can't use the ProcessLinux plug-in to implement stuff functionality for the platform, the platform itself should be doing the work. This is preparing for better remote debugging support where we can launch new remote processes without having to involve any of the process plug-ins. The attach part shouldn't have anything to do with this either because you might want to spawn a new process that is stopped, and then resume it at a controlled time later. The "POSIX_SPAWN_START_SUSPENDED" flag in darwin will have the process halted at the entry point with a SIGSTOP, and it can be resumed later. How about "bool Platform::CanLaunchProcessStoppedAtEntry()"? Platforms are far from complete and we can modify them and grow their abilities over time. Again, the vision is that platforms will eventually launch (possibly for debug), attach to processes, list processes, upload/download and more. They should provide a nice connection to a local or remote machine so that debugging to them is as easy as debugging on your local machine. That is the vision at least, and I know we have some work ahead of us to get there. Greg > Likewise, since you moved the fixes I had made to > DebugProcess() into CommandObjectProcessLaunch(), please also rename > "DebugProcess" to "LaunchViaAttach". Hopefully CanLaunchProcessStoppedAtEntry() makes sense? > Thank you! > -Dawn > > > On Sun, Nov 27, 2011 at 06:03:03PM -0800, Greg Clayton wrote: >> >> On Nov 23, 2011, at 11:31 PM, dawn at burble.org wrote: >> >>> This patch was created using clang/llvm rev 144569, lldb rev 144919 but has >>> been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on >>> Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. >>> >>> Debugging on Linux broke when the assumption was made that a process could be >>> launched by spawning it in a suspended state and then attaching to it. That >>> support does not exist on Linux. To work around this, I added a new method >>> "CanLaunchViaAttach" which tests whether the platform supports being launched >>> in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find >>> an easy way to set it from within the Linux plugins. >>> >>> Commit message: >>> >>> Fix debugging on Linux. >>> Implement remote vs. host platform code as was done with PlatformDarwin. >>> Platform::CanLaunchViaAttach(): new: return true if the process can be launched >>> via spawn and attach. Default is true. Override in PlatformLinux to false. >>> Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) >>> then launch the process via CreateProcess and Launch. >>> >>> Please review and commit if acceptable. >> >> I checked in an alternate fix: >> >> % svn commit >> Sending include/lldb/Core/Module.h >> Sending include/lldb/Symbol/SymbolFile.h >> Sending include/lldb/Target/Platform.h >> Sending source/Commands/CommandObjectProcess.cpp >> Sending source/Core/Module.cpp >> Sending source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp >> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp >> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h >> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp >> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h >> Sending source/Symbol/SymbolFile.cpp >> Transmitting file data ........... >> Committed revision 145219. >> >> % svn commit >> Sending Platform/Linux/PlatformLinux.h >> Transmitting file data . >> Committed revision 145221. >> >> >> The first one contains the necessary changes to CommandObjectProcess.cpp and to include/lldb/Target/Platform.h that allow a platform to say: >> >> >> virtual bool >> CanDebugProcess () >> { >> return true; >> } >> >> This keeps the code out of the platform since when a platform launches a process, it shouldn't be tied to a process plug-in as in the patch you submitted. >> >> Here is the vision of platforms: >> >> - They should be able to list all of the processes on the platform. This way you can connect to your local machine and list the processes, or connect to a remote platform, and if the remote platform supports it, it can list the processes that are there. >> - Platforms should support launching processes. Not always for debugging, but sometimes just to spawn a child process. On the localhost, this means just using the Host::LaunchProcess() functionality. This way, we just need to implement a single copy of the process launching code. When you create a remote platform, you should be able to link against the native linux or darwin launching code and then we don't end up with multiple copies of the launching code like we have now. You make a good point in that not all platforms will be able to support launching with a program stopped for debugging, so we now ask the platform up in the CommandObjectProcessLaunch class before we launch the process. This keeps the platform clean, yet also lets us fall back to just launching the process through the built in process plug-in. >> - Platforms should support attaching to a remote process. Combined with being able to launch for debug, this allows debugging as we have it on MacOSX. If we do this while remotely connected to a remote darwin machine, we now have the ability to talk to a remote computer and launch, attach, list and do a lot more >> - Platforms should know if there are files locally on the current machine in an SDK or PDK or some over developer kit/cross compiling sysroot, etc to allow locating files in terms of the path you would us on the remote machine. For example when debugging on a remote device, if the are asked to find the file for "/bin/ls", this might locally be located in developer kit directory such as >> "/path/to/old/linux/sysroot/bin/ls". This allows you to debug remote machines, or event mount the root file system on a mountpoint so you have access to the files so you can debug. >> - Platforms should be able to upload/download files so you could install a new binary and run it, or upload a shared library so we can locally cache it for faster debugging. >> >> We are in the process of slowly makine these Platforms a reality, so keep the questions coming if anyone has any. >> >> So in short: I made the fix you requested, but in a different way. If you can rework your patch around what is in top of tree, then we can get the rest of it submitted. >> >> Greg Clayton >> >>> Thanks! >>> -Dawn >>> _______________________________________________ >>> lldb-commits mailing list >>> lldb-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From gclayton at apple.com Mon Nov 28 16:09:14 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 28 Nov 2011 14:09:14 -0800 Subject: [Lldb-commits] [PATCH] fix debugging on linux In-Reply-To: <06D1CC93-A433-42D5-9332-BEE9142802CA@apple.com> References: <20111124073122.GA13244@bloodbath.burble.org> <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> <20111128195949.GA24208@bloodbath.burble.org> <06D1CC93-A433-42D5-9332-BEE9142802CA@apple.com> Message-ID: <77D307F0-0336-4F30-AB81-CEF906462202@apple.com> As a follow up, we should be able to modify the linux Host::LaunchProcess() to use fork() and exec() when the "eLaunchFlagDebug" launch flag is set. You would: 1 - fork() 2 - in child process check for eLaunchFlagDebug and if this is set use the "ptrace (PT_TRACE_ME, ...)" 3 - do all file actions 4 - exec 5 - hopefully this starts a process stopped on linux?? There is some example fork + exec code in MachProcess::ForkChildForPTraceDebugging() in lldb/tools/debugserver/source/MacOSX/MachProcess.cpp if you need a head start. On Nov 28, 2011, at 1:48 PM, Greg Clayton wrote: > > On Nov 28, 2011, at 11:59 AM, dawn at burble.org wrote: > >> I find the name "CanDebugProcess" to be misleading. The issue isn't >> whether a process can be debugged on Linux (because it obviously can), >> it's that it can't be spawned in a suspended state and then attached >> to. AFAIK, Linux doesn't have anything like the MacOSX >> "POSIX_SPAWN_START_SUSPENDED" flag for posix_spawnattr_setflags() that >> MacOSX has. > > Yes, this flag is darwin only. > >> I chose the name "CanLaunchViaAttach" for this, which I think better >> describes the problem. Ok to rename "CanDebugProcess" to >> "CanLaunchViaAttach"? > > I am not too fond of the CanLaunchViaAttach because launching a program using a platform doesn't imply that you want to debug or attach to it. Also it doesn't make sense how do you launch via attach? First you launch, then you attach. The attach doesn't have anything to do with launching. You might just want to spawn a server program on the remote platform which you don't want to debug. We are asking the platform (not the process plug-in, but the platform) if it can do something, in this case: can the platform launch a process that can be stopped for debugging. Currently the linux platform can't (though I am sure we can make it work somehow), only the native linux _process_ plug-in can. You can't use the ProcessLinux plug-in to implement stuff functionality for the platform, the platform itself should be doing the work. This is preparing for better remote debugging support where we can launch new remote processes without having to involve any of the process plug-ins. > > The attach part shouldn't have anything to do with this either because you might want to spawn a new process that is stopped, and then resume it at a controlled time later. The "POSIX_SPAWN_START_SUSPENDED" flag in darwin will have the process halted at the entry point with a SIGSTOP, and it can be resumed later. > > How about "bool Platform::CanLaunchProcessStoppedAtEntry()"? > > Platforms are far from complete and we can modify them and grow their abilities over time. Again, the vision is that platforms will eventually launch (possibly for debug), attach to processes, list processes, upload/download and more. They should provide a nice connection to a local or remote machine so that debugging to them is as easy as debugging on your local machine. That is the vision at least, and I know we have some work ahead of us to get there. > > > Greg > > > >> Likewise, since you moved the fixes I had made to >> DebugProcess() into CommandObjectProcessLaunch(), please also rename >> "DebugProcess" to "LaunchViaAttach". > > Hopefully CanLaunchProcessStoppedAtEntry() makes sense? > >> Thank you! >> -Dawn >> >> >> On Sun, Nov 27, 2011 at 06:03:03PM -0800, Greg Clayton wrote: >>> >>> On Nov 23, 2011, at 11:31 PM, dawn at burble.org wrote: >>> >>>> This patch was created using clang/llvm rev 144569, lldb rev 144919 but has >>>> been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on >>>> Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. >>>> >>>> Debugging on Linux broke when the assumption was made that a process could be >>>> launched by spawning it in a suspended state and then attaching to it. That >>>> support does not exist on Linux. To work around this, I added a new method >>>> "CanLaunchViaAttach" which tests whether the platform supports being launched >>>> in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find >>>> an easy way to set it from within the Linux plugins. >>>> >>>> Commit message: >>>> >>>> Fix debugging on Linux. >>>> Implement remote vs. host platform code as was done with PlatformDarwin. >>>> Platform::CanLaunchViaAttach(): new: return true if the process can be launched >>>> via spawn and attach. Default is true. Override in PlatformLinux to false. >>>> Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) >>>> then launch the process via CreateProcess and Launch. >>>> >>>> Please review and commit if acceptable. >>> >>> I checked in an alternate fix: >>> >>> % svn commit >>> Sending include/lldb/Core/Module.h >>> Sending include/lldb/Symbol/SymbolFile.h >>> Sending include/lldb/Target/Platform.h >>> Sending source/Commands/CommandObjectProcess.cpp >>> Sending source/Core/Module.cpp >>> Sending source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp >>> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp >>> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h >>> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp >>> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h >>> Sending source/Symbol/SymbolFile.cpp >>> Transmitting file data ........... >>> Committed revision 145219. >>> >>> % svn commit >>> Sending Platform/Linux/PlatformLinux.h >>> Transmitting file data . >>> Committed revision 145221. >>> >>> >>> The first one contains the necessary changes to CommandObjectProcess.cpp and to include/lldb/Target/Platform.h that allow a platform to say: >>> >>> >>> virtual bool >>> CanDebugProcess () >>> { >>> return true; >>> } >>> >>> This keeps the code out of the platform since when a platform launches a process, it shouldn't be tied to a process plug-in as in the patch you submitted. >>> >>> Here is the vision of platforms: >>> >>> - They should be able to list all of the processes on the platform. This way you can connect to your local machine and list the processes, or connect to a remote platform, and if the remote platform supports it, it can list the processes that are there. >>> - Platforms should support launching processes. Not always for debugging, but sometimes just to spawn a child process. On the localhost, this means just using the Host::LaunchProcess() functionality. This way, we just need to implement a single copy of the process launching code. When you create a remote platform, you should be able to link against the native linux or darwin launching code and then we don't end up with multiple copies of the launching code like we have now. You make a good point in that not all platforms will be able to support launching with a program stopped for debugging, so we now ask the platform up in the CommandObjectProcessLaunch class before we launch the process. This keeps the platform clean, yet also lets us fall back to just launching the process through the built in process plug-in. >>> - Platforms should support attaching to a remote process. Combined with being able to launch for debug, this allows debugging as we have it on MacOSX. If we do this while remotely connected to a remote darwin machine, we now have the ability to talk to a remote computer and launch, attach, list and do a lot more >>> - Platforms should know if there are files locally on the current machine in an SDK or PDK or some over developer kit/cross compiling sysroot, etc to allow locating files in terms of the path you would us on the remote machine. For example when debugging on a remote device, if the are asked to find the file for "/bin/ls", this might locally be located in developer kit directory such as >>> "/path/to/old/linux/sysroot/bin/ls". This allows you to debug remote machines, or event mount the root file system on a mountpoint so you have access to the files so you can debug. >>> - Platforms should be able to upload/download files so you could install a new binary and run it, or upload a shared library so we can locally cache it for faster debugging. >>> >>> We are in the process of slowly makine these Platforms a reality, so keep the questions coming if anyone has any. >>> >>> So in short: I made the fix you requested, but in a different way. If you can rework your patch around what is in top of tree, then we can get the rest of it submitted. >>> >>> Greg Clayton >>> >>>> Thanks! >>>> -Dawn >>>> _______________________________________________ >>>> lldb-commits mailing list >>>> 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 > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From gclayton at apple.com Mon Nov 28 17:30:42 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 28 Nov 2011 23:30:42 -0000 Subject: [Lldb-commits] [lldb] r145314 - /lldb/trunk/docs/lldb-gdb-remote.txt Message-ID: <20111128233042.AB99E2A6C12C@llvm.org> Author: gclayton Date: Mon Nov 28 17:30:42 2011 New Revision: 145314 URL: http://llvm.org/viewvc/llvm-project?rev=145314&view=rev Log: Added some documentation on the new GDB remote packets we have added and use in LLDB. Added: lldb/trunk/docs/lldb-gdb-remote.txt Added: lldb/trunk/docs/lldb-gdb-remote.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-gdb-remote.txt?rev=145314&view=auto ============================================================================== --- lldb/trunk/docs/lldb-gdb-remote.txt (added) +++ lldb/trunk/docs/lldb-gdb-remote.txt Mon Nov 28 17:30:42 2011 @@ -0,0 +1,491 @@ +LLDB has added new GDB server packets to better support multi-threaded and +remote debugging. Why? Normally you need to start the correct GDB and the +correct GDB server when debugging. If you have mismatch, then things go wrong +very quickly. LLDB makes extensive use of the GDB remote protocol and we +wanted to make sure that the experience was a bit more dynamic where we can +discover information about a remote target with having to know anything up +front. We also ran into performance issues with the existing GDB remote +protocol that can be overcome when using a reliable communications layer. +Some packets improve performance, others allow for remote process launching +(if you have an OS), and others allow us to dynamically figure out what +registers a thread might have. Again with GDB, both sides pre-agree on how the +registers will look (how many, their register number,name and offsets). We +prefer to be able to dynamically determine what kind of architecture, os and +vendor we are debugging, as well as how things are laid out when it comes to +the thread register contexts. Below are the details on the new packets we have +added above and beyond the standard GDB remote protocol packets. + +//---------------------------------------------------------------------- +// "QStartNoAckMode" +// +// Try to enable no ACK mode to skip sending ACKs and NACKs. +//---------------------------------------------------------------------- +Having to send an ACK/NACK after every packet slows things down a bit, so we +have a way to disable ACK packets to mimize the traffic for reliable +communication interfaces (like sockets). Below GDB or LLDB will send this +packet to try and disable ACKs. All lines that start with "send packet: " are +from GDB/LLDB, and all lines that start with "read packet: " are from the GDB +remote server: + +send packet: $QStartNoAckMode#b0 +read packet: + +read packet: $OK#9a +send packet: + + + + +//---------------------------------------------------------------------- +// "A" - launch args packet +// +// Launch a program using the supplied arguments +//---------------------------------------------------------------------- + +We have added support for the "set program arguments" packet where we can +startup a connection to a remote server and then later supply the path to the +executable and the arguments to use when executing: + +GDB remote docs for this: + +set program arguments(reserved) Aarglen,argnum,arg,... + +Where A is followed by the length in bytes of the hex encoded argument, +followed by an argument integer, and followed by the ASCII characters +converted into hex bytes foreach arg + +send packet: $A98,0,2f566f6c756d65732f776f726b2f67636c6179746f6e2f446f63756d656e74732f7372632f6174746163682f612e6f7574#00 +read packet: $OK#00 + +The above packet helps when you have remote debugging abilities where you +could launch a process on a remote host, this isn't needed for bare board +debugging. + +//---------------------------------------------------------------------- +// "QEnvironment:NAME=VALUE" +// +// Setup the environment up for a new child process that will soon be +// launched using the "A" packet. +//---------------------------------------------------------------------- + +Both GDB and LLDB support passing down environment variables. Is it ok to +respond with a "$#00" (unimplemented): + +send packet: $QEnvironment:ACK_COLOR_FILENAME=bold yellow#00 +read packet: $OK#00 + +This packet can be sent one or more times _prior_ to sending a "A" packet. + +//---------------------------------------------------------------------- +// "QSetSTDIN:" +// "QSetSTDOUT:" +// "QSetSTDERR:" +// +// Setup where STDIN, STDOUT, and STDERR go prior to sending an "A" +// packet +//---------------------------------------------------------------------- + +When launching a program through the GDB remote protocol with the "A" packet, +you might also want to specify where stdin/out/err go: + +QSetSTDIN: +QSetSTDOUT: +QSetSTDERR: + +These packets must be sent _prior_ to sending a "A" packet. + +//---------------------------------------------------------------------- +// "QSetWorkingDir:" +// +// Set the working directory prior to sending an "A" packet. +//---------------------------------------------------------------------- + +Or specify the working directory: + +QSetWorkingDir: + +This packet must be sent _prior_ to sending a "A" packet. + +//---------------------------------------------------------------------- +// "QSetDisableASLR:" +// +/// Enable or disable ASLR on the next "A" packet. +//---------------------------------------------------------------------- + +Or control if ASLR is enabled/disabled: + +send packet: QSetDisableASLR:1 +read packet: OK + +send packet: QSetDisableASLR:0 +read packet: OK + +This packet must be sent _prior_ to sending a "A" packet. + +//---------------------------------------------------------------------- +// "qRegisterInfo" +// +// Discover register information from the remote GDB server. +//---------------------------------------------------------------------- + +With LLDB, for register information, remote GDB servers can add support for +the "qRegisterInfoN" packet where "N" is a zero based register number that +must start at zero and increase by one for each register that is supported. +The response is done in typical GDB remote fashion where a serious of +"KEY:VALUE;" pairs are returned. An example for the x86_64 registers is +included below: + +send packet: $qRegisterInfo0#00 +read packet: $name:rax;bitsize:64;offset:0;encoding:uint;format:hex;set:General Purpose Registers;gcc:0;dwarf:0;#00 +send packet: $qRegisterInfo1#00 +read packet: $name:rbx;bitsize:64;offset:8;encoding:uint;format:hex;set:General Purpose Registers;gcc:3;dwarf:3;#00 +send packet: $qRegisterInfo2#00 +read packet: $name:rcx;bitsize:64;offset:16;encoding:uint;format:hex;set:General Purpose Registers;gcc:2;dwarf:2;#00 +send packet: $qRegisterInfo3#00 +read packet: $name:rdx;bitsize:64;offset:24;encoding:uint;format:hex;set:General Purpose Registers;gcc:1;dwarf:1;#00 +send packet: $qRegisterInfo4#00 +read packet: $name:rdi;bitsize:64;offset:32;encoding:uint;format:hex;set:General Purpose Registers;gcc:5;dwarf:5;#00 +send packet: $qRegisterInfo5#00 +read packet: $name:rsi;bitsize:64;offset:40;encoding:uint;format:hex;set:General Purpose Registers;gcc:4;dwarf:4;#00 +send packet: $qRegisterInfo6#00 +read packet: $name:rbp;alt-name:fp;bitsize:64;offset:48;encoding:uint;format:hex;set:General Purpose Registers;gcc:6;dwarf:6;generic:fp;#00 +send packet: $qRegisterInfo7#00 +read packet: $name:rsp;alt-name:sp;bitsize:64;offset:56;encoding:uint;format:hex;set:General Purpose Registers;gcc:7;dwarf:7;generic:sp;#00 +send packet: $qRegisterInfo8#00 +read packet: $name:r8;bitsize:64;offset:64;encoding:uint;format:hex;set:General Purpose Registers;gcc:8;dwarf:8;#00 +send packet: $qRegisterInfo9#00 +read packet: $name:r9;bitsize:64;offset:72;encoding:uint;format:hex;set:General Purpose Registers;gcc:9;dwarf:9;#00 +send packet: $qRegisterInfoa#00 +read packet: $name:r10;bitsize:64;offset:80;encoding:uint;format:hex;set:General Purpose Registers;gcc:10;dwarf:10;#00 +send packet: $qRegisterInfob#00 +read packet: $name:r11;bitsize:64;offset:88;encoding:uint;format:hex;set:General Purpose Registers;gcc:11;dwarf:11;#00 +send packet: $qRegisterInfoc#00 +read packet: $name:r12;bitsize:64;offset:96;encoding:uint;format:hex;set:General Purpose Registers;gcc:12;dwarf:12;#00 +send packet: $qRegisterInfod#00 +read packet: $name:r13;bitsize:64;offset:104;encoding:uint;format:hex;set:General Purpose Registers;gcc:13;dwarf:13;#00 +send packet: $qRegisterInfoe#00 +read packet: $name:r14;bitsize:64;offset:112;encoding:uint;format:hex;set:General Purpose Registers;gcc:14;dwarf:14;#00 +send packet: $qRegisterInfof#00 +read packet: $name:r15;bitsize:64;offset:120;encoding:uint;format:hex;set:General Purpose Registers;gcc:15;dwarf:15;#00 +send packet: $qRegisterInfo10#00 +read packet: $name:rip;alt-name:pc;bitsize:64;offset:128;encoding:uint;format:hex;set:General Purpose Registers;gcc:16;dwarf:16;generic:pc;#00 +send packet: $qRegisterInfo11#00 +read packet: $name:rflags;alt-name:flags;bitsize:64;offset:136;encoding:uint;format:hex;set:General Purpose Registers;#00 +send packet: $qRegisterInfo12#00 +read packet: $name:cs;bitsize:64;offset:144;encoding:uint;format:hex;set:General Purpose Registers;#00 +send packet: $qRegisterInfo13#00 +read packet: $name:fs;bitsize:64;offset:152;encoding:uint;format:hex;set:General Purpose Registers;#00 +send packet: $qRegisterInfo14#00 +read packet: $name:gs;bitsize:64;offset:160;encoding:uint;format:hex;set:General Purpose Registers;#00 +send packet: $qRegisterInfo15#00 +read packet: $name:fctrl;bitsize:16;offset:176;encoding:uint;format:hex;set:Floating Point Registers;#00 +send packet: $qRegisterInfo16#00 +read packet: $name:fstat;bitsize:16;offset:178;encoding:uint;format:hex;set:Floating Point Registers;#00 +send packet: $qRegisterInfo17#00 +read packet: $name:ftag;bitsize:8;offset:180;encoding:uint;format:hex;set:Floating Point Registers;#00 +send packet: $qRegisterInfo18#00 +read packet: $name:fop;bitsize:16;offset:182;encoding:uint;format:hex;set:Floating Point Registers;#00 +send packet: $qRegisterInfo19#00 +read packet: $name:fioff;bitsize:32;offset:184;encoding:uint;format:hex;set:Floating Point Registers;#00 +send packet: $qRegisterInfo1a#00 +read packet: $name:fiseg;bitsize:16;offset:188;encoding:uint;format:hex;set:Floating Point Registers;#00 +send packet: $qRegisterInfo1b#00 +read packet: $name:fooff;bitsize:32;offset:192;encoding:uint;format:hex;set:Floating Point Registers;#00 +send packet: $qRegisterInfo1c#00 +read packet: $name:foseg;bitsize:16;offset:196;encoding:uint;format:hex;set:Floating Point Registers;#00 +send packet: $qRegisterInfo1d#00 +read packet: $name:mxcsr;bitsize:32;offset:200;encoding:uint;format:hex;set:Floating Point Registers;#00 +send packet: $qRegisterInfo1e#00 +read packet: $name:mxcsrmask;bitsize:32;offset:204;encoding:uint;format:hex;set:Floating Point Registers;#00 +send packet: $qRegisterInfo1f#00 +read packet: $name:stmm0;bitsize:80;offset:208;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:33;dwarf:33;#00 +send packet: $qRegisterInfo20#00 +read packet: $name:stmm1;bitsize:80;offset:224;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:34;dwarf:34;#00 +send packet: $qRegisterInfo21#00 +read packet: $name:stmm2;bitsize:80;offset:240;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:35;dwarf:35;#00 +send packet: $qRegisterInfo22#00 +read packet: $name:stmm3;bitsize:80;offset:256;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:36;dwarf:36;#00 +send packet: $qRegisterInfo23#00 +read packet: $name:stmm4;bitsize:80;offset:272;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:37;dwarf:37;#00 +send packet: $qRegisterInfo24#00 +read packet: $name:stmm5;bitsize:80;offset:288;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:38;dwarf:38;#00 +send packet: $qRegisterInfo25#00 +read packet: $name:stmm6;bitsize:80;offset:304;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:39;dwarf:39;#00 +send packet: $qRegisterInfo26#00 +read packet: $name:stmm7;bitsize:80;offset:320;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:40;dwarf:40;#00 +send packet: $qRegisterInfo27#00 +read packet: $name:xmm0;bitsize:128;offset:336;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:17;dwarf:17;#00 +send packet: $qRegisterInfo28#00 +read packet: $name:xmm1;bitsize:128;offset:352;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:18;dwarf:18;#00 +send packet: $qRegisterInfo29#00 +read packet: $name:xmm2;bitsize:128;offset:368;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:19;dwarf:19;#00 +send packet: $qRegisterInfo2a#00 +read packet: $name:xmm3;bitsize:128;offset:384;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:20;dwarf:20;#00 +send packet: $qRegisterInfo2b#00 +read packet: $name:xmm4;bitsize:128;offset:400;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:21;dwarf:21;#00 +send packet: $qRegisterInfo2c#00 +read packet: $name:xmm5;bitsize:128;offset:416;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:22;dwarf:22;#00 +send packet: $qRegisterInfo2d#00 +read packet: $name:xmm6;bitsize:128;offset:432;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:23;dwarf:23;#00 +send packet: $qRegisterInfo2e#00 +read packet: $name:xmm7;bitsize:128;offset:448;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:24;dwarf:24;#00 +send packet: $qRegisterInfo2f#00 +read packet: $name:xmm8;bitsize:128;offset:464;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:25;dwarf:25;#00 +send packet: $qRegisterInfo30#00 +read packet: $name:xmm9;bitsize:128;offset:480;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:26;dwarf:26;#00 +send packet: $qRegisterInfo31#00 +read packet: $name:xmm10;bitsize:128;offset:496;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:27;dwarf:27;#00 +send packet: $qRegisterInfo32#00 +read packet: $name:xmm11;bitsize:128;offset:512;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:28;dwarf:28;#00 +send packet: $qRegisterInfo33#00 +read packet: $name:xmm12;bitsize:128;offset:528;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:29;dwarf:29;#00 +send packet: $qRegisterInfo34#00 +read packet: $name:xmm13;bitsize:128;offset:544;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:30;dwarf:30;#00 +send packet: $qRegisterInfo35#00 +read packet: $name:xmm14;bitsize:128;offset:560;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:31;dwarf:31;#00 +send packet: $qRegisterInfo36#00 +read packet: $name:xmm15;bitsize:128;offset:576;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:32;dwarf:32;#00 +send packet: $qRegisterInfo37#00 +read packet: $name:trapno;bitsize:32;offset:696;encoding:uint;format:hex;set:Exception State Registers;#00 +send packet: $qRegisterInfo38#00 +read packet: $name:err;bitsize:32;offset:700;encoding:uint;format:hex;set:Exception State Registers;#00 +send packet: $qRegisterInfo39#00 +read packet: $name:faultvaddr;bitsize:64;offset:704;encoding:uint;format:hex;set:Exception State Registers;#00 +send packet: $qRegisterInfo3a#00 +read packet: $E45#00 + +As we see above we keep making subsequent calls to the remote server to +discover all registers by increasing the number appended to qRegisterInfo and +we get a response back that is a series of "key=value;" strings. The keys and +values are detailed below: + +Key Value +========== ================================================================ +name The primary register name as a string ("rbp" for example) + +alt-name An alternate name for a register as a string ("fp" for example for + the above "rbp") + +bitsize Size in bits of a register (32, 64, etc) + +offset The offset within the "g" and "G" packet of the register data for + this register + +encoding The encoding type of the register which must be one of: + + uint (unsigned integer) + sint (signed integer) + ieee754 (IEEE 754 float) + vector (vector regsiter) + +format The preferred format for display of this register. The value must + be one of: + + binary + decimal + hex + float + vector-sint8 + vector-uint8 + vector-sint16 + vector-uint16 + vector-sint32 + vector-uint32 + vector-float32 + vector-uint128 + +set The regiter set name as a string that this register belongs to. + +gcc The GCC compiler registers number for this register (used for + EH frame and other compiler information that is encoded in the + executable files). + + NOTE: If the compiler doesn't have a register number for this + register, this key/value pair should be omitted. + +dwarf The DWARF register number for this register that is used for this + register in the debug information. + + NOTE: If the compiler doesn't have a register number for this + register, this key/value pair should be omitted. + +generic If the register is a generic register that most CPUs have, classify + it correctly so the debugger knows. Valid values are one of: + pc (a program counter register. for example "name=eip;" (i386), + "name=rip;" (x86_64), "name=r15;" (32 bit arm) would + include a "generic=pc;" key value pair) + sp (a stack pointer register. for example "name=esp;" (i386), + "name=rsp;" (x86_64), "name=r13;" (32 bit arm) would + include a "generic=sp;" key value pair) + fp (a frame pointer register. for example "name=ebp;" (i386), + "name=rbp;" (x86_64), "name=r7;" (32 bit arm with macosx + ABI) would include a "generic=fp;" key value pair) + ra (a return address register. for example "name=lr;" (32 bit ARM) + would include a "generic=ra;" key value pair) + fp (a CPU flags register. for example "name=eflags;" (i386), + "name=rflags;" (x86_64), "name=cpsr;" (32 bit ARM) + would include a "generic=flags;" key value pair) + arg1 - arg8 (specified for registers that contain function + arguments when the argument fits into a register) + +//---------------------------------------------------------------------- +// "qHostInfo" +// +// Get information about the host we are remotely connected to. +//---------------------------------------------------------------------- + +LLDB supports a host info call that gets all sorts of details of the system +that is being debugged: + +send packet: $qHostInfo#00 +read packet: $cputype:16777223;cpusubtype:3;ostype:darwin;vendor:apple;endian:little;ptrsize:8;#00 + +Key value pairs are one of: + +cputype: is a number that is the mach-o CPU type that is being debugged +cpusubtype: is a number that is the mach-o CPU subtype type that is being debugged +ostype: is a string the represents the OS being debugged (darwin, lunix, freebsd) +vendor: is a string that represents the vendor (apple) +endian: is one of "little", "big", or "pdp" +ptrsize: is a number that represents how big pointers are in bytes on the debug target + +//---------------------------------------------------------------------- +// "qShlibInfoAddr" +// +// Get an address where the dynamic linker stores information about +// where shared libraries are loaded. +//---------------------------------------------------------------------- + +LLDB and GDB both support the "qShlibInfoAddr" packet which is a hint to each +debugger as to where to find the dynamic loader information. For darwin +binaires that run in user land this is the address of the "all_image_infos" +stucture in the "/usr/lib/dyld" executable, or the result of a TASK_DYLD_INFO +call. The result is returned as big endian hex bytes that are the address +value: + +send packet: $qShlibInfoAddr#00 +read packet: $7fff5fc40040#00 + + + +//---------------------------------------------------------------------- +// "qThreadStopInfo" +// +// Get information about why a thread, whose ID is "", is stopped. +//---------------------------------------------------------------------- + +LLDB tries to use the "qThreadStopInfo" packet which is formatted as +"qThreadStopInfo%x" where %x is the hex thread ID. This requests information +about why a thread is stopped. The response is the same as the stop reply +packets and tells us what happened to the other threads. The standard GDB +remote packets love to think that there is only _one_ reason that _one_ thread +stops at a time. This allows us to see why all threads stopped and allows us +to implement better multi-threaded debugging support. + +//---------------------------------------------------------------------- +// "QThreadSuffixSupported" +// +// Try to enable thread suffix support for the 'g', 'G', 'p', and 'P' +// packets. +//---------------------------------------------------------------------- + +When reading thread registers, you currently need to set the current +thread,then read the registers. This is kind of cumbersome, so we added the +ability to query if the remote GDB server supports adding a "thread:;" +suffix to all packets that request information for a thread. To test if the +remote GDB server supports this feature: + +send packet: $QThreadSuffixSupported#00 +read packet: OK + +If "OK" is returned, then the 'g', 'G', 'p' and 'P' packets can accept a +thread suffix. So to send a 'g' packet (read all register values): + +send packet: $g;thread:;#00 +read packet: .... + +send packet: $G;thread:;#00 +read packet: .... + +send packet: $p1a;thread:;#00 +read packet: .... + +send packet: $P1a=1234abcd;thread:;#00 +read packet: .... + + +otherwise, without this you would need to always send two packets: + +send packet: $Hg#00 +read packet: .... +send packet: $g#00 +read packet: .... + +We also added support for allocating and deallocating memory. We use this to +allocate memory so we can run JITed code. + +//---------------------------------------------------------------------- +// "_M," +// +// Allocate memory on the remote target with the specified size and +// permissions. +//---------------------------------------------------------------------- + +The allocate memory packet starts with "_M,". It returns a +raw big endian address value, or "" for unimplemented, or "EXX" for an error +code. The packet is formatted as: + +char packet[256]; +int packet_len; +packet_len = ::snprintf ( + packet, + sizeof(packet), + "_M%zx,%s%s%s", + (size_t)size, + permissions & lldb::ePermissionsReadable ? "r" : "", + permissions & lldb::ePermissionsWritable ? "w" : "", + permissions & lldb::ePermissionsExecutable ? "x" : ""); + +You request a size and give the permissions. This packet does NOT need to be +implemented if you don't want to support running JITed code. The return value +is just the address of the newly allocated memory as raw big endian hex bytes. + +//---------------------------------------------------------------------- +// "_m" +// +// Deallocate memory that was previously allocated using an allocate +// memory pack. +//---------------------------------------------------------------------- + +The deallocate memory packet is "_m" where you pass in the address you +got back from a previous call to the allocate memory packet. It returns "OK" +if the memory was successfully deallocated, or "EXX" for an error, or "" if +not supported. + +//---------------------------------------------------------------------- +// "qMemoryRegionInfo:" +// +// Get information about the address the range that contains "" +//---------------------------------------------------------------------- + +We added a way to get information for a memory region. The packet is: + + qMemoryRegionInfo: + +Where is a big endian hex address. The response is returned in a series +of tuples like the data returned in a stop reply packet. The currently valid +tuples tp return are: + + start:; // is a big endian hex address that is + // the start address of the range that contains + + size:; // is a big endian hex byte size of the address + // of the range that contains + + permissions:; // is a string that contains one + // or more of the characters from "rwx" + + error:; // where is + // a hex encoded string value that + // contains an error string + + + \ No newline at end of file From scallanan at apple.com Mon Nov 28 18:42:02 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 29 Nov 2011 00:42:02 -0000 Subject: [Lldb-commits] [lldb] r145342 - in /lldb/trunk: include/lldb/Symbol/ClangASTImporter.h source/Expression/ClangASTSource.cpp source/Symbol/ClangASTImporter.cpp Message-ID: <20111129004202.6A4212A6C12C@llvm.org> Author: spyffe Date: Mon Nov 28 18:42:02 2011 New Revision: 145342 URL: http://llvm.org/viewvc/llvm-project?rev=145342&view=rev Log: Changed ClangASTImporter to allow finer-grained management of what allocations remain after an expression finishes executing. This saves around 2.5KiB per expression for simple expressions. Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Symbol/ClangASTImporter.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTImporter.h?rev=145342&r1=145341&r2=145342&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTImporter.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Mon Nov 28 18:42:02 2011 @@ -106,7 +106,8 @@ void BuildNamespaceMap (const clang::NamespaceDecl *decl); - void PurgeMaps (clang::ASTContext *dest_ast_ctx); + void ForgetDestination (clang::ASTContext *dst_ctx); + void ForgetSource (clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx); private: struct DeclOrigin { Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=145342&r1=145341&r2=145342&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Mon Nov 28 18:42:02 2011 @@ -24,7 +24,20 @@ ClangASTSource::~ClangASTSource() { - m_ast_importer->PurgeMaps(m_ast_context); + m_ast_importer->ForgetDestination(m_ast_context); + + ClangASTContext *scratch_clang_ast_context = m_target->GetScratchClangASTContext(); + + if (!scratch_clang_ast_context) + return; + + clang::ASTContext *scratch_ast_context = scratch_clang_ast_context->getASTContext(); + + if (!scratch_ast_context) + return; + + if (m_ast_context != scratch_ast_context) + m_ast_importer->ForgetSource(scratch_ast_context, m_ast_context); } void Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=145342&r1=145341&r2=145342&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Mon Nov 28 18:42:02 2011 @@ -179,11 +179,32 @@ } void -ClangASTImporter::PurgeMaps (clang::ASTContext *dst_ast) +ClangASTImporter::ForgetDestination (clang::ASTContext *dst_ast) { m_metadata_map.erase(dst_ast); } +void +ClangASTImporter::ForgetSource (clang::ASTContext *dst_ast, clang::ASTContext *src_ast) +{ + ASTContextMetadataSP md = MaybeGetContextMetadata (dst_ast); + + if (!md) + return; + + md->m_minions.erase(src_ast); + + for (OriginMap::iterator iter = md->m_origins.begin(); + iter != md->m_origins.end(); + ) + { + if (iter->second.ctx == src_ast) + md->m_origins.erase(iter++); + else + ++iter; + } +} + ClangASTImporter::NamespaceMapCompleter::~NamespaceMapCompleter () { return; From johnny.chen at apple.com Mon Nov 28 19:09:49 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 29 Nov 2011 01:09:49 -0000 Subject: [Lldb-commits] [lldb] r145345 - in /lldb/trunk/source/Plugins: Disassembler/llvm/DisassemblerLLVM.cpp UnwindAssembly/x86/UnwindAssembly-x86.cpp Message-ID: <20111129010950.150B52A6C12C@llvm.org> Author: johnny Date: Mon Nov 28 19:09:49 2011 New Revision: 145345 URL: http://llvm.org/viewvc/llvm-project?rev=145345&view=rev Log: Patch from Daniel Dunbar for future-proof against http://llvm.org/viewvc/llvm-project?view=rev&revision=145331. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=145345&r1=145344&r2=145345&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Mon Nov 28 19:09:49 2011 @@ -10,6 +10,7 @@ #include "DisassemblerLLVM.h" #include "llvm-c/EnhancedDisassembly.h" +#include "llvm/Support/TargetSelect.h" #include "lldb/Core/Address.h" #include "lldb/Core/DataExtractor.h" @@ -669,6 +670,16 @@ m_disassembler (NULL), m_disassembler_thumb (NULL) // For ARM only { + // Initialize the LLVM objects needed to use the disassembler. + static struct InitializeLLVM { + InitializeLLVM() { + llvm::InitializeAllTargetInfos(); + llvm::InitializeAllTargetMCs(); + llvm::InitializeAllAsmParsers(); + llvm::InitializeAllDisassemblers(); + } + } InitializeLLVM; + const std::string &arch_triple = arch.GetTriple().str(); if (!arch_triple.empty()) { Modified: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp?rev=145345&r1=145344&r2=145345&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp Mon Nov 28 19:09:49 2011 @@ -10,6 +10,7 @@ #include "UnwindAssembly-x86.h" #include "llvm-c/EnhancedDisassembly.h" +#include "llvm/Support/TargetSelect.h" #include "lldb/Core/Address.h" #include "lldb/Core/Error.h" @@ -489,6 +490,16 @@ else triple = "x86_64-unknown-unknown"; + // Initialize the LLVM objects needed to use the disassembler. + static struct InitializeLLVM { + InitializeLLVM() { + llvm::InitializeAllTargetInfos(); + llvm::InitializeAllTargetMCs(); + llvm::InitializeAllAsmParsers(); + llvm::InitializeAllDisassemblers(); + } + } InitializeLLVM; + EDDisassemblerRef disasm; EDInstRef cur_insn; From gclayton at apple.com Mon Nov 28 19:44:07 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 29 Nov 2011 01:44:07 -0000 Subject: [Lldb-commits] [lldb] r145357 - /lldb/trunk/docs/lldb-gdb-remote.txt Message-ID: <20111129014407.DDD7C2A6C12C@llvm.org> Author: gclayton Date: Mon Nov 28 19:44:07 2011 New Revision: 145357 URL: http://llvm.org/viewvc/llvm-project?rev=145357&view=rev Log: I added more complete documentation on all of the new packets we use in LLDB as well as attached a new priority description as to why and when you would want to implement each packet. Also documented the additions we have made to the stop reply packet and why the extra information is necessary. Modified: lldb/trunk/docs/lldb-gdb-remote.txt Modified: lldb/trunk/docs/lldb-gdb-remote.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-gdb-remote.txt?rev=145357&r1=145356&r2=145357&view=diff ============================================================================== --- lldb/trunk/docs/lldb-gdb-remote.txt (original) +++ lldb/trunk/docs/lldb-gdb-remote.txt Mon Nov 28 19:44:07 2011 @@ -18,7 +18,13 @@ //---------------------------------------------------------------------- // "QStartNoAckMode" // -// Try to enable no ACK mode to skip sending ACKs and NACKs. +// BRIEF +// Try to enable no ACK mode to skip sending ACKs and NACKs. +// +// PRIORITY TO IMPLEMENT +// High. Any GDB remote server that can implement this should if the +// connection is reliable. This improves packet throughput and increases +// the performance of the connection. //---------------------------------------------------------------------- Having to send an ACK/NACK after every packet slows things down a bit, so we have a way to disable ACK packets to mimize the traffic for reliable @@ -37,7 +43,13 @@ //---------------------------------------------------------------------- // "A" - launch args packet // -// Launch a program using the supplied arguments +// BRIEF +// Launch a program using the supplied arguments +// +// PRIORITY TO IMPLEMENT +// Low. Only needed if the remote target wants to launch a target after +// making a connection to a GDB server that isn't already connected to +// an inferior process. //---------------------------------------------------------------------- We have added support for the "set program arguments" packet where we can @@ -46,7 +58,7 @@ GDB remote docs for this: -set program arguments(reserved) Aarglen,argnum,arg,... +set program arguments(reserved) Aarglen,argnum,arg,... Where A is followed by the length in bytes of the hex encoded argument, followed by an argument integer, and followed by the ASCII characters @@ -62,8 +74,14 @@ //---------------------------------------------------------------------- // "QEnvironment:NAME=VALUE" // -// Setup the environment up for a new child process that will soon be -// launched using the "A" packet. +// BRIEF +// Setup the environment up for a new child process that will soon be +// launched using the "A" packet. +// +// PRIORITY TO IMPLEMENT +// Low. Only needed if the remote target wants to launch a target after +// making a connection to a GDB server that isn't already connected to +// an inferior process. //---------------------------------------------------------------------- Both GDB and LLDB support passing down environment variables. Is it ok to @@ -79,8 +97,14 @@ // "QSetSTDOUT:" // "QSetSTDERR:" // -// Setup where STDIN, STDOUT, and STDERR go prior to sending an "A" -// packet +// BRIEF +// Setup where STDIN, STDOUT, and STDERR go prior to sending an "A" +// packet. +// +// PRIORITY TO IMPLEMENT +// Low. Only needed if the remote target wants to launch a target after +// making a connection to a GDB server that isn't already connected to +// an inferior process. //---------------------------------------------------------------------- When launching a program through the GDB remote protocol with the "A" packet, @@ -95,7 +119,13 @@ //---------------------------------------------------------------------- // "QSetWorkingDir:" // -// Set the working directory prior to sending an "A" packet. +// BRIEF +// Set the working directory prior to sending an "A" packet. +// +// PRIORITY TO IMPLEMENT +// Low. Only needed if the remote target wants to launch a target after +// making a connection to a GDB server that isn't already connected to +// an inferior process. //---------------------------------------------------------------------- Or specify the working directory: @@ -107,7 +137,14 @@ //---------------------------------------------------------------------- // "QSetDisableASLR:" // -/// Enable or disable ASLR on the next "A" packet. +// BRIEF +// Enable or disable ASLR on the next "A" packet. +// +// PRIORITY TO IMPLEMENT +// Low. Only needed if the remote target wants to launch a target after +// making a connection to a GDB server that isn't already connected to +// an inferior process and if the target supports disabling ASLR +// (Address space layout randomization). //---------------------------------------------------------------------- Or control if ASLR is enabled/disabled: @@ -123,7 +160,14 @@ //---------------------------------------------------------------------- // "qRegisterInfo" // -// Discover register information from the remote GDB server. +// BRIEF +// Discover register information from the remote GDB server. +// +// PRIORITY TO IMPLEMENT +// High. Any target that can self describe its registers, should do so. +// This means if new registers are ever added to a remote target, they +// will get picked up automatically, and allows registers to change +// depending on the actual CPU type that is used. //---------------------------------------------------------------------- With LLDB, for register information, remote GDB servers can add support for @@ -271,65 +315,71 @@ encoding The encoding type of the register which must be one of: - uint (unsigned integer) - sint (signed integer) - ieee754 (IEEE 754 float) - vector (vector regsiter) - -format The preferred format for display of this register. The value must - be one of: - - binary - decimal - hex - float - vector-sint8 - vector-uint8 - vector-sint16 - vector-uint16 - vector-sint32 - vector-uint32 - vector-float32 - vector-uint128 - -set The regiter set name as a string that this register belongs to. - -gcc The GCC compiler registers number for this register (used for - EH frame and other compiler information that is encoded in the - executable files). - - NOTE: If the compiler doesn't have a register number for this - register, this key/value pair should be omitted. - -dwarf The DWARF register number for this register that is used for this - register in the debug information. - - NOTE: If the compiler doesn't have a register number for this - register, this key/value pair should be omitted. - -generic If the register is a generic register that most CPUs have, classify - it correctly so the debugger knows. Valid values are one of: - pc (a program counter register. for example "name=eip;" (i386), - "name=rip;" (x86_64), "name=r15;" (32 bit arm) would - include a "generic=pc;" key value pair) - sp (a stack pointer register. for example "name=esp;" (i386), - "name=rsp;" (x86_64), "name=r13;" (32 bit arm) would - include a "generic=sp;" key value pair) - fp (a frame pointer register. for example "name=ebp;" (i386), - "name=rbp;" (x86_64), "name=r7;" (32 bit arm with macosx - ABI) would include a "generic=fp;" key value pair) - ra (a return address register. for example "name=lr;" (32 bit ARM) - would include a "generic=ra;" key value pair) - fp (a CPU flags register. for example "name=eflags;" (i386), - "name=rflags;" (x86_64), "name=cpsr;" (32 bit ARM) - would include a "generic=flags;" key value pair) - arg1 - arg8 (specified for registers that contain function - arguments when the argument fits into a register) + uint (unsigned integer) + sint (signed integer) + ieee754 (IEEE 754 float) + vector (vector regsiter) + +format The preferred format for display of this register. The value must + be one of: + + binary + decimal + hex + float + vector-sint8 + vector-uint8 + vector-sint16 + vector-uint16 + vector-sint32 + vector-uint32 + vector-float32 + vector-uint128 + +set The regiter set name as a string that this register belongs to. + +gcc The GCC compiler registers number for this register (used for + EH frame and other compiler information that is encoded in the + executable files). + + NOTE: If the compiler doesn't have a register number for this + register, this key/value pair should be omitted. + +dwarf The DWARF register number for this register that is used for this + register in the debug information. + + NOTE: If the compiler doesn't have a register number for this + register, this key/value pair should be omitted. + +generic If the register is a generic register that most CPUs have, classify + it correctly so the debugger knows. Valid values are one of: + pc (a program counter register. for example "name=eip;" (i386), + "name=rip;" (x86_64), "name=r15;" (32 bit arm) would + include a "generic=pc;" key value pair) + sp (a stack pointer register. for example "name=esp;" (i386), + "name=rsp;" (x86_64), "name=r13;" (32 bit arm) would + include a "generic=sp;" key value pair) + fp (a frame pointer register. for example "name=ebp;" (i386), + "name=rbp;" (x86_64), "name=r7;" (32 bit arm with macosx + ABI) would include a "generic=fp;" key value pair) + ra (a return address register. for example "name=lr;" (32 bit ARM) + would include a "generic=ra;" key value pair) + fp (a CPU flags register. for example "name=eflags;" (i386), + "name=rflags;" (x86_64), "name=cpsr;" (32 bit ARM) + would include a "generic=flags;" key value pair) + arg1 - arg8 (specified for registers that contain function + arguments when the argument fits into a register) //---------------------------------------------------------------------- // "qHostInfo" // -// Get information about the host we are remotely connected to. +// BRIEF +// Get information about the host we are remotely connected to. +// +// PRIORITY TO IMPLEMENT +// High. This packet is usually very easy to implement and can help +// LLDB select the correct plug-ins for the job based on the target +// triple information that is suppied. //---------------------------------------------------------------------- LLDB supports a host info call that gets all sorts of details of the system @@ -350,8 +400,19 @@ //---------------------------------------------------------------------- // "qShlibInfoAddr" // -// Get an address where the dynamic linker stores information about -// where shared libraries are loaded. +// BRIEF +// Get an address where the dynamic linker stores information about +// where shared libraries are loaded. +// +// PRIORITY TO IMPLEMENT +// High if you have a dynamic loader plug-in in LLDB for your target +// triple (see the "qHostInfo" packet) that can use this information. +// Many times address load randomization can make it hard to detect +// where the dynamic loader binary and data structures are located and +// some platforms know, or can find out where this information is. +// +// Low if you have a debug target where all object and symbol files +// contain static load addresses. //---------------------------------------------------------------------- LLDB and GDB both support the "qShlibInfoAddr" packet which is a hint to each @@ -369,9 +430,19 @@ //---------------------------------------------------------------------- // "qThreadStopInfo" // -// Get information about why a thread, whose ID is "", is stopped. +// BRIEF +// Get information about why a thread, whose ID is "", is stopped. +// +// PRIORITY TO IMPLEMENT +// High if you need to support multi-threaded or multi-core debugging. +// Many times one thread will hit a breakpoint and while the debugger +// is in the process of suspending the other threads, other threads +// will also hit a breakpoint. This packet allows LLDB to know why all +// threads (live system debug) / cores (JTAG) in your program have +// stopped and allows LLDB to display and control your program +// correctly. //---------------------------------------------------------------------- - + LLDB tries to use the "qThreadStopInfo" packet which is formatted as "qThreadStopInfo%x" where %x is the hex thread ID. This requests information about why a thread is stopped. The response is the same as the stop reply @@ -383,8 +454,18 @@ //---------------------------------------------------------------------- // "QThreadSuffixSupported" // -// Try to enable thread suffix support for the 'g', 'G', 'p', and 'P' -// packets. +// BRIEF +// Try to enable thread suffix support for the 'g', 'G', 'p', and 'P' +// packets. +// +// PRIORITY TO IMPLEMENT +// High. Adding a thread suffix allows us to read and write registers +// more efficiently and stops us from having to select a thread with +// one packet and then read registers with a second packet. It also +// makes sure that no errors can occur where the debugger thinks it +// already has a thread selected (see the "Hg" packet from the standard +// GDB remote protocol documentation) yet the remote GDB server actually +// has another thread selected. //---------------------------------------------------------------------- When reading thread registers, you currently need to set the current @@ -425,8 +506,15 @@ //---------------------------------------------------------------------- // "_M," // -// Allocate memory on the remote target with the specified size and -// permissions. +// BRIEF +// Allocate memory on the remote target with the specified size and +// permissions. +// +// PRIORITY TO IMPLEMENT +// High if you want LLDB to be able to JIT code and run that code. JIT +// code also needs data which is also allocated and tracked. +// +// Low if you don't support running JIT'ed code. //---------------------------------------------------------------------- The allocate memory packet starts with "_M,". It returns a @@ -436,13 +524,13 @@ char packet[256]; int packet_len; packet_len = ::snprintf ( - packet, - sizeof(packet), - "_M%zx,%s%s%s", - (size_t)size, - permissions & lldb::ePermissionsReadable ? "r" : "", - permissions & lldb::ePermissionsWritable ? "w" : "", - permissions & lldb::ePermissionsExecutable ? "x" : ""); + packet, + sizeof(packet), + "_M%zx,%s%s%s", + (size_t)size, + permissions & lldb::ePermissionsReadable ? "r" : "", + permissions & lldb::ePermissionsWritable ? "w" : "", + permissions & lldb::ePermissionsExecutable ? "x" : ""); You request a size and give the permissions. This packet does NOT need to be implemented if you don't want to support running JITed code. The return value @@ -451,8 +539,15 @@ //---------------------------------------------------------------------- // "_m" // -// Deallocate memory that was previously allocated using an allocate -// memory pack. +// BRIEF +// Deallocate memory that was previously allocated using an allocate +// memory pack. +// +// PRIORITY TO IMPLEMENT +// High if you want LLDB to be able to JIT code and run that code. JIT +// code also needs data which is also allocated and tracked. +// +// Low if you don't support running JIT'ed code. //---------------------------------------------------------------------- The deallocate memory packet is "_m" where you pass in the address you @@ -463,29 +558,167 @@ //---------------------------------------------------------------------- // "qMemoryRegionInfo:" // -// Get information about the address the range that contains "" +// BRIEF +// Get information about the address the range that contains "" +// +// PRIORITY TO IMPLEMENT +// Medium. This is nice to have, but it isn't necessary. It helps LLDB +// do stack unwinding when we branch into memory that isn't executable. +// If we can detect that the code we are stopped in isn't executable, +// then we can recover registers for stack frames above the current +// frame. Otherwise we must assume we are in some JIT'ed code (not JIT +// code that LLDB has made) and assume that no registers are available +// in higher stack frames. //---------------------------------------------------------------------- We added a way to get information for a memory region. The packet is: - qMemoryRegionInfo: - + qMemoryRegionInfo: + Where is a big endian hex address. The response is returned in a series of tuples like the data returned in a stop reply packet. The currently valid tuples tp return are: - start:; // is a big endian hex address that is - // the start address of the range that contains - - size:; // is a big endian hex byte size of the address - // of the range that contains - - permissions:; // is a string that contains one - // or more of the characters from "rwx" - - error:; // where is - // a hex encoded string value that - // contains an error string - - - \ No newline at end of file + start:; // is a big endian hex address that is + // the start address of the range that contains + + size:; // is a big endian hex byte size of the address + // of the range that contains + + permissions:; // is a string that contains one + // or more of the characters from "rwx" + + error:; // where is + // a hex encoded string value that + // contains an error string + +//---------------------------------------------------------------------- +// Stop reply packet extensions +// +// BRIEF +// This section describes some of the additional information you can +// specify in stop reply packets that help LLDB to know more detailed +// information about your threads. +// +// DESCRIPTION +// Standard GDB remote stop reply packets are reply packets sent in +// response to a packet that made the program run. They come in the +// following forms: +// +// "SAA" +// "S" means signal and "AA" is a hex signal number that describes why +// the thread or stopped. It doesn't specify which thread, so the "T" +// packet is recommended to use instead of the "S" packet. +// +// "TAAkey1:value1;key2:value2;..." +// "T" means a thread stopped due to a unix signal where "AA" is a hex +// signal number that describes why the program stopped. This is +// followed by a series of key/value pairs: +// - If key is a hex number, it is a register number and value is +// the hex value of the register in debuggee endian byte order. +// - If key == "thread", then the value is the big endian hex +// thread-id of the stopped thread. +// - If key == "core", then value is a hex nujber of the core on +// which the stop was detected. +// - If key == "watch" or key == "rwatch" or key == "awatch", then +// value is the data address in big endian hex +// - If key == "library", then value is ignore and "qXfer:libraries:read" +// packets should be used to detect any newly loaded shared libraries +// +// "WAA" +// "W" means the process exited and "AA" is the exit status. +// +// "XAA" +// "X" means the process exited and "AA" is signal that caused the program +// to exit. +// +// "O" +// "O" means STDOUT has data that was written to its console and is +// being delivered to the debugger. This packet happens asynchronously +// and the debugger is expected to continue to way for another stop reply +// packet. +// +// LLDB EXTENSIONS +// +// We have extended the "T" packet to be able to also understand the +// following keys and values: +// +// KEY VALUE DESCRIPTION +// =========== ======== ================================================ +// "metype" unsigned mach exception type (the value of the EXC_XXX enumerations) +// as an unsigned integer. For targets with mach +// kernels only. +// +// "mecount" unsigned mach exception data count as an unsigned integer +// For targets with mach kernels only. +// +// "medata" unsigned There should be "mecount" of these and it is the data +// that goes along with a mach exception (as an unsigned +// integer). For targets with mach kernels only. +// +// "name" string The name of the thread as a plain string. The string +// must not contain an special packet characters or +// contain a ':' or a ';'. Use "hexname" if the thread +// name has special characters. +// +// "hexname" ascii-hex An ASCII hex string that contains the name of the thread +// +// "qaddr" hex Big endian hex value that contains the libdispatch +// queue address for the queue of the thread. +// +// "reason" enum The enumeration must be one of: +// "trace" the program stopped after a single instruction +// was executed on a core. Usually done when single +// stepping past a breakpoint +// "breakpoint" a breakpoint set using a 'z' packet was hit. +// "trap" stopped due to user interruption +// "signal" stopped due to an actual unix signal, not +// just the debugger using a unix signal to keep +// the GDB remote client happy. +// "watchpoint". Should be used in conjunction with +// the "watch"/"rwatch"/"awatch" key value pairs. +// "exception" an exception stop reason. Use with +// the "description" key/value pair to describe the +// exceptional event the user should see as the stop +// reason. +// "description" ascii-hex An ASCII hex string that contains a more descriptive +// reason that the thread stopped. This is only needed +// if none of the key/value pairs are enough to +// describe why something stopped. +// +// BEST PRACTICES: +// Since register values can be supplied with this packet, it is often useful +// to return the PC, SP, FP, LR (if any), and FLAGS regsiters so that separate +// packets don't need to be sent to read each of these registers from each +// thread. +// +// If a thread is stopped for no reason (like just because another thread +// stopped, or because when one core stops all cores should stop), use a +// "T" packet with "00" as the signal number and fill in as many key values +// and registers as possible. +// +// LLDB likes to know why a thread stopped since many thread contol +// operations like stepping over a source line, actually are implemented +// by running the process multiple times. If a breakpoint is hit while +// trying to step over a source line and LLDB finds out that a breakpoint +// is hit in the "reason", we will know to stop trying to do the step +// over because something happened that should stop us from trying to +// do the step. If we are at a breakpoint and we disable the breakpoint +// at the current PC and do an instruction single step, knowing that +// we stopped due to a "trace" helps us know that we can continue +// running versus stopping due to a "breakpoint" (if we have two +// breakpoint instruction on consucutive instructions). So the more info +// we can get about the reason a thread stops, the better job LLDB can +// do when controlling your process. A typical GDB server behavior is +// to send a SIGTRAP for breakpoints _and_ also when instruction single +// stepping, in this case the debugger doesn't really know why we +// stopped and it can make it hard for the debugger to control your +// program correctly. What if a real SIGTRAP was delivered to a thread +// while we were trying to single step? We woudn't know the difference +// with a standard GDB remote server and we could do the wrong thing. +// +// PRIORITY TO IMPLEMENT +// High. Having the extra information in your stop reply packets makes +// your debug session more reliable and informative. +//---------------------------------------------------------------------- + From dawn at burble.org Mon Nov 28 19:47:18 2011 From: dawn at burble.org (dawn at burble.org) Date: Mon, 28 Nov 2011 17:47:18 -0800 Subject: [Lldb-commits] [PATCH] fix debugging on linux In-Reply-To: <06D1CC93-A433-42D5-9332-BEE9142802CA@apple.com> References: <20111124073122.GA13244@bloodbath.burble.org> <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> <20111128195949.GA24208@bloodbath.burble.org> <06D1CC93-A433-42D5-9332-BEE9142802CA@apple.com> Message-ID: <20111129014718.GA29289@bloodbath.burble.org> > Hopefully CanLaunchProcessStoppedAtEntry() makes sense? Yes, that works. And "DebugProcess" becomes "LaunchProcessStoppedAtEntry"? I like this better than DebugProcess, but I'm still not crazy about it :). Linux can launch a process with it stopped at the entry point, it just doesn't want to "attach" to it afterwards. I should backup to the original problem I was trying to solve... DebugProcess is in Target/Platform.cpp - a common module shared by allplatforms, yet it calls "Attach". When the Linux code launches the process (via fork and exec and a ptrace call of PTRACE_TRACEME), lldb will already be debugging the process. Calling "Attach" at this point will do a ptrace call of PTRACE_ATTACH on the process that is already being debugged - not good. How would you suggest we fix this? Move the call to Attach into the MaxOSX LaunchProcess code? Or have a flag like CanLaunchViaAttach so we'll know to skip the call to Attach? I went with the latter in my patch - that seemed the least intrusive yet generic fix. -Dawn On Mon, Nov 28, 2011 at 01:48:35PM -0800, Greg Clayton wrote: > > On Nov 28, 2011, at 11:59 AM, dawn at burble.org wrote: > > > I find the name "CanDebugProcess" to be misleading. The issue isn't > > whether a process can be debugged on Linux (because it obviously can), > > it's that it can't be spawned in a suspended state and then attached > > to. AFAIK, Linux doesn't have anything like the MacOSX > > "POSIX_SPAWN_START_SUSPENDED" flag for posix_spawnattr_setflags() that > > MacOSX has. > > Yes, this flag is darwin only. > > > I chose the name "CanLaunchViaAttach" for this, which I think better > > describes the problem. Ok to rename "CanDebugProcess" to > > "CanLaunchViaAttach"? > > I am not too fond of the CanLaunchViaAttach because launching a program using a platform doesn't imply that you want to debug or attach to it. Also it doesn't make sense how do you launch via attach? First you launch, then you attach. The attach doesn't have anything to do with launching. You might just want to spawn a server program on the remote platform which you don't want to debug. We are asking the platform (not the process plug-in, but the platform) if it can do something, in this case: can the platform launch a process that can be stopped for debugging. Currently the linux platform can't (though I am sure we can make it work somehow), only the native linux _process_ plug-in can. You can't use the ProcessLinux plug-in to implement stuff functionality for the platform, the platform itself should be doing the work. This is preparing for better remote debugging support where we can launch new remote processes without having to involve any of the process plug-ins. > > The attach part shouldn't have anything to do with this either because you might want to spawn a new process that is stopped, and then resume it at a controlled time later. The "POSIX_SPAWN_START_SUSPENDED" flag in darwin will have the process halted at the entry point with a SIGSTOP, and it can be resumed later. > > How about "bool Platform::CanLaunchProcessStoppedAtEntry()"? > > Platforms are far from complete and we can modify them and grow their abilities over time. Again, the vision is that platforms will eventually launch (possibly for debug), attach to processes, list processes, upload/download and more. They should provide a nice connection to a local or remote machine so that debugging to them is as easy as debugging on your local machine. That is the vision at least, and I know we have some work ahead of us to get there. > > > Greg > > > > > Likewise, since you moved the fixes I had made to > > DebugProcess() into CommandObjectProcessLaunch(), please also rename > > "DebugProcess" to "LaunchViaAttach". > > Hopefully CanLaunchProcessStoppedAtEntry() makes sense? > > > Thank you! > > -Dawn > > > > > > On Sun, Nov 27, 2011 at 06:03:03PM -0800, Greg Clayton wrote: > >> > >> On Nov 23, 2011, at 11:31 PM, dawn at burble.org wrote: > >> > >>> This patch was created using clang/llvm rev 144569, lldb rev 144919 but has > >>> been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on > >>> Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. > >>> > >>> Debugging on Linux broke when the assumption was made that a process could be > >>> launched by spawning it in a suspended state and then attaching to it. That > >>> support does not exist on Linux. To work around this, I added a new method > >>> "CanLaunchViaAttach" which tests whether the platform supports being launched > >>> in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find > >>> an easy way to set it from within the Linux plugins. > >>> > >>> Commit message: > >>> > >>> Fix debugging on Linux. > >>> Implement remote vs. host platform code as was done with PlatformDarwin. > >>> Platform::CanLaunchViaAttach(): new: return true if the process can be launched > >>> via spawn and attach. Default is true. Override in PlatformLinux to false. > >>> Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) > >>> then launch the process via CreateProcess and Launch. > >>> > >>> Please review and commit if acceptable. > >> > >> I checked in an alternate fix: > >> > >> % svn commit > >> Sending include/lldb/Core/Module.h > >> Sending include/lldb/Symbol/SymbolFile.h > >> Sending include/lldb/Target/Platform.h > >> Sending source/Commands/CommandObjectProcess.cpp > >> Sending source/Core/Module.cpp > >> Sending source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp > >> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp > >> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h > >> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp > >> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h > >> Sending source/Symbol/SymbolFile.cpp > >> Transmitting file data ........... > >> Committed revision 145219. > >> > >> % svn commit > >> Sending Platform/Linux/PlatformLinux.h > >> Transmitting file data . > >> Committed revision 145221. > >> > >> > >> The first one contains the necessary changes to CommandObjectProcess.cpp and to include/lldb/Target/Platform.h that allow a platform to say: > >> > >> > >> virtual bool > >> CanDebugProcess () > >> { > >> return true; > >> } > >> > >> This keeps the code out of the platform since when a platform launches a process, it shouldn't be tied to a process plug-in as in the patch you submitted. > >> > >> Here is the vision of platforms: > >> > >> - They should be able to list all of the processes on the platform. This way you can connect to your local machine and list the processes, or connect to a remote platform, and if the remote platform supports it, it can list the processes that are there. > >> - Platforms should support launching processes. Not always for debugging, but sometimes just to spawn a child process. On the localhost, this means just using the Host::LaunchProcess() functionality. This way, we just need to implement a single copy of the process launching code. When you create a remote platform, you should be able to link against the native linux or darwin launching code and then we don't end up with multiple copies of the launching code like we have now. You make a good point in that not all platforms will be able to support launching with a program stopped for debugging, so we now ask the platform up in the CommandObjectProcessLaunch class before we launch the process. This keeps the platform clean, yet also lets us fall back to just launching the process through the built in process plug-in. > >> - Platforms should support attaching to a remote process. Combined with being able to launch for debug, this allows debugging as we have it on MacOSX. If we do this while remotely connected to a remote darwin machine, we now have the ability to talk to a remote computer and launch, attach, list and do a lot more > >> - Platforms should know if there are files locally on the current machine in an SDK or PDK or some over developer kit/cross compiling sysroot, etc to allow locating files in terms of the path you would us on the remote machine. For example when debugging on a remote device, if the are asked to find the file for "/bin/ls", this might locally be located in developer kit directory such as > >> "/path/to/old/linux/sysroot/bin/ls". This allows you to debug remote machines, or event mount the root file system on a mountpoint so you have access to the files so you can debug. > >> - Platforms should be able to upload/download files so you could install a new binary and run it, or upload a shared library so we can locally cache it for faster debugging. > >> > >> We are in the process of slowly makine these Platforms a reality, so keep the questions coming if anyone has any. > >> > >> So in short: I made the fix you requested, but in a different way. If you can rework your patch around what is in top of tree, then we can get the rest of it submitted. > >> > >> Greg Clayton > >> > >>> Thanks! > >>> -Dawn > >>> _______________________________________________ > >>> lldb-commits mailing list > >>> lldb-commits at cs.uiuc.edu > >>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From gclayton at apple.com Mon Nov 28 19:58:05 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 28 Nov 2011 17:58:05 -0800 Subject: [Lldb-commits] [PATCH] fix debugging on linux In-Reply-To: <20111129014718.GA29289@bloodbath.burble.org> References: <20111124073122.GA13244@bloodbath.burble.org> <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> <20111128195949.GA24208@bloodbath.burble.org> <06D1CC93-A433-42D5-9332-BEE9142802CA@apple.com> <20111129014718.GA29289@bloodbath.burble.org> Message-ID: On Nov 28, 2011, at 5:47 PM, dawn at burble.org wrote: >> Hopefully CanLaunchProcessStoppedAtEntry() makes sense? > > Yes, that works. And "DebugProcess" becomes > "LaunchProcessStoppedAtEntry"? No, it remains DebugProcess. > I like this better than DebugProcess, > but I'm still not crazy about it :). Linux can launch a process > with it stopped at the entry point, it just doesn't want to "attach" > to it afterwards. As I said before, you can't use your process plug-in to do the launching, the platform should be the one that does this. This is the reason you can't attach right? > > I should backup to the original problem I was trying to solve... DebugProcess > is in Target/Platform.cpp - a common module shared by allplatforms, yet it > calls "Attach". When the Linux code launches the process (via fork and exec > and a ptrace call of PTRACE_TRACEME), lldb will already be debugging the > process. > Calling "Attach" at this point will do a ptrace call of PTRACE_ATTACH > on the process that is already being debugged - not good. Can you have the linux "Host::LaunchProcess()" do the fork, ptrace me, exec, then do the attach? Or must linux have a debug process attached right from the start? > > How would you suggest we fix this? With my fix that is already checked in (the fix to CommandObjectProcessLaunch that first checks to see if the platform can start a process stopped for debugging and if it can't, it will just use the current process plug-in to do the launch directly and skip the platform launch for debug), the linux process plug-in will be used to do the launching and avoid this issue altogether, right? > Move the call to Attach into the MaxOSX > LaunchProcess code? Or have a flag like CanLaunchViaAttach so we'll know to > skip the call to Attach? I went with the latter in my patch - that seemed the > least intrusive yet generic fix. Again, I don't understand the can launch via attach. You should be able to launch a program on linux and then attach to it without a debugger needing to be there from the start, you will just miss many instructions as the process makes progress until you attach. > > -Dawn > > On Mon, Nov 28, 2011 at 01:48:35PM -0800, Greg Clayton wrote: >> >> On Nov 28, 2011, at 11:59 AM, dawn at burble.org wrote: >> >>> I find the name "CanDebugProcess" to be misleading. The issue isn't >>> whether a process can be debugged on Linux (because it obviously can), >>> it's that it can't be spawned in a suspended state and then attached >>> to. AFAIK, Linux doesn't have anything like the MacOSX >>> "POSIX_SPAWN_START_SUSPENDED" flag for posix_spawnattr_setflags() that >>> MacOSX has. >> >> Yes, this flag is darwin only. >> >>> I chose the name "CanLaunchViaAttach" for this, which I think better >>> describes the problem. Ok to rename "CanDebugProcess" to >>> "CanLaunchViaAttach"? >> >> I am not too fond of the CanLaunchViaAttach because launching a program using a platform doesn't imply that you want to debug or attach to it. Also it doesn't make sense how do you launch via attach? First you launch, then you attach. The attach doesn't have anything to do with launching. You might just want to spawn a server program on the remote platform which you don't want to debug. We are asking the platform (not the process plug-in, but the platform) if it can do something, in this case: can the platform launch a process that can be stopped for debugging. Currently the linux platform can't (though I am sure we can make it work somehow), only the native linux _process_ plug-in can. You can't use the ProcessLinux plug-in to implement stuff functionality for the platform, the platform itself should be doing the work. This is preparing for better remote debugging support where we can launch new remote processes without having to involve any of the process plug-ins. >> >> The attach part shouldn't have anything to do with this either because you might want to spawn a new process that is stopped, and then resume it at a controlled time later. The "POSIX_SPAWN_START_SUSPENDED" flag in darwin will have the process halted at the entry point with a SIGSTOP, and it can be resumed later. >> >> How about "bool Platform::CanLaunchProcessStoppedAtEntry()"? >> >> Platforms are far from complete and we can modify them and grow their abilities over time. Again, the vision is that platforms will eventually launch (possibly for debug), attach to processes, list processes, upload/download and more. They should provide a nice connection to a local or remote machine so that debugging to them is as easy as debugging on your local machine. That is the vision at least, and I know we have some work ahead of us to get there. >> >> >> Greg >> >> >> >>> Likewise, since you moved the fixes I had made to >>> DebugProcess() into CommandObjectProcessLaunch(), please also rename >>> "DebugProcess" to "LaunchViaAttach". >> >> Hopefully CanLaunchProcessStoppedAtEntry() makes sense? >> >>> Thank you! >>> -Dawn >>> >>> >>> On Sun, Nov 27, 2011 at 06:03:03PM -0800, Greg Clayton wrote: >>>> >>>> On Nov 23, 2011, at 11:31 PM, dawn at burble.org wrote: >>>> >>>>> This patch was created using clang/llvm rev 144569, lldb rev 144919 but has >>>>> been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on >>>>> Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. >>>>> >>>>> Debugging on Linux broke when the assumption was made that a process could be >>>>> launched by spawning it in a suspended state and then attaching to it. That >>>>> support does not exist on Linux. To work around this, I added a new method >>>>> "CanLaunchViaAttach" which tests whether the platform supports being launched >>>>> in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find >>>>> an easy way to set it from within the Linux plugins. >>>>> >>>>> Commit message: >>>>> >>>>> Fix debugging on Linux. >>>>> Implement remote vs. host platform code as was done with PlatformDarwin. >>>>> Platform::CanLaunchViaAttach(): new: return true if the process can be launched >>>>> via spawn and attach. Default is true. Override in PlatformLinux to false. >>>>> Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) >>>>> then launch the process via CreateProcess and Launch. >>>>> >>>>> Please review and commit if acceptable. >>>> >>>> I checked in an alternate fix: >>>> >>>> % svn commit >>>> Sending include/lldb/Core/Module.h >>>> Sending include/lldb/Symbol/SymbolFile.h >>>> Sending include/lldb/Target/Platform.h >>>> Sending source/Commands/CommandObjectProcess.cpp >>>> Sending source/Core/Module.cpp >>>> Sending source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp >>>> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp >>>> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h >>>> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp >>>> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h >>>> Sending source/Symbol/SymbolFile.cpp >>>> Transmitting file data ........... >>>> Committed revision 145219. >>>> >>>> % svn commit >>>> Sending Platform/Linux/PlatformLinux.h >>>> Transmitting file data . >>>> Committed revision 145221. >>>> >>>> >>>> The first one contains the necessary changes to CommandObjectProcess.cpp and to include/lldb/Target/Platform.h that allow a platform to say: >>>> >>>> >>>> virtual bool >>>> CanDebugProcess () >>>> { >>>> return true; >>>> } >>>> >>>> This keeps the code out of the platform since when a platform launches a process, it shouldn't be tied to a process plug-in as in the patch you submitted. >>>> >>>> Here is the vision of platforms: >>>> >>>> - They should be able to list all of the processes on the platform. This way you can connect to your local machine and list the processes, or connect to a remote platform, and if the remote platform supports it, it can list the processes that are there. >>>> - Platforms should support launching processes. Not always for debugging, but sometimes just to spawn a child process. On the localhost, this means just using the Host::LaunchProcess() functionality. This way, we just need to implement a single copy of the process launching code. When you create a remote platform, you should be able to link against the native linux or darwin launching code and then we don't end up with multiple copies of the launching code like we have now. You make a good point in that not all platforms will be able to support launching with a program stopped for debugging, so we now ask the platform up in the CommandObjectProcessLaunch class before we launch the process. This keeps the platform clean, yet also lets us fall back to just launching the process through the built in process plug-in. >>>> - Platforms should support attaching to a remote process. Combined with being able to launch for debug, this allows debugging as we have it on MacOSX. If we do this while remotely connected to a remote darwin machine, we now have the ability to talk to a remote computer and launch, attach, list and do a lot more >>>> - Platforms should know if there are files locally on the current machine in an SDK or PDK or some over developer kit/cross compiling sysroot, etc to allow locating files in terms of the path you would us on the remote machine. For example when debugging on a remote device, if the are asked to find the file for "/bin/ls", this might locally be located in developer kit directory such as >>>> "/path/to/old/linux/sysroot/bin/ls". This allows you to debug remote machines, or event mount the root file system on a mountpoint so you have access to the files so you can debug. >>>> - Platforms should be able to upload/download files so you could install a new binary and run it, or upload a shared library so we can locally cache it for faster debugging. >>>> >>>> We are in the process of slowly makine these Platforms a reality, so keep the questions coming if anyone has any. >>>> >>>> So in short: I made the fix you requested, but in a different way. If you can rework your patch around what is in top of tree, then we can get the rest of it submitted. >>>> >>>> Greg Clayton >>>> >>>>> Thanks! >>>>> -Dawn >>>>> _______________________________________________ >>>>> lldb-commits mailing list >>>>> lldb-commits at cs.uiuc.edu >>>>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From dawn at burble.org Mon Nov 28 21:28:25 2011 From: dawn at burble.org (dawn at burble.org) Date: Mon, 28 Nov 2011 19:28:25 -0800 Subject: [Lldb-commits] [PATCH] fix debugging on linux In-Reply-To: References: <20111124073122.GA13244@bloodbath.burble.org> <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> <20111128195949.GA24208@bloodbath.burble.org> <06D1CC93-A433-42D5-9332-BEE9142802CA@apple.com> <20111129014718.GA29289@bloodbath.burble.org> Message-ID: <20111129032825.GA31054@bloodbath.burble.org> On Mon, Nov 28, 2011 at 05:58:05PM -0800, Greg Clayton wrote: > > Can you have the linux "Host::LaunchProcess()" do the fork, ptrace me, exec, then do the attach? Or must linux have a debug process attached right from the start? No, both Linux and Windows (and I think BSD as well) will not allow you to attach to a process that you're already debugging. They want to have a debug process attached right from the start. They do support attaching to an existing process that's already running, but that's a different problem - here we want to debug the process form the start. So I think you see the issue now? > > How would you suggest we fix this? > > With my fix that is already checked in (the fix to CommandObjectProcessLaunch that first checks to see if the platform can start a process stopped for debugging and if it can't, it will just use the current process plug-in to do the launch directly and skip the platform launch for debug), the linux process plug-in will be used to do the launching and avoid this issue altogether, right? Yes, but it doesn't fit in with how the process control code was intended to be used - we're skipping the call to DebugProcess just to avoid a call to Attach? And other platforms will have to go this route as well? > > Move the call to Attach into the MaxOSX > > LaunchProcess code? Or have a flag like CanLaunchViaAttach so we'll know to > > skip the call to Attach? I went with the latter in my patch - that seemed the > > least intrusive yet generic fix. > > Again, I don't understand the can launch via attach. You should be able to launch a program on linux and then attach to it without a debugger needing to be there from the start, you will just miss many instructions as the process makes progress until you attach. Exactly - I think you see the problem now :) -Dawn > > On Mon, Nov 28, 2011 at 01:48:35PM -0800, Greg Clayton wrote: > >> > >> On Nov 28, 2011, at 11:59 AM, dawn at burble.org wrote: > >> > >>> I find the name "CanDebugProcess" to be misleading. The issue isn't > >>> whether a process can be debugged on Linux (because it obviously can), > >>> it's that it can't be spawned in a suspended state and then attached > >>> to. AFAIK, Linux doesn't have anything like the MacOSX > >>> "POSIX_SPAWN_START_SUSPENDED" flag for posix_spawnattr_setflags() that > >>> MacOSX has. > >> > >> Yes, this flag is darwin only. > >> > >>> I chose the name "CanLaunchViaAttach" for this, which I think better > >>> describes the problem. Ok to rename "CanDebugProcess" to > >>> "CanLaunchViaAttach"? > >> > >> I am not too fond of the CanLaunchViaAttach because launching a program using a platform doesn't imply that you want to debug or attach to it. Also it doesn't make sense how do you launch via attach? First you launch, then you attach. The attach doesn't have anything to do with launching. You might just want to spawn a server program on the remote platform which you don't want to debug. We are asking the platform (not the process plug-in, but the platform) if it can do something, in this case: can the platform launch a process that can be stopped for debugging. Currently the linux platform can't (though I am sure we can make it work somehow), only the native linux _process_ plug-in can. You can't use the ProcessLinux plug-in to implement stuff functionality for the platform, the platform itself should be doing the work. This is preparing for better remote debugging support where we can launch new remote processes without having to involve any of the process plug-ins. > >> > >> The attach part shouldn't have anything to do with this either because you might want to spawn a new process that is stopped, and then resume it at a controlled time later. The "POSIX_SPAWN_START_SUSPENDED" flag in darwin will have the process halted at the entry point with a SIGSTOP, and it can be resumed later. > >> > >> How about "bool Platform::CanLaunchProcessStoppedAtEntry()"? > >> > >> Platforms are far from complete and we can modify them and grow their abilities over time. Again, the vision is that platforms will eventually launch (possibly for debug), attach to processes, list processes, upload/download and more. They should provide a nice connection to a local or remote machine so that debugging to them is as easy as debugging on your local machine. That is the vision at least, and I know we have some work ahead of us to get there. > >> > >> > >> Greg > >> > >> > >> > >>> Likewise, since you moved the fixes I had made to > >>> DebugProcess() into CommandObjectProcessLaunch(), please also rename > >>> "DebugProcess" to "LaunchViaAttach". > >> > >> Hopefully CanLaunchProcessStoppedAtEntry() makes sense? > >> > >>> Thank you! > >>> -Dawn > >>> > >>> > >>> On Sun, Nov 27, 2011 at 06:03:03PM -0800, Greg Clayton wrote: > >>>> > >>>> On Nov 23, 2011, at 11:31 PM, dawn at burble.org wrote: > >>>> > >>>>> This patch was created using clang/llvm rev 144569, lldb rev 144919 but has > >>>>> been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on > >>>>> Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. > >>>>> > >>>>> Debugging on Linux broke when the assumption was made that a process could be > >>>>> launched by spawning it in a suspended state and then attaching to it. That > >>>>> support does not exist on Linux. To work around this, I added a new method > >>>>> "CanLaunchViaAttach" which tests whether the platform supports being launched > >>>>> in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find > >>>>> an easy way to set it from within the Linux plugins. > >>>>> > >>>>> Commit message: > >>>>> > >>>>> Fix debugging on Linux. > >>>>> Implement remote vs. host platform code as was done with PlatformDarwin. > >>>>> Platform::CanLaunchViaAttach(): new: return true if the process can be launched > >>>>> via spawn and attach. Default is true. Override in PlatformLinux to false. > >>>>> Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) > >>>>> then launch the process via CreateProcess and Launch. > >>>>> > >>>>> Please review and commit if acceptable. > >>>> > >>>> I checked in an alternate fix: > >>>> > >>>> % svn commit > >>>> Sending include/lldb/Core/Module.h > >>>> Sending include/lldb/Symbol/SymbolFile.h > >>>> Sending include/lldb/Target/Platform.h > >>>> Sending source/Commands/CommandObjectProcess.cpp > >>>> Sending source/Core/Module.cpp > >>>> Sending source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp > >>>> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp > >>>> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h > >>>> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp > >>>> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h > >>>> Sending source/Symbol/SymbolFile.cpp > >>>> Transmitting file data ........... > >>>> Committed revision 145219. > >>>> > >>>> % svn commit > >>>> Sending Platform/Linux/PlatformLinux.h > >>>> Transmitting file data . > >>>> Committed revision 145221. > >>>> > >>>> > >>>> The first one contains the necessary changes to CommandObjectProcess.cpp and to include/lldb/Target/Platform.h that allow a platform to say: > >>>> > >>>> > >>>> virtual bool > >>>> CanDebugProcess () > >>>> { > >>>> return true; > >>>> } > >>>> > >>>> This keeps the code out of the platform since when a platform launches a process, it shouldn't be tied to a process plug-in as in the patch you submitted. > >>>> > >>>> Here is the vision of platforms: > >>>> > >>>> - They should be able to list all of the processes on the platform. This way you can connect to your local machine and list the processes, or connect to a remote platform, and if the remote platform supports it, it can list the processes that are there. > >>>> - Platforms should support launching processes. Not always for debugging, but sometimes just to spawn a child process. On the localhost, this means just using the Host::LaunchProcess() functionality. This way, we just need to implement a single copy of the process launching code. When you create a remote platform, you should be able to link against the native linux or darwin launching code and then we don't end up with multiple copies of the launching code like we have now. You make a good point in that not all platforms will be able to support launching with a program stopped for debugging, so we now ask the platform up in the CommandObjectProcessLaunch class before we launch the process. This keeps the platform clean, yet also lets us fall back to just launching the process through the built in process plug-in. > >>>> - Platforms should support attaching to a remote process. Combined with being able to launch for debug, this allows debugging as we have it on MacOSX. If we do this while remotely connected to a remote darwin machine, we now have the ability to talk to a remote computer and launch, attach, list and do a lot more > >>>> - Platforms should know if there are files locally on the current machine in an SDK or PDK or some over developer kit/cross compiling sysroot, etc to allow locating files in terms of the path you would us on the remote machine. For example when debugging on a remote device, if the are asked to find the file for "/bin/ls", this might locally be located in developer kit directory such as > >>>> "/path/to/old/linux/sysroot/bin/ls". This allows you to debug remote machines, or event mount the root file system on a mountpoint so you have access to the files so you can debug. > >>>> - Platforms should be able to upload/download files so you could install a new binary and run it, or upload a shared library so we can locally cache it for faster debugging. > >>>> > >>>> We are in the process of slowly makine these Platforms a reality, so keep the questions coming if anyone has any. > >>>> > >>>> So in short: I made the fix you requested, but in a different way. If you can rework your patch around what is in top of tree, then we can get the rest of it submitted. > >>>> > >>>> Greg Clayton > >>>> > >>>>> Thanks! > >>>>> -Dawn > >>>>> _______________________________________________ > >>>>> lldb-commits mailing list > >>>>> lldb-commits at cs.uiuc.edu > >>>>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From dawn at burble.org Mon Nov 28 21:49:23 2011 From: dawn at burble.org (dawn at burble.org) Date: Mon, 28 Nov 2011 19:49:23 -0800 Subject: [Lldb-commits] [PATCH] fix debugging on linux In-Reply-To: <4ED34745.7090201@free.fr> References: <20111124073122.GA13244@bloodbath.burble.org> <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> <4ED34745.7090201@free.fr> Message-ID: <20111129034923.GA31461@bloodbath.burble.org> Glad to see there's finally a buildbot for Linux - thank you! I have 32-bit Linux - any way to get a buildbot set up for that? I get much farther, so I suspect this is a problem with the 64-bit Linux. -Dawn On Mon, Nov 28, 2011 at 09:33:09AM +0100, Duncan Sands wrote: > The linux lldb buildbot http://lab.llvm.org:8011/builders/lldb-x86_64-linux > is still failing, now with: > > Collected 442 tests > > 1: test_with_dsym (TestLogging.LogTestCase) ... skipped 'requires Darwin' > 2: test_with_dwarf (TestLogging.LogTestCase) ... FAIL > 3: test_with_dsym (TestFormatters.ExprFormattersTestCase) > Test expr + formatters for good interoperability. ... skipped 'requires > Darwin' > 4: test_with_dwarf_ (TestFormatters.ExprFormattersTestCase) > Test expr + formatters for good interoperability. ... ERROR > 5: test_expr_commands (TestPrintfAfterUp.Radar9531204TestCase) > The evaluating printf(...) after break stop and then up a stack frame. ... > python: LinuxThread.cpp:239: void LinuxThread::BreakNotify(const > ProcessMessage&): Assertion `bp_site' failed. > make: *** [check-local] Aborted > program finished with exit code 2 > > Ciao, Duncan. > > On 28/11/11 03:03, Greg Clayton wrote: > > > > On Nov 23, 2011, at 11:31 PM, dawn at burble.org wrote: > > > >> This patch was created using clang/llvm rev 144569, lldb rev 144919 but has > >> been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on > >> Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. > >> > >> Debugging on Linux broke when the assumption was made that a process could be > >> launched by spawning it in a suspended state and then attaching to it. That > >> support does not exist on Linux. To work around this, I added a new method > >> "CanLaunchViaAttach" which tests whether the platform supports being launched > >> in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find > >> an easy way to set it from within the Linux plugins. > >> > >> Commit message: > >> > >> Fix debugging on Linux. > >> Implement remote vs. host platform code as was done with PlatformDarwin. > >> Platform::CanLaunchViaAttach(): new: return true if the process can be launched > >> via spawn and attach. Default is true. Override in PlatformLinux to false. > >> Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) > >> then launch the process via CreateProcess and Launch. > >> > >> Please review and commit if acceptable. > > > > I checked in an alternate fix: > > > > % svn commit > > Sending include/lldb/Core/Module.h > > Sending include/lldb/Symbol/SymbolFile.h > > Sending include/lldb/Target/Platform.h > > Sending source/Commands/CommandObjectProcess.cpp > > Sending source/Core/Module.cpp > > Sending source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp > > Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp > > Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h > > Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp > > Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h > > Sending source/Symbol/SymbolFile.cpp > > Transmitting file data ........... > > Committed revision 145219. > > > > % svn commit > > Sending Platform/Linux/PlatformLinux.h > > Transmitting file data . > > Committed revision 145221. > > > > > > The first one contains the necessary changes to CommandObjectProcess.cpp and to include/lldb/Target/Platform.h that allow a platform to say: > > > > > > virtual bool > > CanDebugProcess () > > { > > return true; > > } > > > > This keeps the code out of the platform since when a platform launches a process, it shouldn't be tied to a process plug-in as in the patch you submitted. > > > > Here is the vision of platforms: > > > > - They should be able to list all of the processes on the platform. This way you can connect to your local machine and list the processes, or connect to a remote platform, and if the remote platform supports it, it can list the processes that are there. > > - Platforms should support launching processes. Not always for debugging, but sometimes just to spawn a child process. On the localhost, this means just using the Host::LaunchProcess() functionality. This way, we just need to implement a single copy of the process launching code. When you create a remote platform, you should be able to link against the native linux or darwin launching code and then we don't end up with multiple copies of the launching code like we have now. You make a good point in that not all platforms will be able to support launching with a program stopped for debugging, so we now ask the platform up in the CommandObjectProcessLaunch class before we launch the process. This keeps the platform clean, yet also lets us fall back to just launching the process through the built in process plug-in. > > - Platforms should support attaching to a remote process. Combined with being able to launch for debug, this allows debugging as we have it on MacOSX. If we do this while remotely connected to a remote darwin machine, we now have the ability to talk to a remote computer and launch, attach, list and do a lot more > > - Platforms should know if there are files locally on the current machine in an SDK or PDK or some over developer kit/cross compiling sysroot, etc to allow locating files in terms of the path you would us on the remote machine. For example when debugging on a remote device, if the are asked to find the file for "/bin/ls", this might locally be located in developer kit directory such as > > "/path/to/old/linux/sysroot/bin/ls". This allows you to debug remote machines, or event mount the root file system on a mountpoint so you have access to the files so you can debug. > > - Platforms should be able to upload/download files so you could install a new binary and run it, or upload a shared library so we can locally cache it for faster debugging. > > > > We are in the process of slowly makine these Platforms a reality, so keep the questions coming if anyone has any. > > > > So in short: I made the fix you requested, but in a different way. If you can rework your patch around what is in top of tree, then we can get the rest of it submitted. > > > > Greg Clayton > > > >> Thanks! > >> -Dawn > >> _______________________________________________ > >> lldb-commits mailing list > >> 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 > > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From gclayton at apple.com Mon Nov 28 22:03:30 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 29 Nov 2011 04:03:30 -0000 Subject: [Lldb-commits] [lldb] r145371 - in /lldb/trunk/source: API/SBTarget.cpp Commands/CommandObjectProcess.cpp Message-ID: <20111129040330.676622A6C12C@llvm.org> Author: gclayton Date: Mon Nov 28 22:03:30 2011 New Revision: 145371 URL: http://llvm.org/viewvc/llvm-project?rev=145371&view=rev Log: Fixed an issue where if we are debugging on a remote platform and set a platform path for our executable, it was not being honored by the new launch functions that used the ProcessLaunchInfo. Modified: lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=145371&r1=145370&r2=145371&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Mon Nov 28 22:03:30 2011 @@ -235,7 +235,7 @@ Module *exe_module = m_opaque_sp->GetExecutableModulePointer(); if (exe_module) - launch_info.SetExecutableFile(exe_module->GetFileSpec(), true); + launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); if (argv) launch_info.GetArguments().AppendArguments (argv); if (envp) Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=145371&r1=145370&r2=145371&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Mon Nov 28 22:03:30 2011 @@ -35,87 +35,6 @@ { public: -// class CommandOptions : public Options -// { -// public: -// -// CommandOptions (CommandInterpreter &interpreter) : -// Options(interpreter) -// { -// // Keep default values of all options in one place: OptionParsingStarting () -// OptionParsingStarting (); -// } -// -// ~CommandOptions () -// { -// } -// -// Error -// SetOptionValue (uint32_t option_idx, const char *option_arg) -// { -// Error error; -// char short_option = (char) m_getopt_table[option_idx].val; -// -// switch (short_option) -// { -// case 's': stop_at_entry = true; break; -// case 'e': stderr_path.assign (option_arg); break; -// case 'i': stdin_path.assign (option_arg); break; -// case 'o': stdout_path.assign (option_arg); break; -// case 'p': plugin_name.assign (option_arg); break; -// case 'n': no_stdio = true; break; -// case 'w': working_dir.assign (option_arg); break; -// case 't': -// if (option_arg && option_arg[0]) -// tty_name.assign (option_arg); -// in_new_tty = true; -// break; -// default: -// error.SetErrorStringWithFormat("invalid short option character '%c'", short_option); -// break; -// -// } -// return error; -// } -// -// void -// OptionParsingStarting () -// { -// stop_at_entry = false; -// in_new_tty = false; -// tty_name.clear(); -// stdin_path.clear(); -// stdout_path.clear(); -// stderr_path.clear(); -// plugin_name.clear(); -// working_dir.clear(); -// no_stdio = false; -// } -// -// const OptionDefinition* -// GetDefinitions () -// { -// return g_option_table; -// } -// -// // Options table: Required for subclasses of Options. -// -// static OptionDefinition g_option_table[]; -// -// // Instance variables to hold the values for command options. -// -// bool stop_at_entry; -// bool in_new_tty; -// bool no_stdio; -// std::string tty_name; -// std::string stderr_path; -// std::string stdin_path; -// std::string stdout_path; -// std::string plugin_name; -// std::string working_dir; -// -// }; - CommandObjectProcessLaunch (CommandInterpreter &interpreter) : CommandObject (interpreter, "process launch", @@ -175,7 +94,7 @@ exe_module->GetFileSpec().GetPath (filename, sizeof(filename)); const bool add_exe_file_as_first_arg = true; - m_options.launch_info.SetExecutableFile(exe_module->GetFileSpec(), add_exe_file_as_first_arg); + m_options.launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), add_exe_file_as_first_arg); StateType state = eStateInvalid; Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); @@ -593,7 +512,7 @@ if (!m_options.attach_info.ProcessInfoSpecified ()) { if (old_exec_module_sp) - m_options.attach_info.GetExecutableFile().GetFilename() = old_exec_module_sp->GetFileSpec().GetFilename(); + m_options.attach_info.GetExecutableFile().GetFilename() = old_exec_module_sp->GetPlatformFileSpec().GetFilename(); if (!m_options.attach_info.ProcessInfoSpecified ()) { From gclayton at apple.com Mon Nov 28 22:38:04 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 28 Nov 2011 20:38:04 -0800 Subject: [Lldb-commits] [PATCH] fix debugging on linux In-Reply-To: <20111129032825.GA31054@bloodbath.burble.org> References: <20111124073122.GA13244@bloodbath.burble.org> <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> <20111128195949.GA24208@bloodbath.burble.org> <06D1CC93-A433-42D5-9332-BEE9142802CA@apple.com> <20111129014718.GA29289@bloodbath.burble.org> <20111129032825.GA31054@bloodbath.burble.org> Message-ID: <9684474F-52A6-485F-95BD-07376026D54D@apple.com> On Nov 28, 2011, at 7:28 PM, dawn at burble.org wrote: > On Mon, Nov 28, 2011 at 05:58:05PM -0800, Greg Clayton wrote: >> >> Can you have the linux "Host::LaunchProcess()" do the fork, ptrace me, exec, then do the attach? Or must linux have a debug process attached right from the start? > > No, both Linux and Windows (and I think BSD as well) will not allow you > to attach to a process that you're already debugging. I am not asking for that. > They want to have a debug process attached right from the start. They do support > attaching to an existing process that's already running, but that's a > different problem - here we want to debug the process form the start. > > So I think you see the issue now? I see the issue, but your fix in the platform isn't going to help. It works for local debugging only, but not for remote debugging, which is the whole point of going through the platform in the first place. Your current fix will always try and launch the program using the default process plug-in on the current machine. What is intended for the platform is: (lldb) platform select remote-macosx (lldb) platform connect tcp://some.machine.com:1234 (lldb) target create /sdk/linux2.3/bin/ls (lldb) run now when you do the launching, the launching should happen through the platform on the remote host, but in your patch: lldb::ProcessSP Platform::DebugProcess (ProcessLaunchInfo &launch_info, Debugger &debugger, Target *target, // Can be NULL, if NULL create a new target, else use existing one Listener &listener, Error &error) { ProcessSP process_sp; // Make sure we stop at the entry point launch_info.GetFlags ().Set (eLaunchFlagDebug); if (!target->GetPlatform()->CanLaunchProcessStoppedAtEntry()) { const char *plugin_name = launch_info.GetProcessPluginName(); process_sp = target->CreateProcess (listener, plugin_name).get(); error = process_sp->Launch (launch_info); } else .... this will just launch it locally. A fix should actually be happening in the Platform::LaunchProcess: Error Platform::LaunchProcess (ProcessLaunchInfo &launch_info) { Error error; // Take care of the host case so that each subclass can just // call this function to get the host functionality. if (IsHost()) error = Host::LaunchProcess (launch_info); else error.SetErrorString ("base lldb_private::Platform class can't launch remote processes"); return error; } But here LaunchProcess isn't returning a ProcessSP of any kind since this function is also used for just spawning processes. Do you see where I am going with the platform thing here? We can't mix in any specific process class to do the launching. I know there is work to be done on the platforms still to work out how all of this happens. So for now, I think the code is good > >>> How would you suggest we fix this? >> >> With my fix that is already checked in (the fix to CommandObjectProcessLaunch that first checks to see if the platform can start a process stopped for debugging and if it can't, it will just use the current process plug-in to do the launch directly and skip the platform launch for debug), the linux process plug-in will be used to do the launching and avoid this issue altogether, right? > > Yes, but it doesn't fit in with how the process control code was > intended to be used - we're skipping the call to DebugProcess just to > avoid a call to Attach? And other platforms will have to go this route > as well? No, the explanation above should clarify why. > >>> Move the call to Attach into the MaxOSX >>> LaunchProcess code? Or have a flag like CanLaunchViaAttach so we'll know to >>> skip the call to Attach? I went with the latter in my patch - that seemed the >>> least intrusive yet generic fix. >> >> Again, I don't understand the can launch via attach. You should be able to launch a program on linux and then attach to it without a debugger needing to be there from the start, you will just miss many instructions as the process makes progress until you attach. > > Exactly - I think you see the problem now :) So my vote is to leave the code changes as they exist in the top of tree and let the process plug-in do the launching. > > -Dawn > > >>> On Mon, Nov 28, 2011 at 01:48:35PM -0800, Greg Clayton wrote: >>>> >>>> On Nov 28, 2011, at 11:59 AM, dawn at burble.org wrote: >>>> >>>>> I find the name "CanDebugProcess" to be misleading. The issue isn't >>>>> whether a process can be debugged on Linux (because it obviously can), >>>>> it's that it can't be spawned in a suspended state and then attached >>>>> to. AFAIK, Linux doesn't have anything like the MacOSX >>>>> "POSIX_SPAWN_START_SUSPENDED" flag for posix_spawnattr_setflags() that >>>>> MacOSX has. >>>> >>>> Yes, this flag is darwin only. >>>> >>>>> I chose the name "CanLaunchViaAttach" for this, which I think better >>>>> describes the problem. Ok to rename "CanDebugProcess" to >>>>> "CanLaunchViaAttach"? >>>> >>>> I am not too fond of the CanLaunchViaAttach because launching a program using a platform doesn't imply that you want to debug or attach to it. Also it doesn't make sense how do you launch via attach? First you launch, then you attach. The attach doesn't have anything to do with launching. You might just want to spawn a server program on the remote platform which you don't want to debug. We are asking the platform (not the process plug-in, but the platform) if it can do something, in this case: can the platform launch a process that can be stopped for debugging. Currently the linux platform can't (though I am sure we can make it work somehow), only the native linux _process_ plug-in can. You can't use the ProcessLinux plug-in to implement stuff functionality for the platform, the platform itself should be doing the work. This is preparing for better remote debugging support where we can launch new remote processes without having to involve any of the process plug-ins. >>>> >>>> The attach part shouldn't have anything to do with this either because you might want to spawn a new process that is stopped, and then resume it at a controlled time later. The "POSIX_SPAWN_START_SUSPENDED" flag in darwin will have the process halted at the entry point with a SIGSTOP, and it can be resumed later. >>>> >>>> How about "bool Platform::CanLaunchProcessStoppedAtEntry()"? >>>> >>>> Platforms are far from complete and we can modify them and grow their abilities over time. Again, the vision is that platforms will eventually launch (possibly for debug), attach to processes, list processes, upload/download and more. They should provide a nice connection to a local or remote machine so that debugging to them is as easy as debugging on your local machine. That is the vision at least, and I know we have some work ahead of us to get there. >>>> >>>> >>>> Greg >>>> >>>> >>>> >>>>> Likewise, since you moved the fixes I had made to >>>>> DebugProcess() into CommandObjectProcessLaunch(), please also rename >>>>> "DebugProcess" to "LaunchViaAttach". >>>> >>>> Hopefully CanLaunchProcessStoppedAtEntry() makes sense? >>>> >>>>> Thank you! >>>>> -Dawn >>>>> >>>>> >>>>> On Sun, Nov 27, 2011 at 06:03:03PM -0800, Greg Clayton wrote: >>>>>> >>>>>> On Nov 23, 2011, at 11:31 PM, dawn at burble.org wrote: >>>>>> >>>>>>> This patch was created using clang/llvm rev 144569, lldb rev 144919 but has >>>>>>> been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on >>>>>>> Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. >>>>>>> >>>>>>> Debugging on Linux broke when the assumption was made that a process could be >>>>>>> launched by spawning it in a suspended state and then attaching to it. That >>>>>>> support does not exist on Linux. To work around this, I added a new method >>>>>>> "CanLaunchViaAttach" which tests whether the platform supports being launched >>>>>>> in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find >>>>>>> an easy way to set it from within the Linux plugins. >>>>>>> >>>>>>> Commit message: >>>>>>> >>>>>>> Fix debugging on Linux. >>>>>>> Implement remote vs. host platform code as was done with PlatformDarwin. >>>>>>> Platform::CanLaunchViaAttach(): new: return true if the process can be launched >>>>>>> via spawn and attach. Default is true. Override in PlatformLinux to false. >>>>>>> Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) >>>>>>> then launch the process via CreateProcess and Launch. >>>>>>> >>>>>>> Please review and commit if acceptable. >>>>>> >>>>>> I checked in an alternate fix: >>>>>> >>>>>> % svn commit >>>>>> Sending include/lldb/Core/Module.h >>>>>> Sending include/lldb/Symbol/SymbolFile.h >>>>>> Sending include/lldb/Target/Platform.h >>>>>> Sending source/Commands/CommandObjectProcess.cpp >>>>>> Sending source/Core/Module.cpp >>>>>> Sending source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp >>>>>> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp >>>>>> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h >>>>>> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp >>>>>> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h >>>>>> Sending source/Symbol/SymbolFile.cpp >>>>>> Transmitting file data ........... >>>>>> Committed revision 145219. >>>>>> >>>>>> % svn commit >>>>>> Sending Platform/Linux/PlatformLinux.h >>>>>> Transmitting file data . >>>>>> Committed revision 145221. >>>>>> >>>>>> >>>>>> The first one contains the necessary changes to CommandObjectProcess.cpp and to include/lldb/Target/Platform.h that allow a platform to say: >>>>>> >>>>>> >>>>>> virtual bool >>>>>> CanDebugProcess () >>>>>> { >>>>>> return true; >>>>>> } >>>>>> >>>>>> This keeps the code out of the platform since when a platform launches a process, it shouldn't be tied to a process plug-in as in the patch you submitted. >>>>>> >>>>>> Here is the vision of platforms: >>>>>> >>>>>> - They should be able to list all of the processes on the platform. This way you can connect to your local machine and list the processes, or connect to a remote platform, and if the remote platform supports it, it can list the processes that are there. >>>>>> - Platforms should support launching processes. Not always for debugging, but sometimes just to spawn a child process. On the localhost, this means just using the Host::LaunchProcess() functionality. This way, we just need to implement a single copy of the process launching code. When you create a remote platform, you should be able to link against the native linux or darwin launching code and then we don't end up with multiple copies of the launching code like we have now. You make a good point in that not all platforms will be able to support launching with a program stopped for debugging, so we now ask the platform up in the CommandObjectProcessLaunch class before we launch the process. This keeps the platform clean, yet also lets us fall back to just launching the process through the built in process plug-in. >>>>>> - Platforms should support attaching to a remote process. Combined with being able to launch for debug, this allows debugging as we have it on MacOSX. If we do this while remotely connected to a remote darwin machine, we now have the ability to talk to a remote computer and launch, attach, list and do a lot more >>>>>> - Platforms should know if there are files locally on the current machine in an SDK or PDK or some over developer kit/cross compiling sysroot, etc to allow locating files in terms of the path you would us on the remote machine. For example when debugging on a remote device, if the are asked to find the file for "/bin/ls", this might locally be located in developer kit directory such as >>>>>> "/path/to/old/linux/sysroot/bin/ls". This allows you to debug remote machines, or event mount the root file system on a mountpoint so you have access to the files so you can debug. >>>>>> - Platforms should be able to upload/download files so you could install a new binary and run it, or upload a shared library so we can locally cache it for faster debugging. >>>>>> >>>>>> We are in the process of slowly makine these Platforms a reality, so keep the questions coming if anyone has any. >>>>>> >>>>>> So in short: I made the fix you requested, but in a different way. If you can rework your patch around what is in top of tree, then we can get the rest of it submitted. >>>>>> >>>>>> Greg Clayton >>>>>> >>>>>>> Thanks! >>>>>>> -Dawn >>>>>>> _______________________________________________ >>>>>>> lldb-commits mailing list >>>>>>> lldb-commits at cs.uiuc.edu >>>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From dawn at burble.org Tue Nov 29 03:34:28 2011 From: dawn at burble.org (dawn at burble.org) Date: Tue, 29 Nov 2011 01:34:28 -0800 Subject: [Lldb-commits] [PATCH] fix debugging on linux In-Reply-To: <9684474F-52A6-485F-95BD-07376026D54D@apple.com> References: <20111124073122.GA13244@bloodbath.burble.org> <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> <20111128195949.GA24208@bloodbath.burble.org> <06D1CC93-A433-42D5-9332-BEE9142802CA@apple.com> <20111129014718.GA29289@bloodbath.burble.org> <20111129032825.GA31054@bloodbath.burble.org> <9684474F-52A6-485F-95BD-07376026D54D@apple.com> Message-ID: <20111129093428.GA3339@bloodbath.burble.org> Admittedly, I was confused by the host vs. remote process code that was added recently. I understand a bit more now, and tried to copy the process launching code from Plugins/Process/Linux to Host/linux, but got lost in the need to reference the target and listeners needed by ProcessLinux::ProcessLinux(Target& target, Listener &listener) so I give up :(. I don't like what we have now, but I've failed to come up with anything better, so I concede. At least we have a workaround - thank you!!! I've resubitted the rest of my original patch (attached) which adds support for some of the remote vs. host code. LaunchProcess still needs to be implemented, but it's a start. Please commit? Thanks again, -Dawn On Mon, Nov 28, 2011 at 08:38:04PM -0800, Greg Clayton wrote: > > On Nov 28, 2011, at 7:28 PM, dawn at burble.org wrote: > > > On Mon, Nov 28, 2011 at 05:58:05PM -0800, Greg Clayton wrote: > >> > >> Can you have the linux "Host::LaunchProcess()" do the fork, ptrace me, exec, then do the attach? Or must linux have a debug process attached right from the start? > > > > No, both Linux and Windows (and I think BSD as well) will not allow you > > to attach to a process that you're already debugging. > > I am not asking for that. > > > They want to have a debug process attached right from the start. They do support > > attaching to an existing process that's already running, but that's a > > different problem - here we want to debug the process form the start. > > > > So I think you see the issue now? > > I see the issue, but your fix in the platform isn't going to help. It works for local debugging only, but not for remote debugging, which is the whole point of going through the platform in the first place. Your current fix will always try and launch the program using the default process plug-in on the current machine. > > What is intended for the platform is: > > (lldb) platform select remote-macosx > (lldb) platform connect tcp://some.machine.com:1234 > (lldb) target create /sdk/linux2.3/bin/ls > (lldb) run > > now when you do the launching, the launching should happen through the platform on the remote host, but in your patch: > > lldb::ProcessSP > Platform::DebugProcess (ProcessLaunchInfo &launch_info, > Debugger &debugger, > Target *target, // Can be NULL, if NULL create a new target, else use existing one > Listener &listener, > Error &error) > { > ProcessSP process_sp; > // Make sure we stop at the entry point > launch_info.GetFlags ().Set (eLaunchFlagDebug); > > if (!target->GetPlatform()->CanLaunchProcessStoppedAtEntry()) > { > const char *plugin_name = launch_info.GetProcessPluginName(); > process_sp = target->CreateProcess (listener, plugin_name).get(); > error = process_sp->Launch (launch_info); > } > else > .... > > this will just launch it locally. A fix should actually be happening in the Platform::LaunchProcess: > > Error > Platform::LaunchProcess (ProcessLaunchInfo &launch_info) > { > Error error; > // Take care of the host case so that each subclass can just > // call this function to get the host functionality. > if (IsHost()) > error = Host::LaunchProcess (launch_info); > else > error.SetErrorString ("base lldb_private::Platform class can't launch remote processes"); > return error; > } > > But here LaunchProcess isn't returning a ProcessSP of any kind since this function is also used for just spawning processes. > > Do you see where I am going with the platform thing here? We can't mix in any specific process class to do the launching. > > I know there is work to be done on the platforms still to work out how all of this happens. So for now, I think the code is good > > > > >>> How would you suggest we fix this? > >> > >> With my fix that is already checked in (the fix to CommandObjectProcessLaunch that first checks to see if the platform can start a process stopped for debugging and if it can't, it will just use the current process plug-in to do the launch directly and skip the platform launch for debug), the linux process plug-in will be used to do the launching and avoid this issue altogether, right? > > > > Yes, but it doesn't fit in with how the process control code was > > intended to be used - we're skipping the call to DebugProcess just to > > avoid a call to Attach? And other platforms will have to go this route > > as well? > > No, the explanation above should clarify why. > > > > >>> Move the call to Attach into the MaxOSX > >>> LaunchProcess code? Or have a flag like CanLaunchViaAttach so we'll know to > >>> skip the call to Attach? I went with the latter in my patch - that seemed the > >>> least intrusive yet generic fix. > >> > >> Again, I don't understand the can launch via attach. You should be able to launch a program on linux and then attach to it without a debugger needing to be there from the start, you will just miss many instructions as the process makes progress until you attach. > > > > Exactly - I think you see the problem now :) > > So my vote is to leave the code changes as they exist in the top of tree and let the process plug-in do the launching. > > > > > -Dawn > > > > > >>> On Mon, Nov 28, 2011 at 01:48:35PM -0800, Greg Clayton wrote: > >>>> > >>>> On Nov 28, 2011, at 11:59 AM, dawn at burble.org wrote: > >>>> > >>>>> I find the name "CanDebugProcess" to be misleading. The issue isn't > >>>>> whether a process can be debugged on Linux (because it obviously can), > >>>>> it's that it can't be spawned in a suspended state and then attached > >>>>> to. AFAIK, Linux doesn't have anything like the MacOSX > >>>>> "POSIX_SPAWN_START_SUSPENDED" flag for posix_spawnattr_setflags() that > >>>>> MacOSX has. > >>>> > >>>> Yes, this flag is darwin only. > >>>> > >>>>> I chose the name "CanLaunchViaAttach" for this, which I think better > >>>>> describes the problem. Ok to rename "CanDebugProcess" to > >>>>> "CanLaunchViaAttach"? > >>>> > >>>> I am not too fond of the CanLaunchViaAttach because launching a program using a platform doesn't imply that you want to debug or attach to it. Also it doesn't make sense how do you launch via attach? First you launch, then you attach. The attach doesn't have anything to do with launching. You might just want to spawn a server program on the remote platform which you don't want to debug. We are asking the platform (not the process plug-in, but the platform) if it can do something, in this case: can the platform launch a process that can be stopped for debugging. Currently the linux platform can't (though I am sure we can make it work somehow), only the native linux _process_ plug-in can. You can't use the ProcessLinux plug-in to implement stuff functionality for the platform, the platform itself should be doing the work. This is preparing for better remote debugging support where we can launch new remote processes without having to involve any of the process plug-ins. > >>>> > >>>> The attach part shouldn't have anything to do with this either because you might want to spawn a new process that is stopped, and then resume it at a controlled time later. The "POSIX_SPAWN_START_SUSPENDED" flag in darwin will have the process halted at the entry point with a SIGSTOP, and it can be resumed later. > >>>> > >>>> How about "bool Platform::CanLaunchProcessStoppedAtEntry()"? > >>>> > >>>> Platforms are far from complete and we can modify them and grow their abilities over time. Again, the vision is that platforms will eventually launch (possibly for debug), attach to processes, list processes, upload/download and more. They should provide a nice connection to a local or remote machine so that debugging to them is as easy as debugging on your local machine. That is the vision at least, and I know we have some work ahead of us to get there. > >>>> > >>>> > >>>> Greg > >>>> > >>>> > >>>> > >>>>> Likewise, since you moved the fixes I had made to > >>>>> DebugProcess() into CommandObjectProcessLaunch(), please also rename > >>>>> "DebugProcess" to "LaunchViaAttach". > >>>> > >>>> Hopefully CanLaunchProcessStoppedAtEntry() makes sense? > >>>> > >>>>> Thank you! > >>>>> -Dawn > >>>>> > >>>>> > >>>>> On Sun, Nov 27, 2011 at 06:03:03PM -0800, Greg Clayton wrote: > >>>>>> > >>>>>> On Nov 23, 2011, at 11:31 PM, dawn at burble.org wrote: > >>>>>> > >>>>>>> This patch was created using clang/llvm rev 144569, lldb rev 144919 but has > >>>>>>> been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on > >>>>>>> Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. > >>>>>>> > >>>>>>> Debugging on Linux broke when the assumption was made that a process could be > >>>>>>> launched by spawning it in a suspended state and then attaching to it. That > >>>>>>> support does not exist on Linux. To work around this, I added a new method > >>>>>>> "CanLaunchViaAttach" which tests whether the platform supports being launched > >>>>>>> in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find > >>>>>>> an easy way to set it from within the Linux plugins. > >>>>>>> > >>>>>>> Commit message: > >>>>>>> > >>>>>>> Fix debugging on Linux. > >>>>>>> Implement remote vs. host platform code as was done with PlatformDarwin. > >>>>>>> Platform::CanLaunchViaAttach(): new: return true if the process can be launched > >>>>>>> via spawn and attach. Default is true. Override in PlatformLinux to false. > >>>>>>> Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) > >>>>>>> then launch the process via CreateProcess and Launch. > >>>>>>> > >>>>>>> Please review and commit if acceptable. > >>>>>> > >>>>>> I checked in an alternate fix: > >>>>>> > >>>>>> % svn commit > >>>>>> Sending include/lldb/Core/Module.h > >>>>>> Sending include/lldb/Symbol/SymbolFile.h > >>>>>> Sending include/lldb/Target/Platform.h > >>>>>> Sending source/Commands/CommandObjectProcess.cpp > >>>>>> Sending source/Core/Module.cpp > >>>>>> Sending source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp > >>>>>> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp > >>>>>> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h > >>>>>> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp > >>>>>> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h > >>>>>> Sending source/Symbol/SymbolFile.cpp > >>>>>> Transmitting file data ........... > >>>>>> Committed revision 145219. > >>>>>> > >>>>>> % svn commit > >>>>>> Sending Platform/Linux/PlatformLinux.h > >>>>>> Transmitting file data . > >>>>>> Committed revision 145221. > >>>>>> > >>>>>> > >>>>>> The first one contains the necessary changes to CommandObjectProcess.cpp and to include/lldb/Target/Platform.h that allow a platform to say: > >>>>>> > >>>>>> > >>>>>> virtual bool > >>>>>> CanDebugProcess () > >>>>>> { > >>>>>> return true; > >>>>>> } > >>>>>> > >>>>>> This keeps the code out of the platform since when a platform launches a process, it shouldn't be tied to a process plug-in as in the patch you submitted. > >>>>>> > >>>>>> Here is the vision of platforms: > >>>>>> > >>>>>> - They should be able to list all of the processes on the platform. This way you can connect to your local machine and list the processes, or connect to a remote platform, and if the remote platform supports it, it can list the processes that are there. > >>>>>> - Platforms should support launching processes. Not always for debugging, but sometimes just to spawn a child process. On the localhost, this means just using the Host::LaunchProcess() functionality. This way, we just need to implement a single copy of the process launching code. When you create a remote platform, you should be able to link against the native linux or darwin launching code and then we don't end up with multiple copies of the launching code like we have now. You make a good point in that not all platforms will be able to support launching with a program stopped for debugging, so we now ask the platform up in the CommandObjectProcessLaunch class before we launch the process. This keeps the platform clean, yet also lets us fall back to just launching the process through the built in process plug-in. > >>>>>> - Platforms should support attaching to a remote process. Combined with being able to launch for debug, this allows debugging as we have it on MacOSX. If we do this while remotely connected to a remote darwin machine, we now have the ability to talk to a remote computer and launch, attach, list and do a lot more > >>>>>> - Platforms should know if there are files locally on the current machine in an SDK or PDK or some over developer kit/cross compiling sysroot, etc to allow locating files in terms of the path you would us on the remote machine. For example when debugging on a remote device, if the are asked to find the file for "/bin/ls", this might locally be located in developer kit directory such as > >>>>>> "/path/to/old/linux/sysroot/bin/ls". This allows you to debug remote machines, or event mount the root file system on a mountpoint so you have access to the files so you can debug. > >>>>>> - Platforms should be able to upload/download files so you could install a new binary and run it, or upload a shared library so we can locally cache it for faster debugging. > >>>>>> > >>>>>> We are in the process of slowly makine these Platforms a reality, so keep the questions coming if anyone has any. > >>>>>> > >>>>>> So in short: I made the fix you requested, but in a different way. If you can rework your patch around what is in top of tree, then we can get the rest of it submitted. > >>>>>> > >>>>>> Greg Clayton > >>>>>> > >>>>>>> Thanks! > >>>>>>> -Dawn > >>>>>>> _______________________________________________ > >>>>>>> lldb-commits mailing list > >>>>>>> lldb-commits at cs.uiuc.edu > >>>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits -------------- next part -------------- Index: source/Plugins/Platform/Linux/PlatformLinux.cpp =================================================================== --- source/Plugins/Platform/Linux/PlatformLinux.cpp (revision 145313) +++ source/Plugins/Platform/Linux/PlatformLinux.cpp (working copy) @@ -17,6 +17,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Error.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/PluginManager.h" @@ -29,10 +30,12 @@ using namespace lldb; using namespace lldb_private; +static uint32_t g_initialize_count = 0; + Platform * PlatformLinux::CreateInstance () { - return new PlatformLinux(); + return new PlatformLinux(true); } const char * @@ -42,33 +45,51 @@ } const char * -PlatformLinux::GetPluginDescriptionStatic() +PlatformLinux::GetShortPluginNameStatic (bool is_host) { - return "Default platform plugin for Linux"; + if (is_host) + return Platform::GetHostPlatformName (); + else + return "remote-linux"; } +const char * +PlatformLinux::GetPluginDescriptionStatic (bool is_host) +{ + if (is_host) + return "Local Linux user platform plug-in."; + else + return "Remote Linux user platform plug-in."; +} + void PlatformLinux::Initialize () { - static bool g_initialized = false; - - if (!g_initialized) + if (g_initialize_count++ == 0) { - PlatformSP default_platform_sp (CreateInstance()); +#if defined(__linux__) + PlatformSP default_platform_sp (new PlatformLinux(true)); + default_platform_sp->SetSystemArchitecture (Host::GetArchitecture()); Platform::SetDefaultPlatform (default_platform_sp); - PluginManager::RegisterPlugin(GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); - g_initialized = true; +#endif + PluginManager::RegisterPlugin(PlatformLinux::GetShortPluginNameStatic(false), + PlatformLinux::GetPluginDescriptionStatic(false), + PlatformLinux::CreateInstance); } } void PlatformLinux::Terminate () { + if (g_initialize_count > 0) + { + if (--g_initialize_count == 0) + { + PluginManager::UnregisterPlugin (PlatformLinux::CreateInstance); + } + } } - Error PlatformLinux::ResolveExecutable (const FileSpec &exe_file, const ArchSpec &exe_arch, @@ -77,18 +98,51 @@ Error error; // Nothing special to do here, just use the actual file and architecture + char exe_path[PATH_MAX]; FileSpec resolved_exe_file (exe_file); - // If we have "ls" as the exe_file, resolve the executable loation based on - // the current path variables - if (!resolved_exe_file.Exists()) - resolved_exe_file.ResolveExecutableLocation (); + if (IsHost()) + { + // If we have "ls" as the exe_file, resolve the executable location based on + // the current path variables + if (!resolved_exe_file.Exists()) + { + exe_file.GetPath(exe_path, sizeof(exe_path)); + resolved_exe_file.SetFile(exe_path, true); + } - // Resolve any executable within a bundle on MacOSX - Host::ResolveExecutableInBundle (resolved_exe_file); + if (!resolved_exe_file.Exists()) + resolved_exe_file.ResolveExecutableLocation (); - if (resolved_exe_file.Exists()) + if (resolved_exe_file.Exists()) + error.Clear(); + else + { + exe_file.GetPath(exe_path, sizeof(exe_path)); + error.SetErrorStringWithFormat("unable to find executable for '%s'", exe_path); + } + } + else { + if (m_remote_platform_sp) + { + error = m_remote_platform_sp->ResolveExecutable (exe_file, + exe_arch, + exe_module_sp); + } + else + { + // We may connect to a process and use the provided executable (Don't use local $PATH). + + if (resolved_exe_file.Exists()) + error.Clear(); + else + error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", exe_path); + } + } + + if (error.Success()) + { if (exe_arch.IsValid()) { error = ModuleList::GetSharedModule (resolved_exe_file, @@ -152,21 +206,20 @@ } } } - else - { - error.SetErrorStringWithFormat ("'%s%s%s' does not exist", - exe_file.GetDirectory().AsCString(""), - exe_file.GetDirectory() ? "/" : "", - exe_file.GetFilename().AsCString("")); - } return error; } Error PlatformLinux::GetFile (const FileSpec &platform_file, - const UUID *uuid, FileSpec &local_file) + const UUID *uuid_ptr, FileSpec &local_file) { + if (IsRemote()) + { + if (m_remote_platform_sp) + return m_remote_platform_sp->GetFile (platform_file, uuid_ptr, local_file); + } + // Default to the local case local_file = platform_file; return Error(); @@ -176,8 +229,9 @@ //------------------------------------------------------------------ /// Default Constructor //------------------------------------------------------------------ -PlatformLinux::PlatformLinux () : - Platform(true) +PlatformLinux::PlatformLinux (bool is_host) : + Platform(is_host), // This is the local host platform + m_remote_platform_sp () { } @@ -194,7 +248,17 @@ bool PlatformLinux::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) { - return Host::GetProcessInfo (pid, process_info); + bool success = false; + if (IsHost()) + { + success = Platform::GetProcessInfo (pid, process_info); + } + else + { + if (m_remote_platform_sp) + success = m_remote_platform_sp->GetProcessInfo (pid, process_info); + } + return success; } bool @@ -225,11 +289,9 @@ PlatformLinux::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site) { - static const uint8_t g_i386_opcode[] = { 0xCC }; - ArchSpec arch = target.GetArchitecture(); - const uint8_t *opcode = NULL; - size_t opcode_size = 0; + const uint8_t *trap_opcode = NULL; + size_t trap_opcode_size = 0; switch (arch.GetCore()) { @@ -239,15 +301,41 @@ case ArchSpec::eCore_x86_32_i386: case ArchSpec::eCore_x86_64_x86_64: - opcode = g_i386_opcode; - opcode_size = sizeof(g_i386_opcode); + { + static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC }; + trap_opcode = g_i386_breakpoint_opcode; + trap_opcode_size = sizeof(g_i386_breakpoint_opcode); + } break; } - bp_site->SetTrapOpcode(opcode, opcode_size); - return opcode_size; + if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size)) + return trap_opcode_size; + return 0; } +Error +PlatformLinux::LaunchProcess (ProcessLaunchInfo &launch_info) +{ + Error error; + + if (IsHost()) + { + if (launch_info.GetFlags().Test (eLaunchFlagLaunchInShell)) + { + const bool is_localhost = true; + if (!launch_info.ConvertArgumentsForLaunchingInShell (error, is_localhost)) + return error; + } + error = Platform::LaunchProcess (launch_info); + } + else + { + error.SetErrorString ("the platform is not currently connected"); + } + return error; +} + lldb::ProcessSP PlatformLinux::Attach(ProcessAttachInfo &attach_info, Debugger &debugger, @@ -255,7 +343,42 @@ Listener &listener, Error &error) { - ProcessSP processSP; - assert(!"Not implemented yet!"); - return processSP; + lldb::ProcessSP process_sp; + if (IsHost()) + { + if (target == NULL) + { + TargetSP new_target_sp; + FileSpec emptyFileSpec; + ArchSpec emptyArchSpec; + + error = debugger.GetTargetList().CreateTarget (debugger, + emptyFileSpec, + emptyArchSpec, + false, + m_remote_platform_sp, + new_target_sp); + target = new_target_sp.get(); + } + else + error.Clear(); + + if (target && error.Success()) + { + debugger.GetTargetList().SetSelectedTarget(target); + + process_sp = target->CreateProcess (listener, attach_info.GetProcessPluginName()); + + if (process_sp) + error = process_sp->Attach (attach_info); + } + } + else + { + if (m_remote_platform_sp) + process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, listener, error); + else + error.SetErrorString ("the platform is not currently connected"); + } + return process_sp; } Index: source/Plugins/Platform/Linux/PlatformLinux.h =================================================================== --- source/Plugins/Platform/Linux/PlatformLinux.h (revision 145313) +++ source/Plugins/Platform/Linux/PlatformLinux.h (working copy) @@ -28,7 +28,7 @@ static void Terminate (); - PlatformLinux (); + PlatformLinux (bool is_host); virtual ~PlatformLinux(); @@ -43,8 +43,11 @@ GetPluginNameStatic(); static const char * - GetPluginDescriptionStatic(); + GetShortPluginNameStatic(bool is_host); + static const char * + GetPluginDescriptionStatic(bool is_host); + virtual const char * GetPluginName() { @@ -74,7 +77,7 @@ virtual const char * GetDescription () { - return GetPluginDescriptionStatic(); + return GetPluginDescriptionStatic(IsHost()); } virtual void @@ -94,6 +97,9 @@ GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site); + virtual lldb_private::Error + LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info); + virtual lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, Listener &listener, Error &error); @@ -105,8 +111,8 @@ } protected: + lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a remote darwin OS - private: DISALLOW_COPY_AND_ASSIGN (PlatformLinux); }; Index: source/Plugins/Process/Linux/ProcessLinux.cpp =================================================================== --- source/Plugins/Process/Linux/ProcessLinux.cpp (revision 145313) +++ source/Plugins/Process/Linux/ProcessLinux.cpp (working copy) @@ -87,7 +87,6 @@ m_in_limbo(false), m_exit_now(false) { - #if 0 // FIXME: Putting this code in the ctor and saving the byte order in a // member variable is a hack to avoid const qual issues in GetByteOrder. @@ -152,7 +151,6 @@ SetPrivateState(eStateLaunching); - uint32_t launch_flags = launch_info.GetFlags().Get(); const char *stdin_path = NULL; const char *stdout_path = NULL; const char *stderr_path = NULL; @@ -270,7 +268,13 @@ Error ProcessLinux::DoDetach() { - return Error(1, eErrorTypeGeneric); + Error error; + + error = m_monitor->Detach(); + if (error.Success()) + SetPrivateState(eStateDetached); + + return error; } Error @@ -388,7 +392,7 @@ ProcessLinux::IsAlive() { StateType state = GetPrivateState(); - return state != eStateExited && state != eStateInvalid; + return state != eStateDetached && state != eStateExited && state != eStateInvalid; } size_t Index: source/Plugins/Process/Linux/ProcessMonitor.cpp =================================================================== --- source/Plugins/Process/Linux/ProcessMonitor.cpp (revision 145313) +++ source/Plugins/Process/Linux/ProcessMonitor.cpp (working copy) @@ -722,6 +722,30 @@ m_result = true; } +//------------------------------------------------------------------------------ +/// @class KillOperation +/// @brief Implements ProcessMonitor::BringProcessIntoLimbo. +class DetachOperation : public Operation +{ +public: + DetachOperation(Error &result) : m_error(result) { } + + void Execute(ProcessMonitor *monitor); + +private: + Error &m_error; +}; + +void +DetachOperation::Execute(ProcessMonitor *monitor) +{ + lldb::pid_t pid = monitor->GetPID(); + + if (ptrace(PT_DETACH, pid, NULL, 0) < 0) + m_error.SetErrorToErrno(); + +} + ProcessMonitor::OperationArgs::OperationArgs(ProcessMonitor *monitor) : m_monitor(monitor) { @@ -1220,7 +1244,7 @@ ProcessMessage ProcessMonitor::MonitorSIGTRAP(ProcessMonitor *monitor, - const struct siginfo *info, lldb::pid_t pid) + const siginfo_t *info, lldb::pid_t pid) { ProcessMessage message; @@ -1261,7 +1285,7 @@ ProcessMessage ProcessMonitor::MonitorSignal(ProcessMonitor *monitor, - const struct siginfo *info, lldb::pid_t pid) + const siginfo_t *info, lldb::pid_t pid) { ProcessMessage message; int signo = info->si_signo; @@ -1312,7 +1336,7 @@ } ProcessMessage::CrashReason -ProcessMonitor::GetCrashReasonForSIGSEGV(const struct siginfo *info) +ProcessMonitor::GetCrashReasonForSIGSEGV(const siginfo_t *info) { ProcessMessage::CrashReason reason; assert(info->si_signo == SIGSEGV); @@ -1336,7 +1360,7 @@ } ProcessMessage::CrashReason -ProcessMonitor::GetCrashReasonForSIGILL(const struct siginfo *info) +ProcessMonitor::GetCrashReasonForSIGILL(const siginfo_t *info) { ProcessMessage::CrashReason reason; assert(info->si_signo == SIGILL); @@ -1378,7 +1402,7 @@ } ProcessMessage::CrashReason -ProcessMonitor::GetCrashReasonForSIGFPE(const struct siginfo *info) +ProcessMonitor::GetCrashReasonForSIGFPE(const siginfo_t *info) { ProcessMessage::CrashReason reason; assert(info->si_signo == SIGFPE); @@ -1420,7 +1444,7 @@ } ProcessMessage::CrashReason -ProcessMonitor::GetCrashReasonForSIGBUS(const struct siginfo *info) +ProcessMonitor::GetCrashReasonForSIGBUS(const siginfo_t *info) { ProcessMessage::CrashReason reason; assert(info->si_signo == SIGBUS); @@ -1646,7 +1670,9 @@ ProcessMonitor::Detach() { bool result; - KillOperation op(result); + lldb_private::Error error; + DetachOperation op(error); + result = error.Success(); DoOperation(&op); StopMonitor(); return result; Index: source/Plugins/Process/Linux/ProcessMonitor.h =================================================================== --- source/Plugins/Process/Linux/ProcessMonitor.h (revision 145313) +++ source/Plugins/Process/Linux/ProcessMonitor.h (working copy) @@ -257,23 +257,23 @@ static ProcessMessage MonitorSIGTRAP(ProcessMonitor *monitor, - const struct siginfo *info, lldb::pid_t pid); + const siginfo_t *info, lldb::pid_t pid); static ProcessMessage MonitorSignal(ProcessMonitor *monitor, - const struct siginfo *info, lldb::pid_t pid); + const siginfo_t *info, lldb::pid_t pid); static ProcessMessage::CrashReason - GetCrashReasonForSIGSEGV(const struct siginfo *info); + GetCrashReasonForSIGSEGV(const siginfo_t *info); static ProcessMessage::CrashReason - GetCrashReasonForSIGILL(const struct siginfo *info); + GetCrashReasonForSIGILL(const siginfo_t *info); static ProcessMessage::CrashReason - GetCrashReasonForSIGFPE(const struct siginfo *info); + GetCrashReasonForSIGFPE(const siginfo_t *info); static ProcessMessage::CrashReason - GetCrashReasonForSIGBUS(const struct siginfo *info); + GetCrashReasonForSIGBUS(const siginfo_t *info); void DoOperation(Operation *op); From baldrick at free.fr Tue Nov 29 08:10:12 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 29 Nov 2011 15:10:12 +0100 Subject: [Lldb-commits] [PATCH] fix debugging on linux In-Reply-To: <20111129034923.GA31461@bloodbath.burble.org> References: <20111124073122.GA13244@bloodbath.burble.org> <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> <4ED34745.7090201@free.fr> <20111129034923.GA31461@bloodbath.burble.org> Message-ID: <4ED4E7C4.1010406@free.fr> Hi Dawn, On 29/11/11 04:49, dawn at burble.org wrote: > Glad to see there's finally a buildbot for Linux - thank you! I just provided the machine - Peter Collingbourne set up the builder. > I have 32-bit Linux - any way to get a buildbot set up for that? I see that Peter tried to get a 32 bit lldb buildbot going, but stopped at some point. One awkward point is that the machine is 64 bit, so you need to build inside an artificial 32 bit environment, which complicates things a bit. Hopefully Peter will explain if he plans to continue working on this. Ciao, Duncan. > I get much farther, so I suspect this is a problem with the 64-bit > Linux. > > -Dawn > > On Mon, Nov 28, 2011 at 09:33:09AM +0100, Duncan Sands wrote: >> The linux lldb buildbot http://lab.llvm.org:8011/builders/lldb-x86_64-linux >> is still failing, now with: >> >> Collected 442 tests >> >> 1: test_with_dsym (TestLogging.LogTestCase) ... skipped 'requires Darwin' >> 2: test_with_dwarf (TestLogging.LogTestCase) ... FAIL >> 3: test_with_dsym (TestFormatters.ExprFormattersTestCase) >> Test expr + formatters for good interoperability. ... skipped 'requires >> Darwin' >> 4: test_with_dwarf_ (TestFormatters.ExprFormattersTestCase) >> Test expr + formatters for good interoperability. ... ERROR >> 5: test_expr_commands (TestPrintfAfterUp.Radar9531204TestCase) >> The evaluating printf(...) after break stop and then up a stack frame. ... >> python: LinuxThread.cpp:239: void LinuxThread::BreakNotify(const >> ProcessMessage&): Assertion `bp_site' failed. >> make: *** [check-local] Aborted >> program finished with exit code 2 >> >> Ciao, Duncan. >> >> On 28/11/11 03:03, Greg Clayton wrote: >>> >>> On Nov 23, 2011, at 11:31 PM, dawn at burble.org wrote: >>> >>>> This patch was created using clang/llvm rev 144569, lldb rev 144919 but has >>>> been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on >>>> Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. >>>> >>>> Debugging on Linux broke when the assumption was made that a process could be >>>> launched by spawning it in a suspended state and then attaching to it. That >>>> support does not exist on Linux. To work around this, I added a new method >>>> "CanLaunchViaAttach" which tests whether the platform supports being launched >>>> in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find >>>> an easy way to set it from within the Linux plugins. >>>> >>>> Commit message: >>>> >>>> Fix debugging on Linux. >>>> Implement remote vs. host platform code as was done with PlatformDarwin. >>>> Platform::CanLaunchViaAttach(): new: return true if the process can be launched >>>> via spawn and attach. Default is true. Override in PlatformLinux to false. >>>> Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) >>>> then launch the process via CreateProcess and Launch. >>>> >>>> Please review and commit if acceptable. >>> >>> I checked in an alternate fix: >>> >>> % svn commit >>> Sending include/lldb/Core/Module.h >>> Sending include/lldb/Symbol/SymbolFile.h >>> Sending include/lldb/Target/Platform.h >>> Sending source/Commands/CommandObjectProcess.cpp >>> Sending source/Core/Module.cpp >>> Sending source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp >>> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp >>> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h >>> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp >>> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h >>> Sending source/Symbol/SymbolFile.cpp >>> Transmitting file data ........... >>> Committed revision 145219. >>> >>> % svn commit >>> Sending Platform/Linux/PlatformLinux.h >>> Transmitting file data . >>> Committed revision 145221. >>> >>> >>> The first one contains the necessary changes to CommandObjectProcess.cpp and to include/lldb/Target/Platform.h that allow a platform to say: >>> >>> >>> virtual bool >>> CanDebugProcess () >>> { >>> return true; >>> } >>> >>> This keeps the code out of the platform since when a platform launches a process, it shouldn't be tied to a process plug-in as in the patch you submitted. >>> >>> Here is the vision of platforms: >>> >>> - They should be able to list all of the processes on the platform. This way you can connect to your local machine and list the processes, or connect to a remote platform, and if the remote platform supports it, it can list the processes that are there. >>> - Platforms should support launching processes. Not always for debugging, but sometimes just to spawn a child process. On the localhost, this means just using the Host::LaunchProcess() functionality. This way, we just need to implement a single copy of the process launching code. When you create a remote platform, you should be able to link against the native linux or darwin launching code and then we don't end up with multiple copies of the launching code like we have now. You make a good point in that not all platforms will be able to support launching with a program stopped for debugging, so we now ask the platform up in the CommandObjectProcessLaunch class before we launch the process. This keeps the platform clean, yet also lets us fall back to just launching the process through the built in process plug-in. >>> - Platforms should support attaching to a remote process. Combined with being able to launch for debug, this allows debugging as we have it on MacOSX. If we do this while remotely connected to a remote darwin machine, we now have the ability to talk to a remote computer and launch, attach, list and do a lot more >>> - Platforms should know if there are files locally on the current machine in an SDK or PDK or some over developer kit/cross compiling sysroot, etc to allow locating files in terms of the path you would us on the remote machine. For example when debugging on a remote device, if the are asked to find the file for "/bin/ls", this might locally be located in developer kit directory such as >>> "/path/to/old/linux/sysroot/bin/ls". This allows you to debug remote machines, or event mount the root file system on a mountpoint so you have access to the files so you can debug. >>> - Platforms should be able to upload/download files so you could install a new binary and run it, or upload a shared library so we can locally cache it for faster debugging. >>> >>> We are in the process of slowly makine these Platforms a reality, so keep the questions coming if anyone has any. >>> >>> So in short: I made the fix you requested, but in a different way. If you can rework your patch around what is in top of tree, then we can get the rest of it submitted. >>> >>> Greg Clayton >>> >>>> Thanks! >>>> -Dawn >>>> _______________________________________________ >>>> lldb-commits mailing list >>>> 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 >>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits >> >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From johnny.chen at apple.com Tue Nov 29 13:13:38 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 29 Nov 2011 19:13:38 -0000 Subject: [Lldb-commits] [lldb] r145417 - /lldb/trunk/test/bench-history Message-ID: <20111129191339.04E0F1BE001@llvm.org> Author: johnny Date: Tue Nov 29 13:13:38 2011 New Revision: 145417 URL: http://llvm.org/viewvc/llvm-project?rev=145417&view=rev Log: Add bench entries. Modified: lldb/trunk/test/bench-history Modified: lldb/trunk/test/bench-history URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bench-history?rev=145417&r1=145416&r2=145417&view=diff ============================================================================== --- lldb/trunk/test/bench-history (original) +++ lldb/trunk/test/bench-history Tue Nov 29 13:13:38 2011 @@ -164,4 +164,43 @@ lldb stepping benchmark: Avg: 0.102836 (Laps: 50, Total Elapsed Time: 5.141815, min=0.101461, max=0.122378) lldb expr cmd benchmark: Avg: 0.206334 (Laps: 25, Total Elapsed Time: 5.158355, min=0.203804, max=0.241043) lldb disassembly benchmark: Avg: 0.033536 (Laps: 10, Total Elapsed Time: 0.335359, min=0.031975, max=0.041612) -[15:01:59] johnny:/Volumes/data/lldb/svn/trunk/test $ \ No newline at end of file +[15:01:59] johnny:/Volumes/data/lldb/svn/trunk/test $ + +# Redid the r143469 measurements (svn/regress dir) right before the r145371 measurements (svn/trunk dir) on 10.7.2 (build 11C74). +# The lldb startup delay (run to breakpoint) in avg is not as significant. The min still shows some possible regression. +# The frame variable benchmark shows some possible regression. +[10:51:56] johnny:/Volumes/data/lldb/svn/regress/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' +lldb startup delay (create fresh target) benchmark: Avg: 0.109821 (Laps: 30, Total Elapsed Time: 3.294643, min=0.101836, max=0.297468) +lldb startup delay (set first breakpoint) benchmark: Avg: 0.121465 (Laps: 30, Total Elapsed Time: 3.643950, min=0.100776, max=0.665900) +lldb startup delay (run to breakpoint) benchmark: Avg: 0.501870 (Laps: 30, Total Elapsed Time: 15.056112, min=0.469871, max=0.718775) +lldb frame variable benchmark: Avg: 1.663890 (Laps: 20, Total Elapsed Time: 33.277791, min=1.584265, max=1.999998) +lldb stepping benchmark: Avg: 0.105434 (Laps: 50, Total Elapsed Time: 5.271683, min=0.101120, max=0.256289) +lldb expr cmd benchmark: Avg: 0.240440 (Laps: 25, Total Elapsed Time: 6.011000, min=0.203547, max=0.956405) +lldb disassembly benchmark: Avg: 0.096988 (Laps: 10, Total Elapsed Time: 0.969877, min=0.089511, max=0.147797) +[10:55:38] johnny:/Volumes/data/lldb/svn/regress/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' +lldb startup delay (create fresh target) benchmark: Avg: 0.107368 (Laps: 30, Total Elapsed Time: 3.221026, min=0.101374, max=0.163785) +lldb startup delay (set first breakpoint) benchmark: Avg: 0.153588 (Laps: 30, Total Elapsed Time: 4.607645, min=0.101554, max=0.776372) +lldb startup delay (run to breakpoint) benchmark: Avg: 0.510726 (Laps: 30, Total Elapsed Time: 15.321779, min=0.468395, max=0.643357) +lldb frame variable benchmark: Avg: 1.715136 (Laps: 20, Total Elapsed Time: 34.302718, min=1.527872, max=3.125777) +lldb stepping benchmark: Avg: 0.116140 (Laps: 50, Total Elapsed Time: 5.807012, min=0.100857, max=0.796673) +lldb expr cmd benchmark: Avg: 0.206397 (Laps: 25, Total Elapsed Time: 5.159914, min=0.203491, max=0.241283) +lldb disassembly benchmark: Avg: 0.036542 (Laps: 10, Total Elapsed Time: 0.365422, min=0.031872, max=0.060183) +[10:59:43] johnny:/Volumes/data/lldb/svn/regress/test $ pushd +1 +/Volumes/data/lldb/svn/trunk/test /Volumes/data/lldb/llvm /Volumes/data/lldb/svn/regress/test +[10:59:48] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' +lldb startup delay (create fresh target) benchmark: Avg: 0.103919 (Laps: 30, Total Elapsed Time: 3.117560, min=0.101766, max=0.137548) +lldb startup delay (set first breakpoint) benchmark: Avg: 0.102705 (Laps: 30, Total Elapsed Time: 3.081165, min=0.101311, max=0.114192) +lldb startup delay (run to breakpoint) benchmark: Avg: 0.504830 (Laps: 30, Total Elapsed Time: 15.144906, min=0.483528, max=0.627122) +lldb frame variable benchmark: Avg: 1.924774 (Laps: 20, Total Elapsed Time: 38.495475, min=1.798745, max=2.248269) +lldb stepping benchmark: Avg: 0.102595 (Laps: 50, Total Elapsed Time: 5.129757, min=0.100690, max=0.125930) +lldb expr cmd benchmark: Avg: 0.205395 (Laps: 25, Total Elapsed Time: 5.134883, min=0.202864, max=0.210484) +lldb disassembly benchmark: Avg: 0.033576 (Laps: 10, Total Elapsed Time: 0.335765, min=0.032021, max=0.039222) +[11:03:46] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' +lldb startup delay (create fresh target) benchmark: Avg: 0.103371 (Laps: 30, Total Elapsed Time: 3.101121, min=0.101556, max=0.127819) +lldb startup delay (set first breakpoint) benchmark: Avg: 0.103174 (Laps: 30, Total Elapsed Time: 3.095230, min=0.101763, max=0.114733) +lldb startup delay (run to breakpoint) benchmark: Avg: 0.513848 (Laps: 30, Total Elapsed Time: 15.415439, min=0.490004, max=0.748310) +lldb frame variable benchmark: Avg: 1.906068 (Laps: 20, Total Elapsed Time: 38.121364, min=1.872328, max=2.044472) +lldb stepping benchmark: Avg: 0.254817 (Laps: 50, Total Elapsed Time: 12.740872, min=0.100743, max=7.628899) +lldb expr cmd benchmark: Avg: 0.207850 (Laps: 25, Total Elapsed Time: 5.196255, min=0.203986, max=0.257482) +lldb disassembly benchmark: Avg: 0.092003 (Laps: 10, Total Elapsed Time: 0.920026, min=0.089568, max=0.100374) +[11:07:53] johnny:/Volumes/data/lldb/svn/trunk/test $ From gclayton at apple.com Tue Nov 29 14:50:10 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 29 Nov 2011 20:50:10 -0000 Subject: [Lldb-commits] [lldb] r145433 - in /lldb/trunk/source/Plugins: Platform/Linux/PlatformLinux.cpp Platform/Linux/PlatformLinux.h Process/Linux/ProcessLinux.cpp Process/Linux/ProcessMonitor.cpp Process/Linux/ProcessMonitor.h Message-ID: <20111129205010.7A4A51BE001@llvm.org> Author: gclayton Date: Tue Nov 29 14:50:10 2011 New Revision: 145433 URL: http://llvm.org/viewvc/llvm-project?rev=145433&view=rev Log: Patch from Dawn that fixes up linux debugging and a first passs at an implementation of the linux platform. Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=145433&r1=145432&r2=145433&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original) +++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Tue Nov 29 14:50:10 2011 @@ -17,6 +17,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Error.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/PluginManager.h" @@ -29,10 +30,12 @@ using namespace lldb; using namespace lldb_private; +static uint32_t g_initialize_count = 0; + Platform * PlatformLinux::CreateInstance () { - return new PlatformLinux(); + return new PlatformLinux(true); } const char * @@ -42,33 +45,51 @@ } const char * -PlatformLinux::GetPluginDescriptionStatic() +PlatformLinux::GetShortPluginNameStatic (bool is_host) { - return "Default platform plugin for Linux"; + if (is_host) + return Platform::GetHostPlatformName (); + else + return "remote-linux"; +} + +const char * +PlatformLinux::GetPluginDescriptionStatic (bool is_host) +{ + if (is_host) + return "Local Linux user platform plug-in."; + else + return "Remote Linux user platform plug-in."; } void PlatformLinux::Initialize () { - static bool g_initialized = false; - - if (!g_initialized) + if (g_initialize_count++ == 0) { - PlatformSP default_platform_sp (CreateInstance()); +#if defined(__linux__) + PlatformSP default_platform_sp (new PlatformLinux(true)); + default_platform_sp->SetSystemArchitecture (Host::GetArchitecture()); Platform::SetDefaultPlatform (default_platform_sp); - PluginManager::RegisterPlugin(GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); - g_initialized = true; +#endif + PluginManager::RegisterPlugin(PlatformLinux::GetShortPluginNameStatic(false), + PlatformLinux::GetPluginDescriptionStatic(false), + PlatformLinux::CreateInstance); } } void PlatformLinux::Terminate () { + if (g_initialize_count > 0) + { + if (--g_initialize_count == 0) + { + PluginManager::UnregisterPlugin (PlatformLinux::CreateInstance); + } + } } - Error PlatformLinux::ResolveExecutable (const FileSpec &exe_file, const ArchSpec &exe_arch, @@ -77,17 +98,50 @@ Error error; // Nothing special to do here, just use the actual file and architecture + char exe_path[PATH_MAX]; FileSpec resolved_exe_file (exe_file); - // If we have "ls" as the exe_file, resolve the executable loation based on - // the current path variables - if (!resolved_exe_file.Exists()) - resolved_exe_file.ResolveExecutableLocation (); + if (IsHost()) + { + // If we have "ls" as the exe_file, resolve the executable location based on + // the current path variables + if (!resolved_exe_file.Exists()) + { + exe_file.GetPath(exe_path, sizeof(exe_path)); + resolved_exe_file.SetFile(exe_path, true); + } - // Resolve any executable within a bundle on MacOSX - Host::ResolveExecutableInBundle (resolved_exe_file); + if (!resolved_exe_file.Exists()) + resolved_exe_file.ResolveExecutableLocation (); + + if (resolved_exe_file.Exists()) + error.Clear(); + else + { + exe_file.GetPath(exe_path, sizeof(exe_path)); + error.SetErrorStringWithFormat("unable to find executable for '%s'", exe_path); + } + } + else + { + if (m_remote_platform_sp) + { + error = m_remote_platform_sp->ResolveExecutable (exe_file, + exe_arch, + exe_module_sp); + } + else + { + // We may connect to a process and use the provided executable (Don't use local $PATH). + + if (resolved_exe_file.Exists()) + error.Clear(); + else + error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", exe_path); + } + } - if (resolved_exe_file.Exists()) + if (error.Success()) { if (exe_arch.IsValid()) { @@ -152,21 +206,20 @@ } } } - else - { - error.SetErrorStringWithFormat ("'%s%s%s' does not exist", - exe_file.GetDirectory().AsCString(""), - exe_file.GetDirectory() ? "/" : "", - exe_file.GetFilename().AsCString("")); - } return error; } Error PlatformLinux::GetFile (const FileSpec &platform_file, - const UUID *uuid, FileSpec &local_file) + const UUID *uuid_ptr, FileSpec &local_file) { + if (IsRemote()) + { + if (m_remote_platform_sp) + return m_remote_platform_sp->GetFile (platform_file, uuid_ptr, local_file); + } + // Default to the local case local_file = platform_file; return Error(); @@ -176,8 +229,9 @@ //------------------------------------------------------------------ /// Default Constructor //------------------------------------------------------------------ -PlatformLinux::PlatformLinux () : - Platform(true) +PlatformLinux::PlatformLinux (bool is_host) : + Platform(is_host), // This is the local host platform + m_remote_platform_sp () { } @@ -194,7 +248,17 @@ bool PlatformLinux::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) { - return Host::GetProcessInfo (pid, process_info); + bool success = false; + if (IsHost()) + { + success = Platform::GetProcessInfo (pid, process_info); + } + else + { + if (m_remote_platform_sp) + success = m_remote_platform_sp->GetProcessInfo (pid, process_info); + } + return success; } bool @@ -225,11 +289,9 @@ PlatformLinux::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site) { - static const uint8_t g_i386_opcode[] = { 0xCC }; - ArchSpec arch = target.GetArchitecture(); - const uint8_t *opcode = NULL; - size_t opcode_size = 0; + const uint8_t *trap_opcode = NULL; + size_t trap_opcode_size = 0; switch (arch.GetCore()) { @@ -239,13 +301,39 @@ case ArchSpec::eCore_x86_32_i386: case ArchSpec::eCore_x86_64_x86_64: - opcode = g_i386_opcode; - opcode_size = sizeof(g_i386_opcode); + { + static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC }; + trap_opcode = g_i386_breakpoint_opcode; + trap_opcode_size = sizeof(g_i386_breakpoint_opcode); + } break; } - bp_site->SetTrapOpcode(opcode, opcode_size); - return opcode_size; + if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size)) + return trap_opcode_size; + return 0; +} + +Error +PlatformLinux::LaunchProcess (ProcessLaunchInfo &launch_info) +{ + Error error; + + if (IsHost()) + { + if (launch_info.GetFlags().Test (eLaunchFlagLaunchInShell)) + { + const bool is_localhost = true; + if (!launch_info.ConvertArgumentsForLaunchingInShell (error, is_localhost)) + return error; + } + error = Platform::LaunchProcess (launch_info); + } + else + { + error.SetErrorString ("the platform is not currently connected"); + } + return error; } lldb::ProcessSP @@ -255,7 +343,42 @@ Listener &listener, Error &error) { - ProcessSP processSP; - assert(!"Not implemented yet!"); - return processSP; + lldb::ProcessSP process_sp; + if (IsHost()) + { + if (target == NULL) + { + TargetSP new_target_sp; + FileSpec emptyFileSpec; + ArchSpec emptyArchSpec; + + error = debugger.GetTargetList().CreateTarget (debugger, + emptyFileSpec, + emptyArchSpec, + false, + m_remote_platform_sp, + new_target_sp); + target = new_target_sp.get(); + } + else + error.Clear(); + + if (target && error.Success()) + { + debugger.GetTargetList().SetSelectedTarget(target); + + process_sp = target->CreateProcess (listener, attach_info.GetProcessPluginName()); + + if (process_sp) + error = process_sp->Attach (attach_info); + } + } + else + { + if (m_remote_platform_sp) + process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, listener, error); + else + error.SetErrorString ("the platform is not currently connected"); + } + return process_sp; } Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h?rev=145433&r1=145432&r2=145433&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h (original) +++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h Tue Nov 29 14:50:10 2011 @@ -28,7 +28,7 @@ static void Terminate (); - PlatformLinux (); + PlatformLinux (bool is_host); virtual ~PlatformLinux(); @@ -43,7 +43,10 @@ GetPluginNameStatic(); static const char * - GetPluginDescriptionStatic(); + GetShortPluginNameStatic(bool is_host); + + static const char * + GetPluginDescriptionStatic(bool is_host); virtual const char * GetPluginName() @@ -74,7 +77,7 @@ virtual const char * GetDescription () { - return GetPluginDescriptionStatic(); + return GetPluginDescriptionStatic(IsHost()); } virtual void @@ -94,6 +97,9 @@ GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site); + virtual lldb_private::Error + LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info); + virtual lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, Listener &listener, Error &error); @@ -105,7 +111,7 @@ } protected: - + lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a remote darwin OS private: DISALLOW_COPY_AND_ASSIGN (PlatformLinux); Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp?rev=145433&r1=145432&r2=145433&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp Tue Nov 29 14:50:10 2011 @@ -87,7 +87,6 @@ m_in_limbo(false), m_exit_now(false) { - #if 0 // FIXME: Putting this code in the ctor and saving the byte order in a // member variable is a hack to avoid const qual issues in GetByteOrder. @@ -152,7 +151,6 @@ SetPrivateState(eStateLaunching); - uint32_t launch_flags = launch_info.GetFlags().Get(); const char *stdin_path = NULL; const char *stdout_path = NULL; const char *stderr_path = NULL; @@ -270,7 +268,13 @@ Error ProcessLinux::DoDetach() { - return Error(1, eErrorTypeGeneric); + Error error; + + error = m_monitor->Detach(); + if (error.Success()) + SetPrivateState(eStateDetached); + + return error; } Error @@ -388,7 +392,7 @@ ProcessLinux::IsAlive() { StateType state = GetPrivateState(); - return state != eStateExited && state != eStateInvalid; + return state != eStateDetached && state != eStateExited && state != eStateInvalid; } size_t Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=145433&r1=145432&r2=145433&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Tue Nov 29 14:50:10 2011 @@ -722,6 +722,30 @@ m_result = true; } +//------------------------------------------------------------------------------ +/// @class KillOperation +/// @brief Implements ProcessMonitor::BringProcessIntoLimbo. +class DetachOperation : public Operation +{ +public: + DetachOperation(Error &result) : m_error(result) { } + + void Execute(ProcessMonitor *monitor); + +private: + Error &m_error; +}; + +void +DetachOperation::Execute(ProcessMonitor *monitor) +{ + lldb::pid_t pid = monitor->GetPID(); + + if (ptrace(PT_DETACH, pid, NULL, 0) < 0) + m_error.SetErrorToErrno(); + +} + ProcessMonitor::OperationArgs::OperationArgs(ProcessMonitor *monitor) : m_monitor(monitor) { @@ -1220,7 +1244,7 @@ ProcessMessage ProcessMonitor::MonitorSIGTRAP(ProcessMonitor *monitor, - const struct siginfo *info, lldb::pid_t pid) + const siginfo_t *info, lldb::pid_t pid) { ProcessMessage message; @@ -1261,7 +1285,7 @@ ProcessMessage ProcessMonitor::MonitorSignal(ProcessMonitor *monitor, - const struct siginfo *info, lldb::pid_t pid) + const siginfo_t *info, lldb::pid_t pid) { ProcessMessage message; int signo = info->si_signo; @@ -1312,7 +1336,7 @@ } ProcessMessage::CrashReason -ProcessMonitor::GetCrashReasonForSIGSEGV(const struct siginfo *info) +ProcessMonitor::GetCrashReasonForSIGSEGV(const siginfo_t *info) { ProcessMessage::CrashReason reason; assert(info->si_signo == SIGSEGV); @@ -1336,7 +1360,7 @@ } ProcessMessage::CrashReason -ProcessMonitor::GetCrashReasonForSIGILL(const struct siginfo *info) +ProcessMonitor::GetCrashReasonForSIGILL(const siginfo_t *info) { ProcessMessage::CrashReason reason; assert(info->si_signo == SIGILL); @@ -1378,7 +1402,7 @@ } ProcessMessage::CrashReason -ProcessMonitor::GetCrashReasonForSIGFPE(const struct siginfo *info) +ProcessMonitor::GetCrashReasonForSIGFPE(const siginfo_t *info) { ProcessMessage::CrashReason reason; assert(info->si_signo == SIGFPE); @@ -1420,7 +1444,7 @@ } ProcessMessage::CrashReason -ProcessMonitor::GetCrashReasonForSIGBUS(const struct siginfo *info) +ProcessMonitor::GetCrashReasonForSIGBUS(const siginfo_t *info) { ProcessMessage::CrashReason reason; assert(info->si_signo == SIGBUS); @@ -1646,7 +1670,9 @@ ProcessMonitor::Detach() { bool result; - KillOperation op(result); + lldb_private::Error error; + DetachOperation op(error); + result = error.Success(); DoOperation(&op); StopMonitor(); return result; Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h?rev=145433&r1=145432&r2=145433&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h Tue Nov 29 14:50:10 2011 @@ -257,23 +257,23 @@ static ProcessMessage MonitorSIGTRAP(ProcessMonitor *monitor, - const struct siginfo *info, lldb::pid_t pid); + const siginfo_t *info, lldb::pid_t pid); static ProcessMessage MonitorSignal(ProcessMonitor *monitor, - const struct siginfo *info, lldb::pid_t pid); + const siginfo_t *info, lldb::pid_t pid); static ProcessMessage::CrashReason - GetCrashReasonForSIGSEGV(const struct siginfo *info); + GetCrashReasonForSIGSEGV(const siginfo_t *info); static ProcessMessage::CrashReason - GetCrashReasonForSIGILL(const struct siginfo *info); + GetCrashReasonForSIGILL(const siginfo_t *info); static ProcessMessage::CrashReason - GetCrashReasonForSIGFPE(const struct siginfo *info); + GetCrashReasonForSIGFPE(const siginfo_t *info); static ProcessMessage::CrashReason - GetCrashReasonForSIGBUS(const struct siginfo *info); + GetCrashReasonForSIGBUS(const siginfo_t *info); void DoOperation(Operation *op); From gclayton at apple.com Tue Nov 29 14:53:23 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 29 Nov 2011 12:53:23 -0800 Subject: [Lldb-commits] [PATCH] fix debugging on linux In-Reply-To: <20111129093428.GA3339@bloodbath.burble.org> References: <20111124073122.GA13244@bloodbath.burble.org> <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> <20111128195949.GA24208@bloodbath.burble.org> <06D1CC93-A433-42D5-9332-BEE9142802CA@apple.com> <20111129014718.GA29289@bloodbath.burble.org> <20111129032825.GA31054@bloodbath.burble.org> <9684474F-52A6-485F-95BD-07376026D54D@apple.com> <20111129093428.GA3339@bloodbath.burble.org> Message-ID: Patch looks good: % svn commit Sending source/Plugins/Platform/Linux/PlatformLinux.cpp Sending source/Plugins/Platform/Linux/PlatformLinux.h Sending source/Plugins/Process/Linux/ProcessLinux.cpp Sending source/Plugins/Process/Linux/ProcessMonitor.cpp Sending source/Plugins/Process/Linux/ProcessMonitor.h Transmitting file data ..... Committed revision 145433. On Nov 29, 2011, at 1:34 AM, dawn at burble.org wrote: > Admittedly, I was confused by the host vs. remote process code > that was added recently. I understand a bit more now, and tried to > copy the process launching code from Plugins/Process/Linux to Host/linux, > but got lost in the need to reference the target and listeners needed by > ProcessLinux::ProcessLinux(Target& target, Listener &listener) > so I give up :(. I don't like what we have now, but I've failed to come > up with anything better, so I concede. At least we have a workaround - > thank you!!! > > I've resubitted the rest of my original patch (attached) which adds > support for some of the remote vs. host code. LaunchProcess still needs > to be implemented, but it's a start. Please commit? > > Thanks again, > -Dawn > > On Mon, Nov 28, 2011 at 08:38:04PM -0800, Greg Clayton wrote: >> >> On Nov 28, 2011, at 7:28 PM, dawn at burble.org wrote: >> >>> On Mon, Nov 28, 2011 at 05:58:05PM -0800, Greg Clayton wrote: >>>> >>>> Can you have the linux "Host::LaunchProcess()" do the fork, ptrace me, exec, then do the attach? Or must linux have a debug process attached right from the start? >>> >>> No, both Linux and Windows (and I think BSD as well) will not allow you >>> to attach to a process that you're already debugging. >> >> I am not asking for that. >> >>> They want to have a debug process attached right from the start. They do support >>> attaching to an existing process that's already running, but that's a >>> different problem - here we want to debug the process form the start. >>> >>> So I think you see the issue now? >> >> I see the issue, but your fix in the platform isn't going to help. It works for local debugging only, but not for remote debugging, which is the whole point of going through the platform in the first place. Your current fix will always try and launch the program using the default process plug-in on the current machine. >> >> What is intended for the platform is: >> >> (lldb) platform select remote-macosx >> (lldb) platform connect tcp://some.machine.com:1234 >> (lldb) target create /sdk/linux2.3/bin/ls >> (lldb) run >> >> now when you do the launching, the launching should happen through the platform on the remote host, but in your patch: >> >> lldb::ProcessSP >> Platform::DebugProcess (ProcessLaunchInfo &launch_info, >> Debugger &debugger, >> Target *target, // Can be NULL, if NULL create a new target, else use existing one >> Listener &listener, >> Error &error) >> { >> ProcessSP process_sp; >> // Make sure we stop at the entry point >> launch_info.GetFlags ().Set (eLaunchFlagDebug); >> >> if (!target->GetPlatform()->CanLaunchProcessStoppedAtEntry()) >> { >> const char *plugin_name = launch_info.GetProcessPluginName(); >> process_sp = target->CreateProcess (listener, plugin_name).get(); >> error = process_sp->Launch (launch_info); >> } >> else >> .... >> >> this will just launch it locally. A fix should actually be happening in the Platform::LaunchProcess: >> >> Error >> Platform::LaunchProcess (ProcessLaunchInfo &launch_info) >> { >> Error error; >> // Take care of the host case so that each subclass can just >> // call this function to get the host functionality. >> if (IsHost()) >> error = Host::LaunchProcess (launch_info); >> else >> error.SetErrorString ("base lldb_private::Platform class can't launch remote processes"); >> return error; >> } >> >> But here LaunchProcess isn't returning a ProcessSP of any kind since this function is also used for just spawning processes. >> >> Do you see where I am going with the platform thing here? We can't mix in any specific process class to do the launching. >> >> I know there is work to be done on the platforms still to work out how all of this happens. So for now, I think the code is good >> >>> >>>>> How would you suggest we fix this? >>>> >>>> With my fix that is already checked in (the fix to CommandObjectProcessLaunch that first checks to see if the platform can start a process stopped for debugging and if it can't, it will just use the current process plug-in to do the launch directly and skip the platform launch for debug), the linux process plug-in will be used to do the launching and avoid this issue altogether, right? >>> >>> Yes, but it doesn't fit in with how the process control code was >>> intended to be used - we're skipping the call to DebugProcess just to >>> avoid a call to Attach? And other platforms will have to go this route >>> as well? >> >> No, the explanation above should clarify why. >> >>> >>>>> Move the call to Attach into the MaxOSX >>>>> LaunchProcess code? Or have a flag like CanLaunchViaAttach so we'll know to >>>>> skip the call to Attach? I went with the latter in my patch - that seemed the >>>>> least intrusive yet generic fix. >>>> >>>> Again, I don't understand the can launch via attach. You should be able to launch a program on linux and then attach to it without a debugger needing to be there from the start, you will just miss many instructions as the process makes progress until you attach. >>> >>> Exactly - I think you see the problem now :) >> >> So my vote is to leave the code changes as they exist in the top of tree and let the process plug-in do the launching. >> >>> >>> -Dawn >>> >>> >>>>> On Mon, Nov 28, 2011 at 01:48:35PM -0800, Greg Clayton wrote: >>>>>> >>>>>> On Nov 28, 2011, at 11:59 AM, dawn at burble.org wrote: >>>>>> >>>>>>> I find the name "CanDebugProcess" to be misleading. The issue isn't >>>>>>> whether a process can be debugged on Linux (because it obviously can), >>>>>>> it's that it can't be spawned in a suspended state and then attached >>>>>>> to. AFAIK, Linux doesn't have anything like the MacOSX >>>>>>> "POSIX_SPAWN_START_SUSPENDED" flag for posix_spawnattr_setflags() that >>>>>>> MacOSX has. >>>>>> >>>>>> Yes, this flag is darwin only. >>>>>> >>>>>>> I chose the name "CanLaunchViaAttach" for this, which I think better >>>>>>> describes the problem. Ok to rename "CanDebugProcess" to >>>>>>> "CanLaunchViaAttach"? >>>>>> >>>>>> I am not too fond of the CanLaunchViaAttach because launching a program using a platform doesn't imply that you want to debug or attach to it. Also it doesn't make sense how do you launch via attach? First you launch, then you attach. The attach doesn't have anything to do with launching. You might just want to spawn a server program on the remote platform which you don't want to debug. We are asking the platform (not the process plug-in, but the platform) if it can do something, in this case: can the platform launch a process that can be stopped for debugging. Currently the linux platform can't (though I am sure we can make it work somehow), only the native linux _process_ plug-in can. You can't use the ProcessLinux plug-in to implement stuff functionality for the platform, the platform itself should be doing the work. This is preparing for better remote debugging support where we can launch new remote processes without having to involve any of the process plug-ins. >>>>>> >>>>>> The attach part shouldn't have anything to do with this either because you might want to spawn a new process that is stopped, and then resume it at a controlled time later. The "POSIX_SPAWN_START_SUSPENDED" flag in darwin will have the process halted at the entry point with a SIGSTOP, and it can be resumed later. >>>>>> >>>>>> How about "bool Platform::CanLaunchProcessStoppedAtEntry()"? >>>>>> >>>>>> Platforms are far from complete and we can modify them and grow their abilities over time. Again, the vision is that platforms will eventually launch (possibly for debug), attach to processes, list processes, upload/download and more. They should provide a nice connection to a local or remote machine so that debugging to them is as easy as debugging on your local machine. That is the vision at least, and I know we have some work ahead of us to get there. >>>>>> >>>>>> >>>>>> Greg >>>>>> >>>>>> >>>>>> >>>>>>> Likewise, since you moved the fixes I had made to >>>>>>> DebugProcess() into CommandObjectProcessLaunch(), please also rename >>>>>>> "DebugProcess" to "LaunchViaAttach". >>>>>> >>>>>> Hopefully CanLaunchProcessStoppedAtEntry() makes sense? >>>>>> >>>>>>> Thank you! >>>>>>> -Dawn >>>>>>> >>>>>>> >>>>>>> On Sun, Nov 27, 2011 at 06:03:03PM -0800, Greg Clayton wrote: >>>>>>>> >>>>>>>> On Nov 23, 2011, at 11:31 PM, dawn at burble.org wrote: >>>>>>>> >>>>>>>>> This patch was created using clang/llvm rev 144569, lldb rev 144919 but has >>>>>>>>> been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on >>>>>>>>> Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. >>>>>>>>> >>>>>>>>> Debugging on Linux broke when the assumption was made that a process could be >>>>>>>>> launched by spawning it in a suspended state and then attaching to it. That >>>>>>>>> support does not exist on Linux. To work around this, I added a new method >>>>>>>>> "CanLaunchViaAttach" which tests whether the platform supports being launched >>>>>>>>> in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find >>>>>>>>> an easy way to set it from within the Linux plugins. >>>>>>>>> >>>>>>>>> Commit message: >>>>>>>>> >>>>>>>>> Fix debugging on Linux. >>>>>>>>> Implement remote vs. host platform code as was done with PlatformDarwin. >>>>>>>>> Platform::CanLaunchViaAttach(): new: return true if the process can be launched >>>>>>>>> via spawn and attach. Default is true. Override in PlatformLinux to false. >>>>>>>>> Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) >>>>>>>>> then launch the process via CreateProcess and Launch. >>>>>>>>> >>>>>>>>> Please review and commit if acceptable. >>>>>>>> >>>>>>>> I checked in an alternate fix: >>>>>>>> >>>>>>>> % svn commit >>>>>>>> Sending include/lldb/Core/Module.h >>>>>>>> Sending include/lldb/Symbol/SymbolFile.h >>>>>>>> Sending include/lldb/Target/Platform.h >>>>>>>> Sending source/Commands/CommandObjectProcess.cpp >>>>>>>> Sending source/Core/Module.cpp >>>>>>>> Sending source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp >>>>>>>> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp >>>>>>>> Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h >>>>>>>> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp >>>>>>>> Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h >>>>>>>> Sending source/Symbol/SymbolFile.cpp >>>>>>>> Transmitting file data ........... >>>>>>>> Committed revision 145219. >>>>>>>> >>>>>>>> % svn commit >>>>>>>> Sending Platform/Linux/PlatformLinux.h >>>>>>>> Transmitting file data . >>>>>>>> Committed revision 145221. >>>>>>>> >>>>>>>> >>>>>>>> The first one contains the necessary changes to CommandObjectProcess.cpp and to include/lldb/Target/Platform.h that allow a platform to say: >>>>>>>> >>>>>>>> >>>>>>>> virtual bool >>>>>>>> CanDebugProcess () >>>>>>>> { >>>>>>>> return true; >>>>>>>> } >>>>>>>> >>>>>>>> This keeps the code out of the platform since when a platform launches a process, it shouldn't be tied to a process plug-in as in the patch you submitted. >>>>>>>> >>>>>>>> Here is the vision of platforms: >>>>>>>> >>>>>>>> - They should be able to list all of the processes on the platform. This way you can connect to your local machine and list the processes, or connect to a remote platform, and if the remote platform supports it, it can list the processes that are there. >>>>>>>> - Platforms should support launching processes. Not always for debugging, but sometimes just to spawn a child process. On the localhost, this means just using the Host::LaunchProcess() functionality. This way, we just need to implement a single copy of the process launching code. When you create a remote platform, you should be able to link against the native linux or darwin launching code and then we don't end up with multiple copies of the launching code like we have now. You make a good point in that not all platforms will be able to support launching with a program stopped for debugging, so we now ask the platform up in the CommandObjectProcessLaunch class before we launch the process. This keeps the platform clean, yet also lets us fall back to just launching the process through the built in process plug-in. >>>>>>>> - Platforms should support attaching to a remote process. Combined with being able to launch for debug, this allows debugging as we have it on MacOSX. If we do this while remotely connected to a remote darwin machine, we now have the ability to talk to a remote computer and launch, attach, list and do a lot more >>>>>>>> - Platforms should know if there are files locally on the current machine in an SDK or PDK or some over developer kit/cross compiling sysroot, etc to allow locating files in terms of the path you would us on the remote machine. For example when debugging on a remote device, if the are asked to find the file for "/bin/ls", this might locally be located in developer kit directory such as >>>>>>>> "/path/to/old/linux/sysroot/bin/ls". This allows you to debug remote machines, or event mount the root file system on a mountpoint so you have access to the files so you can debug. >>>>>>>> - Platforms should be able to upload/download files so you could install a new binary and run it, or upload a shared library so we can locally cache it for faster debugging. >>>>>>>> >>>>>>>> We are in the process of slowly makine these Platforms a reality, so keep the questions coming if anyone has any. >>>>>>>> >>>>>>>> So in short: I made the fix you requested, but in a different way. If you can rework your patch around what is in top of tree, then we can get the rest of it submitted. >>>>>>>> >>>>>>>> Greg Clayton >>>>>>>> >>>>>>>>> Thanks! >>>>>>>>> -Dawn >>>>>>>>> _______________________________________________ >>>>>>>>> lldb-commits mailing list >>>>>>>>> lldb-commits at cs.uiuc.edu >>>>>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > From jingham at apple.com Tue Nov 29 15:16:37 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 29 Nov 2011 21:16:37 -0000 Subject: [Lldb-commits] [lldb] r145434 - /lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Message-ID: <20111129211637.180811BE001@llvm.org> Author: jingham Date: Tue Nov 29 15:16:36 2011 New Revision: 145434 URL: http://llvm.org/viewvc/llvm-project?rev=145434&view=rev Log: Typo in error string. Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=145434&r1=145433&r2=145434&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original) +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Tue Nov 29 15:16:36 2011 @@ -75,7 +75,7 @@ else { exe_file.GetPath (exe_path, sizeof(exe_path)); - error.SetErrorStringWithFormat ("enable to find executable for '%s'", exe_path); + error.SetErrorStringWithFormat ("unable to find executable for '%s'", exe_path); } } else From jingham at apple.com Tue Nov 29 15:21:26 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 29 Nov 2011 21:21:26 -0000 Subject: [Lldb-commits] [lldb] r145435 - /lldb/trunk/source/Commands/CommandObjectSource.cpp Message-ID: <20111129212126.9E7661BE001@llvm.org> Author: jingham Date: Tue Nov 29 15:21:26 2011 New Revision: 145435 URL: http://llvm.org/viewvc/llvm-project?rev=145435&view=rev Log: Missing return in error handling for "source list". Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=145435&r1=145434&r2=145435&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Tue Nov 29 15:21:26 2011 @@ -277,6 +277,7 @@ { result.AppendErrorWithFormat("'%s' takes no arguments, only flags.\n", GetCommandName()); result.SetStatus (eReturnStatusFailed); + return false; } ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); From scallanan at apple.com Tue Nov 29 16:03:22 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 29 Nov 2011 22:03:22 -0000 Subject: [Lldb-commits] [lldb] r145437 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20111129220322.342D71BE001@llvm.org> Author: spyffe Date: Tue Nov 29 16:03:21 2011 New Revision: 145437 URL: http://llvm.org/viewvc/llvm-project?rev=145437&view=rev Log: Modified ClangExpressionDeclMap to use existing ValueObjects when creating variables referring to live data rather than constructing ValueObjectConstResults. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=145437&r1=145436&r2=145437&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Tue Nov 29 16:03:21 2011 @@ -909,10 +909,14 @@ /// /// @param[in] var /// The LLDB Variable that needs a Decl. + /// + /// @param[in] valobj + /// The LLDB ValueObject for that variable. //------------------------------------------------------------------ void AddOneVariable (NameSearchContext &context, lldb::VariableSP var, + lldb::ValueObjectSP valobj, unsigned int current_id); //------------------------------------------------------------------ Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=145437&r1=145436&r2=145437&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Nov 29 16:03:21 2011 @@ -2507,7 +2507,7 @@ // If we found a variable in scope, no need to pull up function names if (err.Success() && var != NULL) { - AddOneVariable(context, var, current_id); + AddOneVariable(context, var, valobj, current_id); context.m_found.variable = true; return; } @@ -2522,7 +2522,8 @@ if (var) { - AddOneVariable(context, var, current_id); + valobj = frame->TrackGlobalVariable(var, eNoDynamicValues); + AddOneVariable(context, var, valobj, current_id); context.m_found.variable = true; } } @@ -2728,7 +2729,7 @@ } void -ClangExpressionDeclMap::AddOneVariable (NameSearchContext &context, VariableSP var, unsigned int current_id) +ClangExpressionDeclMap::AddOneVariable (NameSearchContext &context, VariableSP var, ValueObjectSP valobj, unsigned int current_id) { assert (m_parser_vars.get()); @@ -2757,11 +2758,8 @@ std::string decl_name(context.m_decl_name.getAsString()); ConstString entity_name(decl_name.c_str()); - ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx->GetBestExecutionContextScope (), - entity_name, - ut, - m_parser_vars->m_target_info.byte_order, - m_parser_vars->m_target_info.address_byte_size)); + ClangExpressionVariableSP entity(m_found_entities.CreateVariable (valobj)); + assert (entity.get()); entity->EnableParserVars(); entity->m_parser_vars->m_parser_type = pt; From scallanan at apple.com Tue Nov 29 16:47:44 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 29 Nov 2011 22:47:44 -0000 Subject: [Lldb-commits] [lldb] r145446 - /lldb/trunk/include/lldb/Expression/ASTDumper.h Message-ID: <20111129224744.551361BE001@llvm.org> Author: spyffe Date: Tue Nov 29 16:47:44 2011 New Revision: 145446 URL: http://llvm.org/viewvc/llvm-project?rev=145446&view=rev Log: Added #ifdef wrappers around the contents of ASTDumper.h. Modified: lldb/trunk/include/lldb/Expression/ASTDumper.h Modified: lldb/trunk/include/lldb/Expression/ASTDumper.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ASTDumper.h?rev=145446&r1=145445&r2=145446&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ASTDumper.h (original) +++ lldb/trunk/include/lldb/Expression/ASTDumper.h Tue Nov 29 16:47:44 2011 @@ -7,6 +7,9 @@ // //===----------------------------------------------------------------------===// +#ifndef liblldb_ASTDumper_h_ +#define liblldb_ASTDumper_h_ + #include "clang/AST/DeclVisitor.h" #include "clang/AST/StmtVisitor.h" #include "clang/AST/TypeVisitor.h" @@ -35,3 +38,5 @@ }; } // namespace lldb_private + +#endif From gclayton at apple.com Tue Nov 29 17:40:34 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 29 Nov 2011 23:40:34 -0000 Subject: [Lldb-commits] [lldb] r145457 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20111129234035.0B6081BE001@llvm.org> Author: gclayton Date: Tue Nov 29 17:40:34 2011 New Revision: 145457 URL: http://llvm.org/viewvc/llvm-project?rev=145457&view=rev Log: Find the one true objective C type definition if there is one within a module. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=145457&r1=145456&r2=145457&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Nov 29 17:40:34 2011 @@ -2211,7 +2211,7 @@ LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); if (log) - log->Printf("Valid namespace does not match symbol file"); + LogMessage(log.get(), "Valid namespace does not match symbol file"); return false; } @@ -2237,7 +2237,7 @@ if (decl_ctx_die->Tag() != DW_TAG_namespace) { if (log) - log->Printf("Found a match, but its parent is not a namespace"); + LogMessage(log.get(), "Found a match, but its parent is not a namespace"); return false; } @@ -2246,7 +2246,7 @@ if (pos == m_decl_ctx_to_die.end()) { if (log) - log->Printf("Found a match in a namespace, but its parent is not the requested namespace"); + LogMessage(log.get(), "Found a match in a namespace, but its parent is not the requested namespace"); return false; } @@ -2265,7 +2265,7 @@ } if (log) - log->Printf("Found a match, but its parent doesn't exist"); + LogMessage(log.get(), "Found a match, but its parent doesn't exist"); return false; } @@ -3874,7 +3874,7 @@ { StreamString s; die->DumpLocation (this, dwarf_cu, s); - log->Printf ("SymbolFileDwarf::%s %s", __FUNCTION__, s.GetData()); + LogMessage (log.get(), "SymbolFileDwarf::%s %s", __FUNCTION__, s.GetData()); } @@ -4046,6 +4046,7 @@ m_die_to_type[die] = DIE_IS_BEING_PARSED; LanguageType class_language = eLanguageTypeUnknown; + bool is_complete_objc_class = false; //bool struct_is_class = false; const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); if (num_attributes > 0) @@ -4093,6 +4094,10 @@ class_language = (LanguageType)form_value.Signed(); break; + case DW_AT_APPLE_objc_complete_type: + is_complete_objc_class = form_value.Signed(); + break; + case DW_AT_allocated: case DW_AT_associated: case DW_AT_data_location: @@ -4152,8 +4157,13 @@ default_accessibility = eAccessPrivate; } + bool look_for_complete_objc_type = false; + if (class_language == eLanguageTypeObjC) + { + look_for_complete_objc_type = !is_complete_objc_class; + } - if (is_forward_declaration) + if (is_forward_declaration || look_for_complete_objc_type) { // We have a forward declaration to a type and we need // to try and find a full declaration. We look in the @@ -4163,11 +4173,12 @@ if (log) { LogMessage (log.get(), - "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is forward declaration, trying to find real type", + "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is %s, trying to find complete type", this, die->GetOffset(), DW_TAG_value_to_name(tag), - type_name_cstr); + type_name_cstr, + look_for_complete_objc_type ? "an incomplete objective C type" : "a forward declaration"); } type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str); @@ -4184,12 +4195,14 @@ { if (log) { - log->Printf ("SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is forward declaration, real type is 0x%8.8llx", - this, - die->GetOffset(), - DW_TAG_value_to_name(tag), - type_name_cstr, - type_sp->GetID()); + LogMessage (log.get(), + "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is %s, complete type is 0x%8.8llx", + this, + die->GetOffset(), + DW_TAG_value_to_name(tag), + type_name_cstr, + look_for_complete_objc_type ? "an incomplete objective C type" : "a forward declaration", + type_sp->GetID()); } // We found a real definition for this type elsewhere From johnny.chen at apple.com Tue Nov 29 17:56:14 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 29 Nov 2011 23:56:14 -0000 Subject: [Lldb-commits] [lldb] r145459 - /lldb/trunk/source/Commands/CommandObjectTarget.cpp Message-ID: <20111129235614.5E99D1BE001@llvm.org> Author: johnny Date: Tue Nov 29 17:56:14 2011 New Revision: 145459 URL: http://llvm.org/viewvc/llvm-project?rev=145459&view=rev Log: Remove possible cut-and-paste code which doesn't belong. Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=145459&r1=145458&r2=145459&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Tue Nov 29 17:56:14 2011 @@ -3991,13 +3991,7 @@ CommandReturnObject &result) { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); - if (target) - { - bool notify = true; - target->GetImageSearchPathList().Clear(notify); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else + if (!target) { result.AppendError ("invalid target\n"); result.SetStatus (eReturnStatusFailed); From johnny.chen at apple.com Tue Nov 29 19:34:00 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 30 Nov 2011 01:34:00 -0000 Subject: [Lldb-commits] [lldb] r145466 - /lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py Message-ID: <20111130013400.292941BE001@llvm.org> Author: johnny Date: Tue Nov 29 19:33:59 2011 New Revision: 145466 URL: http://llvm.org/viewvc/llvm-project?rev=145466&view=rev Log: rdar://problem/9211445 Fix wrong test logic in test_modules_search_paths(). Add additional exercising of 'target modules search-paths list/query". There is a reproducible crash if 'target modules search-paths clear' is exercised during test teardown. So we currently comment out the stmt as follows: # Add teardown hook to clear image-search-paths after the test. # rdar://problem/10501020 # Uncomment the following to reproduce 10501020. #self.addTearDownHook(lambda: self.runCmd("target modules search-paths clear")) Modified: lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py Modified: lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py?rev=145466&r1=145465&r2=145466&view=diff ============================================================================== --- lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py (original) +++ lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py Tue Nov 29 19:33:59 2011 @@ -21,7 +21,6 @@ self.line_d_function = line_number('d.c', '// Find this line number within d_dunction().') - @unittest2.expectedFailure def test_modules_search_paths(self): """Test target modules list after loading a different copy of the library libd.dylib, and verifies that it works with 'target modules search-paths add'.""" @@ -30,8 +29,9 @@ if sys.platform.startswith("darwin"): dylibName = 'libd.dylib' + dylibPath = 'DYLD_LIBRARY_PATH' - # The directory with the the dynamic library we did not link to. + # The directory with the dynamic library we did not link to. new_dir = os.path.join(os.getcwd(), "hidden") old_dylib = os.path.join(os.getcwd(), dylibName) @@ -44,13 +44,33 @@ substrs = [old_dylib]) self.expect("target modules list -t 3", patterns = ["%s-[^-]*-[^-]*" % self.getArchitecture()]) + # Add an image search path substitution pair. self.runCmd("target modules search-paths add %s %s" % (os.getcwd(), new_dir)) + # Add teardown hook to clear image-search-paths after the test. + # rdar://problem/10501020 + # Uncomment the following to reproduce 10501020. + #self.addTearDownHook(lambda: self.runCmd("target modules search-paths clear")) self.expect("target modules search-paths list", substrs = [os.getcwd(), new_dir]) - # Add teardown hook to clear image-search-paths after the test. - self.addTearDownHook(lambda: self.runCmd("target modules search-paths clear")) + self.expect("target modules search-paths query %s" % os.getcwd(), "Image search path successfully transformed", + substrs = [new_dir]) + + # Obliterate traces of libd from the old location. + os.remove(old_dylib) + # Inform dyld of the new path, too. + env_cmd_string = "settings set target.env-vars " + dylibPath + "=" + new_dir + if self.TraceOn(): + print "Set environment to: ", env_cmd_string + self.runCmd(env_cmd_string) + self.runCmd("settings show target.env-vars") + + remove_dyld_path_cmd = "settings remove target.env-vars " + dylibPath + self.addTearDownHook(lambda: self.runCmd(remove_dyld_path_cmd)) + + self.runCmd("run") + self.expect("target modules list", "LLDB successfully locates the relocated dynamic library", substrs = [new_dylib]) From gclayton at apple.com Tue Nov 29 20:48:29 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 30 Nov 2011 02:48:29 -0000 Subject: [Lldb-commits] [lldb] r145471 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20111130024829.15C6A1BE001@llvm.org> Author: gclayton Date: Tue Nov 29 20:48:28 2011 New Revision: 145471 URL: http://llvm.org/viewvc/llvm-project?rev=145471&view=rev Log: Add a work around to deal with incorrect forward class definitions in objective C DWARF emitted by clang. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=145471&r1=145470&r2=145471&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Nov 29 20:48:28 2011 @@ -4156,6 +4156,24 @@ tag_decl_kind = clang::TTK_Class; default_accessibility = eAccessPrivate; } + + if (byte_size_valid && byte_size == 0 && type_name_cstr && + die->HasChildren() == false && + sc.comp_unit->GetLanguage() == eLanguageTypeObjC) + { + // Work around an issue with clang at the moment where + // forward declarations for objective C classes are emitted + // as: + // DW_TAG_structure_type [2] + // DW_AT_name( "ForwardObjcClass" ) + // DW_AT_byte_size( 0x00 ) + // DW_AT_decl_file( "..." ) + // DW_AT_decl_line( 1 ) + // + // Note that there is no DW_AT_declaration and there are + // no children, and the byte size is zero. + is_forward_declaration = true; + } bool look_for_complete_objc_type = false; if (class_language == eLanguageTypeObjC) From jingham at apple.com Tue Nov 29 21:15:08 2011 From: jingham at apple.com (Jim Ingham) Date: Wed, 30 Nov 2011 03:15:08 -0000 Subject: [Lldb-commits] [lldb] r145472 - /lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Message-ID: <20111130031508.E7AB61BE001@llvm.org> Author: jingham Date: Tue Nov 29 21:15:08 2011 New Revision: 145472 URL: http://llvm.org/viewvc/llvm-project?rev=145472&view=rev Log: Turn off the resolver detection till we find a better method to do so. Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=145472&r1=145471&r2=145472&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Tue Nov 29 21:15:08 2011 @@ -1454,7 +1454,12 @@ images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeCode, target_symbols); size_t num_original_symbols = target_symbols.GetSize(); - bool orig_is_resolver = (current_symbol->GetFlags() & MACH_O_N_SYMBOL_RESOLVER) == MACH_O_N_SYMBOL_RESOLVER; + // FIXME: The resolver symbol is only valid in object files. In binaries it is reused for the + // shared library slot number. So we'll have to look this up in the dyld info. + // For now, just turn this off. + + // bool orig_is_resolver = (current_symbol->GetFlags() & MACH_O_N_SYMBOL_RESOLVER) == MACH_O_N_SYMBOL_RESOLVER; + bool orig_is_resolver = false; if (num_original_symbols > 0) { From johnny.chen at apple.com Wed Nov 30 13:09:20 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 30 Nov 2011 19:09:20 -0000 Subject: [Lldb-commits] [lldb] r145507 - /lldb/trunk/source/Commands/CommandObjectTarget.cpp Message-ID: <20111130190920.8B1DA2A6C12C@llvm.org> Author: johnny Date: Wed Nov 30 13:09:20 2011 New Revision: 145507 URL: http://llvm.org/viewvc/llvm-project?rev=145507&view=rev Log: I broke the test suite (4 failures) with r145459 check-in. Fix the breakage by properly setting the result status before returning. Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=145507&r1=145506&r2=145507&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Wed Nov 30 13:09:20 2011 @@ -4013,6 +4013,7 @@ this_hook->GetDescription (&(result.GetOutputStream()), eDescriptionLevelFull); } } + result.SetStatus (eReturnStatusSuccessFinishResult); return result.Succeeded(); } }; From gclayton at apple.com Wed Nov 30 13:36:43 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 30 Nov 2011 19:36:43 -0000 Subject: [Lldb-commits] [lldb] r145511 - /lldb/trunk/source/Core/Disassembler.cpp Message-ID: <20111130193643.28F2A2A6C12C@llvm.org> Author: gclayton Date: Wed Nov 30 13:36:42 2011 New Revision: 145511 URL: http://llvm.org/viewvc/llvm-project?rev=145511&view=rev Log: Make sure that we print out function or symbol information. If we disassembled a symbol, were weren't showing the "`" header. Modified: lldb/trunk/source/Core/Disassembler.cpp Modified: lldb/trunk/source/Core/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=145511&r1=145510&r2=145511&view=diff ============================================================================== --- lldb/trunk/source/Core/Disassembler.cpp (original) +++ lldb/trunk/source/Core/Disassembler.cpp Wed Nov 30 13:36:42 2011 @@ -384,7 +384,7 @@ } } } - else if (!(prev_sc.function == sc.function || prev_sc.symbol == sc.symbol)) + else if ((sc.function || sc.symbol) && (sc.function != prev_sc.function || sc.symbol != prev_sc.symbol)) { if (prev_sc.function || prev_sc.symbol) strm.EOL(); From johnny.chen at apple.com Wed Nov 30 13:46:38 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 30 Nov 2011 19:46:38 -0000 Subject: [Lldb-commits] [lldb] r145516 - /lldb/trunk/test/redo.py Message-ID: <20111130194638.21FFB2A6C12C@llvm.org> Author: johnny Date: Wed Nov 30 13:46:37 2011 New Revision: 145516 URL: http://llvm.org/viewvc/llvm-project?rev=145516&view=rev Log: Add processing of '-help' option. Modified: lldb/trunk/test/redo.py Modified: lldb/trunk/test/redo.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/redo.py?rev=145516&r1=145515&r2=145516&view=diff ============================================================================== --- lldb/trunk/test/redo.py (original) +++ lldb/trunk/test/redo.py Wed Nov 30 13:46:37 2011 @@ -102,6 +102,9 @@ index = 1 while index < len(sys.argv): + if sys.argv[index].startswith('-h'): + usage() + if sys.argv[index].startswith('-'): # We should continue processing... pass From scallanan at apple.com Wed Nov 30 16:11:59 2011 From: scallanan at apple.com (Sean Callanan) Date: Wed, 30 Nov 2011 22:11:59 -0000 Subject: [Lldb-commits] [lldb] r145526 - in /lldb/trunk: include/lldb/Symbol/ include/lldb/Target/ lldb.xcodeproj/ source/Expression/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Plugins/SymbolFile/Symtab/ source/Symbol/ test/functionalities/data-formatter/data-formatter-objc/ Message-ID: <20111130221159.E1D842A6C12C@llvm.org> Author: spyffe Date: Wed Nov 30 16:11:59 2011 New Revision: 145526 URL: http://llvm.org/viewvc/llvm-project?rev=145526&view=rev Log: Added support to the Objective-C language runtime to find Objective-C class types by looking in the symbol tables for the individual object files. I did this as follows: - I added code to SymbolFileSymtab that vends Clang types for symbols matching the pattern "_OBJC_CLASS_$_NSMyClassName," making them appear as Objective-C classes. This only occurs in modules that do not have debug information, since otherwise SymbolFileDWARF would be in charge of looking up types. - I made a new SymbolVendor subclass for the Apple Objective-C runtime that is in charge of making global lookups of Objective-C types. It currently just sends out type lookup requests to the appropriate SymbolFiles, but in the future we will probably extend it to query the runtime more completely. I also modified a testcase whose behavior is changed by the fact that we now actually return an Objective-C type for __NSCFString. Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.h Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/include/lldb/Symbol/SymbolFile.h lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=145526&r1=145525&r2=145526&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Wed Nov 30 16:11:59 2011 @@ -195,6 +195,15 @@ static lldb::clang_type_t GetVoidPtrType(clang::ASTContext *ast, bool is_const); + static clang::DeclContext * + GetTranslationUnitDecl (clang::ASTContext *ast); + + clang::DeclContext * + GetTranslationUnitDecl () + { + return GetTranslationUnitDecl (getASTContext()); + } + static lldb::clang_type_t CopyType(clang::ASTContext *dest_context, clang::ASTContext *source_context, Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=145526&r1=145525&r2=145526&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Wed Nov 30 16:11:59 2011 @@ -30,14 +30,15 @@ TypeAcceleratorTable = (1 << 3), MacroInformation = (1 << 4), CallFrameInformation = (1 << 5), - CompileUnits = (1 << 6), - LineTables = (1 << 7), - LineColumns = (1 << 8), - Functions = (1 << 9), - Blocks = (1 << 10), - GlobalVariables = (1 << 11), - LocalVariables = (1 << 12), - VariableTypes = (1 << 13) + RuntimeTypes = (1 << 6), + CompileUnits = (1 << 7), + LineTables = (1 << 8), + LineColumns = (1 << 9), + Functions = (1 << 10), + Blocks = (1 << 11), + GlobalVariables = (1 << 12), + LocalVariables = (1 << 13), + VariableTypes = (1 << 14), }; static SymbolFile * Modified: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=145526&r1=145525&r2=145526&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h (original) +++ lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h Wed Nov 30 16:11:59 2011 @@ -87,6 +87,12 @@ virtual ObjCISA GetParentClass(ObjCISA isa) = 0; + virtual SymbolVendor * + GetSymbolVendor() + { + return NULL; + } + // Finds the byte offset of the child_type ivar in parent_type. If it can't find the // offset, returns LLDB_INVALID_IVAR_OFFSET. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=145526&r1=145525&r2=145526&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Nov 30 16:11:59 2011 @@ -393,6 +393,7 @@ 49A71FE8141FFACF00D59478 /* DataEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268ED0A4140FF54200DE830F /* DataEncoder.cpp */; }; 49C8507C1384A786007DB519 /* ProcessDataAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49C850781384A0CA007DB519 /* ProcessDataAllocator.cpp */; }; 49D8FB3913B5598F00411094 /* ClangASTImporter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49D8FB3513B558DE00411094 /* ClangASTImporter.cpp */; }; + 49DA65031485C92A005FF180 /* AppleObjCSymbolVendor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DA65021485C92A005FF180 /* AppleObjCSymbolVendor.cpp */; }; 4CAA56131422D96A001FFA01 /* BreakpointResolverFileRegex.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CAA56121422D96A001FFA01 /* BreakpointResolverFileRegex.h */; }; 4CAA56151422D986001FFA01 /* BreakpointResolverFileRegex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CAA56141422D986001FFA01 /* BreakpointResolverFileRegex.cpp */; }; 4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CABA9DF134A8BCD00539BDD /* ValueObjectMemory.cpp */; }; @@ -1171,6 +1172,8 @@ 49D7072811B5AD11001AD875 /* ClangASTSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangASTSource.cpp; path = source/Expression/ClangASTSource.cpp; sourceTree = ""; }; 49D8FB3513B558DE00411094 /* ClangASTImporter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangASTImporter.cpp; path = source/Symbol/ClangASTImporter.cpp; sourceTree = ""; }; 49D8FB3713B5594900411094 /* ClangASTImporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangASTImporter.h; path = include/lldb/Symbol/ClangASTImporter.h; sourceTree = ""; }; + 49DA65021485C92A005FF180 /* AppleObjCSymbolVendor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleObjCSymbolVendor.cpp; sourceTree = ""; }; + 49DA65041485C942005FF180 /* AppleObjCSymbolVendor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppleObjCSymbolVendor.h; sourceTree = ""; }; 49E45FA911F660DC008F7B28 /* ClangASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangASTType.h; path = include/lldb/Symbol/ClangASTType.h; sourceTree = ""; }; 49E45FAD11F660FE008F7B28 /* ClangASTType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangASTType.cpp; path = source/Symbol/ClangASTType.cpp; sourceTree = ""; }; 49EC3E98118F90AC00B1265E /* ThreadPlanCallFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanCallFunction.cpp; path = source/Target/ThreadPlanCallFunction.cpp; sourceTree = ""; }; @@ -2761,6 +2764,8 @@ 4CCA644513B40B82003BDF98 /* AppleObjCRuntimeV1.h */, 4CCA644613B40B82003BDF98 /* AppleObjCRuntimeV2.cpp */, 4CCA644713B40B82003BDF98 /* AppleObjCRuntimeV2.h */, + 49DA65041485C942005FF180 /* AppleObjCSymbolVendor.h */, + 49DA65021485C92A005FF180 /* AppleObjCSymbolVendor.cpp */, 4CCA644813B40B82003BDF98 /* AppleObjCTrampolineHandler.cpp */, 4CCA644913B40B82003BDF98 /* AppleObjCTrampolineHandler.h */, 4CCA644A13B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */, @@ -3515,6 +3520,7 @@ B207C4931429607D00F36E4E /* CommandObjectWatchpoint.cpp in Sources */, 49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */, 494260DA14579144003C1C78 /* VerifyDecl.cpp in Sources */, + 49DA65031485C92A005FF180 /* AppleObjCSymbolVendor.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=145526&r1=145525&r2=145526&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Wed Nov 30 16:11:59 2011 @@ -17,6 +17,7 @@ #include "lldb/Expression/ClangExpression.h" #include "lldb/Symbol/ClangNamespaceDecl.h" #include "lldb/Symbol/SymbolVendor.h" +#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Target.h" using namespace clang; @@ -460,11 +461,29 @@ SymbolContext null_sc; if (module_sp && namespace_decl) + { module_sp->FindTypes(null_sc, name, &namespace_decl, true, 1, types); + } else if(name != id_name && name != Class_name) + { m_target->GetImages().FindTypes (null_sc, name, true, 1, types); + + if (!types.GetSize()) + { + lldb::ProcessSP process = m_target->GetProcessSP(); + + if (process && process->GetObjCLanguageRuntime()) + { + SymbolVendor *objc_symbol_vendor = process->GetObjCLanguageRuntime()->GetSymbolVendor(); + + objc_symbol_vendor->FindTypes(null_sc, name, NULL, true, 1, types); + } + } + } else + { break; + } if (types.GetSize()) { @@ -484,6 +503,7 @@ context.AddTypeDecl(copied_type); } + } while(0); } Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=145526&r1=145525&r2=145526&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Wed Nov 30 16:11:59 2011 @@ -38,9 +38,9 @@ #include "lldb/Target/Thread.h" #include "AppleObjCRuntimeV2.h" +#include "AppleObjCSymbolVendor.h" #include "AppleObjCTrampolineHandler.h" - #include using namespace lldb; @@ -769,3 +769,11 @@ return parent_isa; } +SymbolVendor * +AppleObjCRuntimeV2::GetSymbolVendor() +{ + if (!m_symbol_vendor_ap.get()) + m_symbol_vendor_ap.reset(new AppleObjCSymbolVendor(m_process)); + + return m_symbol_vendor_ap.get(); +} Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h?rev=145526&r1=145525&r2=145526&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h Wed Nov 30 16:11:59 2011 @@ -96,6 +96,9 @@ virtual ObjCLanguageRuntime::ObjCISA GetParentClass(ObjCLanguageRuntime::ObjCISA isa); + virtual SymbolVendor * + GetSymbolVendor(); + protected: private: @@ -123,6 +126,8 @@ ISAToNameCache m_isa_to_name_cache; ISAToParentCache m_isa_to_parent_cache; + std::auto_ptr m_symbol_vendor_ap; + static const char *g_find_class_name_function_name; static const char *g_find_class_name_function_body; static const char *g_objc_class_symbol_prefix; Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp?rev=145526&view=auto ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp (added) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp Wed Nov 30 16:11:59 2011 @@ -0,0 +1,76 @@ +//===-- AppleObjCSymbolVendor.cpp -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "AppleObjCSymbolVendor.h" + +#include "lldb/Core/Log.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" + +#include "clang/AST/ASTContext.h" + +using namespace lldb_private; + +AppleObjCSymbolVendor::AppleObjCSymbolVendor(Process *process) : + SymbolVendor(NULL), + m_process(process->GetSP()), + m_ast_ctx(process->GetTarget().GetArchitecture().GetTriple().getTriple().c_str()) +{ +} + +uint32_t +AppleObjCSymbolVendor::FindTypes (const SymbolContext& sc, + const ConstString &name, + const ClangNamespaceDecl *namespace_decl, + bool append, + uint32_t max_matches, + TypeList& types) +{ + lldb::LogSP log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS)); // FIXME - a more appropriate log channel? + + if (log) + log->Printf("ObjC SymbolVendor asked for '%s'", + name.AsCString()); + + if (!append) + types.Clear(); + + uint32_t ret = 0; + + ModuleList &images = m_process->GetTarget().GetImages(); + + for (size_t image_index = 0, end_index = images.GetSize(); + image_index < end_index; + ++image_index) + { + Module *image = images.GetModulePointerAtIndex(image_index); + + if (!image) + continue; + + SymbolVendor *symbol_vendor = image->GetSymbolVendor(); + + if (!symbol_vendor) + continue; + + SymbolFile *symbol_file = image->GetSymbolVendor()->GetSymbolFile(); + + if (!symbol_file || !(symbol_file->GetAbilities() & SymbolFile::RuntimeTypes)) + continue; + + const bool inferior_append = true; + + ret += symbol_file->FindTypes (sc, name, namespace_decl, inferior_append, max_matches - ret, types); + + if (ret >= max_matches) + break; + } + + return ret; +} Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.h?rev=145526&view=auto ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.h (added) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.h Wed Nov 30 16:11:59 2011 @@ -0,0 +1,47 @@ +//===-- AppleObjCSymbolVendor.h ---------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_AppleObjCSymbolVendor_h_ +#define liblldb_AppleObjCSymbolVendor_h_ + +// C Includes +// C++ Includes + +#include + +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-private.h" +#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/SymbolVendor.h" +#include "lldb/Symbol/SymbolFile.h" + +namespace lldb_private { + +class AppleObjCSymbolVendor : public SymbolVendor +{ +public: + AppleObjCSymbolVendor(Process* process); + + virtual uint32_t + FindTypes (const SymbolContext& sc, + const ConstString &name, + const ClangNamespaceDecl *namespace_decl, + bool append, + uint32_t max_matches, + TypeList& types); + +private: + lldb::ProcessSP m_process; + ClangASTContext m_ast_ctx; +}; + +} // namespace lldb_private + +#endif // liblldb_AppleObjCSymbolVendor_h_ Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=145526&r1=145525&r2=145526&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Wed Nov 30 16:11:59 2011 @@ -63,7 +63,8 @@ m_func_indexes(), m_code_indexes(), m_data_indexes(), - m_addr_indexes() + m_addr_indexes(), + m_has_objc_symbols(eLazyBoolCalculate) { } @@ -71,6 +72,27 @@ { } +ClangASTContext & +SymbolFileSymtab::GetClangASTContext () +{ + ClangASTContext &ast = m_obj_file->GetModule()->GetClangASTContext(); + + return ast; +} + +bool +SymbolFileSymtab::HasObjCSymbols () +{ + if (m_has_objc_symbols == eLazyBoolCalculate) + { + if (m_obj_file->GetSectionList()->FindSectionByName(ConstString("__objc_data"))) + m_has_objc_symbols = eLazyBoolYes; + else + m_has_objc_symbols = eLazyBoolNo; + } + + return m_has_objc_symbols == eLazyBoolYes; +} uint32_t SymbolFileSymtab::GetAbilities () @@ -113,6 +135,11 @@ symtab->SortSymbolIndexesByValue(m_data_indexes, true); abilities |= GlobalVariables; } + + if (HasObjCSymbols()) + { + abilities |= RuntimeTypes; + } } } return abilities; @@ -352,6 +379,42 @@ { if (!append) types.Clear(); + + if (HasObjCSymbols()) + { + std::string symbol_name("OBJC_CLASS_$_"); + symbol_name.append(name.AsCString()); + ConstString symbol_const_string(symbol_name.c_str()); + + std::vector indices; + + if (m_obj_file->GetSymtab()->FindAllSymbolsWithNameAndType(symbol_const_string, lldb::eSymbolTypeRuntime, indices) == 0) + return 0; + + const bool isForwardDecl = false; + const bool isInternal = true; + + ClangASTContext &clang_ast_ctx = GetClangASTContext(); + + lldb::clang_type_t objc_object_type = clang_ast_ctx.CreateObjCClass(name.AsCString(), clang_ast_ctx.GetTranslationUnitDecl(), isForwardDecl, isInternal); + + Declaration decl; + + lldb::TypeSP type(new Type (indices[0], + this, + name, + 0 /*byte_size*/, + NULL /*SymbolContextScope*/, + 0 /*encoding_uid*/, + Type::eEncodingInvalid, + decl, + objc_object_type, + Type::eResolveStateForward)); + + types.Insert(type); + + return 1; + } return 0; } Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h?rev=145526&r1=145525&r2=145526&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Wed Nov 30 16:11:59 2011 @@ -119,12 +119,19 @@ GetPluginVersion(); protected: + lldb_private::LazyBool m_has_objc_symbols; std::vector m_source_indexes; std::vector m_func_indexes; std::vector m_code_indexes; std::vector m_data_indexes; std::vector m_addr_indexes; // Anything that needs to go into an search by address + bool + HasObjCSymbols (); + + lldb_private::ClangASTContext & + GetClangASTContext (); + private: DISALLOW_COPY_AND_ASSIGN (SymbolFileSymtab); }; Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=145526&r1=145525&r2=145526&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Nov 30 16:11:59 2011 @@ -980,6 +980,12 @@ return void_ptr_type.getAsOpaquePtr(); } +clang::DeclContext * +ClangASTContext::GetTranslationUnitDecl (clang::ASTContext *ast) +{ + return ast->getTranslationUnitDecl(); +} + clang_type_t ClangASTContext::CopyType (ASTContext *dst_ast, ASTContext *src_ast, Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py?rev=145526&r1=145525&r2=145526&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Wed Nov 30 16:11:59 2011 @@ -233,10 +233,10 @@ self.expect('frame variable dyn_test', matching=False, substrs = ['Process Name: a.out Process Id:']) self.expect('frame variable dyn_test -d run-target -T', - substrs = ['(id, dynamic type:', + substrs = ['(__NSCFString *, dynamic type:', 'Process Name: a.out Process Id:']) self.expect('frame variable dyn_test -d run-target', - substrs = ['(id)', + substrs = ['(__NSCFString *)', 'Process Name: a.out Process Id:']) From gclayton at apple.com Wed Nov 30 16:18:42 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 30 Nov 2011 22:18:42 -0000 Subject: [Lldb-commits] [lldb] r145528 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20111130221842.529A02A6C12C@llvm.org> Author: gclayton Date: Wed Nov 30 16:18:41 2011 New Revision: 145528 URL: http://llvm.org/viewvc/llvm-project?rev=145528&view=rev Log: Bumped Xcode project versions for lldb-90 and debugserver-154 Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=145528&r1=145527&r2=145528&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Nov 30 16:18:41 2011 @@ -3730,9 +3730,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 89; + CURRENT_PROJECT_VERSION = 90; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 89; + DYLIB_CURRENT_VERSION = 90; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3791,10 +3791,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 89; + CURRENT_PROJECT_VERSION = 90; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 89; + DYLIB_CURRENT_VERSION = 90; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3851,8 +3851,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 89; - DYLIB_CURRENT_VERSION = 89; + CURRENT_PROJECT_VERSION = 90; + DYLIB_CURRENT_VERSION = 90; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3881,8 +3881,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 89; - DYLIB_CURRENT_VERSION = 89; + CURRENT_PROJECT_VERSION = 90; + DYLIB_CURRENT_VERSION = 90; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3911,8 +3911,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 89; - DYLIB_CURRENT_VERSION = 89; + CURRENT_PROJECT_VERSION = 90; + DYLIB_CURRENT_VERSION = 90; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3989,7 +3989,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 89; + CURRENT_PROJECT_VERSION = 90; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4019,10 +4019,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 89; + CURRENT_PROJECT_VERSION = 90; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 89; + DYLIB_CURRENT_VERSION = 90; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4266,7 +4266,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 89; + CURRENT_PROJECT_VERSION = 90; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4297,7 +4297,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 89; + CURRENT_PROJECT_VERSION = 90; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=145528&r1=145527&r2=145528&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Wed Nov 30 16:18:41 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 89 + 90 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=145528&r1=145527&r2=145528&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Wed Nov 30 16:18:41 2011 @@ -475,7 +475,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 153; + CURRENT_PROJECT_VERSION = 154; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; SDKROOT = ""; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 153; + CURRENT_PROJECT_VERSION = 154; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 153; + CURRENT_PROJECT_VERSION = 154; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -534,7 +534,7 @@ "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 153; + CURRENT_PROJECT_VERSION = 154; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -577,7 +577,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 153; + CURRENT_PROJECT_VERSION = 154; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -620,7 +620,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 153; + CURRENT_PROJECT_VERSION = 154; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From gclayton at apple.com Wed Nov 30 16:19:15 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 30 Nov 2011 22:19:15 -0000 Subject: [Lldb-commits] [lldb] r145529 - /lldb/tags/lldb-90/ Message-ID: <20111130221915.B7CE92A6C12C@llvm.org> Author: gclayton Date: Wed Nov 30 16:19:15 2011 New Revision: 145529 URL: http://llvm.org/viewvc/llvm-project?rev=145529&view=rev Log: lldb-90 Added: lldb/tags/lldb-90/ - copied from r145528, lldb/trunk/ From johnny.chen at apple.com Wed Nov 30 17:18:54 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 30 Nov 2011 23:18:54 -0000 Subject: [Lldb-commits] [lldb] r145537 - in /lldb/trunk: include/lldb/Target/Target.h source/Expression/ClangASTSource.cpp source/Target/Target.cpp test/functionalities/load_unload/TestLoadUnload.py Message-ID: <20111130231854.3B2772A6C12C@llvm.org> Author: johnny Date: Wed Nov 30 17:18:53 2011 New Revision: 145537 URL: http://llvm.org/viewvc/llvm-project?rev=145537&view=rev Log: rdar://problem/10501020 ClangASTSource::~ClangASTSource() was calling ClangASTContext *scratch_clang_ast_context = m_target->GetScratchClangASTContext(); which had the side effect of deleting this very ClangASTSource instance. Not good. Change it to // We are in the process of destruction, don't create clang ast context on demand // by passing false to Target::GetScratchClangASTContext(create_on_demand). ClangASTContext *scratch_clang_ast_context = m_target->GetScratchClangASTContext(false); The Target::GetScratchClangASTContext(bool create_on_demand=true) has a new signature. Modified: lldb/trunk/include/lldb/Target/Target.h lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=145537&r1=145536&r2=145537&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Wed Nov 30 17:18:53 2011 @@ -799,7 +799,7 @@ GetImageSearchPathList (); ClangASTContext * - GetScratchClangASTContext(); + GetScratchClangASTContext(bool create_on_demand=true); ClangASTImporter * GetClangASTImporter(); Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=145537&r1=145536&r2=145537&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Wed Nov 30 17:18:53 2011 @@ -27,7 +27,9 @@ { m_ast_importer->ForgetDestination(m_ast_context); - ClangASTContext *scratch_clang_ast_context = m_target->GetScratchClangASTContext(); + // We are in the process of destruction, don't create clang ast context on demand + // by passing false to Target::GetScratchClangASTContext(create_on_demand). + ClangASTContext *scratch_clang_ast_context = m_target->GetScratchClangASTContext(false); if (!scratch_clang_ast_context) return; Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=145537&r1=145536&r2=145537&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Wed Nov 30 17:18:53 2011 @@ -1335,10 +1335,10 @@ } ClangASTContext * -Target::GetScratchClangASTContext() +Target::GetScratchClangASTContext(bool create_on_demand) { // Now see if we know the target triple, and if so, create our scratch AST context: - if (m_scratch_ast_context_ap.get() == NULL && m_arch.IsValid()) + if (m_scratch_ast_context_ap.get() == NULL && m_arch.IsValid() && create_on_demand) { m_scratch_ast_context_ap.reset (new ClangASTContext(m_arch.GetTriple().str().c_str())); m_scratch_ast_source_ap.reset (new ClangASTSource(GetSP())); Modified: lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py?rev=145537&r1=145536&r2=145537&view=diff ============================================================================== --- lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py (original) +++ lldb/trunk/test/functionalities/load_unload/TestLoadUnload.py Wed Nov 30 17:18:53 2011 @@ -49,7 +49,7 @@ # Add teardown hook to clear image-search-paths after the test. # rdar://problem/10501020 # Uncomment the following to reproduce 10501020. - #self.addTearDownHook(lambda: self.runCmd("target modules search-paths clear")) + self.addTearDownHook(lambda: self.runCmd("target modules search-paths clear")) self.expect("target modules search-paths list", substrs = [os.getcwd(), new_dir]) From scallanan at apple.com Wed Nov 30 20:04:16 2011 From: scallanan at apple.com (Sean Callanan) Date: Thu, 01 Dec 2011 02:04:16 -0000 Subject: [Lldb-commits] [lldb] r145554 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h source/Expression/ClangExpressionDeclMap.cpp source/Expression/IRForTarget.cpp Message-ID: <20111201020416.A88D92A6C12C@llvm.org> Author: spyffe Date: Wed Nov 30 20:04:16 2011 New Revision: 145554 URL: http://llvm.org/viewvc/llvm-project?rev=145554&view=rev Log: Made symbol lookup in the expression parser more robust: - Now a client can specify what kind of symbols are needed; notably, this allows looking up Objective-C class symbols specifically. - In the class of symbols being looked up, if one is non-NULL and others are NULL, LLDB now prefers the non-NULL one. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=145554&r1=145553&r2=145554&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Wed Nov 30 20:04:16 2011 @@ -336,10 +336,12 @@ //------------------------------------------------------------------ lldb::addr_t GetSymbolAddress (Target &target, - const ConstString &name); + const ConstString &name, + lldb::SymbolType symbol_type); lldb::addr_t - GetSymbolAddress (const ConstString &name); + GetSymbolAddress (const ConstString &name, + lldb::SymbolType symbol_type); //------------------------------------------------------------------ /// [Used by IRInterpreter] Get basic target information. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=145554&r1=145553&r2=145554&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Nov 30 20:04:16 2011 @@ -718,16 +718,16 @@ } addr_t -ClangExpressionDeclMap::GetSymbolAddress (Target &target, const ConstString &name) +ClangExpressionDeclMap::GetSymbolAddress (Target &target, const ConstString &name, lldb::SymbolType symbol_type) { SymbolContextList sc_list; - target.GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list); + target.GetImages().FindSymbolsWithNameAndType(name, symbol_type, sc_list); const uint32_t num_matches = sc_list.GetSize(); addr_t symbol_load_addr = LLDB_INVALID_ADDRESS; - for (uint32_t i=0; im_exe_ctx->GetTargetPtr()) return false; - return GetSymbolAddress(m_parser_vars->m_exe_ctx->GetTargetRef(), name); + return GetSymbolAddress(m_parser_vars->m_exe_ctx->GetTargetRef(), name, symbol_type); } // Interface for IRInterpreter @@ -1741,7 +1741,7 @@ } else if (sym) { - addr_t location_load_addr = GetSymbolAddress(*target, name); + addr_t location_load_addr = GetSymbolAddress(*target, name, lldb::eSymbolTypeAny); if (location_load_addr == LLDB_INVALID_ADDRESS) { Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=145554&r1=145553&r2=145554&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Wed Nov 30 20:04:16 2011 @@ -1676,7 +1676,7 @@ lldb_private::ConstString name(symbol->getName().str().c_str()); - lldb::addr_t symbol_addr = m_decl_map->GetSymbolAddress (name); + lldb::addr_t symbol_addr = m_decl_map->GetSymbolAddress (name, lldb::eSymbolTypeAny); if (symbol_addr == LLDB_INVALID_ADDRESS) { @@ -1748,7 +1748,7 @@ StringRef name(initializer->getName()); lldb_private::ConstString name_cstr(name.str().c_str()); - lldb::addr_t class_ptr = m_decl_map->GetSymbolAddress(name_cstr); + lldb::addr_t class_ptr = m_decl_map->GetSymbolAddress(name_cstr, lldb::eSymbolTypeRuntime); if (log) log->Printf("Found reference to Objective-C class %s (0x%llx)", name_cstr.AsCString(), (unsigned long long)class_ptr); From jingham at apple.com Wed Nov 30 21:01:30 2011 From: jingham at apple.com (Jim Ingham) Date: Thu, 01 Dec 2011 03:01:30 -0000 Subject: [Lldb-commits] [lldb] r145558 - /lldb/trunk/source/Expression/DWARFExpression.cpp Message-ID: <20111201030130.CA95B2A6C12C@llvm.org> Author: jingham Date: Wed Nov 30 21:01:30 2011 New Revision: 145558 URL: http://llvm.org/viewvc/llvm-project?rev=145558&view=rev Log: If we are going to assert due to an unhanded opcode, stuff the opcode value into the CrashReporter string first. Modified: lldb/trunk/source/Expression/DWARFExpression.cpp Modified: lldb/trunk/source/Expression/DWARFExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=145558&r1=145557&r2=145558&view=diff ============================================================================== --- lldb/trunk/source/Expression/DWARFExpression.cpp (original) +++ lldb/trunk/source/Expression/DWARFExpression.cpp Wed Nov 30 21:01:30 2011 @@ -24,6 +24,7 @@ #include "lldb/Expression/ClangExpressionVariable.h" #include "lldb/Host/Endian.h" +#include "lldb/Host/Host.h" #include "lldb/lldb-private-log.h" @@ -982,8 +983,11 @@ data.Skip_LEB128(&offset); return offset - data_offset; default: - assert (!"Unhandled DW_OP_XXX opcode, add support for it"); - break; + { + Host::SetCrashDescriptionWithFormat ("Unhandled DW_OP_XXX opcode: %d, add support for it.", op); + assert (!"Unhandled DW_OP_XXX opcode: %d, add support for it."); + } + break; } return UINT32_MAX; } From gclayton at apple.com Wed Nov 30 21:52:18 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 01 Dec 2011 03:52:18 -0000 Subject: [Lldb-commits] [lldb] r145561 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist Message-ID: <20111201035218.8E7CC2A6C12C@llvm.org> Author: gclayton Date: Wed Nov 30 21:52:18 2011 New Revision: 145561 URL: http://llvm.org/viewvc/llvm-project?rev=145561&view=rev Log: Bumping Xcode project version for lldb-91. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=145561&r1=145560&r2=145561&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Nov 30 21:52:18 2011 @@ -3730,9 +3730,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 90; + CURRENT_PROJECT_VERSION = 91; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 90; + DYLIB_CURRENT_VERSION = 91; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3791,10 +3791,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 90; + CURRENT_PROJECT_VERSION = 91; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 90; + DYLIB_CURRENT_VERSION = 91; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3851,8 +3851,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 90; - DYLIB_CURRENT_VERSION = 90; + CURRENT_PROJECT_VERSION = 91; + DYLIB_CURRENT_VERSION = 91; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3881,8 +3881,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 90; - DYLIB_CURRENT_VERSION = 90; + CURRENT_PROJECT_VERSION = 91; + DYLIB_CURRENT_VERSION = 91; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3911,8 +3911,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 90; - DYLIB_CURRENT_VERSION = 90; + CURRENT_PROJECT_VERSION = 91; + DYLIB_CURRENT_VERSION = 91; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3989,7 +3989,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 90; + CURRENT_PROJECT_VERSION = 91; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4019,10 +4019,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 90; + CURRENT_PROJECT_VERSION = 91; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 90; + DYLIB_CURRENT_VERSION = 91; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4266,7 +4266,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 90; + CURRENT_PROJECT_VERSION = 91; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4297,7 +4297,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 90; + CURRENT_PROJECT_VERSION = 91; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=145561&r1=145560&r2=145561&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Wed Nov 30 21:52:18 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 90 + 91 CFBundleName ${EXECUTABLE_NAME} From gclayton at apple.com Wed Nov 30 21:52:39 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 01 Dec 2011 03:52:39 -0000 Subject: [Lldb-commits] [lldb] r145562 - /lldb/tags/lldb-91/ Message-ID: <20111201035239.55EE62A6C12C@llvm.org> Author: gclayton Date: Wed Nov 30 21:52:39 2011 New Revision: 145562 URL: http://llvm.org/viewvc/llvm-project?rev=145562&view=rev Log: lldb-91. Added: lldb/tags/lldb-91/ - copied from r145561, lldb/trunk/ From gclayton at apple.com Wed Nov 30 22:06:15 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 01 Dec 2011 04:06:15 -0000 Subject: [Lldb-commits] [lldb] r145564 - /lldb/trunk/source/Expression/DWARFExpression.cpp Message-ID: <20111201040615.4DDEB2A6C12C@llvm.org> Author: gclayton Date: Wed Nov 30 22:06:15 2011 New Revision: 145564 URL: http://llvm.org/viewvc/llvm-project?rev=145564&view=rev Log: Avoid a crash for the new DW_OP_stack_value and DW_OP_implicit_value opcodes that was due to an assertion. Modified: lldb/trunk/source/Expression/DWARFExpression.cpp Modified: lldb/trunk/source/Expression/DWARFExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=145564&r1=145563&r2=145564&view=diff ============================================================================== --- lldb/trunk/source/Expression/DWARFExpression.cpp (original) +++ lldb/trunk/source/Expression/DWARFExpression.cpp Wed Nov 30 22:06:15 2011 @@ -905,6 +905,7 @@ case DW_OP_push_object_address: // 0x97 DWARF3 case DW_OP_form_tls_address: // 0x9b DWARF3 case DW_OP_call_frame_cfa: // 0x9c DWARF3 + case DW_OP_stack_value: // 0x9f DWARF4 return 0; // Opcodes with a single 1 byte arguments @@ -976,12 +977,20 @@ data.Skip_LEB128(&offset); return offset - data_offset; - // All opcodes that have a 2 ULEB (signed or unsigned) arguments + // All opcodes that have a 2 ULEB (signed or unsigned) arguments case DW_OP_bregx: // 0x92 2 ULEB128 register followed by SLEB128 offset case DW_OP_bit_piece: // 0x9d ULEB128 bit size, ULEB128 bit offset (DWARF3); data.Skip_LEB128(&offset); data.Skip_LEB128(&offset); return offset - data_offset; + + case DW_OP_implicit_value: // 0x9e ULEB128 size followed by block of that size (DWARF4) + { + uint64_t block_len = data.Skip_LEB128(&offset); + offset += block_len; + return offset - data_offset; + } + default: { Host::SetCrashDescriptionWithFormat ("Unhandled DW_OP_XXX opcode: %d, add support for it.", op); From gclayton at apple.com Wed Nov 30 22:07:04 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 01 Dec 2011 04:07:04 -0000 Subject: [Lldb-commits] [lldb] r145565 - /lldb/tags/lldb-91/ Message-ID: <20111201040704.0AA612A6C12C@llvm.org> Author: gclayton Date: Wed Nov 30 22:07:03 2011 New Revision: 145565 URL: http://llvm.org/viewvc/llvm-project?rev=145565&view=rev Log: Going to retag lldb-91. Removed: lldb/tags/lldb-91/ From gclayton at apple.com Wed Nov 30 22:07:21 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 01 Dec 2011 04:07:21 -0000 Subject: [Lldb-commits] [lldb] r145566 - /lldb/tags/lldb-91/ Message-ID: <20111201040721.37EB62A6C12C@llvm.org> Author: gclayton Date: Wed Nov 30 22:07:20 2011 New Revision: 145566 URL: http://llvm.org/viewvc/llvm-project?rev=145566&view=rev Log: lldb-91 version 2. Added: lldb/tags/lldb-91/ - copied from r145565, lldb/trunk/ From gclayton at apple.com Wed Nov 30 22:33:45 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 01 Dec 2011 04:33:45 -0000 Subject: [Lldb-commits] [lldb] r145568 - /lldb/tags/lldb-91/ Message-ID: <20111201043345.2FA662A6C12C@llvm.org> Author: gclayton Date: Wed Nov 30 22:33:44 2011 New Revision: 145568 URL: http://llvm.org/viewvc/llvm-project?rev=145568&view=rev Log: Tagging lldb-91 again to get more changes. Removed: lldb/tags/lldb-91/ From gclayton at apple.com Wed Nov 30 22:33:56 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 01 Dec 2011 04:33:56 -0000 Subject: [Lldb-commits] [lldb] r145569 - /lldb/tags/lldb-91/ Message-ID: <20111201043356.F20932A6C12C@llvm.org> Author: gclayton Date: Wed Nov 30 22:33:56 2011 New Revision: 145569 URL: http://llvm.org/viewvc/llvm-project?rev=145569&view=rev Log: lldb-91 version 3. Added: lldb/tags/lldb-91/ - copied from r145568, lldb/trunk/ From jingham at apple.com Thu Dec 1 14:26:15 2011 From: jingham at apple.com (Jim Ingham) Date: Thu, 01 Dec 2011 20:26:15 -0000 Subject: [Lldb-commits] [lldb] r145625 - /lldb/trunk/source/Target/Process.cpp Message-ID: <20111201202615.CCAE22A6C12C@llvm.org> Author: jingham Date: Thu Dec 1 14:26:15 2011 New Revision: 145625 URL: http://llvm.org/viewvc/llvm-project?rev=145625&view=rev Log: Protect a few log->Printf calls with "if (log)"... Modified: lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=145625&r1=145624&r2=145625&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu Dec 1 14:26:15 2011 @@ -3231,7 +3231,8 @@ if (curr_thread_list.GetSize() != num_threads) { lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_PROCESS)); - log->Printf("Number of threads changed from %d to %d while processing event.", num_threads, curr_thread_list.GetSize()); + if (log) + log->Printf("Number of threads changed from %d to %d while processing event.", num_threads, curr_thread_list.GetSize()); break; } @@ -3240,10 +3241,11 @@ if (thread_sp->GetIndexID() != thread_index_array[idx]) { lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_PROCESS)); - log->Printf("The thread at position %d changed from %d to %d while processing event.", - idx, - thread_index_array[idx], - thread_sp->GetIndexID()); + if (log) + log->Printf("The thread at position %d changed from %d to %d while processing event.", + idx, + thread_index_array[idx], + thread_sp->GetIndexID()); break; } From scallanan at apple.com Thu Dec 1 15:04:37 2011 From: scallanan at apple.com (Sean Callanan) Date: Thu, 01 Dec 2011 21:04:37 -0000 Subject: [Lldb-commits] [lldb] r145628 - in /lldb/trunk/source/Expression: ClangASTSource.cpp ClangExpressionDeclMap.cpp Message-ID: <20111201210437.C0FA42A6C12C@llvm.org> Author: spyffe Date: Thu Dec 1 15:04:37 2011 New Revision: 145628 URL: http://llvm.org/viewvc/llvm-project?rev=145628&view=rev Log: Modified clients of ClangASTImporter to be more robust in the face of failures to import types, since blithely passing on NULL types can sometimes lead to trouble. Also eliminated a use of getAs and replaced it with dyn_cast, which is more robust. Modified: lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=145628&r1=145627&r2=145628&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Thu Dec 1 15:04:37 2011 @@ -503,6 +503,14 @@ void *copied_type = GuardedCopyType(m_ast_context, type_sp->GetClangAST(), type_sp->GetClangFullType()); + if (!copied_type) + { + if (log) + log->Printf("ClangExpressionDeclMap::BuildIntegerVariable - Couldn't export the type for a constant integer result"); + + break; + } + context.AddTypeDecl(copied_type); } @@ -845,7 +853,7 @@ // this, we raid the function's FunctionProtoType for types. QualType qual_type (QualType::getFromOpaquePtr(type)); - const FunctionProtoType *func_proto_type = qual_type->getAs(); + const FunctionProtoType *func_proto_type = dyn_cast(qual_type.getTypePtr()); if (func_proto_type) { @@ -872,6 +880,12 @@ func_decl->setParams(ArrayRef(parm_var_decls)); } + else + { + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + log->Printf("Function type wasn't a FunctionProtoType"); + } m_decls.push_back(func_decl); Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=145628&r1=145627&r2=145628&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Dec 1 15:04:37 2011 @@ -201,6 +201,16 @@ type.GetOpaqueQualType()), context); + if (!user_type.GetOpaqueQualType()) + { + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + if (log) + log->Printf("ClangExpressionDeclMap::BuildIntegerVariable - Couldn't export the type for a constant integer result"); + + return lldb::ClangExpressionVariableSP(); + } + if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (exe_ctx->GetBestExecutionContextScope (), name, user_type, @@ -290,6 +300,16 @@ type.GetOpaqueQualType()), context); + if (!user_type.GetOpaqueQualType()) + { + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + if (log) + log->Printf("ClangExpressionDeclMap::BuildCastVariable - Couldn't export the type for a constant cast result"); + + return lldb::ClangExpressionVariableSP(); + } + TypeFromUser var_type = var_sp->GetTypeFromUser(); StackFrame *frame = exe_ctx->GetFramePtr(); @@ -2793,6 +2813,13 @@ user_type.GetOpaqueQualType()), m_ast_context); + if (!parser_type.GetOpaqueQualType()) + { + if (log) + log->Printf(" CEDM::FEVD[%u] Couldn't import type for pvar %s", current_id, pvar_sp->GetName().GetCString()); + return; + } + NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::CreateLValueReferenceType(parser_type.GetASTContext(), parser_type.GetOpaqueQualType())); pvar_sp->EnableParserVars(); @@ -2903,6 +2930,14 @@ lldb::clang_type_t copied_type = m_ast_importer->CopyType(scratch_ast_context, &var_decl->getASTContext(), var_type.getAsOpaquePtr()); + if (!copied_type) + { + if (log) + log->Printf("ClangExpressionDeclMap::ResolveUnknownType - Couldn't import the type for a variable"); + + return lldb::ClangExpressionVariableSP(); + } + TypeFromUser user_type(copied_type, scratch_ast_context); entity->m_parser_vars->m_lldb_value->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType()); @@ -3075,6 +3110,16 @@ ASTContext *user_ast_context = ut.GetASTContext(); void *copied_type = GuardedCopyType(parser_ast_context, user_ast_context, ut.GetOpaqueQualType()); + + if (!copied_type) + { + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + if (log) + log->Printf("ClangExpressionDeclMap::AddOneType - Couldn't import the type"); + + return; + } if (add_method && ClangASTContext::IsAggregateType(copied_type)) { From gclayton at apple.com Thu Dec 1 17:28:38 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 01 Dec 2011 23:28:38 -0000 Subject: [Lldb-commits] [lldb] r145644 - in /lldb/trunk: include/lldb/ include/lldb/Target/ include/lldb/Utility/ source/API/ source/Breakpoint/ source/Commands/ source/Core/ source/Host/macosx/ source/Plugins/Process/gdb-remote/ source/Target/ tools/driver/ Message-ID: <20111201232838.B5BFC2A6C12C@llvm.org> Author: gclayton Date: Thu Dec 1 17:28:38 2011 New Revision: 145644 URL: http://llvm.org/viewvc/llvm-project?rev=145644&view=rev Log: Process IDs (lldb::pid_t) and thread IDs (lldb::tid_t) are now 64 bit. This will allow us to represent a process/thread ID using a pointer for the OS plug-ins where they might want to represent the process or thread ID using the address of the process or thread structure. Modified: lldb/trunk/include/lldb/Target/ThreadList.h lldb/trunk/include/lldb/Utility/PseudoTerminal.h lldb/trunk/include/lldb/lldb-types.h lldb/trunk/source/API/SBBreakpoint.cpp lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/API/SBThread.cpp lldb/trunk/source/Breakpoint/BreakpointLocation.cpp lldb/trunk/source/Commands/CommandObjectPlatform.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Core/Log.cpp lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/ThreadSpec.cpp lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/include/lldb/Target/ThreadList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadList.h?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadList.h (original) +++ lldb/trunk/include/lldb/Target/ThreadList.h Thu Dec 1 17:28:38 2011 @@ -69,7 +69,7 @@ FindThreadByID (lldb::tid_t tid, bool can_update = true); lldb::ThreadSP - FindThreadByIndexID (lldb::tid_t index_id, bool can_update = true); + FindThreadByIndexID (uint32_t index_id, bool can_update = true); lldb::ThreadSP GetThreadSPForThreadPtr (Thread *thread_ptr); Modified: lldb/trunk/include/lldb/Utility/PseudoTerminal.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/PseudoTerminal.h?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/PseudoTerminal.h (original) +++ lldb/trunk/include/lldb/Utility/PseudoTerminal.h Thu Dec 1 17:28:38 2011 @@ -92,7 +92,7 @@ /// than zero, or -1 if the fork fails. /// @li \b Child process: zero. //------------------------------------------------------------------ - pid_t + lldb::pid_t Fork (char *error_str, size_t error_len); //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/lldb-types.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-types.h?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-types.h (original) +++ lldb/trunk/include/lldb/lldb-types.h Thu Dec 1 17:28:38 2011 @@ -97,8 +97,8 @@ { typedef uint64_t addr_t; typedef uint64_t user_id_t; - typedef int32_t pid_t; - typedef uint32_t tid_t; + typedef uint64_t pid_t; + typedef uint64_t tid_t; typedef int32_t break_id_t; typedef int32_t watch_id_t; typedef void * clang_type_t; Modified: lldb/trunk/source/API/SBBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpoint.cpp (original) +++ lldb/trunk/source/API/SBBreakpoint.cpp Thu Dec 1 17:28:38 2011 @@ -316,7 +316,7 @@ } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) - log->Printf ("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4x)", m_opaque_sp.get(), tid); + log->Printf ("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4llx)", m_opaque_sp.get(), tid); } @@ -332,7 +332,7 @@ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) - log->Printf ("SBBreakpoint(%p)::GetThreadID () => 0x%4.4x", m_opaque_sp.get(), tid); + log->Printf ("SBBreakpoint(%p)::GetThreadID () => 0x%4.4llx", m_opaque_sp.get(), tid); return tid; } Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Thu Dec 1 17:28:38 2011 @@ -187,7 +187,7 @@ if (log) { SBStream sstr; error.GetDescription (sstr); - log->Printf ("SBProcess(%p)::RemoteAttachToProcessWithID (%d) => SBError (%p): %s", m_opaque_sp.get(), pid, error.get(), sstr.GetData()); + log->Printf ("SBProcess(%p)::RemoteAttachToProcessWithID (%llu) => SBError (%p): %s", m_opaque_sp.get(), pid, error.get(), sstr.GetData()); } return error.Success(); @@ -459,7 +459,7 @@ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) - log->Printf ("SBProcess(%p)::GetProcessID () => %d", m_opaque_sp.get(), ret_val); + log->Printf ("SBProcess(%p)::GetProcessID () => %llu", m_opaque_sp.get(), ret_val); return ret_val; } @@ -662,7 +662,7 @@ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) { - log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%4.4x) => SBThread (%p)", + log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%4.4llx) => SBThread (%p)", m_opaque_sp.get(), tid, sb_thread.get()); Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Thu Dec 1 17:28:38 2011 @@ -333,7 +333,7 @@ tid = m_opaque_sp->GetID(); if (log) - log->Printf ("SBThread(%p)::GetThreadID () => 0x%4.4x", m_opaque_sp.get(), tid); + log->Printf ("SBThread(%p)::GetThreadID () => 0x%4.4llx", m_opaque_sp.get(), tid); return tid; } Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Thu Dec 1 17:28:38 2011 @@ -412,7 +412,7 @@ if (s == NULL) return; - s->Printf("BreakpointLocation %u: tid = %4.4x load addr = 0x%8.8llx state = %s type = %s breakpoint " + s->Printf("BreakpointLocation %u: tid = %4.4llx load addr = 0x%8.8llx state = %s type = %s breakpoint " "hw_index = %i hit_count = %-4u ignore_count = %-4u", GetID(), GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(), Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Thu Dec 1 17:28:38 2011 @@ -512,7 +512,7 @@ } else { - result.AppendErrorWithFormat ("no process found with pid = %i\n", pid); + result.AppendErrorWithFormat ("no process found with pid = %llu\n", pid); result.SetStatus (eReturnStatusFailed); } } @@ -796,12 +796,12 @@ ProcessInstanceInfo proc_info; if (platform_sp->GetProcessInfo (pid, proc_info)) { - ostrm.Printf ("Process information for process %i:\n", pid); + ostrm.Printf ("Process information for process %llu:\n", pid); proc_info.Dump (ostrm, platform_sp.get()); } else { - ostrm.Printf ("error: no process information is available for process %i\n", pid); + ostrm.Printf ("error: no process information is available for process %llu\n", pid); } ostrm.EOL(); } Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Thu Dec 1 17:28:38 2011 @@ -85,7 +85,7 @@ show_process_status = StateIsStoppedState(state, true); const char *state_cstr = StateAsCString (state); if (pid != LLDB_INVALID_PROCESS_ID) - strm.Printf ("%spid=%i", properties++ > 0 ? ", " : " ( ", pid); + strm.Printf ("%spid=%llu", properties++ > 0 ? ", " : " ( ", pid); strm.Printf ("%sstate=%s", properties++ > 0 ? ", " : " ( ", state_cstr); } if (properties > 0) Modified: lldb/trunk/source/Core/Log.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/source/Core/Log.cpp (original) +++ lldb/trunk/source/Core/Log.cpp Thu Dec 1 17:28:38 2011 @@ -105,7 +105,7 @@ // Add the process and thread if requested if (m_options.Test (LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD)) - header.Printf ("[%4.4x/%4.4x]: ", getpid(), Host::GetCurrentThreadID()); + header.Printf ("[%4.4x/%4.4llx]: ", getpid(), Host::GetCurrentThreadID()); // Add the process and thread if requested if (m_options.Test (LLDB_LOG_OPTION_PREPEND_THREAD_NAME)) Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Thu Dec 1 17:28:38 2011 @@ -1306,7 +1306,7 @@ } #endif - lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; + ::pid_t pid = LLDB_INVALID_PROCESS_ID; const char *tmp_argv[2]; char * const *argv = (char * const*)launch_info.GetArguments().GetConstArgumentVector(); char * const *envp = (char * const*)launch_info.GetEnvironmentEntries().GetConstArgumentVector(); @@ -1493,7 +1493,7 @@ } if (log) - log->Printf ("::waitpid (pid = %i, &status, 0) => pid = %i, status = 0x%8.8x (%s), signal = %i, exit_status = %i", + log->Printf ("::waitpid (pid = %llu, &status, 0) => pid = %i, status = 0x%8.8x (%s), signal = %i, exit_status = %i", pid, wait_pid, status, Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Thu Dec 1 17:28:38 2011 @@ -1019,7 +1019,7 @@ if (pid != LLDB_INVALID_PROCESS_ID) { char packet[64]; - const int packet_len = ::snprintf (packet, sizeof(packet), "vAttach;%x", pid); + const int packet_len = ::snprintf (packet, sizeof(packet), "vAttach;%llx", pid); assert (packet_len < sizeof(packet)); if (SendPacketAndWaitForResponse (packet, packet_len, response, false)) { @@ -1334,7 +1334,7 @@ if (m_supports_qProcessInfoPID) { char packet[32]; - const int packet_len = ::snprintf (packet, sizeof (packet), "qProcessInfoPID:%i", pid); + const int packet_len = ::snprintf (packet, sizeof (packet), "qProcessInfoPID:%llu", pid); assert (packet_len < sizeof(packet)); StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse (packet, packet_len, response, false)) @@ -1404,9 +1404,9 @@ } if (match_info.GetProcessInfo().ProcessIDIsValid()) - packet.Printf("pid:%u;",match_info.GetProcessInfo().GetProcessID()); + packet.Printf("pid:%llu;",match_info.GetProcessInfo().GetProcessID()); if (match_info.GetProcessInfo().ParentProcessIDIsValid()) - packet.Printf("parent_pid:%u;",match_info.GetProcessInfo().GetParentProcessID()); + packet.Printf("parent_pid:%llu;",match_info.GetProcessInfo().GetParentProcessID()); if (match_info.GetProcessInfo().UserIDIsValid()) packet.Printf("uid:%u;",match_info.GetProcessInfo().GetUserID()); if (match_info.GetProcessInfo().GroupIDIsValid()) Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Thu Dec 1 17:28:38 2011 @@ -275,7 +275,7 @@ static void CreateProcessInfoResponse (const ProcessInstanceInfo &proc_info, StreamString &response) { - response.Printf ("pid:%i;ppid:%i;uid:%i;gid:%i;euid:%i;egid:%i;", + response.Printf ("pid:%llu;ppid:%llu;uid:%i;gid:%i;euid:%i;egid:%i;", proc_info.GetProcessID(), proc_info.GetParentProcessID(), proc_info.GetUserID(), @@ -641,7 +641,7 @@ { lldb::pid_t pid = m_process_launch_info.GetProcessID(); StreamString response; - response.Printf("QC%x", pid); + response.Printf("QC%llx", pid); if (m_is_platform) { // If we launch a process and this GDB server is acting as a platform, @@ -707,7 +707,7 @@ { uint16_t port = (intptr_t)accept_thread_result; char response[256]; - const int response_len = ::snprintf (response, sizeof(response), "pid:%u;port:%u;", debugserver_pid, port); + const int response_len = ::snprintf (response, sizeof(response), "pid:%llu;port:%u;", debugserver_pid, port); assert (response_len < sizeof(response)); //m_port_to_pid_map[port] = debugserver_launch_info.GetProcessID(); success = SendPacket (response, response_len) > 0; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Dec 1 17:28:38 2011 @@ -408,10 +408,10 @@ SetPrivateState (state); } else - error.SetErrorStringWithFormat ("Process %i was reported after connecting to '%s', but state was not stopped: %s", pid, remote_url, StateAsCString (state)); + error.SetErrorStringWithFormat ("Process %llu was reported after connecting to '%s', but state was not stopped: %s", pid, remote_url, StateAsCString (state)); } else - error.SetErrorStringWithFormat ("Process %i was reported after connecting to '%s', but no stop reply packet was received", pid, remote_url); + error.SetErrorStringWithFormat ("Process %llu was reported after connecting to '%s', but no stop reply packet was received", pid, remote_url); } return error; } @@ -772,7 +772,7 @@ if (error.Success()) { char packet[64]; - const int packet_len = ::snprintf (packet, sizeof(packet), "vAttach;%x", attach_pid); + const int packet_len = ::snprintf (packet, sizeof(packet), "vAttach;%llx", attach_pid); SetID (attach_pid); m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncContinue, new EventDataBytes (packet, packet_len)); } @@ -890,7 +890,7 @@ if (m_gdb_comm.GetVContSupported ('c')) { for (tid_collection::const_iterator t_pos = m_continue_c_tids.begin(), t_end = m_continue_c_tids.end(); t_pos != t_end; ++t_pos) - continue_packet.Printf(";c:%4.4x", *t_pos); + continue_packet.Printf(";c:%4.4llx", *t_pos); } else continue_packet_error = true; @@ -901,7 +901,7 @@ if (m_gdb_comm.GetVContSupported ('C')) { for (tid_sig_collection::const_iterator s_pos = m_continue_C_tids.begin(), s_end = m_continue_C_tids.end(); s_pos != s_end; ++s_pos) - continue_packet.Printf(";C%2.2x:%4.4x", s_pos->second, s_pos->first); + continue_packet.Printf(";C%2.2x:%4.4llx", s_pos->second, s_pos->first); } else continue_packet_error = true; @@ -912,7 +912,7 @@ if (m_gdb_comm.GetVContSupported ('s')) { for (tid_collection::const_iterator t_pos = m_continue_s_tids.begin(), t_end = m_continue_s_tids.end(); t_pos != t_end; ++t_pos) - continue_packet.Printf(";s:%4.4x", *t_pos); + continue_packet.Printf(";s:%4.4llx", *t_pos); } else continue_packet_error = true; @@ -923,7 +923,7 @@ if (m_gdb_comm.GetVContSupported ('S')) { for (tid_sig_collection::const_iterator s_pos = m_continue_S_tids.begin(), s_end = m_continue_S_tids.end(); s_pos != s_end; ++s_pos) - continue_packet.Printf(";S%2.2x:%4.4x", s_pos->second, s_pos->first); + continue_packet.Printf(";S%2.2x:%4.4llx", s_pos->second, s_pos->first); } else continue_packet_error = true; @@ -2131,7 +2131,7 @@ m_debugserver_pid = LLDB_INVALID_PROCESS_ID; if (error.Fail() || log) - error.PutToLog(log.get(), "Host::LaunchProcess (launch_info) => pid=%i, path='%s'", m_debugserver_pid, debugserver_path); + error.PutToLog(log.get(), "Host::LaunchProcess (launch_info) => pid=%llu, path='%s'", m_debugserver_pid, debugserver_path); } else { @@ -2176,7 +2176,7 @@ TargetSP target_sp (Debugger::FindTargetWithProcess(process)); if (log) - log->Printf ("ProcessGDBRemote::MonitorDebugserverProcess (baton=%p, pid=%i, signo=%i (0x%x), exit_status=%i)", callback_baton, debugserver_pid, signo, signo, exit_status); + log->Printf ("ProcessGDBRemote::MonitorDebugserverProcess (baton=%p, pid=%llu, signo=%i (0x%x), exit_status=%i)", callback_baton, debugserver_pid, signo, signo, exit_status); if (target_sp) { Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu Dec 1 17:28:38 2011 @@ -45,10 +45,10 @@ { const char *cstr; if (m_pid != LLDB_INVALID_PROCESS_ID) - s.Printf (" pid = %i\n", m_pid); + s.Printf (" pid = %llu\n", m_pid); if (m_parent_pid != LLDB_INVALID_PROCESS_ID) - s.Printf (" parent = %i\n", m_parent_pid); + s.Printf (" parent = %llu\n", m_parent_pid); if (m_executable) { @@ -135,7 +135,7 @@ if (m_pid != LLDB_INVALID_PROCESS_ID) { const char *cstr; - s.Printf ("%-6u %-6u ", m_pid, m_parent_pid); + s.Printf ("%-6llu %-6llu ", m_pid, m_parent_pid); if (verbose) @@ -1163,7 +1163,7 @@ { LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PROCESS)); if (log) - log->Printf ("Process::SetProcessExitStatus (baton=%p, pid=%i, exited=%i, signal=%i, exit_status=%i)\n", + log->Printf ("Process::SetProcessExitStatus (baton=%p, pid=%llu, exited=%i, signal=%i, exit_status=%i)\n", callback_baton, pid, exited, @@ -3208,8 +3208,8 @@ if (m_state == eStateStopped && ! m_restarted) { ThreadList &curr_thread_list = m_process_sp->GetThreadList(); - int num_threads = curr_thread_list.GetSize(); - int idx; + uint32_t num_threads = curr_thread_list.GetSize(); + uint32_t idx; // The actions might change one of the thread's stop_info's opinions about whether we should // stop the process, so we need to query that as we go. @@ -3219,7 +3219,7 @@ // that would cause our iteration here to crash. We could make a copy of the thread list, but we'd really like // to also know if it has changed at all, so we make up a vector of the thread ID's and check what we get back // against this list & bag out if anything differs. - std::vector thread_index_array(num_threads); + std::vector thread_index_array(num_threads); for (idx = 0; idx < num_threads; ++idx) thread_index_array[idx] = curr_thread_list.GetThreadAtIndex(idx)->GetIndexID(); @@ -3232,7 +3232,7 @@ { lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_PROCESS)); if (log) - log->Printf("Number of threads changed from %d to %d while processing event.", num_threads, curr_thread_list.GetSize()); + log->Printf("Number of threads changed from %u to %u while processing event.", num_threads, curr_thread_list.GetSize()); break; } @@ -3242,7 +3242,7 @@ { lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_PROCESS)); if (log) - log->Printf("The thread at position %d changed from %d to %d while processing event.", + log->Printf("The thread at position %u changed from %u to %u while processing event.", idx, thread_index_array[idx], thread_sp->GetIndexID()); Modified: lldb/trunk/source/Target/ThreadSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadSpec.cpp?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadSpec.cpp (original) +++ lldb/trunk/source/Target/ThreadSpec.cpp Thu Dec 1 17:28:38 2011 @@ -104,7 +104,7 @@ else { if (GetTID() != LLDB_INVALID_THREAD_ID) - s->Printf("tid: 0x%x ", GetTID()); + s->Printf("tid: 0x%llx ", GetTID()); if (GetIndex() != UINT32_MAX) s->Printf("index: %d ", GetIndex()); Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=145644&r1=145643&r2=145644&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Thu Dec 1 17:28:38 2011 @@ -865,7 +865,7 @@ case eStateDetached: { char message[1024]; - int message_len = ::snprintf (message, sizeof(message), "Process %d %s\n", process.GetProcessID(), + int message_len = ::snprintf (message, sizeof(message), "Process %llu %s\n", process.GetProcessID(), m_debugger.StateAsCString (event_state)); m_io_channel_ap->OutWrite(message, message_len, ASYNC); } @@ -892,7 +892,7 @@ { // FIXME: Do we want to report this, or would that just be annoyingly chatty? char message[1024]; - int message_len = ::snprintf (message, sizeof(message), "Process %d stopped and was programmatically restarted.\n", + int message_len = ::snprintf (message, sizeof(message), "Process %llu stopped and was programmatically restarted.\n", process.GetProcessID()); m_io_channel_ap->OutWrite(message, message_len, ASYNC); } @@ -1293,7 +1293,7 @@ { command_str.append("-p "); char pid_buffer[32]; - ::snprintf (pid_buffer, sizeof(pid_buffer), "%d", m_option_data.m_process_pid); + ::snprintf (pid_buffer, sizeof(pid_buffer), "%llu", m_option_data.m_process_pid); command_str.append(pid_buffer); } else From clattner at apple.com Thu Dec 1 17:38:19 2011 From: clattner at apple.com (Chris Lattner) Date: Thu, 01 Dec 2011 15:38:19 -0800 Subject: [Lldb-commits] [lldb] r145628 - in /lldb/trunk/source/Expression: ClangASTSource.cpp ClangExpressionDeclMap.cpp In-Reply-To: <20111201210437.C0FA42A6C12C@llvm.org> References: <20111201210437.C0FA42A6C12C@llvm.org> Message-ID: <5367AC95-5316-4BDD-BDB4-871E6EE722D0@apple.com> On Dec 1, 2011, at 1:04 PM, Sean Callanan wrote: > Author: spyffe > Date: Thu Dec 1 15:04:37 2011 > New Revision: 145628 > > URL: http://llvm.org/viewvc/llvm-project?rev=145628&view=rev > Log: > Modified clients of ClangASTImporter to be more robust > in the face of failures to import types, since blithely > passing on NULL types can sometimes lead to trouble. > > Also eliminated a use of getAs and replaced it with > dyn_cast, which is more robust. > FYI, dyn_cast and getAs<> are different: dyn_cast returns a syntactic form, where getAs returns the semantic form. This matters when you have typedefs of function types, for example: getAs will look through the typedef, but dyn_cast won't. Is this the right thing for this code? -Chris > @@ -845,7 +853,7 @@ > // this, we raid the function's FunctionProtoType for types. > > QualType qual_type (QualType::getFromOpaquePtr(type)); > - const FunctionProtoType *func_proto_type = qual_type->getAs(); > + const FunctionProtoType *func_proto_type = dyn_cast(qual_type.getTypePtr()); > > if (func_proto_type) > { > @@ -872,6 +880,12 @@ > > func_decl->setParams(ArrayRef(parm_var_decls)); > } > + else > + { > + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); > + > + log->Printf("Function type wasn't a FunctionProtoType"); > + } > > m_decls.push_back(func_decl); > > > Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=145628&r1=145627&r2=145628&view=diff > ============================================================================== > --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) > +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Dec 1 15:04:37 2011 > @@ -201,6 +201,16 @@ > type.GetOpaqueQualType()), > context); > > + if (!user_type.GetOpaqueQualType()) > + { > + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); > + > + if (log) > + log->Printf("ClangExpressionDeclMap::BuildIntegerVariable - Couldn't export the type for a constant integer result"); > + > + return lldb::ClangExpressionVariableSP(); > + } > + > if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (exe_ctx->GetBestExecutionContextScope (), > name, > user_type, > @@ -290,6 +300,16 @@ > type.GetOpaqueQualType()), > context); > > + if (!user_type.GetOpaqueQualType()) > + { > + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); > + > + if (log) > + log->Printf("ClangExpressionDeclMap::BuildCastVariable - Couldn't export the type for a constant cast result"); > + > + return lldb::ClangExpressionVariableSP(); > + } > + > TypeFromUser var_type = var_sp->GetTypeFromUser(); > > StackFrame *frame = exe_ctx->GetFramePtr(); > @@ -2793,6 +2813,13 @@ > user_type.GetOpaqueQualType()), > m_ast_context); > > + if (!parser_type.GetOpaqueQualType()) > + { > + if (log) > + log->Printf(" CEDM::FEVD[%u] Couldn't import type for pvar %s", current_id, pvar_sp->GetName().GetCString()); > + return; > + } > + > NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::CreateLValueReferenceType(parser_type.GetASTContext(), parser_type.GetOpaqueQualType())); > > pvar_sp->EnableParserVars(); > @@ -2903,6 +2930,14 @@ > > lldb::clang_type_t copied_type = m_ast_importer->CopyType(scratch_ast_context, &var_decl->getASTContext(), var_type.getAsOpaquePtr()); > > + if (!copied_type) > + { > + if (log) > + log->Printf("ClangExpressionDeclMap::ResolveUnknownType - Couldn't import the type for a variable"); > + > + return lldb::ClangExpressionVariableSP(); > + } > + > TypeFromUser user_type(copied_type, scratch_ast_context); > > entity->m_parser_vars->m_lldb_value->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType()); > @@ -3075,6 +3110,16 @@ > ASTContext *user_ast_context = ut.GetASTContext(); > > void *copied_type = GuardedCopyType(parser_ast_context, user_ast_context, ut.GetOpaqueQualType()); > + > + if (!copied_type) > + { > + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); > + > + if (log) > + log->Printf("ClangExpressionDeclMap::AddOneType - Couldn't import the type"); > + > + return; > + } > > if (add_method && ClangASTContext::IsAggregateType(copied_type)) > { > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From jingham at apple.com Thu Dec 1 19:12:59 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 02 Dec 2011 01:12:59 -0000 Subject: [Lldb-commits] [lldb] r145660 - /lldb/trunk/source/Interpreter/CommandInterpreter.cpp Message-ID: <20111202011259.4FB3B2A6C12C@llvm.org> Author: jingham Date: Thu Dec 1 19:12:59 2011 New Revision: 145660 URL: http://llvm.org/viewvc/llvm-project?rev=145660&view=rev Log: "f" should be an alias for "frame select" not "finish" to match the gdb usage. Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=145660&r1=145659&r2=145660&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Dec 1 19:12:59 2011 @@ -151,10 +151,15 @@ cmd_obj_sp = GetCommandSPExact ("thread step-out", false); if (cmd_obj_sp) { - AddAlias ("f", cmd_obj_sp); AddAlias ("finish", cmd_obj_sp); } + cmd_obj_sp = GetCommandSPExact ("frame select", false); + if (cmd_obj_sp) + { + AddAlias ("f", cmd_obj_sp); + } + cmd_obj_sp = GetCommandSPExact ("source list", false); if (cmd_obj_sp) { From gclayton at apple.com Thu Dec 1 20:09:28 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 02 Dec 2011 02:09:28 -0000 Subject: [Lldb-commits] [lldb] r145667 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20111202020928.7BB9B2A6C12C@llvm.org> Author: gclayton Date: Thu Dec 1 20:09:28 2011 New Revision: 145667 URL: http://llvm.org/viewvc/llvm-project?rev=145667&view=rev Log: Fixed templates with NonTypeTemplateParmDecl objects. For example: template .... This fixes SmallVector and all of the other classes that have template params that are non types. Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=145667&r1=145666&r2=145667&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Dec 1 20:09:28 2011 @@ -1169,7 +1169,7 @@ depth, i, &ast->Idents.get(name), - template_param_infos.args[i].getAsType(), + template_param_infos.args[i].getIntegralType(), parameter_pack, NULL)); @@ -1202,7 +1202,14 @@ SourceLocation(), SourceLocation(), &identifier_info); - + + for (size_t i=0, template_param_decl_count = template_param_decls.size(); + i < template_param_decl_count; + ++i) + { + template_param_decls[i]->setDeclContext (template_cxx_decl); + } + // With templated classes, we say that a class is templated with // specializations, but that the bare class has no functions. template_cxx_decl->startDefinition(); From gclayton at apple.com Thu Dec 1 20:10:57 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 02 Dec 2011 02:10:57 -0000 Subject: [Lldb-commits] [lldb] r145668 - in /lldb/trunk: include/lldb/API/SBTarget.h source/API/SBTarget.cpp Message-ID: <20111202021057.5CDA42A6C12C@llvm.org> Author: gclayton Date: Thu Dec 1 20:10:57 2011 New Revision: 145668 URL: http://llvm.org/viewvc/llvm-project?rev=145668&view=rev Log: After moving lldb::pid_t to 64 bits, keep a deprecated version around for previous binaries that link against this for a few builds to make sure we can continue to run against previous binaries. Modified: lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/source/API/SBTarget.cpp Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=145668&r1=145667&r2=145668&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Thu Dec 1 20:10:57 2011 @@ -181,6 +181,14 @@ lldb::pid_t pid, lldb::SBError& error); +#if defined(__APPLE__) + // We need to keep this around for a build or two since Xcode links + // to the 32 bit version of this function. We will take it out soon. + lldb::SBProcess + AttachToProcessWithID (SBListener &listener, + ::pid_t pid, // 32 bit int process ID + lldb::SBError& error); // DEPRECATED +#endif //------------------------------------------------------------------ /// Attach to process with name. /// Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=145668&r1=145667&r2=145668&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Thu Dec 1 20:10:57 2011 @@ -284,6 +284,17 @@ return sb_process; } +#if defined(__APPLE__) + +lldb::SBProcess +SBTarget::AttachToProcessWithID (SBListener &listener, + ::pid_t pid, + lldb::SBError& error) +{ + return AttachToProcessWithID (listener, (lldb::pid_t)pid, error); +} + +#endif // #if defined(__APPLE__) lldb::SBProcess SBTarget::AttachToProcessWithID From scallanan at apple.com Thu Dec 1 21:41:39 2011 From: scallanan at apple.com (Sean Callanan) Date: Fri, 02 Dec 2011 03:41:39 -0000 Subject: [Lldb-commits] [lldb] r145675 - in /lldb/trunk/source/Plugins/SymbolFile/Symtab: SymbolFileSymtab.cpp SymbolFileSymtab.h Message-ID: <20111202034139.E21E22A6C12C@llvm.org> Author: spyffe Date: Thu Dec 1 21:41:39 2011 New Revision: 145675 URL: http://llvm.org/viewvc/llvm-project?rev=145675&view=rev Log: Added support for extracting method information from Objective-C symbols. The methods aren't used yet if there is a competing definition in the DWARF; I will resolve that next. Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=145675&r1=145674&r2=145675&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Thu Dec 1 21:41:39 2011 @@ -374,6 +374,20 @@ return 0; } +static int CountMethodArgs(const char *method_signature) +{ + int num_args = 0; + + for (const char *colon_pos = strchr(method_signature, ':'); + colon_pos != NULL; + colon_pos = strchr(colon_pos + 1, ':')) + { + num_args++; + } + + return num_args; +} + uint32_t SymbolFileSymtab::FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types) { @@ -382,6 +396,14 @@ if (HasObjCSymbols()) { + TypeMap::iterator iter = m_objc_class_types.find(name.AsCString()); + + if (iter != m_objc_class_types.end()) + { + types.Insert(iter->second); + return 1; + } + std::string symbol_name("OBJC_CLASS_$_"); symbol_name.append(name.AsCString()); ConstString symbol_const_string(symbol_name.c_str()); @@ -397,6 +419,83 @@ ClangASTContext &clang_ast_ctx = GetClangASTContext(); lldb::clang_type_t objc_object_type = clang_ast_ctx.CreateObjCClass(name.AsCString(), clang_ast_ctx.GetTranslationUnitDecl(), isForwardDecl, isInternal); + + const char *class_method_prefix = "^\\+\\["; + const char *instance_method_prefix = "^\\-\\["; + const char *method_suffix = " [a-zA-Z0-9:]+\\]$"; + + std::string class_method_regexp_str(class_method_prefix); + class_method_regexp_str.append(name.AsCString()); + class_method_regexp_str.append(method_suffix); + + RegularExpression class_method_regexp(class_method_regexp_str.c_str()); + + indices.clear(); + + lldb::clang_type_t unknown_type = clang_ast_ctx.GetUnknownAnyType(); + std::vector arg_types; + + if (m_obj_file->GetSymtab()->FindAllSymbolsMatchingRexExAndType(class_method_regexp, eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, indices) != 0) + { + for (std::vector::iterator ii = indices.begin(), ie = indices.end(); + ii != ie; + ++ii) + { + Symbol *symbol = m_obj_file->GetSymtab()->SymbolAtIndex(*ii); + + if (!symbol) + continue; + + const char *signature = symbol->GetName().AsCString(); + + int num_args = CountMethodArgs(signature); + + while (arg_types.size() < num_args) + arg_types.push_back(unknown_type); + + bool is_variadic = false; + unsigned type_quals = 0; + + lldb::clang_type_t method_type = clang_ast_ctx.CreateFunctionType(unknown_type, arg_types.data(), num_args, is_variadic, type_quals); + + clang_ast_ctx.AddMethodToObjCObjectType(objc_object_type, signature, method_type, eAccessPublic); + } + } + + std::string instance_method_regexp_str(instance_method_prefix); + instance_method_regexp_str.append(name.AsCString()); + instance_method_regexp_str.append(method_suffix); + + RegularExpression instance_method_regexp(instance_method_regexp_str.c_str()); + + indices.clear(); + + if (m_obj_file->GetSymtab()->FindAllSymbolsMatchingRexExAndType(instance_method_regexp, eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, indices) != 0) + { + for (std::vector::iterator ii = indices.begin(), ie = indices.end(); + ii != ie; + ++ii) + { + Symbol *symbol = m_obj_file->GetSymtab()->SymbolAtIndex(*ii); + + if (!symbol) + continue; + + const char *signature = symbol->GetName().AsCString(); + + int num_args = CountMethodArgs(signature); + + while (arg_types.size() < num_args) + arg_types.push_back(unknown_type); + + bool is_variadic = false; + unsigned type_quals = 0; + + lldb::clang_type_t method_type = clang_ast_ctx.CreateFunctionType(unknown_type, arg_types.data(), num_args, is_variadic, type_quals); + + clang_ast_ctx.AddMethodToObjCObjectType(objc_object_type, signature, method_type, eAccessPublic); + } + } Declaration decl; @@ -409,7 +508,9 @@ Type::eEncodingInvalid, decl, objc_object_type, - Type::eResolveStateForward)); + Type::eResolveStateFull)); + + m_objc_class_types[name.AsCString()] = type; types.Insert(type); Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h?rev=145675&r1=145674&r2=145675&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Thu Dec 1 21:41:39 2011 @@ -125,6 +125,10 @@ std::vector m_code_indexes; std::vector m_data_indexes; std::vector m_addr_indexes; // Anything that needs to go into an search by address + + typedef std::map TypeMap; + + TypeMap m_objc_class_types; bool HasObjCSymbols (); From scallanan at apple.com Fri Dec 2 12:06:45 2011 From: scallanan at apple.com (Sean Callanan) Date: Fri, 02 Dec 2011 18:06:45 -0000 Subject: [Lldb-commits] [lldb] r145688 - in /lldb/trunk/source/Plugins/SymbolFile/Symtab: SymbolFileSymtab.cpp SymbolFileSymtab.h Message-ID: <20111202180645.D3AC92A6C12C@llvm.org> Author: spyffe Date: Fri Dec 2 12:06:45 2011 New Revision: 145688 URL: http://llvm.org/viewvc/llvm-project?rev=145688&view=rev Log: Modified the Objective-C type map in SymbolFileSymtab to use ConstStrings. The const char*s were assumed to be from ConstStrings before, but since storing a full-on ConstString is no more expensive than storing a const char* it makes better sense to enforce uniqueness with the type checker. Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=145688&r1=145687&r2=145688&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Fri Dec 2 12:06:45 2011 @@ -396,7 +396,7 @@ if (HasObjCSymbols()) { - TypeMap::iterator iter = m_objc_class_types.find(name.AsCString()); + TypeMap::iterator iter = m_objc_class_types.find(name); if (iter != m_objc_class_types.end()) { @@ -510,7 +510,7 @@ objc_object_type, Type::eResolveStateFull)); - m_objc_class_types[name.AsCString()] = type; + m_objc_class_types[name] = type; types.Insert(type); Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h?rev=145688&r1=145687&r2=145688&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Fri Dec 2 12:06:45 2011 @@ -126,7 +126,7 @@ std::vector m_data_indexes; std::vector m_addr_indexes; // Anything that needs to go into an search by address - typedef std::map TypeMap; + typedef std::map TypeMap; TypeMap m_objc_class_types; From gclayton at apple.com Fri Dec 2 16:48:25 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 02 Dec 2011 22:48:25 -0000 Subject: [Lldb-commits] [lldb] r145720 - /lldb/trunk/source/Core/ValueObject.cpp Message-ID: <20111202224825.DA3162A6C12C@llvm.org> Author: gclayton Date: Fri Dec 2 16:48:25 2011 New Revision: 145720 URL: http://llvm.org/viewvc/llvm-project?rev=145720&view=rev Log: Fixed an issue that could cause an infinite recursion when using "type filter". Modified: lldb/trunk/source/Core/ValueObject.cpp Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=145720&r1=145719&r2=145720&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Dec 2 16:48:25 2011 @@ -2307,7 +2307,7 @@ } else if (options.m_no_synthetic_children == false) // let's try with synthetic children { - child_valobj_sp = root->GetSyntheticValue(eUseSyntheticFilter)->GetChildMemberWithName(child_name, true); + child_valobj_sp = root->GetSyntheticValue(eNoSyntheticFilter)->GetChildMemberWithName(child_name, true); } // if we are here and options.m_no_synthetic_children is true, child_valobj_sp is going to be a NULL SP, From johnny.chen at apple.com Fri Dec 2 18:16:59 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 03 Dec 2011 00:16:59 -0000 Subject: [Lldb-commits] [lldb] r145732 - /lldb/trunk/test/lldbtest.py Message-ID: <20111203001659.884722A6C12C@llvm.org> Author: johnny Date: Fri Dec 2 18:16:59 2011 New Revision: 145732 URL: http://llvm.org/viewvc/llvm-project?rev=145732&view=rev Log: Let's also record the compiler version used for compiling the inferior into the session info Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=145732&r1=145731&r2=145732&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri Dec 2 18:16:59 2011 @@ -779,6 +779,9 @@ else: benchmarks = False + # This records the compiler version used for the test. + system([self.getCompiler(), "-v"], sender=self) + dname = os.path.join(os.environ["LLDB_TEST"], os.environ["LLDB_SESSION_DIRNAME"]) if not os.path.isdir(dname): From gclayton at apple.com Fri Dec 2 18:27:06 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 03 Dec 2011 00:27:06 -0000 Subject: [Lldb-commits] [lldb] r145733 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20111203002706.2F3832A6C12C@llvm.org> Author: gclayton Date: Fri Dec 2 18:27:05 2011 New Revision: 145733 URL: http://llvm.org/viewvc/llvm-project?rev=145733&view=rev Log: Fixed an issue where if we have the DWARF equivalent of: struct foo; class foo { ... }; Or vice versa, we wouldn't be able to find the complete type. Since many compilers allow forward declarations to have struct and definitions to have class, we need to be able to deal with both cases. This commit fixes this in the DWARF parser. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=145733&r1=145732&r2=145733&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Dec 2 18:27:05 2011 @@ -3804,7 +3804,7 @@ const size_t num_matches = die_offsets.size(); - const dw_tag_t type_tag = die->Tag(); + const dw_tag_t die_tag = die->Tag(); DWARFCompileUnit* type_cu = NULL; const DWARFDebugInfoEntry* type_die = NULL; @@ -3818,31 +3818,59 @@ if (type_die) { - if (type_die != die && type_die->Tag() == type_tag) + bool try_resolving_type = false; + + // Don't try and resolve the DIE we are looking for with the DIE itself! + if (type_die != die) { - // Hold off on comparing parent DIE tags until - // we know what happens with stuff in namespaces - // for gcc and clang... - //DWARFDebugInfoEntry *parent_die = die->GetParent(); - //DWARFDebugInfoEntry *parent_type_die = type_die->GetParent(); - //if (parent_die->Tag() == parent_type_die->Tag()) - { - Type *resolved_type = ResolveType (type_cu, type_die, false); - if (resolved_type && resolved_type != DIE_IS_BEING_PARSED) - { - DEBUG_PRINTF ("resolved 0x%8.8llx (cu 0x%8.8llx) from %s to 0x%8.8llx (cu 0x%8.8llx)\n", - MakeUserID(die->GetOffset()), - MakeUserID(curr_cu->GetOffset()), - m_obj_file->GetFileSpec().GetFilename().AsCString(), - MakeUserID(type_die->GetOffset()), - MakeUserID(type_cu->GetOffset())); - - m_die_to_type[die] = resolved_type; - type_sp = resolved_type; + const dw_tag_t type_die_tag = type_die->Tag(); + // Make sure the tags match + if (type_die_tag == die_tag) + { + // The tags match, lets try resolving this type + try_resolving_type = true; + } + else + { + // The tags don't match, but we need to watch our for a + // forward declaration for a struct and ("struct foo") + // ends up being a class ("class foo { ... };") or + // vice versa. + switch (type_die_tag) + { + case DW_TAG_class_type: + // We had a "class foo", see if we ended up with a "struct foo { ... };" + try_resolving_type = (die_tag == DW_TAG_structure_type); + break; + case DW_TAG_structure_type: + // We had a "struct foo", see if we ended up with a "class foo { ... };" + try_resolving_type = (die_tag == DW_TAG_class_type); + break; + default: + // Tags don't match, don't event try to resolve + // using this type whose name matches.... break; } } } + + if (try_resolving_type) + { + Type *resolved_type = ResolveType (type_cu, type_die, false); + if (resolved_type && resolved_type != DIE_IS_BEING_PARSED) + { + DEBUG_PRINTF ("resolved 0x%8.8llx (cu 0x%8.8llx) from %s to 0x%8.8llx (cu 0x%8.8llx)\n", + MakeUserID(die->GetOffset()), + MakeUserID(curr_cu->GetOffset()), + m_obj_file->GetFileSpec().GetFilename().AsCString(), + MakeUserID(type_die->GetOffset()), + MakeUserID(type_cu->GetOffset())); + + m_die_to_type[die] = resolved_type; + type_sp = resolved_type; + break; + } + } } else { From gclayton at apple.com Fri Dec 2 18:46:21 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 03 Dec 2011 00:46:21 -0000 Subject: [Lldb-commits] [lldb] r145735 - in /lldb/trunk: include/lldb/Breakpoint/StoppointLocation.h source/API/SBProcess.cpp source/Breakpoint/StoppointLocation.cpp source/Breakpoint/Watchpoint.cpp source/Symbol/Type.cpp Message-ID: <20111203004621.E38972A6C12C@llvm.org> Author: gclayton Date: Fri Dec 2 18:46:21 2011 New Revision: 145735 URL: http://llvm.org/viewvc/llvm-project?rev=145735&view=rev Log: Fixed some extra warnings that show up with the new clang. Modified: lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/Breakpoint/StoppointLocation.cpp lldb/trunk/source/Breakpoint/Watchpoint.cpp lldb/trunk/source/Symbol/Type.cpp Modified: lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h?rev=145735&r1=145734&r2=145735&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h (original) +++ lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h Fri Dec 2 18:46:21 2011 @@ -32,7 +32,7 @@ StoppointLocation (lldb::break_id_t bid, lldb::addr_t m_addr, - size_t size, + uint32_t byte_size, bool hardware); virtual @@ -57,7 +57,7 @@ return m_addr; } - size_t + uint32_t GetByteSize () const { return m_byte_size; Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=145735&r1=145734&r2=145735&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Fri Dec 2 18:46:21 2011 @@ -732,7 +732,7 @@ m_opaque_sp.get(), addr, dst, - (uint32_t) dst_len, + dst_len, sb_error.get()); } @@ -752,14 +752,14 @@ { SBStream sstr; sb_error.GetDescription (sstr); - log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%llx, dst=%p, dst_len=%zu, SBError (%p): %s) => %d", + log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%llx, dst=%p, dst_len=%zu, SBError (%p): %s) => %zu", m_opaque_sp.get(), addr, dst, - (uint32_t) dst_len, + dst_len, sb_error.get(), sstr.GetData(), - (uint32_t) bytes_read); + bytes_read); } return bytes_read; @@ -777,7 +777,7 @@ m_opaque_sp.get(), addr, src, - (uint32_t) src_len, + src_len, sb_error.get()); } @@ -793,14 +793,14 @@ { SBStream sstr; sb_error.GetDescription (sstr); - log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%llx, src=%p, dst_len=%zu, SBError (%p): %s) => %d", + log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%llx, src=%p, dst_len=%zu, SBError (%p): %s) => %zu", m_opaque_sp.get(), addr, src, - (uint32_t) src_len, + src_len, sb_error.get(), sstr.GetData(), - (uint32_t) bytes_written); + bytes_written); } return bytes_written; Modified: lldb/trunk/source/Breakpoint/StoppointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/StoppointLocation.cpp?rev=145735&r1=145734&r2=145735&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/StoppointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/StoppointLocation.cpp Fri Dec 2 18:46:21 2011 @@ -30,12 +30,12 @@ { } -StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, size_t size, bool hardware) : +StoppointLocation::StoppointLocation (break_id_t bid, addr_t addr, uint32_t byte_size, bool hardware) : m_loc_id(bid), m_addr(addr), m_hw_preferred(hardware), m_hw_index(LLDB_INVALID_INDEX32), - m_byte_size(size), + m_byte_size(byte_size), m_hit_count(0) { } Modified: lldb/trunk/source/Breakpoint/Watchpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Watchpoint.cpp?rev=145735&r1=145734&r2=145735&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/Watchpoint.cpp (original) +++ lldb/trunk/source/Breakpoint/Watchpoint.cpp Fri Dec 2 18:46:21 2011 @@ -112,7 +112,7 @@ assert(description_level >= lldb::eDescriptionLevelBrief && description_level <= lldb::eDescriptionLevelVerbose); - s->Printf("Watchpoint %u: addr = 0x%8.8llx size = %zu state = %s type = %s%s", + s->Printf("Watchpoint %u: addr = 0x%8.8llx size = %u state = %s type = %s%s", GetID(), (uint64_t)m_addr, m_byte_size, Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=145735&r1=145734&r2=145735&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Fri Dec 2 18:46:21 2011 @@ -109,7 +109,7 @@ // Call the get byte size accesor so we resolve our byte size if (GetByteSize()) - s->Printf(", byte-size = %zu", m_byte_size); + s->Printf(", byte-size = %u", m_byte_size); bool show_fullpaths = (level == lldb::eDescriptionLevelVerbose); m_decl.Dump(s, show_fullpaths); @@ -149,7 +149,7 @@ *s << ", name = \"" << m_name << "\""; if (m_byte_size != 0) - s->Printf(", size = %zu", m_byte_size); + s->Printf(", size = %u", m_byte_size); if (show_context && m_context != NULL) { From jingham at apple.com Fri Dec 2 19:52:59 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 03 Dec 2011 01:52:59 -0000 Subject: [Lldb-commits] [lldb] r145740 - in /lldb/trunk: include/lldb/Target/ThreadPlanStepInRange.h include/lldb/Target/ThreadPlanStepOut.h include/lldb/Target/ThreadPlanStepOverRange.h include/lldb/Target/ThreadPlanStepRange.h include/lldb/Target/ThreadPlanStepThrough.h source/Target/Thread.cpp source/Target/ThreadPlanShouldStopHere.cpp source/Target/ThreadPlanStepInRange.cpp source/Target/ThreadPlanStepOverRange.cpp source/Target/ThreadPlanStepRange.cpp source/Target/ThreadPlanStepThrough.cpp Message-ID: <20111203015259.D9A4A2A6C12C@llvm.org> Author: jingham Date: Fri Dec 2 19:52:59 2011 New Revision: 145740 URL: http://llvm.org/viewvc/llvm-project?rev=145740&view=rev Log: Make the ThreadPlanStepThrough set a backstop breakpoint on the return address from the function it is being asked to step through, so that even if we get the trampoline target wrong (for instance) we will still not lose control. The other fix here is to tighten up the handling of the case where the current plan doesn't explain the stop, but a plan above us does. In that case, if the plan that does explain the stop says it is done, we need to clean up the plans below it and continue on with our processing. Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h lldb/trunk/include/lldb/Target/ThreadPlanStepOverRange.h lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h lldb/trunk/include/lldb/Target/ThreadPlanStepThrough.h lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp lldb/trunk/source/Target/ThreadPlanStepInRange.cpp lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp lldb/trunk/source/Target/ThreadPlanStepRange.cpp lldb/trunk/source/Target/ThreadPlanStepThrough.cpp Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h?rev=145740&r1=145739&r2=145740&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h Fri Dec 2 19:52:59 2011 @@ -42,6 +42,9 @@ ShouldStop (Event *event_ptr); void SetAvoidRegexp(const char *name); + + virtual bool + PlanExplainsStop (); static ThreadPlan * DefaultShouldStopHereCallback (ThreadPlan *current_plan, Flags &flags, void *baton); Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h?rev=145740&r1=145739&r2=145740&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h Fri Dec 2 19:52:59 2011 @@ -19,8 +19,6 @@ namespace lldb_private { -class ThreadPlanStepOverRange; - class ThreadPlanStepOut : public ThreadPlan { public: Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepOverRange.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepOverRange.h?rev=145740&r1=145739&r2=145740&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepOverRange.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepOverRange.h Fri Dec 2 19:52:59 2011 @@ -33,6 +33,7 @@ virtual ~ThreadPlanStepOverRange (); + virtual bool PlanExplainsStop (); virtual void GetDescription (Stream *s, lldb::DescriptionLevel level); virtual bool ShouldStop (Event *event_ptr); virtual bool Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h?rev=145740&r1=145739&r2=145740&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h Fri Dec 2 19:52:59 2011 @@ -36,7 +36,6 @@ virtual void GetDescription (Stream *s, lldb::DescriptionLevel level) = 0; virtual bool ValidatePlan (Stream *error); - virtual bool PlanExplainsStop (); virtual bool ShouldStop (Event *event_ptr) = 0; virtual Vote ShouldReportStop (Event *event_ptr); virtual bool StopOthers (); Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepThrough.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepThrough.h?rev=145740&r1=145739&r2=145740&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepThrough.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepThrough.h Fri Dec 2 19:52:59 2011 @@ -33,21 +33,29 @@ virtual bool WillResume (lldb::StateType resume_state, bool current_plan); virtual bool WillStop (); virtual bool MischiefManaged (); + virtual void DidPush(); protected: ThreadPlanStepThrough (Thread &thread, bool stop_others); - bool - HappyToStopHere (); + void + LookForPlanToStepThroughFromCurrentPC (); + + bool + HitOurBackstopBreakpoint(); private: friend ThreadPlan * Thread::QueueThreadPlanForStepThrough (bool abort_other_plans, bool stop_others); - lldb::addr_t m_start_address; - bool m_stop_others; + lldb::ThreadPlanSP m_sub_plan_sp; + lldb::addr_t m_start_address; + lldb::break_id_t m_backstop_bkpt_id; + lldb::addr_t m_backstop_addr; + size_t m_stack_depth; + bool m_stop_others; DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepThrough); Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=145740&r1=145739&r2=145740&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Fri Dec 2 19:52:59 2011 @@ -272,7 +272,59 @@ // The top most plan always gets to do the trace log... current_plan->DoTraceLog (); - if (current_plan->PlanExplainsStop()) + // If the base plan doesn't understand why we stopped, then we have to find a plan that does. + // If that plan is still working, then we don't need to do any more work. If the plan that explains + // the stop is done, then we should pop all the plans below it, and pop it, and then let the plans above it decide + // whether they still need to do more work. + + bool done_processing_current_plan = false; + + if (!current_plan->PlanExplainsStop()) + { + if (current_plan->TracerExplainsStop()) + { + done_processing_current_plan = true; + should_stop = false; + } + else + { + // If the current plan doesn't explain the stop, then, find one that + // does and let it handle the situation. + ThreadPlan *plan_ptr = current_plan; + while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL) + { + if (plan_ptr->PlanExplainsStop()) + { + should_stop = plan_ptr->ShouldStop (event_ptr); + + // plan_ptr explains the stop, next check whether plan_ptr is done, if so, then we should take it + // and all the plans below it off the stack. + + if (plan_ptr->MischiefManaged()) + { + // We're going to pop the plans up to AND INCLUDING the plan that explains the stop. + plan_ptr = GetPreviousPlan(plan_ptr); + + do + { + if (should_stop) + current_plan->WillStop(); + PopPlan(); + } + while ((current_plan = GetCurrentPlan()) != plan_ptr); + done_processing_current_plan = false; + } + else + done_processing_current_plan = true; + + break; + } + + } + } + } + + if (!done_processing_current_plan) { bool over_ride_stop = current_plan->ShouldAutoContinue(event_ptr); @@ -333,25 +385,6 @@ if (over_ride_stop) should_stop = false; } - else if (current_plan->TracerExplainsStop()) - { - should_stop = false; - } - else - { - // If the current plan doesn't explain the stop, then, find one that - // does and let it handle the situation. - ThreadPlan *plan_ptr = current_plan; - while ((plan_ptr = GetPreviousPlan(plan_ptr)) != NULL) - { - if (plan_ptr->PlanExplainsStop()) - { - should_stop = plan_ptr->ShouldStop (event_ptr); - break; - } - - } - } if (log) { @@ -797,22 +830,10 @@ ThreadPlan * Thread::QueueThreadPlanForStepThrough (bool abort_other_plans, bool stop_other_threads) { - // Try the dynamic loader first: - ThreadPlanSP thread_plan_sp(GetProcess().GetDynamicLoader()->GetStepThroughTrampolinePlan (*this, stop_other_threads)); - // If that didn't come up with anything, try the ObjC runtime plugin: - if (thread_plan_sp.get() == NULL) - { - ObjCLanguageRuntime *objc_runtime = GetProcess().GetObjCLanguageRuntime(); - if (objc_runtime) - thread_plan_sp = objc_runtime->GetStepThroughTrampolinePlan (*this, stop_other_threads); - } - - if (thread_plan_sp.get() == NULL) - { - thread_plan_sp.reset(new ThreadPlanStepThrough (*this, stop_other_threads)); - if (thread_plan_sp && !thread_plan_sp->ValidatePlan (NULL)) - return NULL; - } + ThreadPlanSP thread_plan_sp(new ThreadPlanStepThrough (*this, stop_other_threads)); + if (!thread_plan_sp || !thread_plan_sp->ValidatePlan (NULL)) + return NULL; + QueueThreadPlan (thread_plan_sp, abort_other_plans); return thread_plan_sp.get(); } Modified: lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp?rev=145740&r1=145739&r2=145740&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp Fri Dec 2 19:52:59 2011 @@ -7,8 +7,10 @@ // //===----------------------------------------------------------------------===// +#include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlanShouldStopHere.h" +#include "lldb/Core/Log.h" using namespace lldb; using namespace lldb_private; @@ -47,7 +49,26 @@ ThreadPlanShouldStopHere::InvokeShouldStopHereCallback () { if (m_callback) - return m_callback (m_owner, m_flags, m_baton); + { + ThreadPlan *return_plan = m_callback (m_owner, m_flags, m_baton); + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + if (log) + { + lldb::addr_t current_addr = m_owner->GetThread().GetRegisterContext()->GetPC(0); + + if (return_plan) + { + StreamString s; + return_plan->GetDescription (&s, lldb::eDescriptionLevelFull); + log->Printf ("ShouldStopHere callback found a step out plan from 0x%llx: %s.", current_addr, s.GetData()); + } + else + { + log->Printf ("ShouldStopHere callback didn't find a step out plan from: 0x%llx.", current_addr); + } + } + return return_plan; + } else return NULL; } Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=145740&r1=145739&r2=145740&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Fri Dec 2 19:52:59 2011 @@ -68,6 +68,37 @@ } bool +ThreadPlanStepInRange::PlanExplainsStop () +{ + // We always explain a stop. Either we've just done a single step, in which + // case we'll do our ordinary processing, or we stopped for some + // reason that isn't handled by our sub-plans, in which case we want to just stop right + // away. + + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + StopInfoSP stop_info_sp = GetPrivateStopReason(); + if (stop_info_sp) + { + StopReason reason = stop_info_sp->GetStopReason(); + + switch (reason) + { + case eStopReasonBreakpoint: + case eStopReasonWatchpoint: + case eStopReasonSignal: + case eStopReasonException: + if (log) + log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step."); + SetPlanComplete(); + break; + default: + break; + } + } + return true; +} + +bool ThreadPlanStepInRange::ShouldStop (Event *event_ptr) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); @@ -81,6 +112,9 @@ log->Printf("ThreadPlanStepInRange reached %s.", s.GetData()); } + if (IsPlanComplete()) + return true; + // If we're still in the range, keep going. if (InRange()) return false; Modified: lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp?rev=145740&r1=145739&r2=145740&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp Fri Dec 2 19:52:59 2011 @@ -63,6 +63,31 @@ } bool +ThreadPlanStepOverRange::PlanExplainsStop () +{ + // We don't explain signals or breakpoints (breakpoints that handle stepping in or + // out will be handled by a child plan. + StopInfoSP stop_info_sp = GetPrivateStopReason(); + if (stop_info_sp) + { + StopReason reason = stop_info_sp->GetStopReason(); + + switch (reason) + { + case eStopReasonBreakpoint: + case eStopReasonWatchpoint: + case eStopReasonSignal: + case eStopReasonException: + return false; + default: + return true; + } + } + return true; +} + + +bool ThreadPlanStepOverRange::ShouldStop (Event *event_ptr) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); Modified: lldb/trunk/source/Target/ThreadPlanStepRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepRange.cpp?rev=145740&r1=145739&r2=145740&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepRange.cpp Fri Dec 2 19:52:59 2011 @@ -63,30 +63,6 @@ return true; } -bool -ThreadPlanStepRange::PlanExplainsStop () -{ - // We don't explain signals or breakpoints (breakpoints that handle stepping in or - // out will be handled by a child plan. - StopInfoSP stop_info_sp = GetPrivateStopReason(); - if (stop_info_sp) - { - StopReason reason = stop_info_sp->GetStopReason(); - - switch (reason) - { - case eStopReasonBreakpoint: - case eStopReasonWatchpoint: - case eStopReasonSignal: - case eStopReasonException: - return false; - default: - return true; - } - } - return true; -} - Vote ThreadPlanStepRange::ShouldReportStop (Event *event_ptr) { Modified: lldb/trunk/source/Target/ThreadPlanStepThrough.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepThrough.cpp?rev=145740&r1=145739&r2=145740&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepThrough.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepThrough.cpp Fri Dec 2 19:52:59 2011 @@ -20,6 +20,8 @@ #include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Breakpoint/Breakpoint.h" using namespace lldb; using namespace lldb_private; @@ -33,13 +35,86 @@ ThreadPlanStepThrough::ThreadPlanStepThrough (Thread &thread, bool stop_others) : ThreadPlan (ThreadPlan::eKindStepThrough, "Step through trampolines and prologues", thread, eVoteNoOpinion, eVoteNoOpinion), m_start_address (0), + m_backstop_bkpt_id (LLDB_INVALID_BREAK_ID), + m_backstop_addr(LLDB_INVALID_ADDRESS), + m_stack_depth (0), m_stop_others (stop_others) { - m_start_address = GetThread().GetRegisterContext()->GetPC(0); + + LookForPlanToStepThroughFromCurrentPC(); + + // If we don't get a valid step through plan, don't bother to set up a backstop. + if (m_sub_plan_sp) + { + m_start_address = GetThread().GetRegisterContext()->GetPC(0); + m_stack_depth = m_thread.GetStackFrameCount() - 1; + + // We are going to return back to the concrete frame 1, we might pass by some inlined code that we're in + // the middle of by doing this, but it's easier than trying to figure out where the inlined code might return to. + + StackFrameSP return_frame_sp (m_thread.GetFrameWithConcreteFrameIndex(1)); + + if (return_frame_sp) + { + m_backstop_addr = return_frame_sp->GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess().GetTarget()); + Breakpoint *return_bp = m_thread.GetProcess().GetTarget().CreateBreakpoint (m_backstop_addr, true).get(); + if (return_bp != NULL) + { + return_bp->SetThreadID(m_thread.GetID()); + m_backstop_bkpt_id = return_bp->GetID(); + } + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + if (log) + { + log->Printf ("Setting backstop breakpoint %d at address: 0x%llx", m_backstop_bkpt_id, m_backstop_addr); + } + } + } } ThreadPlanStepThrough::~ThreadPlanStepThrough () { + if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID) + { + m_thread.GetProcess().GetTarget().RemoveBreakpointByID (m_backstop_bkpt_id); + m_backstop_bkpt_id = LLDB_INVALID_BREAK_ID; + } +} + +void +ThreadPlanStepThrough::DidPush () +{ + if (m_sub_plan_sp) + PushPlan(m_sub_plan_sp); +} + +void +ThreadPlanStepThrough::LookForPlanToStepThroughFromCurrentPC() +{ + m_sub_plan_sp = m_thread.GetProcess().GetDynamicLoader()->GetStepThroughTrampolinePlan (m_thread, m_stop_others); + // If that didn't come up with anything, try the ObjC runtime plugin: + if (!m_sub_plan_sp.get()) + { + ObjCLanguageRuntime *objc_runtime = m_thread.GetProcess().GetObjCLanguageRuntime(); + if (objc_runtime) + m_sub_plan_sp = objc_runtime->GetStepThroughTrampolinePlan (m_thread, m_stop_others); + } + + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + if (log) + { + lldb::addr_t current_address = GetThread().GetRegisterContext()->GetPC(0); + if (m_sub_plan_sp) + { + StreamString s; + m_sub_plan_sp->GetDescription(&s, lldb::eDescriptionLevelFull); + log->Printf ("Found step through plan from 0x%llx: %s", current_address, s.GetData()); + } + else + { + log->Printf ("Couldn't find step through plan from address 0x%llx.", current_address); + } + } } void @@ -49,30 +124,80 @@ s->Printf ("Step through"); else { - s->Printf ("Stepping through trampoline code from: "); + s->PutCString ("Stepping through trampoline code from: "); s->Address(m_start_address, sizeof (addr_t)); + if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID) + { + s->Printf (" with backstop breakpoint id: %d at address: ", m_backstop_bkpt_id); + s->Address (m_backstop_addr, sizeof (addr_t)); + } + else + s->PutCString (" unable to set a backstop breakpoint."); } } bool ThreadPlanStepThrough::ValidatePlan (Stream *error) { - if (HappyToStopHere()) - return false; - else - return true; + return m_sub_plan_sp.get() != NULL; } bool ThreadPlanStepThrough::PlanExplainsStop () { - return true; + // If we have a sub-plan, it will have been asked first if we explain the stop, and + // we won't get asked. The only time we would be the one directly asked this question + // is if we hit our backstop breakpoint. + + if (HitOurBackstopBreakpoint()) + return true; + else + return false; } bool ThreadPlanStepThrough::ShouldStop (Event *event_ptr) { - return true; + // If we've already marked ourselves done, then we're done... + if (IsPlanComplete()) + return true; + + // If we don't have a sub-plan, then we're also done (can't see how we would ever get here + // without a plan, but just in case. + + if (!m_sub_plan_sp) + { + SetPlanComplete(); + return true; + } + + // First, did we hit the backstop breakpoint? + if (HitOurBackstopBreakpoint()) + { + SetPlanComplete(); + return true; + } + + + // If the current sub plan is not done, we don't want to stop. Actually, we probably won't + // ever get here in this state, since we generally won't get asked any questions if out + // current sub-plan is not done... + if (!m_sub_plan_sp->IsPlanComplete()) + return false; + + // Next see if there is a specific step through plan at our current pc (these might + // chain, for instance stepping through a dylib trampoline to the objc dispatch function...) + LookForPlanToStepThroughFromCurrentPC(); + if (m_sub_plan_sp) + { + PushPlan (m_sub_plan_sp); + return false; + } + else + { + SetPlanComplete(); + return true; + } } bool @@ -91,20 +216,6 @@ ThreadPlanStepThrough::WillResume (StateType resume_state, bool current_plan) { ThreadPlan::WillResume(resume_state, current_plan); - if (current_plan) - { - ThreadPlanSP sub_plan_sp(m_thread.GetProcess().GetDynamicLoader()->GetStepThroughTrampolinePlan (m_thread, m_stop_others)); - // If that didn't come up with anything, try the ObjC runtime plugin: - if (sub_plan_sp == NULL) - { - ObjCLanguageRuntime *objc_runtime = m_thread.GetProcess().GetObjCLanguageRuntime(); - if (objc_runtime) - sub_plan_sp = objc_runtime->GetStepThroughTrampolinePlan (m_thread, m_stop_others); - } - - if (sub_plan_sp != NULL) - PushPlan (sub_plan_sp); - } return true; } @@ -119,11 +230,11 @@ { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); - // Stop if we're happy with the place we've landed... + // ShouldStop will call HappyToStopHere, which will set the plan to complete if + // we're done. So we can just check that here. - if (!HappyToStopHere()) + if (!IsPlanComplete()) { - // If we are still at the PC we were trying to step over. return false; } else @@ -131,16 +242,35 @@ if (log) log->Printf("Completed step through step plan."); ThreadPlan::MischiefManaged (); + if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID) + { + m_thread.GetProcess().GetTarget().RemoveBreakpointByID (m_backstop_bkpt_id); + m_backstop_bkpt_id = LLDB_INVALID_BREAK_ID; + } return true; } } bool -ThreadPlanStepThrough::HappyToStopHere() +ThreadPlanStepThrough::HitOurBackstopBreakpoint() { - // This should again ask the various trampolines whether we are still at a - // trampoline point, and if so, continue through the possibly nested trampolines. - - return true; + StopInfoSP stop_info_sp(m_thread.GetStopInfo()); + if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint) + { + break_id_t stop_value = (break_id_t) stop_info_sp->GetValue(); + BreakpointSiteSP cur_site_sp = m_thread.GetProcess().GetBreakpointSiteList().FindByID(stop_value); + if (cur_site_sp && cur_site_sp->IsBreakpointAtThisSite(m_backstop_bkpt_id)) + { + size_t current_stack_depth = m_thread.GetStackFrameCount(); + if (current_stack_depth == m_stack_depth) + { + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + if (log) + log->PutCString ("ThreadPlanStepThrough hit backstop breakpoint."); + return true; + } + } + } + return false; } From gclayton at apple.com Fri Dec 2 20:30:59 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 03 Dec 2011 02:30:59 -0000 Subject: [Lldb-commits] [lldb] r145744 - in /lldb/trunk: include/lldb/Core/Mangled.h include/lldb/lldb-enumerations.h source/Core/Mangled.cpp source/Expression/ClangExpressionDeclMap.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Symbol/ObjectFile.cpp source/Symbol/Symbol.cpp Message-ID: <20111203023059.A30382A6C12C@llvm.org> Author: gclayton Date: Fri Dec 2 20:30:59 2011 New Revision: 145744 URL: http://llvm.org/viewvc/llvm-project?rev=145744&view=rev Log: Added new symbol types for Objective C classes, metaclasses, and ivars. Each object file can correctly make these symbols which will abstract us from the file format and ABI and we can then ask for the objective C class symbol for a class and find out which object file it was defined in. Modified: lldb/trunk/include/lldb/Core/Mangled.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/source/Core/Mangled.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Symbol/ObjectFile.cpp lldb/trunk/source/Symbol/Symbol.cpp Modified: lldb/trunk/include/lldb/Core/Mangled.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Mangled.h?rev=145744&r1=145743&r2=145744&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Mangled.h (original) +++ lldb/trunk/include/lldb/Core/Mangled.h Fri Dec 2 20:30:59 2011 @@ -400,6 +400,18 @@ const ConstString& GetDemangledName () const; + void + SetDemangledName (const char *name) + { + m_demangled.SetCString (name); + } + + void + SetMangledName (const char *name) + { + m_mangled.SetCString (name); + } + //---------------------------------------------------------------------- /// Mangled name get accessor. /// @@ -407,7 +419,10 @@ /// A reference to the mangled name string object. //---------------------------------------------------------------------- ConstString& - GetMangledName (); + GetMangledName () + { + return m_mangled; + } //---------------------------------------------------------------------- /// Mangled name get accessor. @@ -416,7 +431,10 @@ /// A const reference to the mangled name string object. //---------------------------------------------------------------------- const ConstString& - GetMangledName () const; + GetMangledName () const + { + return m_mangled; + } //---------------------------------------------------------------------- /// Best name get accessor. Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=145744&r1=145743&r2=145744&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Dec 2 20:30:59 2011 @@ -449,7 +449,10 @@ eSymbolTypeAdditional, // When symbols take more than one entry, the extra entries get this type eSymbolTypeCompiler, eSymbolTypeInstrumentation, - eSymbolTypeUndefined + eSymbolTypeUndefined, + eSymbolTypeObjCClass, + eSymbolTypeObjCMetaClass, + eSymbolTypeObjCIVar } SymbolType; typedef enum SectionType Modified: lldb/trunk/source/Core/Mangled.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=145744&r1=145743&r2=145744&view=diff ============================================================================== --- lldb/trunk/source/Core/Mangled.cpp (original) +++ lldb/trunk/source/Core/Mangled.cpp Fri Dec 2 20:30:59 2011 @@ -190,25 +190,6 @@ return false; } - -//---------------------------------------------------------------------- -// Mangled name get accessor -//---------------------------------------------------------------------- -ConstString& -Mangled::GetMangledName () -{ - return m_mangled; -} - -//---------------------------------------------------------------------- -// Mangled name const get accessor -//---------------------------------------------------------------------- -const ConstString& -Mangled::GetMangledName () const -{ - return m_mangled; -} - //---------------------------------------------------------------------- // Get the demangled name if there is one, else return the mangled name. //---------------------------------------------------------------------- Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=145744&r1=145743&r2=145744&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Dec 2 20:30:59 2011 @@ -788,6 +788,9 @@ case eSymbolTypeCompiler: case eSymbolTypeInstrumentation: case eSymbolTypeUndefined: + case eSymbolTypeObjCClass: + case eSymbolTypeObjCMetaClass: + case eSymbolTypeObjCIVar: symbol_load_addr = sym_address->GetLoadAddress (&target); break; } Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=145744&r1=145743&r2=145744&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Dec 2 20:30:59 2011 @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/StringRef.h" #include "llvm/Support/MachO.h" #include "ObjectFileMachO.h" @@ -305,6 +306,9 @@ case eSymbolTypeCompiler: return eAddressClassDebug; case eSymbolTypeInstrumentation:return eAddressClassDebug; case eSymbolTypeUndefined: return eAddressClassUnknown; + case eSymbolTypeObjCClass: return eAddressClassRuntime; + case eSymbolTypeObjCMetaClass: return eAddressClassRuntime; + case eSymbolTypeObjCIVar: return eAddressClassRuntime; } } } @@ -852,7 +856,8 @@ m_module->GetFileSpec().GetFilename().GetCString()); continue; } - const char* symbol_name = &strtab_data[nlist.n_strx]; + const char *symbol_name = &strtab_data[nlist.n_strx]; + const char *symbol_name_non_abi_mangled = NULL; if (symbol_name[0] == '\0') symbol_name = NULL; @@ -1184,121 +1189,167 @@ uint8_t n_type = NlistMaskType & nlist.n_type; sym[sym_idx].SetExternal((NlistMaskExternal & nlist.n_type) != 0); - if (symbol_name && ::strstr (symbol_name, ".objc") == symbol_name) + switch (n_type) { - type = eSymbolTypeRuntime; - } - else - { - switch (n_type) - { - case NListTypeIndirect: // N_INDR - Fall through - case NListTypePreboundUndefined:// N_PBUD - Fall through - case NListTypeUndefined: // N_UNDF - type = eSymbolTypeUndefined; - break; + case NListTypeIndirect: // N_INDR - Fall through + case NListTypePreboundUndefined:// N_PBUD - Fall through + case NListTypeUndefined: // N_UNDF + type = eSymbolTypeUndefined; + break; + + case NListTypeAbsolute: // N_ABS + type = eSymbolTypeAbsolute; + break; - case NListTypeAbsolute: // N_ABS - type = eSymbolTypeAbsolute; + case NListTypeSection: // N_SECT + symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); + + if (symbol_section == NULL) + { + // TODO: warn about this? + add_nlist = false; break; + } - case NListTypeSection: // N_SECT - symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); + if (TEXT_eh_frame_sectID == nlist.n_sect) + { + type = eSymbolTypeException; + } + else + { + uint32_t section_type = symbol_section->Get() & SectionFlagMaskSectionType; - if (symbol_section == NULL) + switch (section_type) { - // TODO: warn about this? - add_nlist = false; - break; + case SectionTypeRegular: break; // regular section + //case SectionTypeZeroFill: type = eSymbolTypeData; break; // zero fill on demand section + case SectionTypeCStringLiterals: type = eSymbolTypeData; break; // section with only literal C strings + case SectionType4ByteLiterals: type = eSymbolTypeData; break; // section with only 4 byte literals + case SectionType8ByteLiterals: type = eSymbolTypeData; break; // section with only 8 byte literals + case SectionTypeLiteralPointers: type = eSymbolTypeTrampoline; break; // section with only pointers to literals + case SectionTypeNonLazySymbolPointers: type = eSymbolTypeTrampoline; break; // section with only non-lazy symbol pointers + case SectionTypeLazySymbolPointers: type = eSymbolTypeTrampoline; break; // section with only lazy symbol pointers + case SectionTypeSymbolStubs: type = eSymbolTypeTrampoline; break; // section with only symbol stubs, byte size of stub in the reserved2 field + case SectionTypeModuleInitFunctionPointers: type = eSymbolTypeCode; break; // section with only function pointers for initialization + case SectionTypeModuleTermFunctionPointers: type = eSymbolTypeCode; break; // section with only function pointers for termination + //case SectionTypeCoalesced: type = eSymbolType; break; // section contains symbols that are to be coalesced + //case SectionTypeZeroFillLarge: type = eSymbolTypeData; break; // zero fill on demand section (that can be larger than 4 gigabytes) + case SectionTypeInterposing: type = eSymbolTypeTrampoline; break; // section with only pairs of function pointers for interposing + case SectionType16ByteLiterals: type = eSymbolTypeData; break; // section with only 16 byte literals + case SectionTypeDTraceObjectFormat: type = eSymbolTypeInstrumentation; break; + case SectionTypeLazyDylibSymbolPointers: type = eSymbolTypeTrampoline; break; + default: break; } - if (TEXT_eh_frame_sectID == nlist.n_sect) + if (type == eSymbolTypeInvalid) { - type = eSymbolTypeException; - } - else - { - uint32_t section_type = symbol_section->Get() & SectionFlagMaskSectionType; - - switch (section_type) + const char *symbol_sect_name = symbol_section->GetName().AsCString(); + if (symbol_section->IsDescendant (text_section_sp.get())) { - case SectionTypeRegular: break; // regular section - //case SectionTypeZeroFill: type = eSymbolTypeData; break; // zero fill on demand section - case SectionTypeCStringLiterals: type = eSymbolTypeData; break; // section with only literal C strings - case SectionType4ByteLiterals: type = eSymbolTypeData; break; // section with only 4 byte literals - case SectionType8ByteLiterals: type = eSymbolTypeData; break; // section with only 8 byte literals - case SectionTypeLiteralPointers: type = eSymbolTypeTrampoline; break; // section with only pointers to literals - case SectionTypeNonLazySymbolPointers: type = eSymbolTypeTrampoline; break; // section with only non-lazy symbol pointers - case SectionTypeLazySymbolPointers: type = eSymbolTypeTrampoline; break; // section with only lazy symbol pointers - case SectionTypeSymbolStubs: type = eSymbolTypeTrampoline; break; // section with only symbol stubs, byte size of stub in the reserved2 field - case SectionTypeModuleInitFunctionPointers: type = eSymbolTypeCode; break; // section with only function pointers for initialization - case SectionTypeModuleTermFunctionPointers: type = eSymbolTypeCode; break; // section with only function pointers for termination - //case SectionTypeCoalesced: type = eSymbolType; break; // section contains symbols that are to be coalesced - //case SectionTypeZeroFillLarge: type = eSymbolTypeData; break; // zero fill on demand section (that can be larger than 4 gigabytes) - case SectionTypeInterposing: type = eSymbolTypeTrampoline; break; // section with only pairs of function pointers for interposing - case SectionType16ByteLiterals: type = eSymbolTypeData; break; // section with only 16 byte literals - case SectionTypeDTraceObjectFormat: type = eSymbolTypeInstrumentation; break; - case SectionTypeLazyDylibSymbolPointers: type = eSymbolTypeTrampoline; break; - default: break; + if (symbol_section->IsClear(SectionAttrUserPureInstructions | + SectionAttrUserSelfModifyingCode | + SectionAttrSytemSomeInstructions)) + type = eSymbolTypeData; + else + type = eSymbolTypeCode; } - - if (type == eSymbolTypeInvalid) + else + if (symbol_section->IsDescendant(data_section_sp.get())) { - const char *symbol_sect_name = symbol_section->GetName().AsCString(); - if (symbol_section->IsDescendant (text_section_sp.get())) - { - if (symbol_section->IsClear(SectionAttrUserPureInstructions | - SectionAttrUserSelfModifyingCode | - SectionAttrSytemSomeInstructions)) - type = eSymbolTypeData; - else - type = eSymbolTypeCode; - } - else - if (symbol_section->IsDescendant(data_section_sp.get())) + if (symbol_sect_name && ::strstr (symbol_sect_name, "__objc") == symbol_sect_name) { - if (symbol_sect_name && ::strstr (symbol_sect_name, "__objc") == symbol_sect_name) - { - type = eSymbolTypeRuntime; - } - else - if (symbol_sect_name && ::strstr (symbol_sect_name, "__gcc_except_tab") == symbol_sect_name) - { - type = eSymbolTypeException; - } - else + type = eSymbolTypeRuntime; + + if (symbol_name && + symbol_name[0] == '_' && + symbol_name[1] == 'O' && + symbol_name[2] == 'B') { - type = eSymbolTypeData; + llvm::StringRef symbol_name_ref(symbol_name); + static const llvm::StringRef g_objc_v2_prefix_class ("_OBJC_CLASS_$_"); + static const llvm::StringRef g_objc_v2_prefix_metaclass ("_OBJC_METACLASS_$_"); + static const llvm::StringRef g_objc_v2_prefix_ivar ("_OBJC_IVAR_$_"); + if (symbol_name_ref.startswith(g_objc_v2_prefix_class)) + { + symbol_name_non_abi_mangled = symbol_name; + symbol_name = symbol_name + g_objc_v2_prefix_class.size(); + type = eSymbolTypeObjCClass; + } + else if (symbol_name_ref.startswith(g_objc_v2_prefix_metaclass)) + { + symbol_name_non_abi_mangled = symbol_name; + symbol_name = symbol_name + g_objc_v2_prefix_metaclass.size(); + type = eSymbolTypeObjCMetaClass; + } + else if (symbol_name_ref.startswith(g_objc_v2_prefix_ivar)) + { + symbol_name_non_abi_mangled = symbol_name; + symbol_name = symbol_name + g_objc_v2_prefix_ivar.size(); + type = eSymbolTypeObjCIVar; + } } } else - if (symbol_sect_name && ::strstr (symbol_sect_name, "__IMPORT") == symbol_sect_name) + if (symbol_sect_name && ::strstr (symbol_sect_name, "__gcc_except_tab") == symbol_sect_name) { - type = eSymbolTypeTrampoline; + type = eSymbolTypeException; } else - if (symbol_section->IsDescendant(objc_section_sp.get())) { - type = eSymbolTypeRuntime; + type = eSymbolTypeData; + } + } + else + if (symbol_sect_name && ::strstr (symbol_sect_name, "__IMPORT") == symbol_sect_name) + { + type = eSymbolTypeTrampoline; + } + else + if (symbol_section->IsDescendant(objc_section_sp.get())) + { + type = eSymbolTypeRuntime; + if (symbol_name && symbol_name[0] == '.') + { + llvm::StringRef symbol_name_ref(symbol_name); + static const llvm::StringRef g_objc_v1_prefix_class (".objc_class_name_"); + if (symbol_name_ref.startswith(g_objc_v1_prefix_class)) + { + symbol_name_non_abi_mangled = symbol_name; + symbol_name = symbol_name + g_objc_v1_prefix_class.size(); + type = eSymbolTypeObjCClass; + } } } } - break; - } - } + } + break; + } } + if (add_nlist) { + uint64_t symbol_value = nlist.n_value; bool symbol_name_is_mangled = false; - if (symbol_name && symbol_name[0] == '_') + + if (symbol_name_non_abi_mangled) { - symbol_name_is_mangled = symbol_name[1] == '_'; - symbol_name++; // Skip the leading underscore + sym[sym_idx].GetMangled().SetMangledName (symbol_name_non_abi_mangled); + sym[sym_idx].GetMangled().SetDemangledName (symbol_name); + } + else + { + if (symbol_name && symbol_name[0] == '_') + { + symbol_name_is_mangled = symbol_name[1] == '_'; + symbol_name++; // Skip the leading underscore + } + + else if (symbol_name) + { + sym[sym_idx].GetMangled().SetValue(symbol_name, symbol_name_is_mangled); + } } - uint64_t symbol_value = nlist.n_value; - if (symbol_name) - sym[sym_idx].GetMangled().SetValue(symbol_name, symbol_name_is_mangled); if (is_debug == false) { if (type == eSymbolTypeCode) Modified: lldb/trunk/source/Symbol/ObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=145744&r1=145743&r2=145744&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ObjectFile.cpp (original) +++ lldb/trunk/source/Symbol/ObjectFile.cpp Fri Dec 2 20:30:59 2011 @@ -260,6 +260,9 @@ case eSymbolTypeCompiler: return eAddressClassDebug; case eSymbolTypeInstrumentation:return eAddressClassDebug; case eSymbolTypeUndefined: return eAddressClassUnknown; + case eSymbolTypeObjCClass: return eAddressClassRuntime; + case eSymbolTypeObjCMetaClass: return eAddressClassRuntime; + case eSymbolTypeObjCIVar: return eAddressClassRuntime; } } } Modified: lldb/trunk/source/Symbol/Symbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=145744&r1=145743&r2=145744&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symbol.cpp (original) +++ lldb/trunk/source/Symbol/Symbol.cpp Fri Dec 2 20:30:59 2011 @@ -339,6 +339,9 @@ ENUM_TO_CSTRING(Compiler); ENUM_TO_CSTRING(Instrumentation); ENUM_TO_CSTRING(Undefined); + ENUM_TO_CSTRING(ObjCClass); + ENUM_TO_CSTRING(ObjCMetaClass); + ENUM_TO_CSTRING(ObjCIVar); default: break; } From gclayton at apple.com Fri Dec 2 21:02:17 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 03 Dec 2011 03:02:17 -0000 Subject: [Lldb-commits] [lldb] r145746 - /lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Message-ID: <20111203030217.9EA3D2A6C12C@llvm.org> Author: gclayton Date: Fri Dec 2 21:02:17 2011 New Revision: 145746 URL: http://llvm.org/viewvc/llvm-project?rev=145746&view=rev Log: Remove accidental "else" that was left in in prior checking. Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=145746&r1=145745&r2=145746&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Dec 2 21:02:17 2011 @@ -1344,7 +1344,7 @@ symbol_name++; // Skip the leading underscore } - else if (symbol_name) + if (symbol_name) { sym[sym_idx].GetMangled().SetValue(symbol_name, symbol_name_is_mangled); } From scallanan at apple.com Fri Dec 2 21:15:29 2011 From: scallanan at apple.com (Sean Callanan) Date: Sat, 03 Dec 2011 03:15:29 -0000 Subject: [Lldb-commits] [lldb] r145748 - in /lldb/trunk: include/lldb/Expression/ClangASTSource.h include/lldb/Symbol/ClangASTContext.h include/lldb/Symbol/ClangExternalASTSourceCallbacks.h include/lldb/Symbol/ClangExternalASTSourceCommon.h lldb.xcodeproj/project.pbxproj source/Symbol/ClangASTContext.cpp source/Symbol/ClangExternalASTSourceCommon.cpp Message-ID: <20111203031529.49AD52A6C12C@llvm.org> Author: spyffe Date: Fri Dec 2 21:15:28 2011 New Revision: 145748 URL: http://llvm.org/viewvc/llvm-project?rev=145748&view=rev Log: Added ClangExternalASTSourceCommon, a local superclass for all our external AST sources that lets us associate arbitrary flags with the types we put into the AST contexts. Also added an API on ClangASTContext that allows access to these flags given only an ASTContext and a type. Because we don't have access to RTTI, and because at some point in the future we might encounter external AST sources that we didn't make (so they don't subclass ClangExternalASTSourceCommon) I added a magic number that we check before doing anything else, so that we can catch that problem as soon as it appears. Added: lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCommon.h lldb/trunk/source/Symbol/ClangExternalASTSourceCommon.cpp Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangASTSource.h?rev=145748&r1=145747&r2=145748&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangASTSource.h (original) +++ lldb/trunk/include/lldb/Expression/ClangASTSource.h Fri Dec 2 21:15:28 2011 @@ -13,7 +13,7 @@ #include #include "clang/Basic/IdentifierTable.h" -#include "clang/AST/ExternalASTSource.h" +#include "lldb/Symbol/ClangExternalASTSourceCommon.h" #include "lldb/Symbol/ClangASTImporter.h" #include "lldb/Target/Target.h" @@ -31,7 +31,7 @@ /// the actual lookups. //---------------------------------------------------------------------- class ClangASTSource : - public clang::ExternalASTSource, + public ClangExternalASTSourceCommon, public ClangASTImporter::NamespaceMapCompleter { public: @@ -198,7 +198,7 @@ /// Clang AST contexts like to own their AST sources, so this is a /// state-free proxy object. //---------------------------------------------------------------------- - class ClangASTSourceProxy : public clang::ExternalASTSource + class ClangASTSourceProxy : public ClangExternalASTSourceCommon { public: ClangASTSourceProxy (ClangASTSource &original) : @@ -213,7 +213,7 @@ return m_original.FindExternalVisibleDeclsByName(DC, Name); } - virtual clang::ExternalLoadResult + clang::ExternalLoadResult FindExternalLexicalDecls (const clang::DeclContext *DC, bool (*isKindWeWant)(clang::Decl::Kind), llvm::SmallVectorImpl &Decls) @@ -221,13 +221,13 @@ return m_original.FindExternalLexicalDecls(DC, isKindWeWant, Decls); } - virtual void + void CompleteType (clang::TagDecl *Tag) { return m_original.CompleteType(Tag); } - virtual void + void CompleteType (clang::ObjCInterfaceDecl *Class) { return m_original.CompleteType(Class); @@ -237,6 +237,21 @@ { return m_original.StartTranslationUnit(Consumer); } + + uint64_t GetMetadata(uintptr_t object) + { + return m_original.GetMetadata(object); + } + + void SetMetadata(uintptr_t object, uint64_t metadata) + { + return m_original.SetMetadata(object, metadata); + } + + bool HasMetadata(uintptr_t object) + { + return m_original.HasMetadata(object); + } private: ClangASTSource &m_original; }; Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=145748&r1=145747&r2=145748&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Fri Dec 2 21:15:28 2011 @@ -849,6 +849,15 @@ //------------------------------------------------------------------ static unsigned GetTypeQualifiers(lldb::clang_type_t clang_type); + + //------------------------------------------------------------------ + // Flags + //------------------------------------------------------------------ + static uint64_t + GetTypeFlags(clang::ASTContext *ast, lldb::clang_type_t clang_type); + + static void + SetTypeFlags(clang::ASTContext *ast, lldb::clang_type_t clang_type, uint64_t flags); protected: //------------------------------------------------------------------ // Classes that inherit from ClangASTContext can see and modify these Modified: lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h?rev=145748&r1=145747&r2=145748&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h Fri Dec 2 21:15:28 2011 @@ -19,40 +19,15 @@ // Other libraries and framework includes -// Clang headers like to use NDEBUG inside of them to enable/disable debug -// releated features using "#ifndef NDEBUG" preprocessor blocks to do one thing -// or another. This is bad because it means that if clang was built in release -// mode, it assumes that you are building in release mode which is not always -// the case. You can end up with functions that are defined as empty in header -// files when NDEBUG is not defined, and this can cause link errors with the -// clang .a files that you have since you might be missing functions in the .a -// file. So we have to define NDEBUG when including clang headers to avoid any -// mismatches. This is covered by rdar://problem/8691220 - -#if !defined(NDEBUG) && !defined(LLVM_NDEBUG_OFF) -#define LLDB_DEFINED_NDEBUG_FOR_CLANG -#define NDEBUG -// Need to include assert.h so it is as clang would expect it to be (disabled) -#include -#endif - -#include "clang/AST/ExternalASTSource.h" - -#ifdef LLDB_DEFINED_NDEBUG_FOR_CLANG -#undef NDEBUG -#undef LLDB_DEFINED_NDEBUG_FOR_CLANG -// Need to re-include assert.h so it is as _we_ would expect it to be (enabled) -#include -#endif - // Project includes #include "lldb/lldb-enumerations.h" #include "lldb/Core/ClangForward.h" #include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/ClangExternalASTSourceCommon.h" namespace lldb_private { -class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource +class ClangExternalASTSourceCallbacks : public ClangExternalASTSourceCommon { public: Added: lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCommon.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCommon.h?rev=145748&view=auto ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCommon.h (added) +++ lldb/trunk/include/lldb/Symbol/ClangExternalASTSourceCommon.h Fri Dec 2 21:15:28 2011 @@ -0,0 +1,62 @@ +//===-- ClangExternalASTSourceCommon.h --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_ClangExternalASTSourceCommon_h +#define liblldb_ClangExternalASTSourceCommon_h + +// Clang headers like to use NDEBUG inside of them to enable/disable debug +// releated features using "#ifndef NDEBUG" preprocessor blocks to do one thing +// or another. This is bad because it means that if clang was built in release +// mode, it assumes that you are building in release mode which is not always +// the case. You can end up with functions that are defined as empty in header +// files when NDEBUG is not defined, and this can cause link errors with the +// clang .a files that you have since you might be missing functions in the .a +// file. So we have to define NDEBUG when including clang headers to avoid any +// mismatches. This is covered by rdar://problem/8691220 + +#if !defined(NDEBUG) && !defined(LLVM_NDEBUG_OFF) +#define LLDB_DEFINED_NDEBUG_FOR_CLANG +#define NDEBUG +// Need to include assert.h so it is as clang would expect it to be (disabled) +#include +#endif + +#include "clang/AST/ExternalASTSource.h" + +#ifdef LLDB_DEFINED_NDEBUG_FOR_CLANG +#undef NDEBUG +#undef LLDB_DEFINED_NDEBUG_FOR_CLANG +// Need to re-include assert.h so it is as _we_ would expect it to be (enabled) +#include +#endif + +namespace lldb_private { + +class ClangExternalASTSourceCommon : public clang::ExternalASTSource +{ +public: + ClangExternalASTSourceCommon(); + + virtual uint64_t GetMetadata(uintptr_t object); + virtual void SetMetadata(uintptr_t object, uint64_t metadata); + virtual bool HasMetadata(uintptr_t object); +private: + typedef llvm::DenseMap MetadataMap; + + MetadataMap m_metadata; + uint64_t m_magic; ///< Because we don't have RTTI, we must take it + ///< on faith that any valid ExternalASTSource that + ///< we try to use the *Metadata APIs on inherits + ///< from ClangExternalASTSourceCommon. This magic + ///< number exists to enforce that. +}; + +}; + +#endif Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=145748&r1=145747&r2=145748&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Dec 2 21:15:28 2011 @@ -387,6 +387,7 @@ 26F5C32D10F3DFDD009D5894 /* libtermcap.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */; }; 26F73062139D8FDB00FD51C7 /* History.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F73061139D8FDB00FD51C7 /* History.cpp */; }; 494260DA14579144003C1C78 /* VerifyDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 494260D914579144003C1C78 /* VerifyDecl.cpp */; }; + 4966DCC4148978A10028481B /* ClangExternalASTSourceCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4966DCC3148978A10028481B /* ClangExternalASTSourceCommon.cpp */; }; 496B015B1406DEB100F830D5 /* IRInterpreter.h in Headers */ = {isa = PBXBuildFile; fileRef = 496B015A1406DEB100F830D5 /* IRInterpreter.h */; }; 49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A1CAC31430E8BD00306AC9 /* ExpressionSourceCode.cpp */; }; 49A71FE7141FFA5C00D59478 /* IRInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 496B01581406DE8900F830D5 /* IRInterpreter.cpp */; }; @@ -1147,8 +1148,10 @@ 49445C2512245E3600C11A81 /* ClangExpressionParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExpressionParser.cpp; path = source/Expression/ClangExpressionParser.cpp; sourceTree = ""; }; 49445C2912245E5500C11A81 /* ClangExpressionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangExpressionParser.h; path = include/lldb/Expression/ClangExpressionParser.h; sourceTree = ""; }; 49445E341225AB6A00C11A81 /* ClangUserExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangUserExpression.h; path = include/lldb/Expression/ClangUserExpression.h; sourceTree = ""; }; + 495B38431489714C002708C5 /* ClangExternalASTSourceCommon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ClangExternalASTSourceCommon.h; path = include/lldb/Symbol/ClangExternalASTSourceCommon.h; sourceTree = ""; }; 495BBACB119A0DBE00418BEA /* PathMappingList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PathMappingList.cpp; path = source/Target/PathMappingList.cpp; sourceTree = ""; }; 495BBACF119A0DE700418BEA /* PathMappingList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PathMappingList.h; path = include/lldb/Target/PathMappingList.h; sourceTree = ""; }; + 4966DCC3148978A10028481B /* ClangExternalASTSourceCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExternalASTSourceCommon.cpp; path = source/Symbol/ClangExternalASTSourceCommon.cpp; sourceTree = ""; }; 496B01581406DE8900F830D5 /* IRInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IRInterpreter.cpp; path = source/Expression/IRInterpreter.cpp; sourceTree = ""; }; 496B015A1406DEB100F830D5 /* IRInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IRInterpreter.h; path = include/lldb/Expression/IRInterpreter.h; sourceTree = ""; }; 497C86BD122823D800B54702 /* ClangUtilityFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangUtilityFunction.cpp; path = source/Expression/ClangUtilityFunction.cpp; sourceTree = ""; }; @@ -2199,6 +2202,8 @@ 49D8FB3513B558DE00411094 /* ClangASTImporter.cpp */, 49E45FA911F660DC008F7B28 /* ClangASTType.h */, 49E45FAD11F660FE008F7B28 /* ClangASTType.cpp */, + 495B38431489714C002708C5 /* ClangExternalASTSourceCommon.h */, + 4966DCC3148978A10028481B /* ClangExternalASTSourceCommon.cpp */, 26E6902E129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h */, 26E69030129C6BEF00DDECD9 /* ClangExternalASTSourceCallbacks.cpp */, 266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */, @@ -3521,6 +3526,7 @@ 49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */, 494260DA14579144003C1C78 /* VerifyDecl.cpp in Sources */, 49DA65031485C92A005FF180 /* AppleObjCSymbolVendor.cpp in Sources */, + 4966DCC4148978A10028481B /* ClangExternalASTSourceCommon.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=145748&r1=145747&r2=145748&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Dec 2 21:15:28 2011 @@ -61,6 +61,7 @@ #include "lldb/Core/Log.h" #include "lldb/Core/RegularExpression.h" #include "lldb/Expression/ASTDumper.h" +#include "lldb/Symbol/ClangExternalASTSourceCommon.h" #include "lldb/Symbol/VerifyDecl.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" @@ -5767,6 +5768,36 @@ return qual_type.getQualifiers().getCVRQualifiers(); } +uint64_t +GetTypeFlags(clang::ASTContext *ast, lldb::clang_type_t clang_type) +{ + assert (clang_type); + + clang::ExternalASTSource *external_ast_source = ast->getExternalSource(); + + if (!external_ast_source) + return 0; + + ClangExternalASTSourceCommon *common_ast_source = static_cast(external_ast_source); + + return common_ast_source->GetMetadata((uintptr_t)clang_type); +} + +void +SetTypeFlags(clang::ASTContext *ast, lldb::clang_type_t clang_type, uint64_t flags) +{ + assert (clang_type); + + clang::ExternalASTSource *external_ast_source = ast->getExternalSource(); + + if (!external_ast_source) + return; + + ClangExternalASTSourceCommon *common_ast_source = static_cast(external_ast_source); + + return common_ast_source->SetMetadata((uintptr_t)clang_type, flags); +} + bool ClangASTContext::GetCompleteType (clang::ASTContext *ast, lldb::clang_type_t clang_type) { Added: lldb/trunk/source/Symbol/ClangExternalASTSourceCommon.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangExternalASTSourceCommon.cpp?rev=145748&view=auto ============================================================================== --- lldb/trunk/source/Symbol/ClangExternalASTSourceCommon.cpp (added) +++ lldb/trunk/source/Symbol/ClangExternalASTSourceCommon.cpp Fri Dec 2 21:15:28 2011 @@ -0,0 +1,40 @@ +//===-- ClangExternalASTSourceCommon.cpp ------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Symbol/ClangExternalASTSourceCommon.h" + +using namespace lldb_private; + +#define ClangExternalASTSourceCommon_MAGIC (0x00112233aabbccddull) + +ClangExternalASTSourceCommon::ClangExternalASTSourceCommon() : clang::ExternalASTSource() +{ + m_magic = ClangExternalASTSourceCommon_MAGIC; +} + +uint64_t ClangExternalASTSourceCommon::GetMetadata (uintptr_t object) +{ + assert (m_magic == ClangExternalASTSourceCommon_MAGIC); + + return m_metadata[object]; +} + +void ClangExternalASTSourceCommon::SetMetadata (uintptr_t object, uint64_t metadata) +{ + assert (m_magic == ClangExternalASTSourceCommon_MAGIC); + + m_metadata[object] = metadata; +} + +bool ClangExternalASTSourceCommon::HasMetadata (uintptr_t object) +{ + assert (m_magic == ClangExternalASTSourceCommon_MAGIC); + + return m_metadata.find(object) != m_metadata.end(); +} \ No newline at end of file From gclayton at apple.com Fri Dec 2 22:35:52 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 03 Dec 2011 04:35:52 -0000 Subject: [Lldb-commits] [lldb] r145756 - in /lldb/trunk/test/lang/objc/real-definition: ./ Bar.h Bar.m Foo.h Foo.m Makefile main.m Message-ID: <20111203043552.4FCB72A6C12C@llvm.org> Author: gclayton Date: Fri Dec 2 22:35:51 2011 New Revision: 145756 URL: http://llvm.org/viewvc/llvm-project?rev=145756&view=rev Log: Added a code for a test to find the real Objective C class definition. I still need to write the test case file. Added: lldb/trunk/test/lang/objc/real-definition/ lldb/trunk/test/lang/objc/real-definition/Bar.h lldb/trunk/test/lang/objc/real-definition/Bar.m lldb/trunk/test/lang/objc/real-definition/Foo.h lldb/trunk/test/lang/objc/real-definition/Foo.m lldb/trunk/test/lang/objc/real-definition/Makefile lldb/trunk/test/lang/objc/real-definition/main.m Added: lldb/trunk/test/lang/objc/real-definition/Bar.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/real-definition/Bar.h?rev=145756&view=auto ============================================================================== --- lldb/trunk/test/lang/objc/real-definition/Bar.h (added) +++ lldb/trunk/test/lang/objc/real-definition/Bar.h Fri Dec 2 22:35:51 2011 @@ -0,0 +1,12 @@ +#import + + at class InternalClass; + + at interface Bar : NSObject { + @private + InternalClass *storage; +} + +- (NSString *)description; + + at end \ No newline at end of file Added: lldb/trunk/test/lang/objc/real-definition/Bar.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/real-definition/Bar.m?rev=145756&view=auto ============================================================================== --- lldb/trunk/test/lang/objc/real-definition/Bar.m (added) +++ lldb/trunk/test/lang/objc/real-definition/Bar.m Fri Dec 2 22:35:51 2011 @@ -0,0 +1,43 @@ +#import "Bar.h" + + at interface InternalClass : NSObject { + @public + NSString *foo; + NSString *bar; +} + at end + + at implementation InternalClass + at end + + at interface Bar () +{ + NSString *_hidden_ivar; +} + + at end + + at implementation Bar + +- (id)init +{ + self = [super init]; + if (self) { + _hidden_ivar = [NSString stringWithFormat:@"%p: @Bar", self]; + } + return self; +} + +- (void)dealloc +{ + [_hidden_ivar release]; + [super dealloc]; +} + +- (NSString *)description +{ + return [_hidden_ivar copyWithZone:NULL]; +} + + at end + \ No newline at end of file Added: lldb/trunk/test/lang/objc/real-definition/Foo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/real-definition/Foo.h?rev=145756&view=auto ============================================================================== --- lldb/trunk/test/lang/objc/real-definition/Foo.h (added) +++ lldb/trunk/test/lang/objc/real-definition/Foo.h Fri Dec 2 22:35:51 2011 @@ -0,0 +1,11 @@ +#import + +#import "Bar.h" + + at interface Foo : NSObject { + Bar *_bar; +} + +- (NSString *)description; + + at end \ No newline at end of file Added: lldb/trunk/test/lang/objc/real-definition/Foo.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/real-definition/Foo.m?rev=145756&view=auto ============================================================================== --- lldb/trunk/test/lang/objc/real-definition/Foo.m (added) +++ lldb/trunk/test/lang/objc/real-definition/Foo.m Fri Dec 2 22:35:51 2011 @@ -0,0 +1,25 @@ +#import "Foo.h" + + at implementation Foo + +- (id)init +{ + self = [super init]; + if (self) { + _bar = [[Bar alloc] init]; + } + return self; +} + +- (void)dealloc +{ + [_bar release]; + [super dealloc]; +} + +- (NSString *)description +{ + return [NSString stringWithFormat:@"%p: @Foo { _bar = %@ }", self, _bar]; +} + + at end Added: lldb/trunk/test/lang/objc/real-definition/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/real-definition/Makefile?rev=145756&view=auto ============================================================================== --- lldb/trunk/test/lang/objc/real-definition/Makefile (added) +++ lldb/trunk/test/lang/objc/real-definition/Makefile Fri Dec 2 22:35:51 2011 @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +OBJC_SOURCES := Bar.m Foo.m main.m +LDFLAGS = $(CFLAGS) -lobjc -framework Foundation + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/lang/objc/real-definition/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/real-definition/main.m?rev=145756&view=auto ============================================================================== --- lldb/trunk/test/lang/objc/real-definition/main.m (added) +++ lldb/trunk/test/lang/objc/real-definition/main.m Fri Dec 2 22:35:51 2011 @@ -0,0 +1,13 @@ +#include +#include +#import +#import "Foo.h" + +int main (int argc, char const *argv[]) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + Foo *foo = [[Foo alloc] init]; + NSLog (@"foo is %@", foo); + [pool release]; + return 0; +} From scallanan at apple.com Fri Dec 2 22:38:43 2011 From: scallanan at apple.com (Sean Callanan) Date: Sat, 03 Dec 2011 04:38:43 -0000 Subject: [Lldb-commits] [lldb] r145758 - in /lldb/trunk: include/lldb/Symbol/SymbolFile.h source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Message-ID: <20111203043843.D987B2A6C12C@llvm.org> Author: spyffe Date: Fri Dec 2 22:38:43 2011 New Revision: 145758 URL: http://llvm.org/viewvc/llvm-project?rev=145758&view=rev Log: Testcase fixes with the new symbol lookup code for Objective-C, making symbol lookups for various raw Objective-C symbols work correctly. The IR interpreter makes these lookups because Clang has emitted raw symbol references for ivars and classes. Also improved performance in SymbolFiles, caching the result of asking for SymbolFile abilities. Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=145758&r1=145757&r2=145758&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Fri Dec 2 22:38:43 2011 @@ -48,7 +48,9 @@ // Constructors and Destructors //------------------------------------------------------------------ SymbolFile(ObjectFile* obj_file) : - m_obj_file(obj_file) + m_obj_file(obj_file), + m_abilities(0), + m_calculated_abilities(false) { } @@ -86,7 +88,18 @@ /// enumeration. Any bits that are set represent an ability that /// this symbol plug-in can parse from the object file. ///------------------------------------------------------------------ - virtual uint32_t GetAbilities () = 0; + uint32_t GetAbilities () + { + if (!m_calculated_abilities) + { + m_abilities = CalculateAbilities(); + m_calculated_abilities = true; + } + + return m_abilities; + } + + virtual uint32_t CalculateAbilities() = 0; //------------------------------------------------------------------ /// Initialize the SymbolFile object. @@ -144,7 +157,8 @@ void ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3))); protected: ObjectFile* m_obj_file; // The object file that symbols can be extracted from. - + uint32_t m_abilities; + bool m_calculated_abilities; private: DISALLOW_COPY_AND_ASSIGN (SymbolFile); }; Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=145758&r1=145757&r2=145758&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Dec 2 22:38:43 2011 @@ -1271,19 +1271,19 @@ static const llvm::StringRef g_objc_v2_prefix_ivar ("_OBJC_IVAR_$_"); if (symbol_name_ref.startswith(g_objc_v2_prefix_class)) { - symbol_name_non_abi_mangled = symbol_name; + symbol_name_non_abi_mangled = symbol_name + 1; symbol_name = symbol_name + g_objc_v2_prefix_class.size(); type = eSymbolTypeObjCClass; } else if (symbol_name_ref.startswith(g_objc_v2_prefix_metaclass)) { - symbol_name_non_abi_mangled = symbol_name; + symbol_name_non_abi_mangled = symbol_name + 1; symbol_name = symbol_name + g_objc_v2_prefix_metaclass.size(); type = eSymbolTypeObjCMetaClass; } else if (symbol_name_ref.startswith(g_objc_v2_prefix_ivar)) { - symbol_name_non_abi_mangled = symbol_name; + symbol_name_non_abi_mangled = symbol_name + 1; symbol_name = symbol_name + g_objc_v2_prefix_ivar.size(); type = eSymbolTypeObjCIVar; } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=145758&r1=145757&r2=145758&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Dec 2 22:38:43 2011 @@ -307,7 +307,7 @@ } uint32_t -SymbolFileDWARF::GetAbilities () +SymbolFileDWARF::CalculateAbilities () { uint32_t abilities = 0; if (m_obj_file != NULL) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=145758&r1=145757&r2=145758&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Dec 2 22:38:43 2011 @@ -84,7 +84,7 @@ SymbolFileDWARF(lldb_private::ObjectFile* ofile); virtual ~SymbolFileDWARF(); - virtual uint32_t GetAbilities (); + virtual uint32_t CalculateAbilities (); virtual void InitializeObject(); //------------------------------------------------------------------ Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=145758&r1=145757&r2=145758&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Fri Dec 2 22:38:43 2011 @@ -419,7 +419,7 @@ } uint32_t -SymbolFileDWARFDebugMap::GetAbilities () +SymbolFileDWARFDebugMap::CalculateAbilities () { // In order to get the abilities of this plug-in, we look at the list of // N_OSO entries (object files) from the symbol table and make sure that Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=145758&r1=145757&r2=145758&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Fri Dec 2 22:38:43 2011 @@ -48,7 +48,7 @@ SymbolFileDWARFDebugMap (lldb_private::ObjectFile* ofile); virtual ~ SymbolFileDWARFDebugMap (); - virtual uint32_t GetAbilities (); + virtual uint32_t CalculateAbilities (); virtual void InitializeObject(); Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=145758&r1=145757&r2=145758&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Fri Dec 2 22:38:43 2011 @@ -83,19 +83,11 @@ bool SymbolFileSymtab::HasObjCSymbols () { - if (m_has_objc_symbols == eLazyBoolCalculate) - { - if (m_obj_file->GetSectionList()->FindSectionByName(ConstString("__objc_data"))) - m_has_objc_symbols = eLazyBoolYes; - else - m_has_objc_symbols = eLazyBoolNo; - } - - return m_has_objc_symbols == eLazyBoolYes; + return (m_abilities & RuntimeTypes) != 0; } uint32_t -SymbolFileSymtab::GetAbilities () +SymbolFileSymtab::CalculateAbilities () { uint32_t abilities = 0; if (m_obj_file) @@ -136,8 +128,11 @@ abilities |= GlobalVariables; } - if (HasObjCSymbols()) + symtab->AppendSymbolIndexesWithType(eSymbolTypeObjCClass, m_objc_class_indexes); + + if (!m_objc_class_indexes.empty()) { + symtab->SortSymbolIndexesByValue(m_objc_class_indexes, true); abilities |= RuntimeTypes; } } @@ -403,14 +398,10 @@ types.Insert(iter->second); return 1; } - - std::string symbol_name("OBJC_CLASS_$_"); - symbol_name.append(name.AsCString()); - ConstString symbol_const_string(symbol_name.c_str()); - + std::vector indices; - - if (m_obj_file->GetSymtab()->FindAllSymbolsWithNameAndType(symbol_const_string, lldb::eSymbolTypeRuntime, indices) == 0) + /*const ConstString &name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& symbol_indexes*/ + if (m_obj_file->GetSymtab()->FindAllSymbolsWithNameAndType(name, lldb::eSymbolTypeAny, Symtab::eDebugNo, Symtab::eVisibilityAny, m_objc_class_indexes) == 0) return 0; const bool isForwardDecl = false; Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h?rev=145758&r1=145757&r2=145758&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Fri Dec 2 22:38:43 2011 @@ -42,7 +42,7 @@ virtual ~SymbolFileSymtab(); - virtual uint32_t GetAbilities (); + virtual uint32_t CalculateAbilities (); //------------------------------------------------------------------ // Compile Unit function calls @@ -119,12 +119,14 @@ GetPluginVersion(); protected: - lldb_private::LazyBool m_has_objc_symbols; std::vector m_source_indexes; std::vector m_func_indexes; std::vector m_code_indexes; std::vector m_data_indexes; std::vector m_addr_indexes; // Anything that needs to go into an search by address + std::vector m_objc_class_indexes; + + lldb_private::LazyBool m_has_objc_symbols; typedef std::map TypeMap; From gclayton at apple.com Fri Dec 2 22:40:04 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 03 Dec 2011 04:40:04 -0000 Subject: [Lldb-commits] [lldb] r145759 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: SymbolFileDWARF.cpp SymbolFileDWARF.h SymbolFileDWARFDebugMap.cpp SymbolFileDWARFDebugMap.h Message-ID: <20111203044004.41CA52A6C12C@llvm.org> Author: gclayton Date: Fri Dec 2 22:40:03 2011 New Revision: 145759 URL: http://llvm.org/viewvc/llvm-project?rev=145759&view=rev Log: Added code to make sure we don't recursively try to find an objective C class. The thing with Objective C classes is the debug info might have a definition that isn't just a forward decl, but it is incomplete. So we need to look and see if we can find the complete definition and avoid recursing a lot due to the fact that our accelerator tables will have many versions of the type, but only one complete one. We might not also have the complete type and we need to deal with this correctly. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=145759&r1=145758&r2=145759&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Dec 2 22:40:03 2011 @@ -3770,6 +3770,146 @@ } +Symbol * +SymbolFileDWARF::GetObjCClassSymbol (const ConstString &objc_class_name) +{ + Symbol *objc_class_symbol = NULL; + if (m_obj_file) + { + Symtab *symtab = m_obj_file->GetSymtab(); + if (symtab) + { + objc_class_symbol = symtab->FindFirstSymbolWithNameAndType (objc_class_name, + eSymbolTypeObjCClass, + Symtab::eDebugNo, + Symtab::eVisibilityAny); + } + } + return objc_class_symbol; +} + + +// This function can be used when a DIE is found that is a forward declaration +// DIE and we want to try and find a type that has the complete definition. +TypeSP +SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (DWARFCompileUnit* cu, + const DWARFDebugInfoEntry *die, + const ConstString &type_name) +{ + + TypeSP type_sp; + + if (cu == NULL || die == NULL || !type_name || !GetObjCClassSymbol (type_name)) + return type_sp; + + DIEArray die_offsets; + + if (m_using_apple_tables) + { + if (m_apple_types_ap.get()) + { + const char *name_cstr = type_name.GetCString(); + m_apple_types_ap->FindByName (name_cstr, die_offsets); + } + } + else + { + if (!m_indexed) + Index (); + + m_type_index.Find (type_name, die_offsets); + } + + + const size_t num_matches = die_offsets.size(); + + const dw_tag_t die_tag = die->Tag(); + + DWARFCompileUnit* type_cu = NULL; + const DWARFDebugInfoEntry* type_die = NULL; + if (num_matches) + { + DWARFDebugInfo* debug_info = DebugInfo(); + for (size_t i=0; iGetDIEPtrWithCompileUnitHint (die_offset, &type_cu); + + if (type_die) + { + bool try_resolving_type = false; + + // Don't try and resolve the DIE we are looking for with the DIE itself! + if (type_die != die) + { + const dw_tag_t type_die_tag = type_die->Tag(); + // Make sure the tags match + if (type_die_tag == die_tag) + { + // The tags match, lets try resolving this type + try_resolving_type = true; + } + else + { + // The tags don't match, but we need to watch our for a + // forward declaration for a struct and ("struct foo") + // ends up being a class ("class foo { ... };") or + // vice versa. + switch (type_die_tag) + { + case DW_TAG_class_type: + // We had a "class foo", see if we ended up with a "struct foo { ... };" + try_resolving_type = (die_tag == DW_TAG_structure_type); + break; + case DW_TAG_structure_type: + // We had a "struct foo", see if we ended up with a "class foo { ... };" + try_resolving_type = (die_tag == DW_TAG_class_type); + break; + default: + // Tags don't match, don't event try to resolve + // using this type whose name matches.... + break; + } + } + } + + if (try_resolving_type) + { + try_resolving_type = type_die->GetAttributeValueAsUnsigned (this, type_cu, DW_AT_APPLE_objc_complete_type, 0); + + if (try_resolving_type) + { + Type *resolved_type = ResolveType (type_cu, type_die, false); + if (resolved_type && resolved_type != DIE_IS_BEING_PARSED) + { + DEBUG_PRINTF ("resolved 0x%8.8llx (cu 0x%8.8llx) from %s to 0x%8.8llx (cu 0x%8.8llx)\n", + MakeUserID(die->GetOffset()), + MakeUserID(curr_cu->GetOffset()), + m_obj_file->GetFileSpec().GetFilename().AsCString(), + MakeUserID(type_die->GetOffset()), + MakeUserID(type_cu->GetOffset())); + + m_die_to_type[die] = resolved_type; + type_sp = resolved_type; + break; + } + } + } + } + else + { + if (m_using_apple_tables) + { + ReportError (".apple_types accelerator table had bad die 0x%8.8x for '%s'\n", + die_offset, type_name.GetCString()); + } + } + + } + } + return type_sp; +} + // This function can be used when a DIE is found that is a forward declaration // DIE and we want to try and find a type that has the complete definition. @@ -4203,13 +4343,49 @@ is_forward_declaration = true; } - bool look_for_complete_objc_type = false; if (class_language == eLanguageTypeObjC) { - look_for_complete_objc_type = !is_complete_objc_class; + if (!is_complete_objc_class) + { + // We have a valid eSymbolTypeObjCClass class symbol whose + // name matches the current objective C class that we + // are trying to find and this DIE isn't the complete + // definition (we checked is_complete_objc_class above and + // know it is false), so the real definition is in here somewhere + type_sp = FindCompleteObjCDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str); + + if (!type_sp && m_debug_map_symfile) + { + // We weren't able to find a full declaration in + // this DWARF, see if we have a declaration anywhere + // else... + type_sp = m_debug_map_symfile->FindCompleteObjCDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str); + } + + if (type_sp) + { + if (log) + { + LogMessage (log.get(), + "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is an incomplete objc type, complete type is 0x%8.8llx", + this, + die->GetOffset(), + DW_TAG_value_to_name(tag), + type_name_cstr, + type_sp->GetID()); + } + + // We found a real definition for this type elsewhere + // so lets use it and cache the fact that we found + // a complete type for this die + m_die_to_type[die] = type_sp.get(); + return type_sp; + } + } } + - if (is_forward_declaration || look_for_complete_objc_type) + if (is_forward_declaration) { // We have a forward declaration to a type and we need // to try and find a full declaration. We look in the @@ -4219,12 +4395,11 @@ if (log) { LogMessage (log.get(), - "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is %s, trying to find complete type", + "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a forward declaration, trying to find complete type", this, die->GetOffset(), DW_TAG_value_to_name(tag), - type_name_cstr, - look_for_complete_objc_type ? "an incomplete objective C type" : "a forward declaration"); + type_name_cstr); } type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str); @@ -4242,12 +4417,11 @@ if (log) { LogMessage (log.get(), - "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is %s, complete type is 0x%8.8llx", + "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a forward declaration, complete type is 0x%8.8llx", this, die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr, - look_for_complete_objc_type ? "an incomplete objective C type" : "a forward declaration", type_sp->GetID()); } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=145759&r1=145758&r2=145759&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Dec 2 22:40:03 2011 @@ -372,7 +372,14 @@ DWARFCompileUnit* cu, const DWARFDebugInfoEntry *die, const lldb_private::ConstString &type_name); - + + lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE ( + DWARFCompileUnit* cu, + const DWARFDebugInfoEntry *die, + const lldb_private::ConstString &type_name); + + lldb_private::Symbol * GetObjCClassSymbol (const lldb_private::ConstString &objc_class_name); + void ParseFunctions (const DIEArray &die_offsets, lldb_private::SymbolContextList& sc_list); lldb::TypeSP GetTypeForDIE (DWARFCompileUnit *cu, Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=145759&r1=145758&r2=145759&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Fri Dec 2 22:40:03 2011 @@ -936,11 +936,9 @@ } TypeSP -SymbolFileDWARFDebugMap::FindDefinitionTypeForDIE ( - DWARFCompileUnit* cu, - const DWARFDebugInfoEntry *die, - const ConstString &type_name -) +SymbolFileDWARFDebugMap::FindDefinitionTypeForDIE (DWARFCompileUnit* cu, + const DWARFDebugInfoEntry *die, + const ConstString &type_name) { TypeSP type_sp; SymbolFileDWARF *oso_dwarf; @@ -953,6 +951,23 @@ return type_sp; } + +TypeSP +SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE (DWARFCompileUnit* cu, + const DWARFDebugInfoEntry *die, + const ConstString &type_name) +{ + TypeSP type_sp; + SymbolFileDWARF *oso_dwarf; + for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) + { + type_sp = oso_dwarf->FindCompleteObjCDefinitionTypeForDIE (cu, die, type_name); + if (type_sp) + break; + } + return type_sp; +} + uint32_t SymbolFileDWARFDebugMap::FindTypes ( Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=145759&r1=145758&r2=145759&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Fri Dec 2 22:40:03 2011 @@ -216,6 +216,12 @@ const DWARFDebugInfoEntry *die, const lldb_private::ConstString &type_name); + lldb::TypeSP + FindCompleteObjCDefinitionTypeForDIE (DWARFCompileUnit* cu, + const DWARFDebugInfoEntry *die, + const lldb_private::ConstString &type_name); + + UniqueDWARFASTTypeMap & GetUniqueDWARFASTTypeMap () { From gclayton at apple.com Sat Dec 3 14:02:42 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 03 Dec 2011 20:02:42 -0000 Subject: [Lldb-commits] [lldb] r145777 - in /lldb/trunk: include/lldb/Symbol/Symtab.h source/Expression/IRForTarget.cpp source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h source/Symbol/ClangExternalASTSourceCommon.cpp source/Symbol/Symtab.cpp Message-ID: <20111203200242.D0E232A6C12C@llvm.org> Author: gclayton Date: Sat Dec 3 14:02:42 2011 New Revision: 145777 URL: http://llvm.org/viewvc/llvm-project?rev=145777&view=rev Log: Added the ability for clients to grab a set of symbol table indexes and then add them to a fast lookup map. lldb_private::Symtab now export the following public typedefs: namespace lldb_private { class Symtab { typedef std::vector IndexCollection; typedef UniqueCStringMap NameToIndexMap; }; } Clients can then find symbols by name and or type and end up with a Symtab::IndexCollection that is filled with indexes. These indexes can then be put into a name to index lookup map and control if the mangled and demangled names get added to the map: bool add_demangled = true; bool add_mangled = true; Symtab::NameToIndexMap name_to_index; symtab->AppendSymbolNamesToMap (indexes, add_demangled, add_mangled, name_to_index). This can be repeated as many times as needed to get a lookup table that you are happy with, and then this can be sorted: name_to_index.Sort(); Now name lookups can be done using a subset of the symbols you extracted from the symbol table. This is currently being used to extract objective C types from object files when there is no debug info in SymbolFileSymtab. Cleaned up how the objective C types were being vended to be more efficient and fixed some errors in the regular expression that was being used. Modified: lldb/trunk/include/lldb/Symbol/Symtab.h lldb/trunk/source/Expression/IRForTarget.cpp lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h lldb/trunk/source/Symbol/ClangExternalASTSourceCommon.cpp lldb/trunk/source/Symbol/Symtab.cpp Modified: lldb/trunk/include/lldb/Symbol/Symtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symtab.h?rev=145777&r1=145776&r2=145777&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Symtab.h (original) +++ lldb/trunk/include/lldb/Symbol/Symtab.h Sat Dec 3 14:02:42 2011 @@ -23,17 +23,20 @@ class Symtab { public: - typedef enum Debug { - eDebugNo, // Not a debug symbol - eDebugYes, // A debug symbol - eDebugAny - } Debug; - - typedef enum Visibility { - eVisibilityAny, - eVisibilityExtern, - eVisibilityPrivate - } Visibility; + typedef std::vector IndexCollection; + typedef UniqueCStringMap NameToIndexMap; + + typedef enum Debug { + eDebugNo, // Not a debug symbol + eDebugYes, // A debug symbol + eDebugAny + } Debug; + + typedef enum Visibility { + eVisibilityAny, + eVisibilityExtern, + eVisibilityPrivate + } Visibility; Symtab(ObjectFile *objfile); ~Symtab(); @@ -88,6 +91,12 @@ m_symbols.swap (new_symbols); } } + + void AppendSymbolNamesToMap (const IndexCollection &indexes, + bool add_demangled, + bool add_mangled, + NameToIndexMap &name_to_index_map) const; + protected: typedef std::vector collection; typedef collection::iterator iterator; Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=145777&r1=145776&r2=145777&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Sat Dec 3 14:02:42 2011 @@ -1748,7 +1748,7 @@ StringRef name(initializer->getName()); lldb_private::ConstString name_cstr(name.str().c_str()); - lldb::addr_t class_ptr = m_decl_map->GetSymbolAddress(name_cstr, lldb::eSymbolTypeRuntime); + lldb::addr_t class_ptr = m_decl_map->GetSymbolAddress(name_cstr, lldb::eSymbolTypeObjCClass); if (log) log->Printf("Found reference to Objective-C class %s (0x%llx)", name_cstr.AsCString(), (unsigned long long)class_ptr); Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=145777&r1=145776&r2=145777&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Sat Dec 3 14:02:42 2011 @@ -62,9 +62,7 @@ m_source_indexes(), m_func_indexes(), m_code_indexes(), - m_data_indexes(), - m_addr_indexes(), - m_has_objc_symbols(eLazyBoolCalculate) + m_objc_class_name_to_index () { } @@ -80,12 +78,6 @@ return ast; } -bool -SymbolFileSymtab::HasObjCSymbols () -{ - return (m_abilities & RuntimeTypes) != 0; -} - uint32_t SymbolFileSymtab::CalculateAbilities () { @@ -95,45 +87,43 @@ const Symtab *symtab = m_obj_file->GetSymtab(); if (symtab) { - //---------------------------------------------------------------------- // The snippet of code below will get the indexes the module symbol // table entries that are code, data, or function related (debug info), // sort them by value (address) and dump the sorted symbols. //---------------------------------------------------------------------- - symtab->AppendSymbolIndexesWithType(eSymbolTypeSourceFile, m_source_indexes); - if (!m_source_indexes.empty()) + if (symtab->AppendSymbolIndexesWithType(eSymbolTypeSourceFile, m_source_indexes)) { abilities |= CompileUnits; } - symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugYes, Symtab::eVisibilityAny, m_func_indexes); - if (!m_func_indexes.empty()) + + if (symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugYes, Symtab::eVisibilityAny, m_func_indexes)) { symtab->SortSymbolIndexesByValue(m_func_indexes, true); abilities |= Functions; } - symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, m_code_indexes); - if (!m_code_indexes.empty()) + if (symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, m_code_indexes)) { symtab->SortSymbolIndexesByValue(m_code_indexes, true); abilities |= Labels; } - symtab->AppendSymbolIndexesWithType(eSymbolTypeData, m_data_indexes); - - if (!m_data_indexes.empty()) + if (symtab->AppendSymbolIndexesWithType(eSymbolTypeData, m_data_indexes)) { symtab->SortSymbolIndexesByValue(m_data_indexes, true); abilities |= GlobalVariables; } - symtab->AppendSymbolIndexesWithType(eSymbolTypeObjCClass, m_objc_class_indexes); - - if (!m_objc_class_indexes.empty()) + lldb_private::Symtab::IndexCollection objc_class_indexes; + if (symtab->AppendSymbolIndexesWithType (eSymbolTypeObjCClass, objc_class_indexes)) { - symtab->SortSymbolIndexesByValue(m_objc_class_indexes, true); abilities |= RuntimeTypes; + symtab->AppendSymbolNamesToMap (objc_class_indexes, + true, + true, + m_objc_class_name_to_index); + m_objc_class_name_to_index.Sort(); } } } @@ -384,12 +374,17 @@ } uint32_t -SymbolFileSymtab::FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types) +SymbolFileSymtab::FindTypes (const lldb_private::SymbolContext& sc, + const lldb_private::ConstString &name, + const ClangNamespaceDecl *namespace_decl, + bool append, + uint32_t max_matches, + lldb_private::TypeList& types) { if (!append) types.Clear(); - if (HasObjCSymbols()) + if (!m_objc_class_name_to_index.IsEmpty()) { TypeMap::iterator iter = m_objc_class_types.find(name); @@ -398,47 +393,48 @@ types.Insert(iter->second); return 1; } - - std::vector indices; - /*const ConstString &name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& symbol_indexes*/ - if (m_obj_file->GetSymtab()->FindAllSymbolsWithNameAndType(name, lldb::eSymbolTypeAny, Symtab::eDebugNo, Symtab::eVisibilityAny, m_objc_class_indexes) == 0) - return 0; + const Symtab::NameToIndexMap::Entry *match = m_objc_class_name_to_index.FindFirstValueForName(name.GetCString()); + + if (match == NULL) + return 0; + const bool isForwardDecl = false; const bool isInternal = true; - ClangASTContext &clang_ast_ctx = GetClangASTContext(); - - lldb::clang_type_t objc_object_type = clang_ast_ctx.CreateObjCClass(name.AsCString(), clang_ast_ctx.GetTranslationUnitDecl(), isForwardDecl, isInternal); - - const char *class_method_prefix = "^\\+\\["; - const char *instance_method_prefix = "^\\-\\["; - const char *method_suffix = " [a-zA-Z0-9:]+\\]$"; - - std::string class_method_regexp_str(class_method_prefix); - class_method_regexp_str.append(name.AsCString()); - class_method_regexp_str.append(method_suffix); + ClangASTContext &ast = GetClangASTContext(); - RegularExpression class_method_regexp(class_method_regexp_str.c_str()); + lldb::clang_type_t objc_object_type = ast.CreateObjCClass (name.AsCString(), + ast.GetTranslationUnitDecl(), + isForwardDecl, + isInternal); + + ast.StartTagDeclarationDefinition (objc_object_type); + + std::string regex_str("^[-+]\\["); // Make sure it starts with "+[" or "-[" + regex_str.append(name.AsCString()); // Followed by the class name + regex_str.append("[ \\(]"); // Followed by a space or '(' (for a category) + RegularExpression regex(regex_str.c_str()); - indices.clear(); + Symtab::IndexCollection indices; - lldb::clang_type_t unknown_type = clang_ast_ctx.GetUnknownAnyType(); + lldb::clang_type_t unknown_type = ast.GetUnknownAnyType(); std::vector arg_types; - if (m_obj_file->GetSymtab()->FindAllSymbolsMatchingRexExAndType(class_method_regexp, eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, indices) != 0) + if (m_obj_file->GetSymtab()->FindAllSymbolsMatchingRexExAndType (regex, eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, indices) != 0) { - for (std::vector::iterator ii = indices.begin(), ie = indices.end(); - ii != ie; - ++ii) + for (Symtab::IndexCollection::iterator pos = indices.begin(), end = indices.end(); + pos != end; + ++pos) { - Symbol *symbol = m_obj_file->GetSymtab()->SymbolAtIndex(*ii); + Symbol *symbol = m_obj_file->GetSymtab()->SymbolAtIndex(*pos); if (!symbol) continue; const char *signature = symbol->GetName().AsCString(); + //printf ("%s: adding '%s'\n", name.GetCString(), signature); int num_args = CountMethodArgs(signature); while (arg_types.size() < num_args) @@ -447,55 +443,29 @@ bool is_variadic = false; unsigned type_quals = 0; - lldb::clang_type_t method_type = clang_ast_ctx.CreateFunctionType(unknown_type, arg_types.data(), num_args, is_variadic, type_quals); - - clang_ast_ctx.AddMethodToObjCObjectType(objc_object_type, signature, method_type, eAccessPublic); - } - } - - std::string instance_method_regexp_str(instance_method_prefix); - instance_method_regexp_str.append(name.AsCString()); - instance_method_regexp_str.append(method_suffix); - - RegularExpression instance_method_regexp(instance_method_regexp_str.c_str()); - - indices.clear(); - - if (m_obj_file->GetSymtab()->FindAllSymbolsMatchingRexExAndType(instance_method_regexp, eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, indices) != 0) - { - for (std::vector::iterator ii = indices.begin(), ie = indices.end(); - ii != ie; - ++ii) - { - Symbol *symbol = m_obj_file->GetSymtab()->SymbolAtIndex(*ii); - - if (!symbol) - continue; - - const char *signature = symbol->GetName().AsCString(); - - int num_args = CountMethodArgs(signature); - - while (arg_types.size() < num_args) - arg_types.push_back(unknown_type); - - bool is_variadic = false; - unsigned type_quals = 0; - - lldb::clang_type_t method_type = clang_ast_ctx.CreateFunctionType(unknown_type, arg_types.data(), num_args, is_variadic, type_quals); - - clang_ast_ctx.AddMethodToObjCObjectType(objc_object_type, signature, method_type, eAccessPublic); + lldb::clang_type_t method_type = ast.CreateFunctionType (unknown_type, + arg_types.data(), + num_args, + is_variadic, + type_quals); + + ast.AddMethodToObjCObjectType (objc_object_type, + signature, + method_type, + eAccessPublic); } } + ast.CompleteTagDeclarationDefinition (objc_object_type); + Declaration decl; lldb::TypeSP type(new Type (indices[0], this, name, - 0 /*byte_size*/, - NULL /*SymbolContextScope*/, - 0 /*encoding_uid*/, + 0, // byte_size + NULL, // SymbolContextScope* + 0, // encoding_uid Type::eEncodingInvalid, decl, objc_object_type, Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h?rev=145777&r1=145776&r2=145777&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Sat Dec 3 14:02:42 2011 @@ -11,6 +11,7 @@ #define liblldb_SymbolFileSymtab_h_ #include "lldb/Symbol/SymbolFile.h" +#include "lldb/Symbol/Symtab.h" #include class SymbolFileSymtab : public lldb_private::SymbolFile @@ -119,22 +120,15 @@ GetPluginVersion(); protected: - std::vector m_source_indexes; - std::vector m_func_indexes; - std::vector m_code_indexes; - std::vector m_data_indexes; - std::vector m_addr_indexes; // Anything that needs to go into an search by address - std::vector m_objc_class_indexes; - - lldb_private::LazyBool m_has_objc_symbols; - typedef std::map TypeMap; - - TypeMap m_objc_class_types; - bool - HasObjCSymbols (); - + lldb_private::Symtab::IndexCollection m_source_indexes; + lldb_private::Symtab::IndexCollection m_func_indexes; + lldb_private::Symtab::IndexCollection m_code_indexes; + lldb_private::Symtab::IndexCollection m_data_indexes; + lldb_private::Symtab::NameToIndexMap m_objc_class_name_to_index; + TypeMap m_objc_class_types; + lldb_private::ClangASTContext & GetClangASTContext (); Modified: lldb/trunk/source/Symbol/ClangExternalASTSourceCommon.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangExternalASTSourceCommon.cpp?rev=145777&r1=145776&r2=145777&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangExternalASTSourceCommon.cpp (original) +++ lldb/trunk/source/Symbol/ClangExternalASTSourceCommon.cpp Sat Dec 3 14:02:42 2011 @@ -37,4 +37,4 @@ assert (m_magic == ClangExternalASTSourceCommon_MAGIC); return m_metadata.find(object) != m_metadata.end(); -} \ No newline at end of file +} Modified: lldb/trunk/source/Symbol/Symtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=145777&r1=145776&r2=145777&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symtab.cpp (original) +++ lldb/trunk/source/Symbol/Symtab.cpp Sat Dec 3 14:02:42 2011 @@ -262,9 +262,6 @@ Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); // Create the name index vector to be able to quickly search by name const size_t count = m_symbols.size(); - assert(m_objfile != NULL); - assert(m_objfile->GetModule() != NULL); - #if 1 m_name_to_index.Reserve (count); #else @@ -287,7 +284,7 @@ m_name_to_index.Reserve (actual_count); #endif - UniqueCStringMap::Entry entry; + NameToIndexMap::Entry entry; for (entry.value = 0; entry.value < count; ++entry.value) { @@ -328,6 +325,44 @@ } } +void +Symtab::AppendSymbolNamesToMap (const IndexCollection &indexes, + bool add_demangled, + bool add_mangled, + NameToIndexMap &name_to_index_map) const +{ + if (add_demangled || add_mangled) + { + Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); + Mutex::Locker locker (m_mutex); + + // Create the name index vector to be able to quickly search by name + NameToIndexMap::Entry entry; + const size_t num_indexes = indexes.size(); + for (size_t i=0; iGetMangled(); + if (add_demangled) + { + entry.cstring = mangled.GetDemangledName().GetCString(); + if (entry.cstring && entry.cstring[0]) + name_to_index_map.Append (entry); + } + + if (add_mangled) + { + entry.cstring = mangled.GetMangledName().GetCString(); + if (entry.cstring && entry.cstring[0]) + name_to_index_map.Append (entry); + } + } + } +} + uint32_t Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, std::vector& indexes, uint32_t start_idx, uint32_t end_index) const {