* [Review is neded] gprofng: include a new function in the right place
@ 2023-05-13 17:29 vladimir.mezentsev
0 siblings, 0 replies; only message in thread
From: vladimir.mezentsev @ 2023-05-13 17:29 UTC (permalink / raw)
To: binutils; +Cc: Vladimir Mezentsev
From: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
If there are no rejections, on Tuestday I will apply my fixes.
It is tested on x86_64 and aarch64.
Static function name is not available in stripped libraries.
In this case, gprofng maps PC to a fake function like <static>@0xPC (<libname>).
Sometimes gprofng creates two functions instead of one.
Also FUNC_FLAG_SIMULATED is needed for these fake functions.
gprofng/ChangeLog
2023-05-11 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
* src/LoadObject.cc (LoadObject::find_function): Set FUNC_FLAG_SIMULATED.
Include a new function in the right place.
---
gprofng/src/LoadObject.cc | 63 +++++++++++----------------------------
1 file changed, 18 insertions(+), 45 deletions(-)
diff --git a/gprofng/src/LoadObject.cc b/gprofng/src/LoadObject.cc
index f57db6001a9..9601dee7bd9 100644
--- a/gprofng/src/LoadObject.cc
+++ b/gprofng/src/LoadObject.cc
@@ -445,59 +445,31 @@ LoadObject::find_function (uint64_t foff)
if (func == NULL)
{
int last = functions->size () - 1;
- uint64_t usize = (uint64_t) size;
- if (foff >= usize)
+ uint64_t usize = size < 0 ? 0 : (uint64_t) size;
+ if (last < 0)
+ high_bound = foff >= usize ? foff : usize;
+ else if (left == 0)
+ high_bound = functions->fetch (left)->img_offset;
+ else if (left < last)
{
- // Cannot map to this LoadObject. Probably LoadObject was changed.
- if (last >= 0 && functions->fetch (last)->img_offset == usize)
- {
- // Function is already created
- func = functions->fetch (last);
- if (func->size < 0 || (uint64_t) func->size < foff - usize)
- func->size = foff - usize;
- }
- else
- {
- low_bound = size;
- high_bound = foff;
- func_name = dbe_sprintf (GTXT ("<static>@0x%llx (%s) -- no functions found"),
- low_bound, name);
- }
- }
- else if (last < 0)
- {
- low_bound = 0;
- high_bound = size;
- func_name = dbe_sprintf (GTXT ("<static>@0x%llx (%s) -- no functions found"),
- low_bound, name);
- }
- else if (foff < functions->fetch (0)->img_offset)
- {
- low_bound = 0;
- high_bound = functions->fetch (0)->img_offset;
+ Function *fp = functions->fetch (left - 1);
+ low_bound = fp->img_offset + fp->size;
+ high_bound = functions->fetch (left)->img_offset;
}
else
{
Function *fp = functions->fetch (last);
- if (foff >= fp->img_offset + fp->size)
+ if (fp->flags & FUNC_FLAG_SIMULATED)
{
- low_bound = fp->img_offset + fp->size;
- high_bound = size;
+ // Function is already created
+ func = fp;
+ if (func->size < foff - func->img_offset)
+ func->size = foff - func->img_offset;
}
else
{
- fp = functions->fetch (left);
- if (foff >= fp->img_offset + fp->size)
- {
- low_bound = fp->img_offset + fp->size;
- high_bound = functions->fetch (left + 1)->img_offset;
- }
- else
- {
- Function *fp1 = functions->fetch (left - 1);
- low_bound = fp1->img_offset + fp1->size;
- high_bound = fp->img_offset;
- }
+ low_bound = fp->img_offset + fp->size;
+ high_bound = foff > usize ? foff : usize;
}
}
}
@@ -505,6 +477,7 @@ LoadObject::find_function (uint64_t foff)
if (func == NULL)
{
func = dbeSession->createFunction ();
+ func->flags |= FUNC_FLAG_SIMULATED;
func->size = (unsigned) (high_bound - low_bound);
func->module = noname;
func->img_fname = get_pathname ();
@@ -512,7 +485,7 @@ LoadObject::find_function (uint64_t foff)
noname->functions->append (func); // unordered
if (func_name == NULL)
func_name = dbe_sprintf (GTXT ("<static>@0x%llx (%s)"), low_bound,
- name);
+ name);
func->set_name (func_name);
free (func_name);
--
2.31.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-13 17:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-13 17:29 [Review is neded] gprofng: include a new function in the right place vladimir.mezentsev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).