If you decide to recompile parts of your Linux distro with XRay, it may
be useful to know which trace belongs to which binary. While there, get
rid of the incorrect strncat() usage; it always returns a pointer to the
start which makes that if() always true. Replace with snprintf which is
bounded so that enough from both strings fits nicely.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Mark as done.
lib/xray/xray_inmemory_log.cc | ||
---|---|---|
116 ↗ | (On Diff #81915) | I was actually thinking of "(unknown)", similar to when printf(3) prints "(null)" on NULL strings. I don't have a strong preference but wanted something that immediately suggests something's gone wrong. |
121 ↗ | (On Diff #81915) | I tried to find it in the coding standards, I promise! :-) |
124–125 ↗ | (On Diff #81915) | The buffer is 256 characters long; 120 is a decent bound for not overflowing the string. Should I bind it with sizeof(TmpFilename) somehow? Its size is a magic number too, and they're close to one another for people to see. |
127 ↗ | (On Diff #81915) | The function returns how many bytes would you need to satisfy the operation; "overflow" would indicate it's the amount of characters over 256 (sizeof TmpFilename) IMHO. Do you still want me to change it? |
lib/xray/xray_inmemory_log.cc | ||
---|---|---|
116 ↗ | (On Diff #81915) | "(unknown)" seems strictly better if not annoying to refer to in the filesystem. Either that or just keeping it empty? |
124–125 ↗ | (On Diff #81915) | Yeah, you can probably do something about making it relative to the sizeof(TmpFilename). |
127 ↗ | (On Diff #81915) | Yeah, so "Need" isn't the best name. Is "Length" a better name? |
Did the tests need updating, so that we know the "default" would do the right thing?
Currently we set the pattern explicitly. It'd be great to see a test that makes sure that the default pattern including argv[0] actually shows up.
I was thinking it might be better if you made a specific test just for this -- that the "default" (i.e. not setting the pattern with the XRAY_OPTIONS environment variable) would be better, so that we can isolate the feature in a specific test.
test/xray/TestCases/Linux/fixedsize-logging.cc | ||
---|---|---|
5 ↗ | (On Diff #81928) | I'm not sure we can rely on shell expansion to work here. Can you think of a different way of doing this, where you look for the filename on the "default" (i.e. non-configured explicitly) name here? |
- make a bespoke test for argv[0] being in the file name
- make it more complicated and not use $() and ??????