I broke down and bought the 2nd edition, but it will not be here for a while; have had the 1st for a while. One of the things I saw in Chapter 2 page 14 was a long listing for debug AGoodStart. After this, there is a statement that as of the writing that Apple was working on a new debugger, LLDB to replace the GDB debugger. I have Xcode 8.3 and don’t know if there is another debugger newer than the LLDB out now.
What I am having an issue is, is in finding the new debugger log; if one is indeed generated. All that I can see is a repeat of the bottom debugger section when I select the current debug log.
Therefore is there a way to see a log generated by LLDB, or did that go away with GDB? Perhaps the 2nd edition says something about this.
Thank you
I am very happy to see that you are learning Objective-C.
To see some logs generated by lldb, build run the following code, after putting breakpoints on the two statements in the objectiveC function:
// main.m
#import <Foundation/Foundation.h>
static long objectiveC ();
int main (int argc, const char * argv[])
{
objectiveC ();
return 0;
}
static long objectiveC () {
NSLog (@"Objective-C matters...\n");
return 0;
}
Note the version command to the lldb on the second line.
Thank you for your reply. I copied and pasted your code into a new project, but I got this error after I pasted:
#import <Foundation/Foundation.h> !Could not build module ‘Foundation’
and have not tried to build/run it yet
Rats! It’s early here. It just sunk in that I was to build an objective C project. At this point in the book, it’s all C rather than Objective-C.
I did see that just inserting a breakpoint does pull up some log information on my initial C project and after realizing that I needed to create an Objective C project, I got a report but it looks very different from you posted:
objLog`objectiveC:
0x100000f60 <+0>: pushq %rbp
0x100000f61 <+1>: movq %rsp, %rbp
0x100000f64 <+4>: leaq 0xad(%rip), %rax ; @“Objective-C matters…\n”
-> 0x100000f6b <+11>: movq %rax, %rdi
0x100000f6e <+14>: movb $0x0, %al
0x100000f70 <+16>: callq 0x100000f7c ; symbol stub for: NSLog
0x100000f75 <+21>: xorl %ecx, %ecx
0x100000f77 <+23>: movl %ecx, %eax
0x100000f79 <+25>: popq %rbp
0x100000f7a <+26>: retq
Alas, I don’t know how to include screen shots to show you what I did or did not do.
Oh, and I finally did see this:
2017-11-05 07:34:12.760629-0600 ObjectiveCMatters[1957:434722] Objective-C matters…
(lldb)
If I were you I would not worry about debugging the code with the debugger at this stage. I would just use print statements for that purpose, to find out what is going on or what’s not going on.
void jibber ();
int main () {
jibber ();
return 0;
}
void jabber ();
void jibber () {
NSLog (@"%s...", __func__);
...
jabber ();
...
}
void jabber () {
NSLog (@"%s...", __func__);
...
}