Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zipr_unpin_plugin
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Open Source Software
zipr_unpin_plugin
Commits
1c1e26a1
Commit
1c1e26a1
authored
6 years ago
by
Jason Hiser
Browse files
Options
Downloads
Patches
Plain Diff
refactored to deal with options better
parent
3da58cb1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
unpin.cpp
+10
-8
10 additions, 8 deletions
unpin.cpp
unpin.h
+16
-10
16 additions, 10 deletions
unpin.h
with
26 additions
and
18 deletions
unpin.cpp
+
10
−
8
View file @
1c1e26a1
...
@@ -73,9 +73,10 @@ bool Unpin_t::should_cfi_pin(Instruction_t* insn)
...
@@ -73,9 +73,10 @@ bool Unpin_t::should_cfi_pin(Instruction_t* insn)
// add command line option that:
// add command line option that:
// 1) return false if !has_cfi_reloc(insn)
// 1) return false if !has_cfi_reloc(insn)
// 2) return true if option is on.
// 2) return true if option is on.
return
m_should_cfi_pin
;
return
*
m_should_cfi_pin
;
}
}
#if 0
ZiprOptionsNamespace_t *Unpin_t::registerOptions(ZiprOptionsNamespace_t *global)
ZiprOptionsNamespace_t *Unpin_t::registerOptions(ZiprOptionsNamespace_t *global)
{
{
auto unpin_ns = new ZiprOptionsNamespace_t("unpin");
auto unpin_ns = new ZiprOptionsNamespace_t("unpin");
...
@@ -92,6 +93,7 @@ ZiprOptionsNamespace_t *Unpin_t::registerOptions(ZiprOptionsNamespace_t *global)
...
@@ -92,6 +93,7 @@ ZiprOptionsNamespace_t *Unpin_t::registerOptions(ZiprOptionsNamespace_t *global)
return unpin_ns;
return unpin_ns;
}
}
#endif
// CAN BE DELETED, left in just for stats? (Would speed up zipr step to delete)
// CAN BE DELETED, left in just for stats? (Would speed up zipr step to delete)
void
Unpin_t
::
DoUnpin
()
void
Unpin_t
::
DoUnpin
()
...
@@ -104,7 +106,7 @@ void Unpin_t::DoUnpin()
...
@@ -104,7 +106,7 @@ void Unpin_t::DoUnpin()
// scan instructions and process instruction relocs that can be unpinned.
// scan instructions and process instruction relocs that can be unpinned.
void
Unpin_t
::
DoUnpinForFixedCalls
()
void
Unpin_t
::
DoUnpinForFixedCalls
()
{
{
if
(
m_max_unpins
!=
-
1
&&
unpins
>=
m_max_unpins
)
if
(
*
m_max_unpins
!=
-
1
&&
unpins
>=
*
m_max_unpins
)
return
;
return
;
auto
insn_unpins
=
0
;
auto
insn_unpins
=
0
;
auto
missed_unpins
=
0
;
auto
missed_unpins
=
0
;
...
@@ -128,7 +130,7 @@ void Unpin_t::DoUnpinForFixedCalls()
...
@@ -128,7 +130,7 @@ void Unpin_t::DoUnpinForFixedCalls()
unpins
++
;
unpins
++
;
insn_unpins
++
;
insn_unpins
++
;
if
(
m_max_unpins
!=
-
1
&&
unpins
>=
m_max_unpins
)
if
(
*
m_max_unpins
!=
-
1
&&
unpins
>=
*
m_max_unpins
)
return
;
return
;
}
}
}
}
...
@@ -141,7 +143,7 @@ void Unpin_t::DoUnpinForFixedCalls()
...
@@ -141,7 +143,7 @@ void Unpin_t::DoUnpinForFixedCalls()
// CAN BE DELETED, left in just for stats?
// CAN BE DELETED, left in just for stats?
void
Unpin_t
::
DoUnpinForScoops
()
void
Unpin_t
::
DoUnpinForScoops
()
{
{
if
(
m_max_unpins
!=
-
1
&&
unpins
>=
m_max_unpins
)
if
(
*
m_max_unpins
!=
-
1
&&
unpins
>=
*
m_max_unpins
)
return
;
return
;
auto
missed_unpins
=
0
;
auto
missed_unpins
=
0
;
auto
scoop_unpins
=
0
;
auto
scoop_unpins
=
0
;
...
@@ -159,7 +161,7 @@ void Unpin_t::DoUnpinForScoops()
...
@@ -159,7 +161,7 @@ void Unpin_t::DoUnpinForScoops()
unpins
++
;
unpins
++
;
scoop_unpins
++
;
scoop_unpins
++
;
if
(
m_max_unpins
!=
-
1
&&
unpins
>=
m_max_unpins
)
if
(
*
m_max_unpins
!=
-
1
&&
unpins
>=
*
m_max_unpins
)
return
;
return
;
}
}
}
}
...
@@ -174,10 +176,10 @@ Zipr_SDK::ZiprPreference Unpin_t::retargetCallback(
...
@@ -174,10 +176,10 @@ Zipr_SDK::ZiprPreference Unpin_t::retargetCallback(
const
DollopEntry_t
*
callback_entry
,
const
DollopEntry_t
*
callback_entry
,
RangeAddress_t
&
target_address
)
RangeAddress_t
&
target_address
)
{
{
if
(
!
m_on
)
return
Zipr_SDK
::
ZiprPluginInterface_t
::
retargetCallback
(
callback_address
,
callback_entry
,
target_address
);
if
(
!
*
m_on
)
return
Zipr_SDK
::
ZiprPluginInterface_t
::
retargetCallback
(
callback_address
,
callback_entry
,
target_address
);
unpins
++
;
// unpinning a call to a scoop.
unpins
++
;
// unpinning a call to a scoop.
if
(
m_max_unpins
!=
-
1
&&
unpins
>=
m_max_unpins
)
if
(
*
m_max_unpins
!=
-
1
&&
unpins
>=
*
m_max_unpins
)
return
Zipr_SDK
::
ZiprPluginInterface_t
::
retargetCallback
(
callback_address
,
callback_entry
,
target_address
);
return
Zipr_SDK
::
ZiprPluginInterface_t
::
retargetCallback
(
callback_address
,
callback_entry
,
target_address
);
...
@@ -193,7 +195,7 @@ Zipr_SDK::ZiprPreference Unpin_t::retargetCallback(
...
@@ -193,7 +195,7 @@ Zipr_SDK::ZiprPreference Unpin_t::retargetCallback(
target_address
=
wrt
->
getStart
()
->
getVirtualOffset
()
+
addend
;
target_address
=
wrt
->
getStart
()
->
getVirtualOffset
()
+
addend
;
if
(
m_verbose
)
{
if
(
*
m_verbose
)
{
cout
<<
"Unpin::callback_to_scoop: target_addr "
cout
<<
"Unpin::callback_to_scoop: target_addr "
<<
std
::
hex
<<
target_address
<<
endl
;
<<
std
::
hex
<<
target_address
<<
endl
;
}
}
...
...
This diff is collapsed.
Click to expand it.
unpin.h
+
16
−
10
View file @
1c1e26a1
...
@@ -40,17 +40,23 @@ class Unpin_t : public Zipr_SDK::ZiprPluginInterface_t
...
@@ -40,17 +40,23 @@ class Unpin_t : public Zipr_SDK::ZiprPluginInterface_t
Unpin_t
(
Zipr_SDK
::
Zipr_t
*
zipr_object
)
Unpin_t
(
Zipr_SDK
::
Zipr_t
*
zipr_object
)
:
:
zo
(
zipr_object
),
zo
(
zipr_object
),
m_verbose
(
"verbose"
,
false
),
m_should_cfi_pin
(
"should_cfi_pin"
,
false
)
,
m_on
(
"on"
,
true
),
m_max_unpins
(
"max-unpins"
,
-
1
),
unpins
(
0
),
unpins
(
0
),
missed_unpins
(
0
),
missed_unpins
(
0
),
ms
(
*
zo
->
getMemorySpace
()),
ms
(
*
zo
->
getMemorySpace
()),
locMap
(
*
(
zo
->
getLocationMap
())),
locMap
(
*
(
zo
->
getLocationMap
())),
firp
(
*
(
zo
->
getFileIR
()))
firp
(
*
(
zo
->
getFileIR
()))
{
}
{
auto
global
=
zo
->
getOptionsManager
()
->
getNamespace
(
"global"
);
auto
unpin
=
zo
->
getOptionsManager
()
->
getNamespace
(
"unpin"
);
m_verbose
=
global
->
getBooleanOption
(
"verbose"
);
m_should_cfi_pin
=
unpin
->
getBooleanOption
(
"should_cfi_pin"
,
"Pin CFI instructions."
,
false
);
m_on
=
unpin
->
getBooleanOption
(
"on"
,
"Turn unpin plugin on/off."
,
true
);
m_max_unpins
=
unpin
->
getIntegerOption
(
"max-unpins"
,
"Set how many unpins are allowed, useful for debugging."
,
-
1
);
}
virtual
~
Unpin_t
()
virtual
~
Unpin_t
()
{
}
{
}
...
@@ -66,7 +72,7 @@ class Unpin_t : public Zipr_SDK::ZiprPluginInterface_t
...
@@ -66,7 +72,7 @@ class Unpin_t : public Zipr_SDK::ZiprPluginInterface_t
DoUpdate
();
DoUpdate
();
}
}
virtual
Zipr_SDK
::
ZiprOptionsNamespace_t
*
registerOptions
(
Zipr_SDK
::
ZiprOptionsNamespace_t
*
)
override
;
//
virtual Zipr_SDK::ZiprOptionsNamespace_t *registerOptions(Zipr_SDK::ZiprOptionsNamespace_t *) override;
Zipr_SDK
::
ZiprPreference
retargetCallback
(
Zipr_SDK
::
ZiprPreference
retargetCallback
(
const
Zipr_SDK
::
RangeAddress_t
&
callback_address
,
const
Zipr_SDK
::
RangeAddress_t
&
callback_address
,
...
@@ -93,10 +99,10 @@ class Unpin_t : public Zipr_SDK::ZiprPluginInterface_t
...
@@ -93,10 +99,10 @@ class Unpin_t : public Zipr_SDK::ZiprPluginInterface_t
Zipr_SDK
::
Zipr_t
*
zo
;
Zipr_SDK
::
Zipr_t
*
zo
;
Zipr_SDK
::
ZiprBooleanOption_t
m_verbose
;
Zipr_SDK
::
ZiprBooleanOption_t
*
m_verbose
;
Zipr_SDK
::
ZiprBooleanOption_t
m_should_cfi_pin
;
Zipr_SDK
::
ZiprBooleanOption_t
*
m_should_cfi_pin
;
Zipr_SDK
::
ZiprBooleanOption_t
m_on
;
Zipr_SDK
::
ZiprBooleanOption_t
*
m_on
;
Zipr_SDK
::
ZiprIntegerOption_t
m_max_unpins
;
Zipr_SDK
::
ZiprIntegerOption_t
*
m_max_unpins
;
int
unpins
;
int
unpins
;
int
missed_unpins
=
0
;
int
missed_unpins
=
0
;
...
...
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