Commit Graph

132 Commits (ca6f09292925a7bd936338cb598efb3ddc8524bf)

Author SHA1 Message Date
Nat Goodspeed ca6f092929 DRTVWR-476: Merge branch 'master' of lindenlab/viewer into DRTVWR-476-boost-1.72 2020-05-06 16:06:26 -04:00
Nat Goodspeed 962ccb4f01 DRTVWR-476: Facilitate debugging test programs with logging.
On Mac, even if you run a test program with --debug or set LOGTEST=DEBUG, it
won't log to stderr if you're filtering build output or running the build in
an emacs compile buffer. This is because, on Mac, a viewer launched by mouse
rather than from the command line is passed a stderr stream that ultimately
gets logged to the system Console. The shouldLogToStderr() function is
intended to avoid spamming the Console with the (voluminous) viewer log
output. It tests whether stderr isatty() and, if not, suppresses calling
LLError::logToStderr().

This makes debugging test programs using log output trickier than necessary.
Change shouldLogToStderr() to permit logging when either stderr isatty() or is
a pipe. The original intention is preserved in that empirically, a viewer
launched by mouse is passed a stderr stream identified as a character device
rather than as a pipe.

Also introduce SetEnv, a class that facilitates setting (e.g.) LOGTEST=DEBUG
for specific test programs without setting it for all test programs in the
build. Using the constructor for a static object means you can set environment
variables before main() is entered, which is important because it's the main()
function in test.cpp that acts on the LOGTEST and LOGFAIL environment
variables.

These changes make it unnecessary to retain the temporary change in test.cpp
to force LOGTEST to DEBUG.
2020-04-03 10:46:17 -04:00
Nat Goodspeed cc9bdbcf19 DRTVWR-476: Introduce LLStacktrace, a token to stream stack trace.
LLStacktrace has no behavior except when you stream an instance to a
std::ostream. Then it reports the current traceback at that point to the
ostream.

This bit of indirection is intended to avoid the boost/stacktrace.hpp header
from being included everywhere.
2020-03-25 19:21:16 -04:00
Nat Goodspeed 7826683fa2 DRTVWR-476: Back out 355d9db4a59f: unroll stderr redirection. 2020-03-25 19:06:13 -04:00
Nat Goodspeed 99d4ddc668 DRTVWR-476: Back out e913c05d43b6: unroll stderr redirection. 2020-03-25 19:06:13 -04:00
Nat Goodspeed d94e4613ca DRTVWR-476: Back out e66ec842b851: unrolling stderr redirection. 2020-03-25 19:06:13 -04:00
Nat Goodspeed 950204a5d7 DRTVWR-476: Partially revert 978e09882565: undo using LLTempRedirect.
But leave LLTempRedirect available in the code base.
2020-03-25 19:06:13 -04:00
Nat Goodspeed 7ef10fe11c DRTVWR-476: Don't test configuration.emptyMap().
LLSD::emptyMap() is a factory for an empty map instance, NOT a predicate on
any particular instance. In fact checking configuration.isUndefined() and
testing whether the map is empty are both subsumed by (! configuration).
2020-03-25 19:06:13 -04:00
Nat Goodspeed ec2bd40d3e DRTVWR-476: Encapsulate dup()/dup2() fd saving as LLTempRedirect. 2020-03-25 19:06:12 -04:00
Nat Goodspeed 7f1a200214 DRTVWR-476: On Windows, dup2() et al. need <io.h> 2020-03-25 19:05:17 -04:00
Nat Goodspeed 07134aaee7 DRTVWR-476: Try to extend stderr redirection to Windows as well.
Make the LLError::Settings LLSingleton duplicate the file handle for stderr
(usually 2) on construction. Make its destructor restore the original target
for that file handle. Provide a getDupStderr() method to obtain the duplicate
file handle.

Move Settings declaration up to the top of the file so other code can
reference it.

Make RecordToFile (the Recorder subclass engaged by LLError::logToFile()),
instead of duplicating stderr's file handle itself, capture the duplicate
stderr file handle from Settings to revert stderr redirection on destruction.

Make RecordToStderr (the Recorder subclass engaged by LLError::logToStderr())
use fdopen() to create an LLFILE* targeting the duplicate file handle from
Settings. Write output to that instead of to stderr so logToStderr() continues
to provide output for the user instead of duplicating each line into the log
file.
2020-03-25 19:05:17 -04:00
Nat Goodspeed 7845f73c76 DRTVWR-476: Try to log stderr output from classic-C libraries.
Some of the libraries we use produce log output to stderr. Such output can be
informative, but is invisible unless you launch the viewer from a console. In
particular, it's invisible to anyone trying to diagnose a problem by reading
someone else's SecondLife.log file.

Make RecordToFile -- the Recorder subclass engaged by LLError::logToFile() --
redirect STDERR_FILENO to the newly-opened log file so that any subsequent
writes to stderr (or cerr, for that matter) will be captured in the log file.
But first duplicate the original stderr file handle, and restore it when
RecordToFile is destroyed. That way, output written to stderr during the final
moments of application shutdown should still appear on (console) stderr.
2020-03-25 19:05:17 -04:00
Nat Goodspeed 6b70493ddb DRTVWR-476: Make test program --debug switch work like LOGTEST=DEBUG.
The comments within indra/test/test.cpp promise that --debug is, in fact, like
LOGTEST=DEBUG. Until now, that was a lie. LOGTEST=level displayed log output
on stderr as well as in testprogram.log, while --debug did not.

Add LLError::logToStderr() function, and make initForApplication() (i.e.
commonInit()) call that instead of instantiating RecordToStderr inline. Also
call it when test.cpp recognizes --debug switch.

Remove the mFileRecorder, mFixedBufferRecorder and mFileRecorderFileName
members from SettingsConfig. That tactic doesn't scale.

Instead, add findRecorder<RECORDER>() and removeRecorder<RECORDER>() template
functions to locate (or remove) a RecorderPtr to an object of the specified
subclass. Both are based on an underlying findRecorderPos<RECORDER>() template
function. Since we never expect to manage more than a handful of RecorderPtrs,
and since access to the deleted members is very much application setup rather
than any kind of ongoing access, a search loop suffices.

logToFile() uses removeRecorder<RecordToFile>() rather than removing
mFileRecorder (the only use of mFileRecorder).

logToFixedBuffer() uses removeRecorder<RecordToFixedBuffer>() rather than
removing mFixedBufferRecorder (the only use of mFixedBufferRecorder).

Make RecordToFile store the filename with which it was instantiated. Add a
getFilename() method to retrieve it. logFileName() is now based on
findRecorder<RecordToFile>() instead of mFileRecorderFileName (the only use of
mFileRecorderFileName).

Make RecordToStderr::mUseANSI a simple bool rather than a three-state enum,
and set it immediately on construction. Apparently the reason it was set
lazily was because it consults its own checkANSI() method, and of course
'this' doesn't acquire the leaf class type until the constructor has completed
successfully. But since nothing in checkANSI() depends on anything else in
RecordToStderr, making it static solves that problem.
2020-03-25 18:47:13 -04:00
Brad Kittenbrink a6f31e9167 Fixed variadic macro usage in LL_ERRS_IF and LL_WARNS_IF and improved LLError::shouldLogToStderr() behavior under xcode. 2020-03-25 18:39:21 -04:00
Nat Goodspeed 4c9e90de43 DRTVWR-494: Get initialized LLMutexes for very early log calls.
Use function-static LLMutex instances instead of module-static instances,
since some log calls are evidently issued before we get around to initializing
llerror.cpp module-static variables.
2020-03-25 15:28:17 -04:00
Nat Goodspeed 1fc7c994d6 DRTVWR-494: Fix VS LLError::Log::demangle() vulnerability.
The Windows implementation of demangle() assumed that a "mangled" class name
produced by typeid(class).name() always starts with the prefix "class ",
checked for that and removed it. If the mangled name didn't start with that
prefix, it would emit a debug message and return the full name.

When the class in question is actually a struct, the prefix is "struct "
instead. But when demangle() was being called before logging had been fully
initialized, the debug message remarking that it didn't start with "class "
crashed.

Look for either "class " or "struct " prefix. Remove whichever is found and
return the rest of the name. If neither is found, only log if logging is
available.
2020-03-25 15:28:17 -04:00
Graham Linden 9bb6da1e76 Make llerror do 66% fewer fprintf calls when engaging ANSI encoding and eliminate branches from high-traffic code. 2019-07-30 11:59:20 -07:00
AndreyL ProductEngine 36cb6933e6 Merged in lindenlab/viewer-release 2019-03-01 02:24:00 +02:00
andreykproductengine 26fae750ba SL-10291 Replace apr_mutex with standard C++11 functionality 2019-01-14 22:04:44 +02:00
andreykproductengine 13f8cfd1c2 SL-9954 Mac Viewer crashes if logcontrol-dev.xml is modified 2018-11-29 19:25:00 +02:00
Nat Goodspeed f7e99f0db7 Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2018-11-14 16:17:36 -05:00
Oz Linden d87cc1859f Modify logging so that the in-viewer console and stderr do not escape line breaks
Improve the implementation so that escaping is computed only once
2018-10-11 14:17:52 -04:00
Brad Payne (Vir Linden) a84ee929a5 merge 2018-09-27 19:54:10 +01:00
Nat Goodspeed fc8b4ec587 DRTVWR-447: Finish pulling in new viewer-release. 2018-09-26 16:50:58 -04:00
Brad Payne (Vir Linden) d6cec8d68d SL-944 - enabled log types consistent notation in xml and cpp 2018-09-07 16:00:43 +01:00
Oz Linden f1d4e788e7 SL-967 simplify viewer log file field syntax
MAINT-8991: only escape log message characters once, add unit test
remove extra log line created by LL_ERRS
document that tags may not contain spaces
2018-08-29 16:43:45 -04:00
AndreyL ProductEngine 36e89143b7 Backed out changeset: 5b0f20062633 2018-08-28 22:25:18 +03:00
Brad Payne (Vir Linden) 9ae973ec5b SL-944 - mac build error fix: wants override to be used throughout a class if it is used at all 2018-08-27 14:22:42 +01:00
Brad Payne (Vir Linden) 9c6678b5e7 SL-944 - logcontrol options to control which log recorders get used. This can be useful for performance reasons when especially verbose debug logging is needed. 2018-08-24 21:55:07 +01:00
maxim_productengine 7aaaabdea7 MAINT-8991 Escape newlines in log entries 2018-08-17 16:14:03 +03:00
Brad Payne (Vir Linden) 6ce09ad712 merge 2018-08-02 21:54:09 +01:00
Brad Payne (Vir Linden) edf6795eda SL-915, MAINT-8554 - cleanup/reorg, added encroachment fix info to DebugAnimatedObjects output 2018-06-13 21:49:24 +01:00
Brad Payne (Vir Linden) 887638c4d2 SL-915 - fix for crash when logcontrol file reloaded 2018-06-11 13:55:34 +01:00
Brad Payne (Vir Linden) 430f9420cf SL-915 - more on dynamic extent tracking, possible fix for 32-bit crash issues 2018-06-07 22:18:15 +01:00
Graham Linden 88da45148e Better fix for OSX 10.14 libc++abi demangling crash on mem shenanigans.
Silence nagging about running launcher for non-release for download builds.

Tweak newview CMake to use executable instead of SL_Launcher and
re-enable debugging within Xcode.
2018-06-07 22:14:46 +01:00
Graham Linden 1c4decadfe Disable name demangling via libc++abi on OS X to avoid malloc abort trap on OS X 10.14 Mojave 2018-06-07 01:22:49 +01:00
Oz Linden d7c8678c3a merge 5.1.0-release 2018-01-17 12:43:28 -05:00
Oz Linden fa53653e60 fix separator between tags and file/function 2017-07-24 14:49:56 -04:00
Oz Linden 347015be33 fix presentation of log tags for better searchability 2017-06-20 17:03:20 -04:00
Nat Goodspeed a3066b7375 Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2017-06-20 16:11:33 -04:00
Nat Goodspeed 1a8c8df686 DRTVWR-418: Ignore logging that requires resurrecting singletons.
The logging subsystem depends on two different LLSingletons for some reason.
It turns out to be very difficult to completely avoid executing any logging
calls after the LLSingletonBase::deleteAll(), but we really don't want to
resurrect those LLSingletons so late in the run for a couple stragglers.
Introduce LLSingleton::wasDeleted() query method, and use it in logging
subsystem to simply bypass last-millisecond logging requests.
2017-03-13 14:09:14 -04:00
Oz Linden dd63291355 construct tag string without using += 2017-03-09 17:56:30 -05:00
Oz Linden e479d51068 experiment reformatting of tags in log lines 2017-03-09 14:16:33 -05:00
Brad Payne (Vir Linden) f70abb4ad6 SL-409 - added tracking for bytes fetched to viewer assets metrics (does not currently work for textures) 2017-03-03 15:14:09 -05:00
Oz Linden 0a7fd3686a Look for logcontrol-dev.xml in the user settings directory 2017-02-27 09:52:50 -05:00
AndreyL ProductEngine 2abd0eef41 Merged in lindenlab/viewer-release
DRTVWR-412 Bento (avatar skeleton extensions)
2016-12-05 21:51:29 +02:00
Brad Payne (Vir Linden) d31596db6a merge 2016-11-16 08:39:41 -05:00
AndreyL ProductEngine 7fceb3a63f Merged in lindenlab/viewer-cleanup 2016-11-14 22:04:37 +02:00
Glenn Glazer d68befaced maint-6633: remove commented out code 2016-10-11 13:28:30 -07:00
Glenn Glazer f447cf7223 maint-6633: yet more futzing with spaces 2016-10-11 08:16:25 -07:00