** Get a "base line" to find the line corresponding to an instruction. ** For that, search the array of absolute line info for the largest saved ** instruction smaller or equal to the wanted instruction. A special ** case is when there is no absolute info or the instruction is before ** the first absolute one. */
| 56 | ** the first absolute one. |
| 57 | */ |
| 58 | static int getbaseline (const Proto *f, int pc, int *basepc) { |
| 59 | if (f->sizeabslineinfo == 0 || pc < f->abslineinfo[0].pc) { |
| 60 | *basepc = -1; /* start from the beginning */ |
| 61 | return f->linedefined; |
| 62 | } |
| 63 | else { |
| 64 | unsigned int i; |
| 65 | if (pc >= f->abslineinfo[f->sizeabslineinfo - 1].pc) |
| 66 | i = f->sizeabslineinfo - 1; /* instruction is after last saved one */ |
| 67 | else { /* binary search */ |
| 68 | unsigned int j = f->sizeabslineinfo - 1; /* pc < anchorlines[j] */ |
| 69 | i = 0; /* abslineinfo[i] <= pc */ |
| 70 | while (i < j - 1) { |
| 71 | unsigned int m = (j + i) / 2; |
| 72 | if (pc >= f->abslineinfo[m].pc) |
| 73 | i = m; |
| 74 | else |
| 75 | j = m; |
| 76 | } |
| 77 | } |
| 78 | *basepc = f->abslineinfo[i].pc; |
| 79 | return f->abslineinfo[i].line; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | |
| 84 | /* |