This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfa/mips] Stop backtraces when we've lost the PC


{
int low, mid, high;
char *ptr;
+ CORE_ADDR pdr_pc;
low = 0;
high = priv->size / 32;
+ /* First, find the last .pdr entry starting at or before PC. */

A summary here of what the objective is and what / why the follow on code is doing.


do
{
- CORE_ADDR pdr_pc;
-
mid = (low + high) / 2;
ptr = priv->contents + mid * 32;
pdr_pc = bfd_get_signed_32 (sec->objfile->obfd, ptr);
pdr_pc += ANOFFSET (sec->objfile->section_offsets,
SECT_OFF_TEXT (sec->objfile));

-	      if (pdr_pc == startaddr)
+	      if (pdr_pc == pc)
 		break;

-	      if (pdr_pc > startaddr)
+	      if (pdr_pc > pc)
 		high = mid;
 	      else
 		low = mid + 1;

}

while (low != high);

Other than that, just an observation that the binary search is [already] pretty messed up. In all likelyhood the test:


if (pdr_pc == pc)

will never fire and having it gains little if anything (one less iteration VS logN extra compares). Eliminating it means cleaning up the binary search though. Can you attach a fixme to that test indicating that it should be eliminated.

I also suspect that STARTADDR's computation can be delayed until it is needed (the latter reference that goes with the "pathological", should no longer occure, I think it has been moved into symbol reading. However, leave that for the moment.

Otherwize ok, and way better than the original patch, thanks,

Andrew



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]