Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef LulDwarfSummariser_h
8 : #define LulDwarfSummariser_h
9 :
10 : #include "LulMainInt.h"
11 :
12 : namespace lul {
13 :
14 : class Summariser
15 : {
16 : public:
17 : Summariser(SecMap* aSecMap, uintptr_t aTextBias, void(*aLog)(const char*));
18 :
19 : virtual void Entry(uintptr_t aAddress, uintptr_t aLength);
20 : virtual void End();
21 :
22 : // Tell the summariser that the value for |aNewReg| at |aAddress| is
23 : // recovered using the LExpr that can be constructed using the
24 : // components |how|, |oldReg| and |offset|. The summariser will
25 : // inspect the components and may reject them for various reasons,
26 : // but the hope is that it will find them acceptable and record this
27 : // rule permanently.
28 : virtual void Rule(uintptr_t aAddress, int aNewReg,
29 : LExprHow how, int16_t oldReg, int64_t offset);
30 :
31 : virtual uint32_t AddPfxInstr(PfxInstr pfxi);
32 :
33 : // Send output to the logging sink, for debugging.
34 0 : virtual void Log(const char* str) { mLog(str); }
35 :
36 : private:
37 : // The SecMap in which we park the finished summaries (RuleSets) and
38 : // also any PfxInstrs derived from Dwarf expressions.
39 : SecMap* mSecMap;
40 :
41 : // Running state for the current summary (RuleSet) under construction.
42 : RuleSet mCurrRules;
43 :
44 : // The start of the address range to which the RuleSet under
45 : // construction applies.
46 : uintptr_t mCurrAddr;
47 :
48 : // The highest address, plus one, for which the RuleSet under
49 : // construction could possibly apply. If there are no further
50 : // incoming events then mCurrRules will eventually be emitted
51 : // as-is, for the range mCurrAddr.. mMax1Addr - 1, if that is
52 : // nonempty.
53 : uintptr_t mMax1Addr;
54 :
55 : // The bias value (to add to the SVMAs, to get AVMAs) to be used
56 : // when adding entries into mSecMap.
57 : uintptr_t mTextBias;
58 :
59 : // A logging sink, for debugging.
60 : void (*mLog)(const char* aFmt);
61 : };
62 :
63 : } // namespace lul
64 :
65 : #endif // LulDwarfSummariser_h
|