Recent

Author Topic: Is there any way to name my threads for debugging?  (Read 23976 times)

balazsszekely

  • Guest
Re: Is there any way to name my threads for debugging?
« Reply #30 on: January 10, 2018, 09:50:19 pm »
Pascal there is no need for thanks. If the DebuggerIntf idea is not working you can try something else, like sending a message to ThreadDlg window with PostMessage for example.  Unfortunately we are limited by the gdb, a custom debugger would be the ideal solution.

balazsszekely

  • Guest
Re: Is there any way to name my threads for debugging?
« Reply #31 on: January 12, 2018, 11:01:53 am »
Hi Pascal,

Please apply the attached patch(LazFiles.zip), then test the attached project(ThreadName.zip). The patch modifies the following files, please do backup before start:
   $(LazarusDir)\components\debuggerintf\dbgintfdebuggerbase.pp
   $(LazarusDir)\debugger\threaddlg.pp
   $(LazarusDir)\ide\debugmanager.pas
With the patch, I also attach the units if you need them. After IDE rebuild, open the project, put a break point in the thread execute method, run the project then press the "Create thread" button.
You should see the thread name as in the attached screenshot. Tested with 64 bit Lazarus too.

regards,
GetMem

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Is there any way to name my threads for debugging?
« Reply #32 on: January 12, 2018, 12:07:44 pm »
Great  8)
And now integrate it into TThread.NameThreadForDebugging and we have it working crossplatform :D
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

balazsszekely

  • Guest
Re: Is there any way to name my threads for debugging?
« Reply #33 on: January 12, 2018, 01:17:52 pm »
Quote
And now integrate it into TThread.NameThreadForDebugging and we have it working crossplatform :D
It is cross-platform already. I will ask the core developers if this or a similar solution is accepted in Lazarus. TThread.NameThreadForDebugging is in FPC, adding the name there it's useless because of the gdb.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Is there any way to name my threads for debugging?
« Reply #34 on: January 12, 2018, 01:48:28 pm »
Quote
And now integrate it into TThread.NameThreadForDebugging and we have it working crossplatform :D
It is cross-platform already. I will ask the core developers if this or a similar solution is accepted in Lazarus. TThread.NameThreadForDebugging is in FPC, adding the name there it's useless because of the gdb.
Yes, but you can integrate it in fpc and if NameThreadForDebugging is used it'll work. All you need is in fpc.

Edit:
Of cause this is only usefull if it's used with Lazarus.
« Last Edit: January 12, 2018, 02:07:05 pm by Pascal »
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Is there any way to name my threads for debugging?
« Reply #35 on: January 12, 2018, 02:24:04 pm »
Have a look at the attched patch for fpc. It's neither tested nor build so far.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

balazsszekely

  • Guest
Re: Is there any way to name my threads for debugging?
« Reply #36 on: January 12, 2018, 04:16:57 pm »
Quote
Have a look at the attched patch for fpc.
Looks good but I seriously doubt it will be accepted by FPC developers. The code is only useful when you debug an application from Lazarus, why should be present in classes.inc? At least this is how I see it.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Is there any way to name my threads for debugging?
« Reply #37 on: January 12, 2018, 05:11:47 pm »
Looks good but I seriously doubt it will be accepted by FPC developers. The code is only useful when you debug an application from Lazarus, why should be present in classes.inc? At least this is how I see it.
Yes, but that's another story.

Maybe there could be implemented an interface class for Lazarus which can be instantiated by Lazarus apps and fpc classes use it if assigned.
I'll update the patch and test it.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Is there any way to name my threads for debugging?
« Reply #38 on: January 12, 2018, 05:25:57 pm »
Looks good but I seriously doubt it will be accepted by FPC developers. The code is only useful when you debug an application from Lazarus, why should be present in classes.inc? At least this is how I see it.
Yes, but that's another story.
No it is not: classes unit should be clean. It is the base unit for classes. Basically introducing something like this is a sin.
Quote
Maybe there could be implemented an interface class for Lazarus which can be instantiated by Lazarus apps and fpc classes use it if assigned.
I'll update the patch and test it.
The implementation can only be for platform(s) that support it which I count as one (one). So it should be in the windows specific code.
Specialize a type, not a var.

balazsszekely

  • Guest
Re: Is there any way to name my threads for debugging?
« Reply #39 on: January 12, 2018, 05:30:32 pm »
Quote
@Thaddy
The implementation can only be for platform(s) that support it which I count as one (one). So it should be in the windows specific code.
Just apply the patch(see above), then test the project. In theory it should work in every platform. In fact this is a good chance to test it on raspberry pi. Can you please do a quick test?

PS: I already tested on Linux mint and works fine.
PS1: If it's not working then IPC fails on that specific platform. IPC is a built in FPC feature.
« Last Edit: January 12, 2018, 05:39:04 pm by GetMem »

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Is there any way to name my threads for debugging?
« Reply #40 on: January 12, 2018, 10:07:01 pm »
10:00 CET tomorrow morning  :)
Specialize a type, not a var.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Is there any way to name my threads for debugging?
« Reply #41 on: January 13, 2018, 07:52:29 am »
I integrated an interface class to fpc and fpc compiles fine with -dFPC_USE_LAZINTF. (See atached patches).

Unit lazintf is placed in /rtl/objpas. But it's not build during build of fpc. What do i have to do to make it build during fpc build?
« Last Edit: January 13, 2018, 08:19:43 am by Pascal »
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

balazsszekely

  • Guest
Re: Is there any way to name my threads for debugging?
« Reply #42 on: January 13, 2018, 08:25:52 am »
Quote
But it's not build during build of fpc. What do i have to do to make it build during fpc build?
Try to add lazintf to fpmake from /rtl/.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Is there any way to name my threads for debugging?
« Reply #43 on: January 15, 2018, 08:00:23 am »
10:00 CET tomorrow morning  :)

Good morning Thaddy, did you test it?
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Is there any way to name my threads for debugging?
« Reply #44 on: January 18, 2018, 07:55:30 am »
10:00 CET tomorrow morning  :)

Good morning Thaddy, did you test it?
Thaddy, did you had a chance to test it?
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

 

TinyPortal © 2005-2018