[lldb-dev] Using LLDB C++ API for automated debugging sessions
Jayvee Neumann via lldb-dev
lldb-dev at lists.llvm.org
Thu Jul 18 22:15:29 PDT 2019
Thank you Jim and Greg, for your help. I will be careful with threads and I
will also switch to using launch info.
Kind regards
Jayvee
Am Do., 18. Juli 2019 um 19:19 Uhr schrieb Jim Ingham <jingham at apple.com>:
> The main problem with trying to run a debug session multithreaded is
> coordinating execution control. Thread A gets a variable list and iterates
> over it to get child values. Thread B issues a "step" command. The API's
> thread A calls will either fail (because the target is running) or maybe
> fetch data that is now one step too new for some of the calls, if the step
> completed quickly. LLDB doesn't have any built-in mechanism for a thread
> to start a session which locks out other threads from running the target.
> So if you want to do your work on multiple threads you'll need to add
> something like that. And as Greg says, for many purposes you will need to
> have a cancellation mechanism as well, since people often want to "step
> really quickly" and don't want to wait for fresh values of the local
> variables to be fetched before the next step can start.
>
> Jim
>
>
> > On Jul 18, 2019, at 4:00 AM, Jayvee Neumann via lldb-dev <
> lldb-dev at lists.llvm.org> wrote:
> >
> > Thank you for your help.
> >
> > What is the reason for using SBLaunchInfo over calling tgt.Launch with
> the launch configuration as a set of parameters? Furthermore I do not see a
> way to set stdout, stdin, and stderr for the launched process by using
> SBLaunchInfo.
> >
> > I have a question regarding the event loop.
> > Is lldb thread-safe enough such that I can run that loop in another
> std::thread while simultaneously using other debugger functions?
> >
> > Kind regards,
> > Jayvee
> >
> > Am Fr., 12. Juli 2019 um 19:56 Uhr schrieb Greg Clayton <
> clayborg at gmail.com>:
> > You need to call SBDebugger::Initialize() before calling
> SBDebugger::Create().
> >
> > Also, please use the SBLaunchInfo method for launching if possible where
> you create a SBLaunchInfo, then call tgt.Launch() with the instance.
> >
> > Other than that, as Jim said, you need to setup an event loop if you
> don't use synchronous mode where you wait for events and respond to events.
> >
> > Greg
> >
> >> On Jun 26, 2019, at 4:58 AM, Jayvee Neumann via lldb-dev <
> lldb-dev at lists.llvm.org> wrote:
> >>
> >> Dear LLDB developers,
> >>
> >> I am currently stuck while using the C++ API of LLDB. I am unable to
> correctly launch a process.
> >> The code I have written looks as follows:
> >>
> >> int main(int argc, char *argv[]){
> >> LLDBSentry senty;
> >> SBDebugger dbg(SBDebugger::Create());
> >> ...
> >> const char *exeFilePath = "./target";
> >> const char *arch = "x86_64";
> >> const char *platform = "";
> >> const char *dependentLibs = "";
> >> SBError error;
> >> SBTarget tgt = dbg.CreateTarget(exeFilePath, arch, platform,
> dependentLibs, error);
> >> ...
> >> SBListener listen;
> >> SBProcess proc = tgt.Launch(
> >> listen,
> >> nullptr,
> >> nullptr,
> >> nullptr,
> >> "targetout.txt",
> >> nullptr,
> >> "./",
> >> eLaunchFlagExec | eLaunchFlagDebug,
> >> false,
> >> error
> >> );
> >> ...
> >> SBThread thread = proc.GetSelectedThread(); // (1)
> >> ...
> >> }
> >>
> >> The complete code (usr.cpp) is added as an attachment to this email.
> >> Its output is also added as a text file (stdout.txt) to this email.
> >>
> >> The problem I have is, that thread.IsValid() returns null after line
> (1). Furthermore, the process says, that its state is eStateStopped, when
> asked via proc.IsStopped() it answers "false", however.
> >> The debugging target is a simple file that writes a hexadecimal number
> every 10us to stdout. I can see that the target is running, because
> targetout.txt is growing in size and its content is valid output from
> "target".
> >> Can you tell me what my mistake is?
> >>
> >> Kind Regards
> >> Jayvee
> >>
> >> <usr.cpp><stdout.txt>_______________________________________________
> >> lldb-dev mailing list
> >> lldb-dev at lists.llvm.org
> >> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
> >
> > _______________________________________________
> > lldb-dev mailing list
> > lldb-dev at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20190719/bdaace4a/attachment.html>
More information about the lldb-dev
mailing list