ReactOS 0.4.16-dev-199-g898cc56
dwarfdump.c File Reference
#include "dwarf.h"
#include "pe.h"
Include dependency graph for dwarfdump.c:

Go to the source code of this file.

Functions

void printrules (Dwarf *d, ulong pc)
 
void usage (void)
 
void main (int argc, char **argv)
 

Function Documentation

◆ main()

void main ( int argc  ,
char **  argv 
)

Definition at line 21 of file dwarfdump.c.

22{
23 int c;
24 Pe *pe;
25 Dwarf *d;
26 DwarfSym s;
27 char *cdir, *dir, *file;
28 ulong line, mtime, length;
29
30 if(argc != 2)
31 usage();
32
33#if 0
34 fmtinstall('R', exprfmt);
35 fmtinstall('H', encodefmt);
36#endif
37
38 if((pe = peopen(argv[1])) == nil)
39 sysfatal("elfopen %s: %r", argv[1]);
40 if((d=dwarfopen(pe)) == nil)
41 sysfatal("dwarfopen: %r");
42
43 if(dwarfenum(d, &s) < 0)
44 sysfatal("dwarfenumall: %r");
45
46 while(dwarfnextsym(d, &s) == 1){
47 switch(s.attrs.tag){
48 case TagCompileUnit:
49 print("compileunit %s\n", s.attrs.name);
50 break;
51 case TagSubprogram:
52 c = 't';
53 goto sym;
54 case TagVariable:
55 c = 'd';
56 goto sym;
57 case TagConstant:
58 c = 'c';
59 goto sym;
61 if(!s.attrs.name)
62 break;
63 c = 'p';
64 sym:
65 if(s.attrs.isexternal)
66 c += 'A' - 'a';
67 print("%c %s", c, s.attrs.name);
68 if(s.attrs.have.lowpc)
69 print(" 0x%lux-0x%lux", s.attrs.lowpc, s.attrs.highpc);
70 switch(s.attrs.have.location){
71 case TBlock:
72 print(" @ %.*H", s.attrs.location.b.len, s.attrs.location.b.data);
73 break;
74 case TConstant:
75 print(" @ 0x%lux", s.attrs.location.c);
76 break;
77 }
78 if(s.attrs.have.ranges)
79 print(" ranges@0x%lux", s.attrs.ranges);
80 print("\n");
81 if(s.attrs.have.lowpc){
82 if(dwarfpctoline(d, s.attrs.lowpc, &cdir, &dir, &file, &line, &mtime, &length) < 0)
83 print("\tcould not find source: %r\n");
84 else if(dir == nil)
85 print("\t%s/%s:%lud mtime=%lud length=%lud\n",
86 cdir, file, line, mtime, length);
87 else
88 print("\t%s/%s/%s:%lud mtime=%lud length=%lud\n",
89 cdir, dir, file, line, mtime, length);
90
91 if(0) printrules(d, s.attrs.lowpc);
92 if(0) printrules(d, (s.attrs.lowpc+s.attrs.highpc)/2);
93 }
94 break;
95 }
96 }
97 exits(0);
98}
static int argc
Definition: ServiceArgs.c:12
unsigned int dir
Definition: maze.c:112
static void print(LPPRINTDLGW pd, LPWSTR wszFileName)
Definition: print.c:438
unsigned long ulong
Definition: linux.h:275
GLdouble s
Definition: gl.h:2039
const GLubyte * c
Definition: glext.h:8905
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define d
Definition: ke_i.h:81
#define c
Definition: ke_i.h:80
#define argv
Definition: mplay32.c:18
void printrules(Dwarf *d, ulong pc)
Definition: dwarfdump.c:101
void usage(void)
Definition: dwarfdump.c:14
Pe * peopen(const char *name)
#define nil
Definition: compat.h:23
int dwarfpctoline(Dwarf *, ulong, char **, char **, char **, char **, ulong *, ulong *, ulong *)
Definition: dwarfpc.c:48
Dwarf * dwarfopen(struct _Pe *elf)
Definition: dwarfopen.c:16
int dwarfnextsym(Dwarf *, DwarfSym *)
Definition: dwarfinfo.c:250
int dwarfenum(Dwarf *, DwarfSym *)
Definition: dwarfinfo.c:241
@ TagCompileUnit
Definition: dwarf.h:24
@ TagVariable
Definition: dwarf.h:58
@ TagFormalParameter
Definition: dwarf.h:17
@ TagConstant
Definition: dwarf.h:45
@ TConstant
Definition: dwarf.h:132
@ TagSubprogram
Definition: dwarf.h:52
@ TBlock
Definition: dwarf.h:131
Definition: dwarf.h:437
Definition: pe.h:14
Definition: fci.c:127
Definition: parser.c:49

◆ printrules()

void printrules ( Dwarf d,
ulong  pc 
)

Definition at line 101 of file dwarfdump.c.

102{
103 int i;
104 DwarfExpr r[10];
105 DwarfExpr cfa, ra;
106
107 if(dwarfunwind(d, pc, &cfa, &ra, r, nelem(r)) < 0)
108 print("\tcannot unwind from pc 0x%lux: %r\n", pc);
109
110 print("\tpc=0x%lux cfa=%R ra=%R", pc, &cfa, &ra);
111 for(i=0; i<nelem(r); i++)
112 if(r[i].type != RuleSame)
113 print(" r%d=%R", i, &r[i]);
114 print("\n");
115}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ RuleSame
Definition: dwarf.h:359
int dwarfunwind(Dwarf *, ulong, DwarfExpr *, DwarfExpr *, DwarfExpr *, int)
Definition: dwarfcfa.c:47
#define nelem(x)
Definition: shaptest.c:19

Referenced by main().

◆ usage()

void usage ( void  )

Definition at line 14 of file dwarfdump.c.

15{
16 fprint(2, "usage: dwarfdump file\n");
17 exits("usage");
18}

Referenced by main().