[lldb-dev] Question for debugging a forked program and reload symbol

Yin Ma yin at affinic.com
Tue Nov 19 17:08:32 PST 2013


Hi Jim,

I would like to file a bug. Our Affinic Debugger GUI depends
An output to reload message to update source code windows. Without
A hint, our users have to refresh source manually.

Thanks,

Yin

-----Original Message-----
From: jingham at apple.com [mailto:jingham at apple.com] 
Sent: Tuesday, November 19, 2013 4:59 PM
To: Yin Ma
Cc: lldb-dev at cs.uiuc.edu
Subject: Re: [lldb-dev] Question for debugging a forked program and reload symbol

Yin,

Sorry if I was confusing.  Even on the Mavericks lldb we don't put up a message for reloading, we just do the right thing...  

What I was saying was I won't guarantee that we did the reloading itself correctly on that older lldb, thought I am pretty sure we do.  I just don't have a copy around to test.

If we think we should have a reloading message, somebody should file a bug or just implement it.

Jim

On Nov 19, 2013, at 4:16 PM, Yin Ma <yin at affinic.com> wrote:

> Hi Jim,
> 
> Thank you for the quick reply. 
> I am try lldb on Maverick to see if any message for 
> Reloading.
> 
> Thanks,
> 
> Yin 
> 
> -----Original Message-----
> From: jingham at apple.com [mailto:jingham at apple.com] 
> Sent: Tuesday, November 19, 2013 3:42 PM
> To: Yin Ma
> Cc: lldb-dev at cs.uiuc.edu
> Subject: Re: [lldb-dev] Question for debugging a forked program and reload symbol
> 
> 
> On Nov 19, 2013, at 2:49 PM, Yin Ma <yin at affinic.com> wrote:
> 
>> Hi
>> 
>> I have a very simple program
>> 
>> #include <stdio.h>
>> int num = 0;
>> int main(int argc, char*argv[]){
>>    int pid;
>>        int num;
>>    pid = fork();
>>    printf("%d", pid);
>>    if(pid == 0){       /*child*/
>>        num = 1;
>>    }else if(pid > 0){  /*parent*/
>>        num = 2;
>>    }
>>    printf("%d", num);
>>        while(num) {
>>                num ++;
>>        }
>> 
>>        return num;
>> }
>> 
>> I break at num = 1;
>> B g.c:9
>> 
>> And I run
>> The program never hits the breakpoint.
>> And the output from the program is
>> 4862
>> 2
>> 0
>> 
>> However, if I run in terminal
>> The output is
>> 4813
>> 2
>> 0
>> 1
>> 
>> It looks like the forked portion is not available in lldb.
>> What’s going on here?
> 
> Since fork copies the address space of the parent, the breakpoint trap we put in goes along for the ride, and when the child gets running it hits it.  lldb doesn't follow forks at present, so it doesn't know to catch the child's breakpoint hit, and so the child will just die. That's why you didn't see its output.
> 
>> 
>> Another question:
>> If I am debugging an executable, after I modified the source
>> And re-compile the executable, the next time when I run
>> Under debugger, gdb will show reload symbol. I didn’t see
>> The same thing for lldb or any output about updating. Do
>> I have to reload the executable every time I modify it?
> 
> lldb just reloads the executable if it changes.  We don't print a message saying we did this.  Maybe we ought to, just to reassure folks we did the right thing?
> 
>> 
>> I am using Moutain Lion, lldb-179.5
> 
> That's a pretty old lldb, but I'm pretty sure we've done this correctly for quite some time.
> 
> Jim=
> 





More information about the lldb-dev mailing list