Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SMPStaticAnalyzer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
SMPStaticAnalyzer
Commits
13e3bf25
Commit
13e3bf25
authored
16 years ago
by
clc5q
Browse files
Options
Downloads
Patches
Plain Diff
Code cleanup to compile on Visual Studio.
parent
5850c5a3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ProfilerInformation.cpp
+67
-46
67 additions, 46 deletions
ProfilerInformation.cpp
with
67 additions
and
46 deletions
ProfilerInformation.cpp
+
67
−
46
View file @
13e3bf25
#include
<cstdlib>
#include
"ProfilerInformation.h"
#define qfeof feof
/*
* ascii-to-longlong conversion; Visual Studio 2005 lacks atoll() library func
*
* no error checking; assumes decimal digits
*
* efficient conversion:
* start with value = 0
* then, starting at first character, repeat the following
* until the end of the string:
*
* new value = (10 * (old value)) + decimal value of next character
*
*/
long
long
my_atoll
(
char
*
instr
)
{
long
long
retval
=
0
;
for
(;
*
instr
;
++
instr
)
{
retval
=
10
*
retval
+
(
*
instr
-
'0'
);
}
return
retval
;
}
#ifdef WIN32
#define atoll my_atoll
#endif
ProfilerInformation
::
ProfilerInformation
(
const
char
*
fn
)
:
filename
(
std
::
string
(
fn
))
{
FILE
*
fin
;
int
addr
;
union
{
int
size
,
type
;}
size_type_u
;
union
{
int
size
,
type
;}
size_type_u
;
char
type
[
200
];
char
scope
[
200
];
char
remainder
[
2000
];
int
line
=
0
;
if
(
fn
[
0
]
==
0
)
if
(
fn
[
0
]
==
0
)
return
;
fin
=
qfopen
(
fn
,
"r"
);
fin
=
qfopen
(
fn
,
"r"
);
if
(
!
fin
)
if
(
!
fin
)
{
msg
(
"Cannot open strata annotation file %s
\n
"
,
fn
);
return
;
...
...
@@ -36,26 +62,26 @@ ProfilerInformation::ProfilerInformation(const char* fn)
{
qfscanf
(
fin
,
"%x %d
\n
"
,
&
addr
,
&
size_type_u
);
if
(
qfeof
(
fin
))
// deal with blank lines at the EOF
if
(
qfeof
(
fin
))
// deal with blank lines at the EOF
break
;
qfscanf
(
fin
,
"%s%s"
,
type
,
scope
);
/* if the size > 0, then this is a declaration of a variable */
if
(
strcmp
(
type
,
"FUNC"
)
==
0
)
if
(
strcmp
(
type
,
"FUNC"
)
==
0
)
{
// no useful info for the SA.
;
// no useful info for the SA.
}
else
if
(
strcmp
(
type
,
"MEMORYHOLE"
)
==
0
)
else
if
(
strcmp
(
type
,
"MEMORYHOLE"
)
==
0
)
{
// no useful info for the SA.
}
else
if
(
strcmp
(
type
,
"INSTR"
)
==
0
)
else
if
(
strcmp
(
type
,
"INSTR"
)
==
0
)
{
// no useful info for the SA.
}
else
if
(
strcmp
(
type
,
"PTRIMMEDEBP"
)
==
0
||
else
if
(
strcmp
(
type
,
"PTRIMMEDEBP"
)
==
0
||
strcmp
(
type
,
"PTRIMMEDESP"
)
==
0
||
strcmp
(
type
,
"PTRIMMEDESP2"
)
==
0
||
strcmp
(
type
,
"PTRIMMEDABSOLUTE"
)
==
0
...
...
@@ -64,25 +90,24 @@ ProfilerInformation::ProfilerInformation(const char* fn)
int
the_const
;
int
real_const
=
0
;
char
field
[
100
];
assert
(
strcmp
(
scope
,
"STACK"
)
==
0
||
strcmp
(
scope
,
"GLOBAL"
)
==
0
);
assert
(
strcmp
(
scope
,
"STACK"
)
==
0
||
strcmp
(
scope
,
"GLOBAL"
)
==
0
);
/* remaining params are <const> <field> <real_const_if_global> <comment> */
qfscanf
(
fin
,
"%d %s"
,
&
the_const
,
field
);
if
(
strcmp
(
type
,
"PTRIMMEDESP2"
)
==
0
||
strcmp
(
type
,
"PTRIMMEDABSOLUTE"
)
==
0
)
if
(
strcmp
(
type
,
"PTRIMMEDESP2"
)
==
0
||
strcmp
(
type
,
"PTRIMMEDABSOLUTE"
)
==
0
)
qfscanf
(
fin
,
"%x"
,
&
real_const
);
else
real_const
=
the_const
;
// successfully read in, but, ignoring for now.
if
(
strcmp
(
type
,
"PTRIMMEDESP2"
)
==
0
||
strcmp
(
type
,
"PTRIMMEDABSOLUTE"
)
==
0
)
if
(
strcmp
(
type
,
"PTRIMMEDESP2"
)
==
0
||
strcmp
(
type
,
"PTRIMMEDABSOLUTE"
)
==
0
)
{
profileAddressingInformation
(
addr
,
size_type_u
.
size
,
type
,
scope
,
the_const
,
field
,
real_const
);
}
}
else
if
(
strcmp
(
type
,
"DATAREF"
)
==
0
)
else
if
(
strcmp
(
type
,
"DATAREF"
)
==
0
)
{
// no useful info for the SA.
...
...
@@ -93,17 +118,17 @@ ProfilerInformation::ProfilerInformation(const char* fn)
assert
(
strcmp
(
scope
,
"STACK"
)
==
0
);
/* remaining params: comment */
}
else
if
(
strcmp
(
type
,
"PROFILEDNUMERIC"
)
==
0
)
else
if
(
strcmp
(
type
,
"PROFILEDNUMERIC"
)
==
0
)
{
/* profiler generated information */
addProfileInformation
(
addr
,
atoll
(
scope
),
0
,
0
);
}
else
if
(
strcmp
(
type
,
"PROFILEDPOINTER"
)
==
0
)
else
if
(
strcmp
(
type
,
"PROFILEDPOINTER"
)
==
0
)
{
/* profiler generated information */
addProfileInformation
(
addr
,
0
,
atoll
(
scope
),
0
);
}
else
if
(
strcmp
(
type
,
"PROFILEDOTHER"
)
==
0
)
else
if
(
strcmp
(
type
,
"PROFILEDOTHER"
)
==
0
)
{
/* profiler generated information */
addProfileInformation
(
addr
,
0
,
0
,
atoll
(
scope
));
...
...
@@ -115,23 +140,21 @@ ProfilerInformation::ProfilerInformation(const char* fn)
qfgets
(
remainder
,
sizeof
(
remainder
),
fin
);
line
++
;
}
while
(
!
qfeof
(
fin
));
}
while
(
!
qfeof
(
fin
));
qfclose
(
fin
);
msg
(
"Successfully loaded annotation file %s
\n
"
,
fn
);
}
ProfilerInformation
::~
ProfilerInformation
()
{
FILE
*
fout
=
qfopen
(
filename
.
c_str
(),
"a+"
);
ProfilerInformation
::~
ProfilerInformation
()
{
FILE
*
fout
=
qfopen
(
filename
.
c_str
(),
"a+"
);
if
(
!
fout
)
{
if
(
!
fout
)
{
msg
(
"Cannot open annotations file (%s) for output
\n
"
,
filename
.
c_str
());
assert
(
0
);
assert
(
fout
);
}
for
(
std
::
set
<
std
::
string
>::
iterator
iter
=
constant_info
.
begin
();
for
(
std
::
set
<
std
::
string
>::
iterator
iter
=
constant_info
.
begin
();
iter
!=
constant_info
.
end
();
++
iter
)
...
...
@@ -139,27 +162,27 @@ ProfilerInformation::~ProfilerInformation()
qfprintf
(
fout
,
"%s"
,
(
*
iter
).
c_str
());
}
for
(
std
::
map
<
ea_t
,
InstructionInformation
*>::
iterator
iter
=
the_map
.
begin
();
for
(
std
::
map
<
ea_t
,
InstructionInformation
*>::
iterator
iter
=
the_map
.
begin
();
iter
!=
the_map
.
end
();
++
iter
)
{
ea_t
addr
=
(
*
iter
).
first
;
InstructionInformation
*
ii
=
(
*
iter
).
second
;
if
(
ii
)
if
(
ii
)
{
if
(
ii
->
getNumericCount
())
if
(
ii
->
getNumericCount
())
{
qfprintf
(
fout
,
"%x %d %s %d Profiler generated, summarized by idal
\n
"
,
addr
,
0
,
"PROFILEDNUMERIC"
,
ii
->
getNumericCount
());
}
if
(
ii
->
getPointerCount
())
if
(
ii
->
getPointerCount
())
{
qfprintf
(
fout
,
"%x %d %s %d Profiler generated, summarized by idal
\n
"
,
addr
,
0
,
"PROFILEDPOINTER"
,
ii
->
getPointerCount
());
}
if
(
ii
->
getOtherCount
())
if
(
ii
->
getOtherCount
())
{
qfprintf
(
fout
,
"%x %d %s %d Profiler generated, summarized by idal
\n
"
,
addr
,
0
,
"PROFILEDOTHER"
,
ii
->
getOtherCount
());
...
...
@@ -172,22 +195,20 @@ ProfilerInformation::~ProfilerInformation()
}
void
ProfilerInformation
::
addProfileInformation
(
ea_t
addr
,
long
long
nc
,
long
long
pc
,
long
long
oc
)
{
InstructionInformation
*
ii
=
GetInfo
(
addr
);
void
ProfilerInformation
::
addProfileInformation
(
ea_t
addr
,
long
long
nc
,
long
long
pc
,
long
long
oc
)
{
InstructionInformation
*
ii
=
GetInfo
(
addr
);
if
(
!
ii
)
{
if
(
!
ii
)
{
ii
=
new
InstructionInformation
;
SetInfo
(
addr
,
ii
);
SetInfo
(
addr
,
ii
);
}
if
(
nc
)
ii
->
setNumericCount
(
nc
);
if
(
pc
)
ii
->
setPointerCount
(
pc
);
if
(
oc
)
ii
->
setOtherCount
(
oc
);
if
(
nc
)
ii
->
setNumericCount
(
(
int
)
nc
);
if
(
pc
)
ii
->
setPointerCount
(
(
int
)
pc
);
if
(
oc
)
ii
->
setOtherCount
(
(
int
)
oc
);
// msg("Profiled %x to be nc:%lld pc:%lld oc:%lld\n", addr,
// ii->getNumericCount(),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment