blob: df15c8ab435f0ab615bf5cec4f6adedb97a3a5f0 [file] [log] [blame]
Andres Amaya Garciaf2d17922017-10-24 22:47:14 +01001# test_zeroize.gdb
2#
3# This file is part of mbed TLS (https://tls.mbed.org)
4#
5# Copyright (c) 2017, ARM Limited, All Rights Reserved
6#
7# Purpose
8#
9# Run a test using the debugger to check that the mbedtls_zeroize() function in
10# utils.h is not being optimized out by the compiler. To do so, the script
11# loads the test program at programs/test/zeroize.c and sets a breakpoint at
12# the last return statement in the main(). When the breakpoint is hit, the
13# debugger manually checks the contents to be zeroized and checks that it is
14# actually cleared.
15#
16# Note: This test requires that the test program is compiled with -g3.
17
Andres Amaya Garciaddebc492017-10-24 22:16:34 +010018set confirm off
19file ./programs/test/zeroize
Andres Amaya Garcia7111a0d2017-10-31 21:28:31 +000020break zeroize.c:90
Andres Amaya Garciaddebc492017-10-24 22:16:34 +010021
22set args ./programs/test/zeroize.c
23run
24
25set $i = 0
26set $len = sizeof(buf)
27set $buf = buf
28
Andres Amaya Garciaddebc492017-10-24 22:16:34 +010029while $i < $len
30 if $buf[$i++] != 0
31 echo The buffer at was not zeroized\n
32 quit 1
33 end
34end
35
36echo The buffer was correctly zeroized\n
Andres Amaya Garcia806f4032017-11-01 10:03:36 +000037
38continue
39
40if $_exitcode != 0
41 echo The program did not terminate correctly\n
42 quit 1
43end
44
Andres Amaya Garciaddebc492017-10-24 22:16:34 +010045quit 0