Skip to content

Commit

Permalink
fix up printers
Browse files Browse the repository at this point in the history
  • Loading branch information
peadar committed Jul 8, 2024
1 parent f775601 commit 570a455
Show file tree
Hide file tree
Showing 4 changed files with 341 additions and 314 deletions.
9 changes: 9 additions & 0 deletions dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ std::ostream &operator << (std::ostream &os, const JSON<Dwarf::Unit::sptr> &unit
return fmt;
}

std::ostream & operator << (std::ostream &os, Dwarf::Tag tag) {
#define DWARF_TAG(x,y) case Dwarf::x: return os << #x;
switch (tag) {
#include "libpstack/dwarf/tags.h"
default: return os << int(tag);
}
#undef DWARF_TAG
}

std::ostream & operator << (std::ostream &os, const JSON<Dwarf::Tag> &tag) {
#define DWARF_TAG(x,y) case Dwarf::x: return os << json(#x);
switch (tag.object) {
Expand Down
6 changes: 2 additions & 4 deletions libpstack/dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ class LineInfo;
class Unit;
class CFI;
struct CIE;
}

std::ostream & operator << (std::ostream &os, const JSON<pstack::Dwarf::CFI> &);

namespace pstack::Dwarf {

#define DWARF_TAG(a,b) a = (b),
enum Tag {
Expand Down Expand Up @@ -864,5 +860,7 @@ Units::iterator::iterator(const Info *info_, Elf::Off offset)
std::ostream &operator << (std::ostream &os, const JSON<pstack::Dwarf::Info> &);
std::ostream &operator << (std::ostream &os, const JSON<pstack::Dwarf::Macros> &);
std::ostream &operator << (std::ostream &os, const JSON<pstack::Dwarf::DIE> &);
std::ostream &operator << (std::ostream &os, pstack::Dwarf::Tag);
std::ostream &operator << (std::ostream &os, const JSON<pstack::Dwarf::CFI> &);

#endif
8 changes: 6 additions & 2 deletions libpstack/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ class Reader : public std::enable_shared_from_this<Reader> {
virtual csptr view(const std::string &name, Off start, Off length=std::numeric_limits<Off>::max()) const;
};

static inline std::ostream &operator << (std::ostream &os, const Reader &reader)
{
}

inline std::ostream &operator << (std::ostream &os, const pstack::Reader &reader) {
reader.describe(os);
return os;
}

namespace pstack {

template <typename Obj> void
Reader::readObj(Off offset, Obj *object, size_t count) const
{
Expand Down Expand Up @@ -302,4 +305,5 @@ template <typename T, typename Iter> static inline std::pair<T, size_t> readleb1
};
}
}

#endif
Loading

0 comments on commit 570a455

Please sign in to comment.