public inbox for gdb-testers@sourceware.org help / color / mirror / Atom feed
From: sergiodj+buildbot@sergiodj.net To: gdb-testers@sourceware.org Subject: [binutils-gdb] Add unit test to gdbarch methods register_to_value and value_to_register Date: Thu, 25 May 2017 00:29:00 -0000 [thread overview] Message-ID: <b77b02a5ca5a021ee8b5e5453e8843447d1132b2@gdb-build> (raw) *** TEST RESULTS FOR COMMIT b77b02a5ca5a021ee8b5e5453e8843447d1132b2 *** Author: Yao Qi <yao.qi@linaro.org> Branch: master Commit: b77b02a5ca5a021ee8b5e5453e8843447d1132b2 Add unit test to gdbarch methods register_to_value and value_to_register This patch adds one unit test for gdbarch methods register_to_value and value_to_register. The test pass different combinations of {regnu, type} to gdbarch_register_to_value and gdbarch_value_to_register. In order to do the test, add a new function create_new_frame to create a fake frame. It can be improved after we converted frame_info to class. In order to isolate regcache (from target_ops operations on writing registers, like target_store_registers), the sub-class of regcache in the test override raw_write. Also, in order to get the right regcache from get_thread_arch_aspace_regcache, the sub-class of regcache inserts itself to current_regcache. Suppose I incorrectly modified the size of buffer as below, @@ -1228,7 +1228,7 @@ ia64_register_to_value (struct frame_info *frame, int regnum, int *optimizedp, int *unavailablep) { struct gdbarch *gdbarch = get_frame_arch (frame); - gdb_byte in[MAX_REGISTER_SIZE]; + gdb_byte in[1]; /* Convert to TYPE. */ if (!get_frame_register_bytes (frame, regnum, 0, build GDB with "-fsanitize=address" and run unittest.exp, asan can detect such error ==2302==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff98193870 at pc 0xbd55ea bp 0x7fff981935a0 sp 0x7fff98193598 WRITE of size 16 at 0x7fff98193870 thread T0 #0 0xbd55e9 in frame_register_unwind(frame_info*, int, int*, int*, lval_type*, unsigned long*, int*, unsigned char*) /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1119 #1 0xbd58c8 in frame_register(frame_info*, int, int*, int*, lval_type*, unsigned long*, int*, unsigned char*) /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1147 #2 0xbd6e25 in get_frame_register_bytes(frame_info*, int, unsigned long, int, unsigned char*, int*, int*) /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1427 #3 0x70080a in ia64_register_to_value /home/yao/SourceCode/gnu/gdb/git/gdb/ia64-tdep.c:1236 #4 0xbf570e in gdbarch_register_to_value(gdbarch*, frame_info*, int, type*, unsigned char*, int*, int*) /home/yao/SourceCode/gnu/gdb/git/gdb/gdbarch.c:2619 #5 0xc05975 in register_to_value_test /home/yao/SourceCode/gnu/gdb/git/gdb/gdbarch-selftests.c:131 Or, even if GDB is not built with asan, GDB just crashes. *** stack smashing detected ***: ./gdb terminated Aborted (core dumped) gdb: 2017-05-24 Yao Qi <yao.qi@linaro.org> * Makefile.in (SFILES): Add gdbarch-selftests.c. (COMMON_OBS): Add gdbarch-selftests.o. * frame.c [GDB_SELF_TESTS] (create_new_frame): New function. * frame.h [GDB_SELF_TESTS] (create_new_frame): Declare. * gdbarch-selftests.c: New file. * regcache.h (regcache) <~regcache>: Mark it virtual if GDB_SELF_TEST. <raw_write>: Likewise.
next reply other threads:[~2017-05-25 0:29 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-05-25 0:29 sergiodj+buildbot [this message] 2017-05-25 0:29 ` Failures on Fedora-s390x-m64, branch master sergiodj+buildbot 2017-05-25 3:51 ` Failures on Ubuntu-AArch64-native-gdbserver-m64, " sergiodj+buildbot 2017-05-25 4:25 ` Failures on Ubuntu-AArch64-m64, " sergiodj+buildbot 2017-05-25 6:09 ` Failures on Ubuntu-AArch32-native-gdbserver-m32, " sergiodj+buildbot 2017-05-25 6:33 ` Failures on Ubuntu-AArch32-native-extended-gdbserver-m32, " sergiodj+buildbot 2017-05-25 6:56 ` Failures on Ubuntu-AArch32-m32, " sergiodj+buildbot 2017-05-25 7:26 ` Failures on Fedora-x86_64-m64, " sergiodj+buildbot 2017-05-25 7:53 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " sergiodj+buildbot 2017-05-25 8:21 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " sergiodj+buildbot
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=b77b02a5ca5a021ee8b5e5453e8843447d1132b2@gdb-build \ --to=sergiodj+buildbot@sergiodj.net \ --cc=gdb-testers@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).