[swift-users] بخصوص: About Swift Package Manager and LLDB

Michael Gottesman mgottesman at apple.com
Tue Nov 7 12:19:55 CST 2017


Hey Fadi, do you think you can thread this email thread a little better? Right now (for whatever reason) a bunch of your emails are getting new threads in mail. It would be a lot easier to track/respond to the email if you always responded in the same mail thread.

[Just friendly advice = )]

Michael

> On Nov 7, 2017, at 8:10 AM, ⁨‫Fadi Botros‬ ‫⁩ <⁨botros_fadi at yahoo.com⁩> wrote:
> 
> Some information may be leading to resolve of this problem
> 
> I think "ld" tool does a lot of the trick
> 
> Notice the difference between the results of the two compilations (Xcode and SPM):
> 
> Kitura example via Xcode, when invoked "target modules list" on lldb
> 
> Gets this
> [ 0] 788D7481-3E7E-3B4D-805E-A18937409552 0x0000000100000000 /Users/mac/Documen - Pastebin.com <https://pastebin.com/vWQEF760>
> 
> 
> [ 0] 788D7481-3E7E-3B4D-805E-A18937409552 0x0000000100000000 /Users/mac/Do...
>  <https://pastebin.com/vWQEF760>
> 
>  When invoked on the compiled via SPM it results in :
> [ 0] ED5DAA33-8E50-3EE9-8487-1C5931520130 0x0000000100000000 /Users/mac/Documen - Pastebin.com <https://pastebin.com/6LERECUk>
> 
> 
> [ 0] ED5DAA33-8E50-3EE9-8487-1C5931520130 0x0000000100000000 /Users/mac/Do...
>  <https://pastebin.com/6LERECUk>
> 
> 
> 
> It seems the modules are compiled and linked SEPARATELY in Xcode, and this succeed in debugging
> But in SPM, all are compiled as one module (it may have submodules)
> 
> I think if you provide something compiles to dynamic link libraries on Linux (and SPM in general) like frameworks on macOS, it will solve the problem
> 
> 
> 
> Pastebin.com - #1 paste tool since 2002!
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for ...
>  <https://pastebin.com/>
> 
> 
> 
> 
> من: Jim Ingham <jingham at apple.com>
> إلى: ‫Fadi Botros‬ ‫ <botros_fadi at yahoo.com> 
> نسخة كربونية: Michael Gottesman <mgottesman at apple.com>; "swift-users at swift.org" <swift-users at swift.org>
> تاريخ الإرسال: الثلاثاء 7 نوفمبر، 2017‏ 2:29 ص
> الموضوع: Re: [swift-users] About Swift Package Manager and LLDB
> 
> It does look like this is a known bug (not yet fixed) in SPM:
> 
> https://bugs.swift.org/browse/SR-3280 <https://bugs.swift.org/browse/SR-3280>
> 
> The bug isn’t fixed yet (apparently it’s blocked on a swift compiler issue.)  There’s a workaround in that report, though I don’t know how viable it is.  Anyway, you can track that bug to see when this gets fixed.
> 
> Jim
> 
>> On Nov 6, 2017, at 3:45 PM, ⁨‫Fadi Botros‬ ‫⁩ <⁨botros_fadi at yahoo.com <mailto:botros_fadi at yahoo.com>⁩> wrote:
>> 
>> 
>> I don't think Perfect has problems because it debugs perfectly on Xcode
>> Kitura may have some flaws because on Xcode also causes some issues BUT YOU STILL CAN GET FRAME, ETC.. WHILE NOT HAVING THOSE IN SPM
>> 
>> The problem is in SPM
>> Just make the SPM build Swift Packages like Xcode (or equivalent)
>> 
>> من: Jim Ingham <jingham at apple.com <mailto:jingham at apple.com>>
>> إلى: ‫Fadi Botros‬ ‫ <botros_fadi at yahoo.com <mailto:botros_fadi at yahoo.com>> 
>> نسخة كربونية: Michael Gottesman <mgottesman at apple.com <mailto:mgottesman at apple.com>>; "swift-users at swift.org <mailto:swift-users at swift.org>" <swift-users at swift.org <mailto:swift-users at swift.org>>
>> تاريخ الإرسال: الثلاثاء 7 نوفمبر، 2017‏ 1:39 ص
>> الموضوع: Re: بخصوص: بخصوص: [swift-users] About Swift Package Manager and LLDB
>> 
>> It isn’t quite as mysterious as that.  lldb emulates the context of the frame you are stopped in when you run “frame variable” or “expression”.  It looks like PerfectTemplate doesn’t have a problem, and doesn’t rely on modules that we can’t reconstruct.  But some of the other modules do have problems.  For instance, if I let the program come up, interrupt it and switch to a frame in the PerfectHTTPServer, then I see:
>> 
>> (lldb) expr let $mystr = "Some string"
>> error: in auto-import:
>> failed to get module 'PerfectHTTPServer' from AST context:
>> error: missing required modules: 'PerfectCHTTPParser', 'PerfectCZlib'
>> 
>> 
>> But that’s not the only one with problems, and I’m still not getting any useful error messages back from swift.  I’ll have to dig into this more.
>> 
>> Jim
>> 
>> 
>> 
>>> On Nov 6, 2017, at 2:38 PM, ⁨‫Fadi Botros‬ ‫⁩ <⁨botros_fadi at yahoo.com <mailto:botros_fadi at yahoo.com>⁩> wrote:
>>> 
>>> WEIRD WEIRD WEIRD
>>> It seems it is threading issue
>>> Because when I tried to breakpoint on line 71 file main.swift (like you did)
>>> It worked perfectly
>>> I even could "frame variable" fully
>>> 
>>> It seems that perfect framework when handle an HTTP request, it makes something in threads, I don't know how to debug it
>>> 
>>> Try to debug on line 31 then invoke an HTTP request on localhost:8181, you will reproduce the error
>>> 
>>> But it works when I use xcode (Again this is irreleveant, this is not the solution)
>>> 
>>> 
>>> من: Jim Ingham <jingham at apple.com <mailto:jingham at apple.com>>
>>> إلى: ‫Fadi Botros‬ ‫ <botros_fadi at yahoo.com <mailto:botros_fadi at yahoo.com>> 
>>> نسخة كربونية: Michael Gottesman <mgottesman at apple.com <mailto:mgottesman at apple.com>>; "swift-users at swift.org <mailto:swift-users at swift.org>" <swift-users at swift.org <mailto:swift-users at swift.org>>
>>> تاريخ الإرسال: الثلاثاء 7 نوفمبر، 2017‏ 12:21 ص
>>> الموضوع: Re: بخصوص: [swift-users] About Swift Package Manager and LLDB
>>> 
>>> This works for me (with Xcode 9.0):
>>> 
>>>  > git clone https://github.com/PerfectlySoft/PerfectTemplate.git <https://github.com/PerfectlySoft/PerfectTemplate.git> PT
>>> Cloning into 'PT'...
>>> remote: Counting objects: 214, done.
>>> remote: Total 214 (delta 0), reused 0 (delta 0), pack-reused 214
>>> Receiving objects: 100% (214/214), 48.65 KiB | 0 bytes/s, done.
>>> Resolving deltas: 100% (110/110), done.
>>>  > cd PT
>>>  > swift build
>>> <lots of output>
>>>  > cd .build/debug
>>>  > lldb PerfectTemplate
>>> (lldb) target create "PerfectTemplate"
>>> Current executable set to 'PerfectTemplate' (x86_64).
>>> (lldb) b s -l 71
>>> Breakpoint 1: where = PerfectTemplate`main + 2627 at main.swift:71, address = 0x0000000100436c33
>>> (lldb) run
>>> Process 26948 launched: '/private/tmp/PT/.build/x86_64-apple-macosx10.10/debug/PerfectTemplate' (x86_64)
>>> Process 26948 stopped
>>> * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
>>>     frame #0: 0x0000000100436c33 PerfectTemplate`main at main.swift:71
>>>    68  	
>>>    69  	do {
>>>    70  		// Launch the servers based on the configuration data.
>>> -> 71  		try HTTPServer.launch(configurationData: confData)
>>>     		    ^
>>>    72  	} catch {
>>>    73  		fatalError("\(error)") // fatal error launching one of the servers
>>>    74  	}
>>> Target 0: (PerfectTemplate) stopped.
>>> (lldb) expr confData.count
>>> (Int) $R1 = 1
>>> 
>>> Do the same steps not work for you?  If you were doing something different can you describe the steps you took?
>>> 
>>> Jim
>>> 
>>>> On Nov 6, 2017, at 2:10 PM, ⁨‫Fadi Botros‬ ‫⁩ <⁨botros_fadi at yahoo.com <mailto:botros_fadi at yahoo.com>⁩> wrote:
>>>> 
>>>> Also please noted
>>>> I think it is a SPM issue not an LLDB one
>>>> Because when compiled on the same mac with Xcode (Swift package manager generate Xcode project), then use xcode-build
>>>> LLDB works perfectly in this circumstances
>>>> 
>>>> I think you should refine the compilation script generated by SPM to generate something like Xcode results (I think Xcode itself uses normal Swift toolchain, I think it does nothing here more than generating a better compilation/linking script)
>>>> 
>>>> 
>>>> من: Jim Ingham <jingham at apple.com <mailto:jingham at apple.com>>
>>>> إلى: ‫Fadi Botros‬ ‫ <botros_fadi at yahoo.com <mailto:botros_fadi at yahoo.com>> 
>>>> نسخة كربونية: Michael Gottesman <mgottesman at apple.com <mailto:mgottesman at apple.com>>; "swift-users at swift.org <mailto:swift-users at swift.org>" <swift-users at swift.org <mailto:swift-users at swift.org>>
>>>> تاريخ الإرسال: الإثنين 6 نوفمبر، 2017‏ 11:45 م
>>>> الموضوع: Re: [swift-users] About Swift Package Manager and LLDB
>>>> 
>>>> Swift doesn’t seem to be reporting whatever the error is, I just see:
>>>> 
>>>> ((SwiftASTContext*)0x7f8c555c84a0)->GetModule('PerfectTemplate') -- failed with no error
>>>> 
>>>> That’s not very helpful.  Again, I’ll probably need to make this happen locally to see what went wrong.  If you have a project that shows the issue which you can make available, please file a bug with a description of how you build and debug this app, I’ll take a look.
>>>> 
>>>> Jim
>>>> 
>>>> 
>>>>> On Nov 6, 2017, at 12:56 PM, ⁨‫Fadi Botros‬ ‫⁩ <⁨botros_fadi at yahoo.com <mailto:botros_fadi at yahoo.com>⁩> wrote:
>>>>> 
>>>>> OK
>>>>> Here is when captured "print self" log from the beginning
>>>>> 
>>>>> Attached here is the full log file
>>>>> See the attachments
>>>>> من: Jim Ingham <jingham at apple.com <mailto:jingham at apple.com>>
>>>>> إلى: ‫Fadi Botros‬ ‫ <botros_fadi at yahoo.com <mailto:botros_fadi at yahoo.com>> 
>>>>> نسخة كربونية: Michael Gottesman <mgottesman at apple.com <mailto:mgottesman at apple.com>>; "swift-users at swift.org <mailto:swift-users at swift.org>" <swift-users at swift.org <mailto:swift-users at swift.org>>
>>>>> تاريخ الإرسال: الإثنين 6 نوفمبر، 2017‏ 10:15 م
>>>>> الموضوع: Re: [swift-users] About Swift Package Manager and LLDB
>>>>> 
>>>>> The log for “print self” was unfortunately captured too late.  Reading in the PerfectTemplate module had already failed, and so any subsequent attempt will just report it as failed.  To get the complete error log for this, you need to put:
>>>>> 
>>>>> log enable -f /tmp/lldb-type-log.txt lldb types
>>>>> 
>>>>> in your ~/.lldbinit file and then start a fresh debugging session and capture the whole session.
>>>>> 
>>>>> The failure from the REPL  is because you have to tell the REPL where to look for other frameworks from which it might load modules.  You can pass appropriate -I, -L and -F flags to the “swift” invocation too tell the compiler lldb’s using to implement the REPL where to look for this module.
>>>>> 
>>>>> The example you gave seems to be a MacOS X example.  The binary type was MachO etc.  If this is just a small example that you are using to demonstrate the problem, can you file a PR with the swift bug reporter with this example and how you built/ran it and we can take a look here.  That’s probably easier than trying to pass logs back and forth.
>>>>> 
>>>>> Jim
>>>>> 
>>>>>> On Nov 6, 2017, at 11:27 AM, ⁨‫Fadi Botros‬ ‫ via swift-users⁩ <⁨swift-users at swift.org <mailto:swift-users at swift.org>⁩> wrote:
>>>>>> 
>>>>>> This happens when try to print(self)
>>>>>> Processing command: po print(self) HandleCommand, cmd_obj : 'expression' Handl - Pastebin.com <https://pastebin.com/15b52C1x>
>>>>>> 
>>>>>> 
>>>>>> Processing command: po print(self) HandleCommand, cmd_obj : 'expressio...
>>>>>>  <https://pastebin.com/15b52C1x>
>>>>>> 
>>>>>> 
>>>>>> This happens when REPL then try to "import PerfectTemplate"
>>>>>> == [UserExpression::Evaluate] Parsing expression import PerfectTemplate == Swif - Pastebin.com <https://pastebin.com/FsGgXa54>
>>>>>> 
>>>>>> 
>>>>>> == [UserExpression::Evaluate] Parsing expression import PerfectTemplate == ...
>>>>>>  <https://pastebin.com/FsGgXa54>
>>>>>> 
>>>>>> 
>>>>>> Also the same problem happens in Kitura (even if only use packages that depend on Swift 4)
>>>>>> 
>>>>>> من: Michael Gottesman <mgottesman at apple.com <mailto:mgottesman at apple.com>>
>>>>>> إلى: Michael Gottesman <mgottesman at apple.com <mailto:mgottesman at apple.com>> 
>>>>>> نسخة كربونية: "swift-users at swift.org <mailto:swift-users at swift.org>" <swift-users at swift.org <mailto:swift-users at swift.org>>; ‫Fadi Botros‬ ‫ <botros_fadi at yahoo.com <mailto:botros_fadi at yahoo.com>>
>>>>>> تاريخ الإرسال: الإثنين 6 نوفمبر، 2017‏ 7:01 م
>>>>>> الموضوع: Re: [swift-users] About Swift Package Manager and LLDB
>>>>>> 
>>>>>> Or actually:
>>>>>> 
>>>>>> https://github.com/apple/swift/blob/master/docs/DebuggingTheCompiler.rst#debugging-failures-in-lldb <https://github.com/apple/swift/blob/master/docs/DebuggingTheCompiler.rst#debugging-failures-in-lldb>
>>>>>> 
>>>>>> I would just enable all of the logging and post it here or if the log is very big put the log into a pastebin.
>>>>>> 
>>>>>>> On Nov 6, 2017, at 8:59 AM, Michael Gottesman via swift-users <swift-users at swift.org <mailto:swift-users at swift.org>> wrote:
>>>>>>> 
>>>>>> 
>>>>>> I am not going to answer this fully (I forwarded it to the appropriate people though). But to help them out, can you go to ./docs/DebuggingTheCompiler and enable lldb logging and post the output here?
>>>>>> 
>>>>>> Michael
>>>>>> 
>>>>>>> On Nov 6, 2017, at 8:43 AM, ⁨‫Fadi Botros‬ ‫ via swift-users⁩ <⁨swift-users at swift.org <mailto:swift-users at swift.org>⁩> wrote:
>>>>>>> 
>>>>>>> I'm interested in doing Web Application using Swift and promoting this to be a trend someday.
>>>>>>> But I couldn't find a way to debug web apps without using Xcode
>>>>>>> This is irrelevant because web applications are mainly on Linux, so what if we want to do remote debugging ?
>>>>>>> 
>>>>>>> I tried using the SPM, and when I try to compile a Kitura or Perfect app then try to debug it, it gives me this
>>>>>>> 
>>>>>>> (lldb) po print(self)
>>>>>>> warning: Swift error in module <moduleName>.
>>>>>>> Debug info from this module will be unavailable in the debugger.
>>>>>>> 
>>>>>>> error: in auto-import:
>>>>>>> failed to get module '<SomeModuleName>' from AST context
>>>>>>> 
>>>>>>> I'm using macOS Sierra (sorry didn't have time to upgrade), with Swift 4 that comes with Xcode 9
>>>>>>> Also tried the same experiment on Xubuntu using Swift 4 debian package provided on swift.org <http://swift.org/> itself
>>>>>>> 
>>>>>>> The only succeeded way is to generate an xcodeproj and compile it, this is irrelevant because it is only macOS, while servers are Linux.
>>>>>>> _______________________________________________
>>>>>>> swift-users mailing list
>>>>>>> swift-users at swift.org <mailto:swift-users at swift.org>
>>>>>>> https://lists.swift.org/mailman/listinfo/swift-users <https://lists.swift.org/mailman/listinfo/swift-users>
>>>>>> 
>>>>>> _______________________________________________
>>>>>> swift-users mailing list
>>>>>> swift-users at swift.org <mailto:swift-users at swift.org>
>>>>>> https://lists.swift.org/mailman/listinfo/swift-users <https://lists.swift.org/mailman/listinfo/swift-users>
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> _______________________________________________
>>>>>> swift-users mailing list
>>>>>> swift-users at swift.org <mailto:swift-users at swift.org>
>>>>>> https://lists.swift.org/mailman/listinfo/swift-users <https://lists.swift.org/mailman/listinfo/swift-users>
>>>>> 
>>>>> 
>>>>> 
>>>>> <lldb-type-log.txt>
>>>> 
>>>> 
>>>> 
>>> 
>>> 
>>> 
>> 
>> 
>> 
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20171107/92d8d692/attachment.html>


More information about the swift-users mailing list