Skip to content

Commit e91aac1

Browse files
committed
For science. Let's see if sentry.io accepts these annotations...
1 parent a294916 commit e91aac1

3 files changed

Lines changed: 49 additions & 7 deletions

File tree

indra/llcommon/llevents.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ class LL_COMMON_API LLListenerOrPumpName
182182
bool operator! () const { return ! mListener; }
183183

184184
/// explicit accessor
185-
const LLEventListener& getListener() const { return *mListener; }
185+
const ::LLEventListener& getListener() const { return *mListener; }
186186

187187
/// implicit conversion to LLEventListener
188-
operator LLEventListener() const { return *mListener; }
188+
operator ::LLEventListener() const { return *mListener; }
189189

190190
/// allow calling directly
191191
bool operator()(const LLSD& event) const;
@@ -277,7 +277,7 @@ namespace LLEventDetail
277277
/// Any callable capable of connecting an LLEventListener to an
278278
/// LLStandardSignal to produce an LLBoundListener can be mapped to this
279279
/// signature.
280-
typedef boost::function<LLBoundListener(const LLEventListener&)> ConnectFunc;
280+
typedef boost::function<LLBoundListener(const ::LLEventListener&)> ConnectFunc;
281281

282282
/// overload of visit_and_connect() when we have a string identifier available
283283
template <typename LISTENER>
@@ -547,7 +547,7 @@ class LL_COMMON_API LLEventPump: public LLEventTrackable
547547
virtual void reset();
548548

549549
private:
550-
virtual LLBoundListener listen_impl(const std::string& name, const LLEventListener&,
550+
virtual LLBoundListener listen_impl(const std::string& name, const ::LLEventListener&,
551551
const NameList& after,
552552
const NameList& before);
553553
std::string mName;
@@ -845,7 +845,7 @@ namespace LLEventDetail
845845
* Visitor binds a reference to LLEventListener so we can track() any
846846
* shared_ptrs we find in the argument list.
847847
*/
848-
Visitor(LLEventListener& listener):
848+
Visitor(::LLEventListener& listener):
849849
mListener(listener)
850850
{
851851
}
@@ -988,7 +988,7 @@ namespace LLEventDetail
988988
|*==========================================================================*/
989989

990990
/// Bind a reference to the LLEventListener to call its track() method.
991-
LLEventListener& mListener;
991+
::LLEventListener& mListener;
992992
};
993993

994994
/**
@@ -1005,7 +1005,7 @@ namespace LLEventDetail
10051005
const ConnectFunc& connect_func)
10061006
{
10071007
// Capture the listener
1008-
LLEventListener listener(raw_listener);
1008+
::LLEventListener listener(raw_listener);
10091009
// Define our Visitor, binding the listener so we can call
10101010
// listener.track() if we discover any shared_ptr<Foo>.
10111011
LLEventDetail::Visitor visitor(listener);

indra/newview/llappviewer.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,40 @@
220220
#include <client/crashpad_client.h>
221221
#include <client/prune_crash_reports.h>
222222
#include <client/settings.h>
223+
#include <client/annotation.h>
223224

224225
#include <fmt/format.h>
225226

226227
#include "llnotificationsutil.h"
227228
#include "llversioninfo.h"
229+
230+
231+
template <size_t SIZE, crashpad::Annotation::Type T = crashpad::Annotation::Type::kString>
232+
struct crashpad_annotation : public crashpad::Annotation {
233+
std::array<char, SIZE> buffer;
234+
crashpad_annotation(const char* name) : crashpad::Annotation(T, name, buffer.data())
235+
{}
236+
void set(const std::string& src) {
237+
LL_INFOS() << name() << ": " << src.c_str() << LL_ENDL;
238+
const size_t min_size = llmin(SIZE, src.size());
239+
memcpy(buffer.data(), src.data(), min_size);
240+
buffer.data()[SIZE - 1] = '\0';
241+
SetSize(min_size);
242+
}
243+
};
244+
#define DEFINE_CRASHPAD_ANNOTATION(name, len) \
245+
static crashpad_annotation<len> g_crashpad_annotation_##name##_buffer(#name);
246+
#define SET_CRASHPAD_ANNOTATION_VALUE(name, value) \
247+
g_crashpad_annotation_##name##_buffer.set(value);
248+
#else
249+
#define SET_CRASHPAD_ANNOTATION_VALUE(name, value)
250+
#define DEFINE_CRASHPAD_ANNOTATION(name, len)
228251
#endif
229252

253+
DEFINE_CRASHPAD_ANNOTATION(fatal_message, 512);
254+
DEFINE_CRASHPAD_ANNOTATION(grid_name, 64);
255+
DEFINE_CRASHPAD_ANNOTATION(cpu_string, 128);
256+
DEFINE_CRASHPAD_ANNOTATION(startup_state, 32);
230257

231258
////// Windows-specific includes to the bottom - nasty defines in these pollute the preprocessor
232259
//
@@ -770,8 +797,18 @@ bool LLAppViewer::init()
770797
initCrashReporting();
771798
#endif
772799

800+
writeDebugInfo();
801+
773802
setupErrorHandling();
774803

804+
{
805+
auto fn = boost::bind<bool>([](const LLSD& stateInfo) -> bool {
806+
SET_CRASHPAD_ANNOTATION_VALUE(startup_state, stateInfo["str"].asString());
807+
return false;
808+
}, _1);
809+
LLStartUp::getStateEventPump().listen<::LLEventListener>("LLAppViewer", fn);
810+
}
811+
775812
//
776813
// Start of the application
777814
//
@@ -2741,6 +2778,10 @@ void LLAppViewer::writeDebugInfo(bool isStatic)
27412778

27422779
isStatic ? LLSDSerialize::toPrettyXML(gDebugInfo, out_file)
27432780
: LLSDSerialize::toPrettyXML(gDebugInfo["Dynamic"], out_file);
2781+
#else
2782+
SET_CRASHPAD_ANNOTATION_VALUE(fatal_message, gDebugInfo["FatalMessage"].asString());
2783+
SET_CRASHPAD_ANNOTATION_VALUE(grid_name, gDebugInfo["GridName"].asString());
2784+
SET_CRASHPAD_ANNOTATION_VALUE(cpu_string, gDebugInfo["CPUInfo"]["CPUString"].asString());
27442785
#endif
27452786
}
27462787

indra/newview/llstartup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class LLStartUp
139139
static bool startLLProxy(); // Initialize the SOCKS 5 proxy
140140

141141
static LLViewerStats::PhaseMap& getPhases() { return *sPhases; }
142+
static LLEventPump& getStateEventPump() { return *sStateWatcher; }
142143
private:
143144
static LLSLURL sStartSLURL;
144145

0 commit comments

Comments
 (0)