diff options
author | Vladimir Mezentsev <vladimir.mezentsev@oracle.com> | 2023-05-11 17:30:18 -0700 |
---|---|---|
committer | Vladimir Mezentsev <vladimir.mezentsev@oracle.com> | 2023-05-16 12:04:51 -0700 |
commit | b5fbb4c2b468bc776ba71e2c4ef692f095e034bd (patch) | |
tree | fb8180b2548ad51fdfd36da74463a62948f7533e /gprofng | |
parent | 68b25a74aa492fa84bc530b471036d762cf772bf (diff) | |
download | binutils-b5fbb4c2b468bc776ba71e2c4ef692f095e034bd.zip binutils-b5fbb4c2b468bc776ba71e2c4ef692f095e034bd.tar.gz binutils-b5fbb4c2b468bc776ba71e2c4ef692f095e034bd.tar.bz2 |
gprofng: include a new function in the right place
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.
Diffstat (limited to 'gprofng')
-rw-r--r-- | gprofng/src/LoadObject.cc | 63 |
1 files changed, 18 insertions, 45 deletions
diff --git a/gprofng/src/LoadObject.cc b/gprofng/src/LoadObject.cc index f57db60..9601dee 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); |