aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/MachineDebugInfo.h
blob: c728418a89c55f0b7b98dd1bcecc34541ecaa7e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//===-- llvm/CodeGen/MachineDebugInfo.h -------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by James M. Laskey and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Collect debug information for a module.  This information should be in a
// neutral form that can be used by different debugging schemes.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CODEGEN_MACHINEDEBUGINFO_H
#define LLVM_CODEGEN_MACHINEDEBUGINFO_H

#include "llvm/Pass.h"
#include <string>
#include <map>
#include <vector>

namespace llvm {
//===----------------------------------------------------------------------===//
/// MachineDebugInfo - This class contains debug information specific to a
/// module.  Queries can be made by different debugging schemes and reformated
/// for specific use.
///
class MachineDebugInfo : public ImmutablePass {
private:
  std::map<std::string, unsigned> SourceMap; // Map of source file path to id
  unsigned SourceCount;                 // Number of source files (used to
                                        // generate id)
  unsigned UniqueID;                    // Number used to unique labels used
                                        // by debugger.

public:
  // Ctor.
  MachineDebugInfo()
  : SourceMap()
  , SourceCount(0)
  , UniqueID(1)
  {}
  ~MachineDebugInfo() { }
  
  /// hasInfo - Returns true if debug info is present.
  ///
  // FIXME - need scheme to suppress debug output.
  bool hasInfo() const { return SourceCount != 0; }
  
  /// getNextUniqueID - Returns a unique number for labels used by debugger.
  ///
  unsigned getNextUniqueID() { return UniqueID++; }
  
  bool doInitialization();
  bool doFinalization();
  
  /// getUniqueSourceID - Register a source file with debug info. Returns an id.
  ///
  unsigned getUniqueSourceID(const std::string &fname, 
                             const std::string &dirname);
  
  /// getSourceFiles - Return a vector of files.  Vector index + 1 equals id.
  ///
  std::vector<std::string> getSourceFiles() const;
  
}; // End class MachineDebugInfo

} // End llvm namespace

#endif