Page MenuHomeWildfire Games

Add thread names on Linux
Needs ReviewPublic

Authored by linkmauve on Dec 18 2019, 1:41 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

This helps with debugging which thread is doing what.

Also add the thread name of the UPnP thread.

Test Plan
  • Run pyrogenesis.
  • Run ps H -o 'tid comm' $(pidof pyrogenesis)
  • See that all threads are named.

Event Timeline

linkmauve created this revision.Dec 18 2019, 1:41 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/783/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/lib/sysdep/os/linux/ldbg.cpp
|   1| /*·Copyright·(C)·2010·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2019" year instead of "2010"
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1299/display/redirect

vladislavbelov added inline comments.
source/lib/sysdep/os/linux/ldbg.cpp
162

It's not a portable function in nonstandard GNU extensions. So it's not guaranteed to be present.

linkmauve updated this revision to Diff 10666.Fri, Dec 20, 12:44 PM
  • Update the copyright year.
  • Replace glibc’s non-portable pthread_setname_np() with an implementation that will work on all Linux libc.
linkmauve marked an inline comment as done.Fri, Dec 20, 12:45 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1325/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/809/display/redirect

linkmauve updated this revision to Diff 10667.Fri, Dec 20, 12:50 PM

Include missing unistd.h header for gettid().

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1326/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/810/display/redirect

linkmauve updated this revision to Diff 10668.Fri, Dec 20, 12:55 PM

Use syscall() directly instead of a wrapper.

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/811/display/redirect

linkmauve updated this revision to Diff 10669.Fri, Dec 20, 12:58 PM

Check for fopen()’s failure, thanks Angen for the suggestion!

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/812/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1327/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1328/display/redirect

linkmauve updated this revision to Diff 10670.Fri, Dec 20, 1:15 PM

Make magic constants less magic by binding them to a name.

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/813/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1329/display/redirect

vladislavbelov added inline comments.Thu, Dec 26, 4:01 PM
source/lib/sysdep/os/linux/ldbg.cpp
166

It'd be good to attach a comment, what's going there. Why do we need to open some file and which limitations do/did we have here. Why didn't we use the posix*_np function.

linkmauve updated this revision to Diff 10876.Sat, Jan 4, 6:17 PM
  • Add a comment explaining the function.
  • Update the copyright year.
Vulcan added a comment.Sat, Jan 4, 6:20 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/947/display/redirect

Vulcan added a comment.Sat, Jan 4, 6:22 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/43/display/redirect

Vulcan added a comment.Sat, Jan 4, 6:23 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1465/display/redirect

source/lib/sysdep/os/linux/ldbg.cpp
159

We use const char* in its declaration, so we might fix it here.

161

Can't we use TASK_COMM_LEN here?

162

|/proc/self/task//comm| = 21. On some platforms typeof(tid) = uint64_t, length of maximum possible id has 20 symbol length. It means that 32 isn't enough here.

166

It works only since Linux 2.6.33, maybe we need a comment about that.