etm: prevent segfault when reading bogus information
commitd1ae39efc02bb67bc637ec92b5f60254c8ac959f
authorPaul Fertser <fercerpav@gmail.com>
Tue, 16 Jul 2013 07:29:15 +0000 (16 11:29 +0400)
committerSpencer Oliver <spen@spen-soft.co.uk>
Wed, 17 Jul 2013 14:34:07 +0000 (17 14:34 +0000)
treea06fa8924759760d7d22596e4143578cf36b6e4d
parentd18807e7bc43228e214563ba15fd7b24acb2f8f3
etm: prevent segfault when reading bogus information

When I do not have the JTAG adapter connected to the target, I often
end up always reading 1s from the chain. If the OpenOCD is configured
to connect to an ETM-equipped target (i.MX25 ARM9 in my case), this
results in writing garbage values in the etm reg_cache as the ETM bit
fields for the comparators, counters and outputs are wider than the
amount of entries in the corresponding arrays. This later results in a
segfault in the first etm_reg_lookup() call.

Change-Id: Ied81fdbf3a53a3dd749e2e5e97adf86c012df575
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/1505
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/target/etm.c