diff options
| author | Alistair Popple <alistair@popple.id.au> | 2018-11-09 12:10:23 +1100 |
|---|---|---|
| committer | Alistair Popple <alistair@popple.id.au> | 2018-11-09 12:18:16 +1100 |
| commit | 5bf4a0142b58d60a9c09aea0930aa612f46053a9 (patch) | |
| tree | 0595ece2fcb4690dc187c06149d7d0c4c4887835 /src | |
| parent | 60b2ec3a95ddebd8943bdf5d61f700d7d2fca923 (diff) | |
| download | pdbg-5bf4a0142b58d60a9c09aea0930aa612f46053a9.tar.gz pdbg-5bf4a0142b58d60a9c09aea0930aa612f46053a9.zip | |
device.c: Fix pdbg_target_address
Commit 936dbdcedb27 ("libpdbg: Rework target addressing") introduced a
bug leading to the following assertion failing:
pdbg: libpdbg/device.c:634: pdbg_target_address: Assertion `(pos + n) <= p->len' failed.
When this function was reworked the index parameter was dropped as
every caller set index == 0. Removal should have also resulted in the
local pos variable being removed. Instead it was set as if index == 1
resulting in the above violation.
Fix the bug and add a test to check pdbg_target_address().
Signed-off-by: Alistair Popple <alistair@popple.id.au>
Diffstat (limited to 'src')
| -rw-r--r-- | src/tests/libpdbg_target_test.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/tests/libpdbg_target_test.c b/src/tests/libpdbg_target_test.c index 6b64326..eb5e0f4 100644 --- a/src/tests/libpdbg_target_test.c +++ b/src/tests/libpdbg_target_test.c @@ -63,7 +63,7 @@ int main(void) { struct pdbg_target *root, *target, *parent, *parent2; const char *name; - int count; + int count, i; pdbg_targets_init(&_binary_fake_dtb_o_start); @@ -161,7 +161,10 @@ int main(void) assert(!strncmp(name, "pib", 3)); } + i = 0; pdbg_for_each_class_target("core", target) { + uint64_t addr, size; + parent = pdbg_target_parent("fsi", target); assert(parent); @@ -203,6 +206,11 @@ int main(void) name = pdbg_target_dn_name(target); assert(!strncmp(name, "core", 4)); + + addr = pdbg_target_address(target, &size); + assert(size == 0); + assert(addr == 0x10000 + (i / 4)*0x1000 + ((i % 4) + 1)*0x10); + i++; } pdbg_for_each_class_target("thread", target) { |

