Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] perldebguts does not have any info how to check that we are in THREADED mode #22854

Open
KES777 opened this issue Dec 10, 2024 · 4 comments

Comments

@KES777
Copy link
Contributor

KES777 commented Dec 10, 2024

Where
https://perldoc.perl.org/perldebguts

Description
The perldebguts does not provide any info how to debug threaded perl.

Here we can find that we can debug a given program using threads: perl -dt threaded_program_name

Here we can find that this support was built into the debugger as of Perl version 5.8.6

TODO:
It should be documented how to use that capability.

@jkeenan
Copy link
Contributor

jkeenan commented Dec 13, 2024

Where https://perldoc.perl.org/perldebguts

Description The perldebguts does not provide any info how to debug threaded perl.

Here we can find that we can debug a given program using threads: perl -dt threaded_program_name

Here we can find that this support was built into the debugger as of Perl version 5.8.6

TODO: It should be documented how to use that capability.

I myself have never written a threaded Perl program ... and I'll bet that's true for lots of us. Could you supply a simple threaded program for people to try debugging on?

@richardleach
Copy link
Contributor

It should be documented how to use that capability.

@KES777 - I'm not clear on what you're asking for, in that:

  • perldebug is the user guide for the debugger and is where you found perl -dt threaded_program_name.
  • perldebguts seems to be gory internals details and specific use cases.

Are you looking for:

  • perldebguts to include thread-related detail in the "Debugger Internals" section?
  • perldebguts to tell you how to implement threads support when writing your own debugger?
  • perldebug to include some of the thread id and breakpoint info mentioned in https://perldoc.perl.org/perl5db.pl#DEBUGGER-INITIALIZATION1 ?
  • something else?

If you have a specific use case or problem in mind, knowing what that is might also help us.

@jkeenan jkeenan changed the title [doc] perldebguts does not have any info how to check that we are in THERADED mode [doc] perldebguts does not have any info how to check that we are in THREADED mode Dec 15, 2024
@KES777
Copy link
Contributor Author

KES777 commented Dec 16, 2024

@jkeenan I was thinking that the script I am debugging is multithreaded. Hopefully it is not. Until I realized that I tried to find what should I implement inside my debugger to support perl -dt script.pl. I did not find any mentions on perldebguts page about threads at all.

@richardleach

perldebguts to include thread-related detail in the "Debugger Internals" section?

Yes.

perldebguts to tell you how to implement threads support when writing your own debugger?

Yes.


I expect to see on perldebguts page something like this:

If your script is threaded, then in your debugger you should implement sub xxx ... to be able to see yyy. To check that your script is threaded please check yyy. To check that your debugger was run with -t flag please check $^P bit to ...

I expect to see cautions about gotchas I should aware of when debugging threaded script. What is the environment differences with regular and threaded debugging.

PS. I am not going to write something threaded or debug something threaded. I just noticed that perldebguts page does not have any info about that and decided to create this ticket.

@tonycoz
Copy link
Contributor

tonycoz commented Dec 18, 2024

perl sets PERL5DB_THREADED=1 in the environment when invoked with -dt and the debugger itself will load threads and threads::shared when that is set, this is described in perldoc perl5db.

The debugger detects thread creation in DB::sub by checking if threads::new is being called, so it uses already documented mechanisms.

Settings breakpoints under threads works the same as non-threads (updating ${"_<$filename"}[$line] (iirc) sets/clears a bit in the dbstate op, yay race conditions.)

The E and e commands, and the thread id in the prompt use the API provided by threads.pm.

Is there other information you're looking for?

This isn't the solution to your issue, but checking exactly what we're missing so we can update it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants