This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 12/16] test, btrace: more branch tracing tests


From: Barkha Ahuja <barkha.ahuja@intel.com>

Non-stop tests are failing with gdbserver.

    2012-05-23 Barkha Ahuja <barkha.ahuja@intel.com>

      gdb/testsuite/gdb.btrace/
      * a.s: New file
      * allthreads_trace.exp: New file
      * b.s: New file
      * decrement.exp: New file
      * decrement.s: New file
      * disable_all.exp: New file
      * enable_all.exp: New file
      * enable_range.exp: New file
      * list_options.exp: New file
      * main.s: New file
      * main_asm.exp: New file
      * main_segv.exp: New file
      * main_segv.s: New file
      * sanity_crash.exp: New file
      * sanity_crash.s: New file
      * thr_callback_32.s: New file
      * thr_callback_64.s: New file
      * threads.c: New file
      * threads_asm.c: New file
      * threads_auto.exp: New file
      * threads_independent.exp: New file
      * threads_nonstop.exp: New file
      * trace_iteration.exp: New file


---
 gdb/testsuite/gdb.btrace/a.s                     |   24 ++
 gdb/testsuite/gdb.btrace/allthreads_trace.exp    |  270 ++++++++++++++++++++++
 gdb/testsuite/gdb.btrace/b.s                     |   23 ++
 gdb/testsuite/gdb.btrace/decrement.exp           |  140 +++++++++++
 gdb/testsuite/gdb.btrace/decrement.s             |   32 +++
 gdb/testsuite/gdb.btrace/disable_all.exp         |  198 ++++++++++++++++
 gdb/testsuite/gdb.btrace/enable_all.exp          |  201 ++++++++++++++++
 gdb/testsuite/gdb.btrace/enable_range.exp        |  198 ++++++++++++++++
 gdb/testsuite/gdb.btrace/list_options.exp        |  107 +++++++++
 gdb/testsuite/gdb.btrace/main.s                  |   32 +++
 gdb/testsuite/gdb.btrace/main_asm.exp            |  113 +++++++++
 gdb/testsuite/gdb.btrace/main_segv.exp           |   84 +++++++
 gdb/testsuite/gdb.btrace/main_segv.s             |   28 +++
 gdb/testsuite/gdb.btrace/sanity_crash.exp        |   69 ++++++
 gdb/testsuite/gdb.btrace/sanity_crash.s          |   52 ++++
 gdb/testsuite/gdb.btrace/thr_callback_32.s       |  116 +++++++++
 gdb/testsuite/gdb.btrace/thr_callback_64.s       |  116 +++++++++
 gdb/testsuite/gdb.btrace/threads.c               |   96 ++++++++
 gdb/testsuite/gdb.btrace/threads_asm.c           |   78 +++++++
 gdb/testsuite/gdb.btrace/threads_auto.exp        |  113 +++++++++
 gdb/testsuite/gdb.btrace/threads_independent.exp |  119 ++++++++++
 gdb/testsuite/gdb.btrace/threads_nonstop.exp     |  182 +++++++++++++++
 gdb/testsuite/gdb.btrace/trace_iteration.exp     |  264 +++++++++++++++++++++
 23 files changed, 2655 insertions(+), 0 deletions(-)
 create mode 100755 gdb/testsuite/gdb.btrace/a.s
 create mode 100755 gdb/testsuite/gdb.btrace/allthreads_trace.exp
 create mode 100755 gdb/testsuite/gdb.btrace/b.s
 create mode 100755 gdb/testsuite/gdb.btrace/decrement.exp
 create mode 100755 gdb/testsuite/gdb.btrace/decrement.s
 create mode 100755 gdb/testsuite/gdb.btrace/disable_all.exp
 create mode 100755 gdb/testsuite/gdb.btrace/enable_all.exp
 create mode 100755 gdb/testsuite/gdb.btrace/enable_range.exp
 create mode 100755 gdb/testsuite/gdb.btrace/list_options.exp
 create mode 100755 gdb/testsuite/gdb.btrace/main.s
 create mode 100755 gdb/testsuite/gdb.btrace/main_asm.exp
 create mode 100755 gdb/testsuite/gdb.btrace/main_segv.exp
 create mode 100755 gdb/testsuite/gdb.btrace/main_segv.s
 create mode 100755 gdb/testsuite/gdb.btrace/sanity_crash.exp
 create mode 100755 gdb/testsuite/gdb.btrace/sanity_crash.s
 create mode 100755 gdb/testsuite/gdb.btrace/thr_callback_32.s
 create mode 100755 gdb/testsuite/gdb.btrace/thr_callback_64.s
 create mode 100755 gdb/testsuite/gdb.btrace/threads.c
 create mode 100755 gdb/testsuite/gdb.btrace/threads_asm.c
 create mode 100755 gdb/testsuite/gdb.btrace/threads_auto.exp
 create mode 100755 gdb/testsuite/gdb.btrace/threads_independent.exp
 create mode 100755 gdb/testsuite/gdb.btrace/threads_nonstop.exp
 create mode 100755 gdb/testsuite/gdb.btrace/trace_iteration.exp

diff --git a/gdb/testsuite/gdb.btrace/a.s b/gdb/testsuite/gdb.btrace/a.s
new file mode 100755
index 0000000..75e7ba3
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/a.s
@@ -0,0 +1,24 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corp. <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+	.text
+        .globl  callA
+        .type   callA, @function
+callA:
+	nop
+	ret
+        
\ No newline at end of file
diff --git a/gdb/testsuite/gdb.btrace/allthreads_trace.exp b/gdb/testsuite/gdb.btrace/allthreads_trace.exp
new file mode 100755
index 0000000..250e24d
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/allthreads_trace.exp
@@ -0,0 +1,270 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Barkha Ahuja <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+###############
+#Test Purpose: In GDB non-stop mode, Enable trace  for all the threads by "btr enable auto" on primary thread and check the trace availability for all the threads
+# Sourcefiles : threads_asm.c, thr_callback_32.s, thr_callback_64.s
+# Compiled using '-g -lpthread' option.
+#executed as :
+#                    make check  RUNTESTFLAGS="GDB=<path to gdb>  gdb.trace/allthreads_trace.exp"
+###############
+
+load_lib btrace.exp
+
+# start fresh - without an executable
+gdb_exit
+gdb_start
+
+global srcdir
+global objdir
+global subdir
+
+set srcfilemain ${srcdir}/${subdir}/threads_asm.c
+set objcallback ${objdir}/${subdir}/thr_callback.o
+set objmain ${objdir}/${subdir}/threads_asm.o
+set binfile ${objdir}/${subdir}/allthreads_trace.x
+set options "{debug}"
+
+#Load different callback files for 32 and 64 bit.
+# 32 bit platform
+if {[ishost "i?86-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/thr_callback_32.s
+} elseif {[ishost "x86_64-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/thr_callback_64.s
+} else {
+	warning "host platform not supported "
+	untested allthreads_trace.exp
+	return -1
+}
+set objfiles "${objmain}  ${objcallback}"
+
+#compile
+if {[gdb_compile_pthreads ${srcfilemain} ${objmain} "object" ${options}] != ""} {
+	untested allthreads_trace.exp
+	return -1
+}
+if {[gdb_compile ${srccallback} ${objcallback} "object" ${options}] != ""} {
+	untested allthreads_trace.exp
+	return -1
+}
+
+if {[gdb_compile_pthreads ${objfiles} ${binfile} "executable" ${options}] != ""} {
+	untested allthreads_trace.exp
+	return -1
+}
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+gdb_test_no_output "set pagination off"
+gdb_test_no_output "set target-async 1"
+gdb_test_no_output "set non-stop 1"
+
+runto main
+# set breakpoint at line 67, at call to mybarrier() for primary thread.
+gdb_breakpoint "67" "Breakpoint 2 at.*: file.*threads_asm.c, line 67." " breakpoint at line 67, 1.1"
+
+# set a breakpoint at mybarrier() to halt all the new threads from exiting.
+gdb_breakpoint "mybarrier" "Breakpoint 3, mybarrier \\(\\) at .*thr_callback_...s:114" "Breakpoint at my barrier for all the threads to stop, 1.2"
+
+# enable trace in primary thread, which automatically enables trace in all new threads crated.
+gdb_test "btr enable auto"
+send_gdb "continue\n"
+gdb_expect 8 {
+      -re "Breakpoint 3, mybarrier \\(\\) at.*thr_callback_...s:114.*"
+	{
+	  pass "continuing"
+	}
+      }
+# This "info threads" is needed to get a $gdb_prompt, since gdb seems to get hanged at this particular location.
+set test "info for threads"
+gdb_test_multiple "info threads" $test {
+	-re ".*\n" {
+		pass $test
+	}
+}
+
+# this is added to get the prompt, which is missing.
+gdb_test "" ""
+
+# We need to do a seperate listing from here, since the instr length is different
+# on different platforms.
+gdb_test "thread 2" ".*Switching to thread 2.*mybarrier.*" " switch to thread 2, 1.3"
+# 64 bit platform
+if {[ishost "x86_64-*-*"]} {
+
+# trace for thread 2
+gdb_test "btr list /a" "
+1     0x\[a-f0-9\]* - 0x\[a-f0-9\]*\r
+2     0x\[a-f0-9\]* - 0x\[a-f0-9\]*\r
+.*" "BTR listing for thread 2, 1.4"
+
+gdb_test "btr /m 1" "
+ *0x\[a-f0-9\]* <mybarrier\\+0>:\[\[:blank:\]\]*push.*\r
+ *0x\[a-f0-9\]* <mybarrier\\+1>:\[\[:blank:\]\]*mov.*\r
+=> *0x\[a-f0-9\]* <mybarrier\\+4>:\[\[:blank:\]\]*mov.*" " BTR of 1 for thread 2, 1.5"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <th_a\\+14>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <th_a\\+19>:\[\[:blank:\]\]*call.*" " BTR of 2 for thread 2, 1.6"
+
+# trace for thread 3
+gdb_test "thread 3" ".*Switching to thread 3.*mybarrier.*" " switch to thread 3, 1.7"
+
+gdb_test "btr list /la" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*thr_callback_64.s:112-114\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*thr_callback_64.s:44-45\r
+3 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*thr_callback_64.s:85-89\r
+4 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*thr_callback_64.s:40-43\r
+.*" "BTR listing for thread 3, 1.8"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <mybarrier\\+0>:\[\[:blank:\]\]*push.*\r
+ *0x\[a-f0-9\]* <mybarrier\\+1>:\[\[:blank:\]\]*mov.*\r
+=> *0x\[a-f0-9\]* <mybarrier\\+4>:\[\[:blank:\]\]*mov.*" " BTR of 1 for thread 3, 1.9"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <th_b\\+14>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <th_b\\+19>:\[\[:blank:\]\]*call.*" " BTR of 2 for thread 3, 1.10"
+
+# trace for thread 4
+gdb_test "thread 4" ".*Switching to thread 4.*mybarrier.*" " switch to thread 4, 1.11"
+
+gdb_test "btr list /lf" "
+1 *in mybarrier \\(\\) at.*thr_callback_64.s:112-114\r
+2 *in th_c \\(\\) at.*thr_callback_64.s:56-57\r
+3 *in call_C \\(\\) at.*thr_callback_64.s:94-98\r
+4 *in th_c \\(\\) at.*thr_callback_64.s:52-55\r
+.*" "BTR listing for thread 4, 1.12"
+
+gdb_test "btr /m 1" "
+ *0x\[a-f0-9\]* <mybarrier\\+0>:\[\[:blank:\]\]*push.*\r
+ *0x\[a-f0-9\]* <mybarrier\\+1>:\[\[:blank:\]\]*mov.*\r
+=> *0x\[a-f0-9\]* <mybarrier\\+4>:\[\[:blank:\]\]*mov.*" " BTR of 1 for thread 4, 1.13"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <th_c\\+14>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <th_c\\+19>:\[\[:blank:\]\]*call.*" " BTR of 2 for thread 4, 1.14"
+
+# trace for thread 5
+gdb_test "thread 5" ".*Switching to thread 5.*mybarrier.*" " switch to thread 5, 1.15"
+
+gdb_test "btr list /fa" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in mybarrier \\(\\)\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in th_d \\(\\)\r
+.*" "BTR listing for thread 5, 1.16"
+
+gdb_test "btr " "
+ *0x\[a-f0-9\]* <mybarrier\\+0>:\[\[:blank:\]\]*push.*\r
+ *0x\[a-f0-9\]* <mybarrier\\+1>:\[\[:blank:\]\]*mov.*\r
+=> *0x\[a-f0-9\]* <mybarrier\\+4>:\[\[:blank:\]\]*mov.*" " BTR of 1 for thread 5, 1.17"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <th_d\\+14>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <th_d\\+19>:\[\[:blank:\]\]*call.*" " BTR of 2 for thread 5, 1.18"
+
+ gdb_test "btr +" "
+ *0x\[a-f0-9\]* <call_D\\+0>:\[\[:blank:\]\]*push.*\r
+ *0x\[a-f0-9\]* <call_D\\+1>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <call_D\\+4>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <call_D\\+9>:\[\[:blank:\]\]*leave.*\r
+ *0x\[a-f0-9\]* <call_D\\+10>:\[\[:blank:\]\]*ret.*\r" " BTR of 3 for thread 5, 1.19"
+
+} elseif {[ishost "i?86-*-*"]} {
+# 32 bit platform
+
+#trace for thread 2
+gdb_test "btr list /a" "
+1     0x\[a-f0-9\]* - 0x\[a-f0-9\]*\r
+2     0x\[a-f0-9\]* - 0x\[a-f0-9\]*\r
+.*" "BTR listing for thread 2, 1.4"
+
+gdb_test "btr /m 1" "
+ *0x\[a-f0-9\]* <mybarrier\\+0>:\[\[:blank:\]\]*push.*\r
+ *0x\[a-f0-9\]* <mybarrier\\+1>:\[\[:blank:\]\]*mov.*\r
+=> *0x\[a-f0-9\]* <mybarrier\\+3>:\[\[:blank:\]\]*mov.*" " BTR of 1 for thread 2, 1.5"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <th_a\\+13>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <th_a\\+18>:\[\[:blank:\]\]*call.*" " BTR of 2 for thread 2, 1.6"
+
+gdb_test "thread 3" ".*Switching to thread 3.*mybarrier.*" " switch to thread 3, 1.7"
+
+#trace for thread 3
+gdb_test "btr list /la" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*thr_callback_32.s:112-114\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*thr_callback_32.s:44-45\r
+3 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*thr_callback_32.s:85-89\r
+4 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*thr_callback_32.s:40-43\r
+.*" "BTR listing for thread 3, 1.8"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <mybarrier\\+0>:\[\[:blank:\]\]*push.*\r
+ *0x\[a-f0-9\]* <mybarrier\\+1>:\[\[:blank:\]\]*mov.*\r
+=> *0x\[a-f0-9\]* <mybarrier\\+3>:\[\[:blank:\]\]*mov.*" " BTR of 1 for thread 3, 1.9"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <th_b\\+13>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <th_b\\+18>:\[\[:blank:\]\]*call.*" " BTR of 2 for thread 3, 1.10"
+
+gdb_test "thread 4" ".*Switching to thread 4.*mybarrier.*" " switch to thread 4, 1.11"
+
+#trace for thread 4
+gdb_test "btr list /lf" "
+1 *in mybarrier \\(\\) at.*thr_callback_32.s:112-114\r
+2 *in th_c \\(\\) at.*thr_callback_32.s:56-57\r
+3 *in call_C \\(\\) at.*thr_callback_32.s:94-98\r
+4 *in th_c \\(\\) at.*thr_callback_32.s:52-55\r
+.*" "BTR listing for thread 4, 1.12"
+
+gdb_test "btr /m 1" "
+ *0x\[a-f0-9\]* <mybarrier\\+0>:\[\[:blank:\]\]*push.*\r
+ *0x\[a-f0-9\]* <mybarrier\\+1>:\[\[:blank:\]\]*mov.*\r
+=> *0x\[a-f0-9\]* <mybarrier\\+3>:\[\[:blank:\]\]*mov.*" " BTR of 1 for thread 4, 1.13"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <th_c\\+13>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <th_c\\+18>:\[\[:blank:\]\]*call.*" " BTR of 2 for thread 4, 1.14"
+
+gdb_test "thread 5" ".*Switching to thread 5.*mybarrier.*" " switch to thread 5, 1.15"
+
+#trace for thread 5
+gdb_test "btr list /fa" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in mybarrier \\(\\)\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in th_d \\(\\)\r
+.*" "BTR listing for thread 5, 1.16"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <mybarrier\\+0>:\[\[:blank:\]\]*push.*\r
+ *0x\[a-f0-9\]* <mybarrier\\+1>:\[\[:blank:\]\]*mov.*\r
+=> *0x\[a-f0-9\]* <mybarrier\\+3>:\[\[:blank:\]\]*mov.*" " BTR of 1 for thread 5, 1.17"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <th_d\\+13>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <th_d\\+18>:\[\[:blank:\]\]*call.*" " BTR of 2 for thread 5, 1.18"
+
+ gdb_test "btr +" "
+ *0x\[a-f0-9\]* <call_D\\+0>:\[\[:blank:\]\]*push.*\r
+ *0x\[a-f0-9\]* <call_D\\+1>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <call_D\\+3>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <call_D\\+8>:\[\[:blank:\]\]*leave.*\r
+ *0x\[a-f0-9\]* <call_D\\+9>:\[\[:blank:\]\]*ret.*\r" " BTR of 3 for thread 5, 1.19"
+
+} else {
+  note "Platform not supported"
+  untested allthreads_trace.exp
+}
\ No newline at end of file
diff --git a/gdb/testsuite/gdb.btrace/b.s b/gdb/testsuite/gdb.btrace/b.s
new file mode 100755
index 0000000..271091f
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/b.s
@@ -0,0 +1,23 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corp. <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+	.text
+        .globl  callB
+        .type   callB, @function
+callB:
+	nop
+	ret
diff --git a/gdb/testsuite/gdb.btrace/decrement.exp b/gdb/testsuite/gdb.btrace/decrement.exp
new file mode 100755
index 0000000..11f3900
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/decrement.exp
@@ -0,0 +1,140 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Barkha Ahuja <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+###############
+#Test Purpose: Fix a location while linking, where teh debuggee will be loaded and then
+# see that trace gives the correct addresses.
+# Source file: decrement.s
+###############
+
+load_lib btrace.exp
+
+# start fresh - without an executable
+gdb_exit
+gdb_start
+
+set srcfile ${srcdir}/${subdir}/decrement.s
+set objfile ${objdir}/${subdir}/decrement.o
+set binfile ${objdir}/${subdir}/decrement.x
+set options "{debug}"
+#compile
+if {[target_assemble ${srcfile} ${objfile} ""] != ""} { return "" }
+#link
+if {[target_link ${objfile} ${binfile} " -Ttext 0x400400 "] != ""} {
+	untested decrement.exp
+	return -1
+}
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+
+# Make sure we don't die when enabling trace for a newly created thread.
+runto L1
+
+# Enable branch trace to trace the startup.
+gdb_test_no_output "btr enable"
+
+# Reset branch trace so we get predictable output.
+btrace_reset_trace
+
+gdb_test "next" "0x0*40041a in L1.*" ""
+
+gdb_test "btr list /lfa" "
+1 *0x0*40041a - 0x0*40041a in L1 \\(\\)" "list L1, 1.1"
+
+gdb_continue_to_breakpoint "L1"
+
+if {[ishost "x86_64-*-*"]} {
+#We enter the loop for 5 times from here.
+gdb_test "btr list /lfa" "
+1 *0x0*40041a - 0x0*40041a in L1 \\(\\)\r
+2 *0x0*40041a - 0x0*400421 in L1 \\(\\)" "list L1 again , 1.2"
+} elseif {[ishost "i?86-*-*"]} {
+#We enter the loop for 5 times from here.
+gdb_test "btr list /lfa" "
+1 *0x0*40041a - 0x0*40041a in L1 \\(\\)\r
+2 *0x0*40041a - 0x0*400420 in L1 \\(\\)" "list L1 again, 1.2"
+}
+
+#Delete all Breakpoints
+delete_breakpoints
+
+#Set a Breakpoint at L2
+gdb_breakpoint  "L2"
+
+#Continue to L2
+gdb_continue_to_breakpoint "L2"
+
+if {[ishost "x86_64-*-*"]} {
+# BTR listing in method L2, when the loop exits 
+gdb_test "btr list /lfa" "
+1 *0x0*400423 - 0x0*400423 in L2 \\(\\)\r
+2 *0x0*40041a - 0x0*40041d in L1 \\(\\)\r
+3 *0x0*40041a - 0x0*400421 in L1 \\(\\)\r
+4 *0x0*40041a - 0x0*400421 in L1 \\(\\)\r
+5 *0x0*40041a - 0x0*400421 in L1 \\(\\)\r
+6 *0x0*40041a - 0x0*400421 in L1 \\(\\)\r" "BTR listing at L2, 1.3"
+
+# Exit the loop
+gdb_test "btr /m 1" "
+=> 0x0*400423 *<L2\\+0>:\[\[:blank:\]\]*ret.*\r" "BTR at block 1, 1.4"
+
+# Comparison, if we are exiting the loop
+gdb_test "btr /m 2" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400423 *<L2>" "BTR at block 2, 1.5"
+
+#in the loop
+gdb_test "btr +" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400423 <L2>\r
+ *0x0*40041f *<L1\\+5>:\[\[:blank:\]\]*dec *%eax\r
+ *0x0*400421 *<L1\\+7>:\[\[:blank:\]\]*jmp *0x40041a <L1>" "BTR at block 3, 1.6"
+
+} elseif {[ishost "i?86-*-*"]} {
+# BTR listing in method L2, when the loop exits 
+gdb_test "btr list /lfa" "
+1 *0x0*400422 - 0x0*400422 in L2 \\(\\)\r
+2 *0x0*40041a - 0x0*40041d in L1 \\(\\)\r
+3 *0x0*40041a - 0x0*400420 in L1 \\(\\)\r
+4 *0x0*40041a - 0x0*400420 in L1 \\(\\)\r
+5 *0x0*40041a - 0x0*400420 in L1 \\(\\)\r
+6 *0x0*40041a - 0x0*400420 in L1 \\(\\)\r" "BTR listing at L2, 1.3"
+
+# Exit the loop
+gdb_test "btr /m 1" "
+=> 0x0*400422 *<L2\\+0>:\[\[:blank:\]\]*ret.*\r" "BTR at block 1, 1.4"
+
+# Comparison, if we are exiting the loop
+gdb_test "btr /m 2" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400422 *<L2>" "BTR at block 2, 1.5"
+
+#in the loop
+gdb_test "btr +" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400422 <L2>\r
+ *0x0*40041f *<L1\\+5>:\[\[:blank:\]\]*dec *%eax\r
+ *0x0*400420 *<L1\\+6>:\[\[:blank:\]\]*jmp *0x40041a <L1>" "BTR at block 3, 1.6"
+
+} else {
+	warning "host platform not supported "
+	return -1
+}
+
diff --git a/gdb/testsuite/gdb.btrace/decrement.s b/gdb/testsuite/gdb.btrace/decrement.s
new file mode 100755
index 0000000..c94a98a
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/decrement.s
@@ -0,0 +1,32 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corp. <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+#Decrements the number 5 by 1 untill it is 0. The
+	.text
+	.globl _start
+_start:
+	.align 0x10    		# 0x400010
+	movl $5, %eax
+	.align 0x10    		# 0x400010
+	movl $1, %ebx
+	call L1
+
+L1:	cmpl $0, %eax		#compare 0 with value in eax
+	je L2			        #jump to L2 if 0==eax (je - jump if equal)
+	decl %eax		        #decrement eax
+	jmp L1			# unconditional jump to L1
+L2: 	ret
diff --git a/gdb/testsuite/gdb.btrace/disable_all.exp b/gdb/testsuite/gdb.btrace/disable_all.exp
new file mode 100755
index 0000000..7f67503
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/disable_all.exp
@@ -0,0 +1,198 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Barkha Ahuja <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+###############
+#Test Purpose: In GDB non-stop mode, Enable trace  for all the threads by "btr enable auto" on primary thread and check the trace availability for all the threads
+# Sourcefiles : threads_asm.c, thr_callback_32.s, thr_callback_64.s
+# Compiled using '-g -lpthread' option.
+#executed on 32 bit as :
+#                    make check  RUNTESTFLAGS="GDB=/users/bahuja/work_gdb/gdb_32/gdb --host i686-linux-gnu --target i686-linux-gnu gdb.trace/thread_auto.exp"
+#executed on 64 bit as :
+#                    make check  RUNTESTFLAGS="GDB=/users/bahuja/work_gdb/gdb_32/gdb --host x86_64-linux-gnu --target x86_64-linux-gnu gdb.trace/thread_auto.exp"
+###############
+
+load_lib btrace.exp
+
+# start fresh - without an executable
+gdb_exit
+gdb_start
+
+global srcdir
+global objdir
+global subdir
+
+set srcfilemain ${srcdir}/${subdir}/threads_asm.c
+set objcallback ${objdir}/${subdir}/thr_callback.o
+set objmain ${objdir}/${subdir}/threads_asm.o
+set binfile ${objdir}/${subdir}/disable_all.x
+set options "{debug}"
+
+#Load different callback files for 32 and 64 bit.
+# 32 bit platform
+if {[ishost "i?86-*-*"]} {
+	note "This is 32 bit host."
+	set srccallback ${srcdir}/${subdir}/thr_callback_32.s
+} elseif {[ishost "x86_64-*-*"]} {
+	note "This is 64 bit host."
+	set srccallback ${srcdir}/${subdir}/thr_callback_64.s
+} else {
+	warning "host platform not supported "
+	untested disable_all.exp
+	return -1
+}
+set objfiles "${objmain}  ${objcallback}"
+
+#compile
+if {[gdb_compile_pthreads ${srcfilemain} ${objmain} "object" ${options}] != ""} {
+	untested disable_all.exp
+	return -1
+}
+if {[gdb_compile ${srccallback} ${objcallback} "object" ${options}] != ""} {
+	untested disable_all.exp
+	return -1
+}
+
+if {[gdb_compile_pthreads ${objfiles} ${binfile} "executable" ${options}] != ""} {
+	untested disable_all.exp
+	return -1
+}
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+gdb_test_no_output "set pagination off"
+gdb_test_no_output "set target-async 1"
+gdb_test_no_output "set non-stop 1"
+
+runto main
+# set breakpoint at line 67, at call to mybarrier() for primary thread.
+gdb_breakpoint "67" "Breakpoint 2 at.*: file.*threads_asm.c, line 67." " breakpoint at line 67, 1.1"
+
+# set a breakpoint at mybarrier() to halt all the new threads from exiting.
+gdb_breakpoint "mybarrier" "Breakpoint 3, mybarrier \\(\\) at .*thr_callback_...s:114" "Breakpoint at my barrier for all the threads to stop, 1.2"
+
+gdb_breakpoint "${srccallback}:35" "Breakpoint 4 at 0x\[a-f0-9\]*: file .*thr_callback_...s, line 35." "Breakpoint after the barrier for thread 2, 1.3"
+
+gdb_breakpoint "${srccallback}:47" "Breakpoint 5 at 0x\[a-f0-9\]*: file .*thr_callback_...s, line 47." "Breakpoint after the barrier for thread 3, 1.4"
+gdb_breakpoint "${srccallback}:59" "Breakpoint 6 at 0x\[a-f0-9\]*: file .*thr_callback_...s, line 59." "Breakpoint after the barrier for thread 4, 1.5"
+gdb_breakpoint "${srccallback}:71" "Breakpoint 7 at 0x\[a-f0-9\]*: file .*thr_callback_...s, line 71." "Breakpoint after the barrier for thread 5, 1.6"
+
+# enable trace in primary thread, which automatically enables trace in all new threads crated.
+gdb_test "btr enable auto"
+send_gdb "continue\n"
+gdb_expect 8 {
+      -re "Breakpoint 3, mybarrier \\(\\) at.*thr_callback_...s:114.*"
+	{
+	  pass "continuing"
+	}
+      }
+# This "info threads" is needed to get a $gdb_prompt, since gdb seems to get hanged at this particular location.
+set test "info for threads"
+gdb_test_multiple "info threads" $test {
+	-re ".*\n" {
+		pass $test
+	}
+}
+
+# this is added to get the prompt, which is missing.
+gdb_test "" ""
+
+# Enable btrace on all threads
+gdb_test "btr disable all"
+
+# We need to do a seperate listing from here, since the instr length is different
+# on different platforms.
+gdb_test "thread 2" ".*Switching to thread 2.*mybarrier.*" " switch to thread 2, 1.7"
+# 64 bit platform
+if {[ishost "x86_64-*-*"]} {
+note "64 bit platform"
+
+# trace for thread 2
+gdb_test "continue" ".*
+Breakpoint 4, th_a \\(\\) at .*thr_callback_...s:35.*" "BTR listing for thread 2, 1.8"
+
+gdb_test "btr" "
+No trace." " BTR of thread 2, 1.9"
+
+# trace for thread 3
+gdb_test "thread 3" ".*Switching to thread 3.*mybarrier.*" " switch to thread 3, 1.10"
+
+gdb_test "continue" ".*
+Breakpoint 5, th_b \\(\\) at .*thr_callback_...s:47.*" "BTR listing for thread 3, 1.11"
+
+gdb_test "btr" "
+No trace." " BTR of thread 3, 1.12"
+
+# trace for thread 4
+gdb_test "thread 4" ".*Switching to thread 4.*mybarrier.*" " switch to thread 4, 1.13"
+
+gdb_test "continue" ".*
+Breakpoint 6, th_c \\(\\) at .*thr_callback_...s:59.*" "BTR listing for thread 4, 1.14"
+
+gdb_test "btr" "
+No trace." " BTR of thread 4, 1.15"
+
+# trace for thread 5
+gdb_test "thread 5" ".*Switching to thread 5.*mybarrier.*" " switch to thread 5, 1.16"
+
+gdb_test "continue" ".*
+Breakpoint 7, th_d \\(\\) at .*thr_callback_...s:71.*" "BTR listing for thread 5, 1.17"
+
+gdb_test "btr" "
+No trace." " BTR of thread 5, 1.18"
+
+} elseif {[ishost "i?86-*-*"]} {
+# 32 bit platform
+note "32 bit platform"
+
+# trace for thread 2
+gdb_test "continue" ".*
+Breakpoint 4, th_a \\(\\) at .*thr_callback_...s:35.*" "BTR listing for thread 2, 1.8"
+
+gdb_test "btr" "
+No trace." " BTR of thread 2, 1.9"
+
+# trace for thread 3
+gdb_test "thread 3" ".*Switching to thread 3.*mybarrier.*" " switch to thread 3, 1.10"
+
+gdb_test "continue" ".*
+Breakpoint 5, th_b \\(\\) at .*thr_callback_...s:47.*" "BTR listing for thread 3, 1.11"
+
+gdb_test "btr" "
+No trace." " BTR of thread 3, 1.12"
+
+# trace for thread 4
+gdb_test "thread 4" ".*Switching to thread 4.*mybarrier.*" " switch to thread 4, 1.13"
+
+gdb_test "continue" ".*
+Breakpoint 6, th_c \\(\\) at .*thr_callback_...s:59.*" "BTR listing for thread 4, 1.14"
+
+gdb_test "btr" "
+No trace." " BTR of thread 4, 1.15"
+
+# trace for thread 5
+gdb_test "thread 5" ".*Switching to thread 5.*mybarrier.*" " switch to thread 5, 1.16"
+
+gdb_test "continue" ".*
+Breakpoint 7, th_d \\(\\) at .*thr_callback_...s:71.*" "BTR listing for thread 5, 1.17"
+
+gdb_test "btr" "
+No trace." " BTR of thread 5, 1.18"
+
+} else {
+ note "Platform not supported"
+}
\ No newline at end of file
diff --git a/gdb/testsuite/gdb.btrace/enable_all.exp b/gdb/testsuite/gdb.btrace/enable_all.exp
new file mode 100755
index 0000000..2ccd02c
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/enable_all.exp
@@ -0,0 +1,201 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Barkha Ahuja <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+###############
+#Test Purpose: In GDB non-stop mode, Enable trace  for all the threads by "btr enable auto" on primary thread and check the trace availability for all the threads
+# Sourcefiles : threads_asm.c, thr_callback_32.s, thr_callback_64.s
+# Compiled using '-g -lpthread' option.
+#executed on 32 bit as :
+#                    make check  RUNTESTFLAGS="GDB=<path to gdb> gdb.trace/enable_all.exp"
+###############
+
+load_lib btrace.exp
+
+# start fresh - without an executable
+gdb_exit
+gdb_start
+
+global srcdir
+global objdir
+global subdir
+
+set srcfilemain ${srcdir}/${subdir}/threads_asm.c
+set objcallback ${objdir}/${subdir}/thr_callback.o
+set objmain ${objdir}/${subdir}/threads_asm.o
+set binfile ${objdir}/${subdir}/enable_all.x
+set options "{debug}"
+
+#Load different callback files for 32 and 64 bit.
+# 32 bit platform
+if {[ishost "i?86-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/thr_callback_32.s
+} elseif {[ishost "x86_64-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/thr_callback_64.s
+} else {
+	warning "host platform not supported "
+	untested enable_all.exp
+	return -1
+}
+set objfiles "${objmain}  ${objcallback}"
+
+#compile
+if {[gdb_compile_pthreads ${srcfilemain} ${objmain} "object" ${options}] != ""} {
+	untested enable_all.exp
+	return -1
+}
+if {[gdb_compile ${srccallback} ${objcallback} "object" ${options}] != ""} {
+	untested enable_all.exp
+	return -1
+}
+
+if {[gdb_compile_pthreads ${objfiles} ${binfile} "executable" ${options}] != ""} {
+	untested enable_all.exp
+	return -1
+}
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+gdb_test_no_output "set pagination off"
+gdb_test_no_output "set target-async 1"
+gdb_test_no_output "set non-stop 1"
+
+runto main
+# set breakpoint at line 67, at call to mybarrier() for primary thread.
+gdb_breakpoint "67" "Breakpoint 2 at.*: file.*threads_asm.c, line 67." " breakpoint at line 67, 1.1"
+
+# set a breakpoint at mybarrier() to halt all the new threads from exiting.
+gdb_breakpoint "mybarrier" "Breakpoint 3, mybarrier \\(\\) at .*thr_callback_...s:114" "Breakpoint at my barrier for all the threads to stop, 1.2"
+
+gdb_breakpoint "${srccallback}:35" "Breakpoint 4 at 0x\[a-f0-9\]*: file .*thr_callback_...s, line 35." "Breakpoint after the barrier for thread 2, 1.3"
+
+gdb_breakpoint "${srccallback}:47" "Breakpoint 5 at 0x\[a-f0-9\]*: file .*thr_callback_...s, line 47." "Breakpoint after the barrier for thread 3, 1.4"
+gdb_breakpoint "${srccallback}:59" "Breakpoint 6 at 0x\[a-f0-9\]*: file .*thr_callback_...s, line 59." "Breakpoint after the barrier for thread 4, 1.5"
+gdb_breakpoint "${srccallback}:71" "Breakpoint 7 at 0x\[a-f0-9\]*: file .*thr_callback_...s, line 71." "Breakpoint after the barrier for thread 5, 1.6"
+
+# enable trace in primary thread, which automatically enables trace in all new threads crated.
+#gdb_test "btr enable all"
+send_gdb "continue\n"
+gdb_expect 8 {
+      -re "Breakpoint 3, mybarrier \\(\\) at.*thr_callback_...s:114.*"
+	{
+	  pass "continuing"
+	}
+      }
+# This "info threads" is needed to get a $gdb_prompt, since gdb seems to get hanged at this particular location.
+set test "info for threads"
+gdb_test_multiple "info threads" $test {
+	-re ".*\n" {
+		pass $test
+	}
+}
+
+# this is added to get the prompt, which is missing.
+gdb_test "" ""
+
+# Enable btrace on all threads
+gdb_test "btr enable all"
+
+# We need to do a seperate listing from here, since the instr length is different
+# on different platforms.
+gdb_test "thread 2" ".*Switching to thread 2.*mybarrier.*" " switch to thread 2, 1.7"
+# 64 bit platform
+if {[ishost "x86_64-*-*"]} {
+
+# trace for thread 2
+gdb_test "continue" ".*
+Breakpoint 4, th_a \\(\\) at .*thr_callback_...s:35.*" "BTR listing for thread 2, 1.8"
+
+gdb_test "btr" "
+ *0x\[a-f0-9\]* <th_a\\+24>:\[\[:blank:\]\]*leave.*\r
+=> *0x\[a-f0-9\]* <th_a\\+25>:\[\[:blank:\]\]*ret.*" " BTR of thread 2, 1.9"
+
+# trace for thread 3
+gdb_test "thread 3" ".*Switching to thread 3.*mybarrier.*" " switch to thread 3, 1.10"
+
+gdb_test "continue" ".*
+Breakpoint 5, th_b \\(\\) at .*thr_callback_...s:47.*" "BTR listing for thread 3, 1.11"
+
+gdb_test "btr" "
+ *0x\[a-f0-9\]* <th_b\\+24>:\[\[:blank:\]\]*leave.*\r
+=> *0x\[a-f0-9\]* <th_b\\+25>:\[\[:blank:\]\]*ret.*" " BTR of thread 3, 1.12"
+
+# trace for thread 4
+gdb_test "thread 4" ".*Switching to thread 4.*mybarrier.*" " switch to thread 4, 1.13"
+
+gdb_test "continue" ".*
+Breakpoint 6, th_c \\(\\) at .*thr_callback_...s:59.*" "BTR listing for thread 4, 1.14"
+
+gdb_test "btr" "
+ *0x\[a-f0-9\]* <th_c\\+24>:\[\[:blank:\]\]*leave.*\r
+=> *0x\[a-f0-9\]* <th_c\\+25>:\[\[:blank:\]\]*ret.*" " BTR of thread 4, 1.15"
+
+# trace for thread 5
+gdb_test "thread 5" ".*Switching to thread 5.*mybarrier.*" " switch to thread 5, 1.16"
+
+gdb_test "continue" ".*
+Breakpoint 7, th_d \\(\\) at .*thr_callback_...s:71.*" "BTR listing for thread 5, 1.17"
+
+gdb_test "btr" "
+ *0x\[a-f0-9\]* <th_d\\+24>:\[\[:blank:\]\]*leave.*\r
+=> *0x\[a-f0-9\]* <th_d\\+25>:\[\[:blank:\]\]*ret.*" " BTR of thread 5, 1.18"
+
+} elseif {[ishost "i?86-*-*"]} {
+# 32 bit platform
+
+# trace for thread 2
+gdb_test "continue" ".*
+Breakpoint 4, th_a \\(\\) at .*thr_callback_...s:35.*" "BTR listing for thread 2, 1.8"
+
+gdb_test "btr" "
+ *0x\[a-f0-9\]* <th_a\\+23>:\[\[:blank:\]\]*leave.*\r
+=> *0x\[a-f0-9\]* <th_a\\+24>:\[\[:blank:\]\]*ret.*" " BTR of thread 2, 1.9"
+
+# trace for thread 3
+gdb_test "thread 3" ".*Switching to thread 3.*mybarrier.*" " switch to thread 3, 1.10"
+
+gdb_test "continue" ".*
+Breakpoint 5, th_b \\(\\) at .*thr_callback_...s:47.*" "BTR listing for thread 3, 1.11"
+
+gdb_test "btr" "
+ *0x\[a-f0-9\]* <th_b\\+23>:\[\[:blank:\]\]*leave.*\r
+=> *0x\[a-f0-9\]* <th_b\\+24>:\[\[:blank:\]\]*ret.*" " BTR of thread 3, 1.12"
+
+# trace for thread 4
+gdb_test "thread 4" ".*Switching to thread 4.*mybarrier.*" " switch to thread 4, 1.13"
+
+gdb_test "continue" ".*
+Breakpoint 6, th_c \\(\\) at .*thr_callback_...s:59.*" "BTR listing for thread 4, 1.14"
+
+gdb_test "btr" "
+ *0x\[a-f0-9\]* <th_c\\+23>:\[\[:blank:\]\]*leave.*\r
+=> *0x\[a-f0-9\]* <th_c\\+24>:\[\[:blank:\]\]*ret.*" " BTR of thread 4, 1.15"
+
+# trace for thread 5
+gdb_test "thread 5" ".*Switching to thread 5.*mybarrier.*" " switch to thread 5, 1.16"
+
+gdb_test "continue" ".*
+Breakpoint 7, th_d \\(\\) at .*thr_callback_...s:71.*" "BTR listing for thread 5, 1.17"
+
+gdb_test "btr" "
+ *0x\[a-f0-9\]* <th_d\\+23>:\[\[:blank:\]\]*leave.*\r
+=> *0x\[a-f0-9\]* <th_d\\+24>:\[\[:blank:\]\]*ret.*" " BTR of thread 5, 1.18"
+
+} else {
+ note "Platform not supported"
+ untested enable_all.exp
+}
\ No newline at end of file
diff --git a/gdb/testsuite/gdb.btrace/enable_range.exp b/gdb/testsuite/gdb.btrace/enable_range.exp
new file mode 100755
index 0000000..509f93c
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/enable_range.exp
@@ -0,0 +1,198 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Barkha Ahuja <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+###############
+#Test Purpose: In GDB non-stop mode, Enable trace  for a range of threads on primary thread and check the trace availability for all the threads
+# Sourcefiles : threads_asm.c, thr_callback_32.s, thr_callback_64.s
+# Compiled using '-g -lpthread' option.
+#executed on 32 bit as :
+#                    make check  RUNTESTFLAGS="GDB=<path to gdb> gdb.trace/enable_range.exp"
+###############
+
+load_lib btrace.exp
+
+# start fresh - without an executable
+gdb_exit
+gdb_start
+
+global srcdir
+global objdir
+global subdir
+
+set srcfilemain ${srcdir}/${subdir}/threads_asm.c
+set objcallback ${objdir}/${subdir}/thr_callback.o
+set objmain ${objdir}/${subdir}/threads_asm.o
+set binfile ${objdir}/${subdir}/enable_range.x
+set options "{debug}"
+
+#Load different callback files for 32 and 64 bit.
+# 32 bit platform
+if {[ishost "i?86-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/thr_callback_32.s
+} elseif {[ishost "x86_64-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/thr_callback_64.s
+} else {
+	warning "host platform not supported "
+	untested enable_range.exp
+	return -1
+}
+set objfiles "${objmain}  ${objcallback}"
+
+#compile
+if {[gdb_compile_pthreads ${srcfilemain} ${objmain} "object" ${options}] != ""} {
+	untested enable_range.exp
+	return -1
+}
+if {[gdb_compile ${srccallback} ${objcallback} "object" ${options}] != ""} {
+	untested enable_range.exp
+	return -1
+}
+
+if {[gdb_compile_pthreads ${objfiles} ${binfile} "executable" ${options}] != ""} {
+	untested enable_range.exp
+	return -1
+}
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+gdb_test_no_output "set pagination off"
+gdb_test_no_output "set target-async 1"
+gdb_test_no_output "set non-stop 1"
+
+runto main
+# set breakpoint at line 67, at call to mybarrier() for primary thread.
+gdb_breakpoint "67" "Breakpoint 2 at.*: file.*threads_asm.c, line 67." " breakpoint at line 67, 1.1"
+
+# set a breakpoint at mybarrier() to halt all the new threads from exiting.
+gdb_breakpoint "mybarrier" "Breakpoint 3, mybarrier \\(\\) at .*thr_callback_...s:114" "Breakpoint at my barrier for all the threads to stop, 1.2"
+
+gdb_breakpoint "${srccallback}:35" "Breakpoint 4 at 0x\[a-f0-9\]*: file .*thr_callback_...s, line 35." "Breakpoint after the barrier for thread 2, 1.3"
+
+gdb_breakpoint "${srccallback}:47" "Breakpoint 5 at 0x\[a-f0-9\]*: file .*thr_callback_...s, line 47." "Breakpoint after the barrier for thread 3, 1.4"
+gdb_breakpoint "${srccallback}:59" "Breakpoint 6 at 0x\[a-f0-9\]*: file .*thr_callback_...s, line 59." "Breakpoint after the barrier for thread 4, 1.5"
+gdb_breakpoint "${srccallback}:71" "Breakpoint 7 at 0x\[a-f0-9\]*: file .*thr_callback_...s, line 71." "Breakpoint after the barrier for thread 5, 1.6"
+
+# enable trace in primary thread, which automatically enables trace in all new threads crated.
+#gdb_test "btr enable all"
+send_gdb "continue\n"
+gdb_expect 8 {
+      -re "Breakpoint 3, mybarrier \\(\\) at.*thr_callback_...s:114.*"
+	{
+	  pass "continuing"
+	}
+      }
+# This "info threads" is needed to get a $gdb_prompt, since gdb seems to get hanged at this particular location.
+set test "info for threads"
+gdb_test_multiple "info threads" $test {
+	-re ".*\n" {
+		pass $test
+	}
+}
+
+# this is added to get the prompt, which is missing.
+gdb_test "" ""
+
+# Enable btrace on all threads
+gdb_test "btr enable 2-3"
+
+# We need to do a seperate listing from here, since the instr length is different
+# on different platforms.
+gdb_test "thread 2" ".*Switching to thread 2.*mybarrier.*" " switch to thread 2, 1.7"
+# 64 bit platform
+if {[ishost "x86_64-*-*"]} {
+
+
+# trace for thread 2
+gdb_test "continue" ".*
+Breakpoint 4, th_a \\(\\) at .*thr_callback_...s:35.*" "BTR listing for thread 2, 1.8"
+
+gdb_test "btr" "
+ *0x\[a-f0-9\]* <th_a\\+24>:\[\[:blank:\]\]*leave.*\r
+=> *0x\[a-f0-9\]* <th_a\\+25>:\[\[:blank:\]\]*ret.*" " BTR of thread 2, 1.9"
+
+# trace for thread 3
+gdb_test "thread 3" ".*Switching to thread 3.*mybarrier.*" " switch to thread 3, 1.10"
+
+gdb_test "continue" ".*
+Breakpoint 5, th_b \\(\\) at .*thr_callback_...s:47.*" "BTR listing for thread 3, 1.11"
+
+gdb_test "btr" "
+ *0x\[a-f0-9\]* <th_b\\+24>:\[\[:blank:\]\]*leave.*\r
+=> *0x\[a-f0-9\]* <th_b\\+25>:\[\[:blank:\]\]*ret.*" " BTR of thread 3, 1.12"
+
+# trace for thread 4
+gdb_test "thread 4" ".*Switching to thread 4.*mybarrier.*" " switch to thread 4, 1.13"
+
+gdb_test "continue" ".*
+Breakpoint 6, th_c \\(\\) at .*thr_callback_...s:59.*" "BTR listing for thread 4, 1.14"
+
+gdb_test "btr" "
+No trace." " BTR of thread 4, 1.15"
+
+# trace for thread 5
+gdb_test "thread 5" ".*Switching to thread 5.*mybarrier.*" " switch to thread 5, 1.16"
+
+gdb_test "continue" ".*
+Breakpoint 7, th_d \\(\\) at .*thr_callback_...s:71.*" "BTR listing for thread 5, 1.17"
+
+gdb_test "btr" "
+No trace." " BTR of thread 5, 1.18"
+
+} elseif {[ishost "i?86-*-*"]} {
+# 32 bit platform
+
+# trace for thread 2
+gdb_test "continue" ".*
+Breakpoint 4, th_a \\(\\) at .*thr_callback_...s:35.*" "BTR listing for thread 2, 1.8"
+
+gdb_test "btr" "
+ *0x\[a-f0-9\]* <th_a\\+23>:\[\[:blank:\]\]*leave.*\r
+=> *0x\[a-f0-9\]* <th_a\\+24>:\[\[:blank:\]\]*ret.*" " BTR of thread 2, 1.9"
+
+# trace for thread 3
+gdb_test "thread 3" ".*Switching to thread 3.*mybarrier.*" " switch to thread 3, 1.10"
+
+gdb_test "continue" ".*
+Breakpoint 5, th_b \\(\\) at .*thr_callback_...s:47.*" "BTR listing for thread 3, 1.11"
+
+gdb_test "btr" "
+ *0x\[a-f0-9\]* <th_b\\+23>:\[\[:blank:\]\]*leave.*\r
+=> *0x\[a-f0-9\]* <th_b\\+24>:\[\[:blank:\]\]*ret.*" " BTR of thread 3, 1.12"
+
+# trace for thread 4
+gdb_test "thread 4" ".*Switching to thread 4.*mybarrier.*" " switch to thread 4, 1.13"
+
+gdb_test "continue" ".*
+Breakpoint 6, th_c \\(\\) at .*thr_callback_...s:59.*" "BTR listing for thread 4, 1.14"
+
+gdb_test "btr" "
+No trace." " BTR of thread 4, 1.15"
+
+# trace for thread 5
+gdb_test "thread 5" ".*Switching to thread 5.*mybarrier.*" " switch to thread 5, 1.16"
+
+gdb_test "continue" ".*
+Breakpoint 7, th_d \\(\\) at .*thr_callback_...s:71.*" "BTR listing for thread 5, 1.17"
+
+gdb_test "btr" "
+No trace." " BTR of thread 5, 1.18"
+
+} else {
+ note "Platform not supported"
+ untested enable_range.exp
+}
\ No newline at end of file
diff --git a/gdb/testsuite/gdb.btrace/list_options.exp b/gdb/testsuite/gdb.btrace/list_options.exp
new file mode 100755
index 0000000..103f22a
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/list_options.exp
@@ -0,0 +1,107 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corp. <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+###############
+#Test Purpose: Testing the other options of btrace list like /t, /af
+#Also tests the other commands like giving a range to btr list "btr list n1-n2"
+# Sourcefiles : main.s, a.s, b.s
+# Compiled using '-g' option.
+###############
+
+load_lib btrace.exp
+
+set testfile "main"
+
+# start fresh - without an executable
+gdb_exit
+gdb_start
+
+global srcdir
+global objdir
+global subdir
+
+set srcfilemain ${srcdir}/${subdir}/main.s
+set srcfilea ${srcdir}/${subdir}/a.s
+set srcfileb ${srcdir}/${subdir}/b.s
+set objfilemain ${objdir}/${subdir}/main_asm.o
+set objfilea ${objdir}/${subdir}/a.o
+set objfileb ${objdir}/${subdir}/b.o
+set binfile ${objdir}/${subdir}/list_options.x
+set options " -g "
+#compile
+if {[target_assemble ${srcfilemain} ${objfilemain} ${options}] != ""} { return "" }
+if {[target_assemble ${srcfilea} ${objfilea}  ${options}]!= ""} { return "" }
+if {[target_assemble ${srcfileb} ${objfileb}  ${options}]!= ""} { return "" }
+
+set objfiles "${objfilemain}  ${objfilea} ${objfileb}"
+#link
+if {[target_link ${objfiles} ${binfile} " "] != ""} {
+	untested list_options.exp
+	return -1
+}
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+gdb_breakpoint "25" "Breakpoint 1 at .*:.*main.s, line 25." "Breakpoint at line 25, 1.1"
+gdb_breakpoint "30" "Breakpoint 4 at .*:.*main.s, line 30." "Breakpoint at line 30, 1.2"
+
+gdb_test "r" ".*Breakpoint 1, _start .* at.*main.s:25\r
+25.*" "Run to Breakpoint at line 25, 1.3"
+
+# Enable branch trace to trace the startup.
+gdb_test_no_output "btr enable"
+
+gdb_test "c"
+
+gdb_test "btr list /t" "total: 4" "total number of btrace blocks, 1.4"
+
+#Get the trace listing after it returns from callB
+gdb_test "btr list /af" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in _start \\(\\)\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in callB \\(\\)\r
+3 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in _start \\(\\)\r
+4 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in callA \\(\\)\r" "Listing at return, 1.5"
+
+#Get the trace listing for only 1-3
+gdb_test "btr list /lf 1-3" "
+1 *in _start \\(\\) at .*main.s:29-30\r
+2 *in callB \\(\\) at .*b.s:22-23\r
+3 *in _start \\(\\) at .*main.s:27-28\r" "Listing at return, 1.6"
+
+#Get the trace listing for only 2-3
+gdb_test "btr list /lf 2-4" "
+2 *in callB \\(\\) at .*b.s:22-23\r
+3 *in _start \\(\\) at .*main.s:27-28\r
+4 *in callA \\(\\) at .*a.s:22-23\r" "Listing at return, 1.7"
+
+gdb_test "btrace /m 3"  "
+.*main.s:27\[\[:blank:\]\]*movl *.0, %eax\r
+ *0x\[a-f0-9\]* <_start\\+10>:\[\[:blank:\]\]*mov *.0x0,%eax\r
+\r
+.*main.s:28\[\[:blank:\]\]*call\[\[:blank:\]\]*callB\r
+ *0x\[a-f0-9\]* <_start\\+15>:\[\[:blank:\]\]*call. *0x\[a-f0-9\]* *<callB>"  "btrace for 1 to 3, 1.8"
+
+gdb_test "btrace /r 3" "
+ *0x\[a-f0-9\]* <_start\\+10>:.*mov *.0x0,%eax\r
+ *0x\[a-f0-9\]* <_start\\+15>:.*call. *0x\[a-f0-9\]* <callB>" "btrace with /r options at 3, 1.9"
+
+
+gdb_test "btrace /r -" "
+ *0x\[a-f0-9\]* <callB\\+0>:\[\[:blank:\]\]*90\[\[:blank:\]\]*nop *\r
+ *0x\[a-f0-9\]* <callB\\+1>:\[\[:blank:\]\]*c3\[\[:blank:\]\]*ret. *" " btrace with /r option at 2, 1.10"
diff --git a/gdb/testsuite/gdb.btrace/main.s b/gdb/testsuite/gdb.btrace/main.s
new file mode 100755
index 0000000..b314ada
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/main.s
@@ -0,0 +1,32 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corp. <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+###################
+# main.s, uses a.s and b.s 
+###################
+
+	.text
+        .globl  _start
+        .type   _start, @function
+_start:
+        movl    $0, %eax
+        call    callA
+        movl    $0, %eax
+        call    callB
+        movl    $0, %eax
+        leave
+        ret
+	
\ No newline at end of file
diff --git a/gdb/testsuite/gdb.btrace/main_asm.exp b/gdb/testsuite/gdb.btrace/main_asm.exp
new file mode 100755
index 0000000..0e7363d
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/main_asm.exp
@@ -0,0 +1,113 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corp. <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+###############
+#Test Purpose: The trace works when we step into multiple source files in '.s' format
+# Sourcefiles : main.s, a.s, b.s
+# Compiled using '-g' option.
+###############
+
+load_lib btrace.exp
+
+set testfile "main"
+
+# start fresh - without an executable
+gdb_exit
+gdb_start
+
+global srcdir
+global objdir
+global subdir
+
+set srcfilemain ${srcdir}/${subdir}/main.s
+set srcfilea ${srcdir}/${subdir}/a.s
+set srcfileb ${srcdir}/${subdir}/b.s
+set objfilemain ${objdir}/${subdir}/main_asm.o
+set objfilea ${objdir}/${subdir}/a.o
+set objfileb ${objdir}/${subdir}/b.o
+set binfile ${objdir}/${subdir}/main_asm.x
+set options " -g "
+#compile
+if {[target_assemble ${srcfilemain} ${objfilemain} ${options}] != ""} { return "" }
+if {[target_assemble ${srcfilea} ${objfilea}  ${options}]!= ""} { return "" }
+if {[target_assemble ${srcfileb} ${objfileb}  ${options}]!= ""} { return "" }
+
+set objfiles "${objfilemain}  ${objfilea} ${objfileb}"
+#link
+if {[target_link ${objfiles} ${binfile} " "] != ""} {
+	untested main_asm.exp
+	return -1
+}
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+gdb_breakpoint "25" "Breakpoint 1 at .*:.*main.s, line 25." "Breakpoint at line 25, 1.1"
+gdb_breakpoint "26" "Breakpoint 2 at .*:.*main.s, line 26." "Breakpoint at line 26, 1.2"
+gdb_breakpoint "28" "Breakpoint 3 at .*:.*main.s, line 28." "Breakpoint at line 28, 1.3"
+gdb_breakpoint "30" "Breakpoint 4 at .*:.*main.s, line 30." "Breakpoint at line 30, 1.4"
+
+gdb_test "r" ".*Breakpoint 1, _start .* at.*main.s:25\r
+25.*" "Run to Breakpoint at line 25, 1.5"
+
+# Enable branch trace to trace the startup.
+gdb_test_no_output "btr enable"
+
+gdb_test "c" ".*Breakpoint 2, _start .* at.*main.s:26\r
+26.*call.*callA" "Run to Breakpoint at line 26, 1.6"
+
+# run to callB
+gdb_test "c" ".*Breakpoint 3, _start .* at.*main.s:28\r
+28.*call.*callB" "Run to Breakpoint at line 28, 1.7"
+
+#get BTR listing in CallB
+gdb_test "btr list /lfa" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in _start \\(\\) at .*main.s:27-28\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in callA \\(\\) at .*a.s:22-23" "BTR listing at line 28, 1.8"
+
+#return to main
+gdb_test "c" ".*Breakpoint 4, _start .* at.*main.s:30\r
+30.*leave" "Run to Breakpoint at line 30, 1.9"
+
+# we do get trace for main, callB, main, callA here
+gdb_test "btr list /lfa" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in _start \\(\\) at .*main.s:29-30\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in callB \\(\\) at .*b.s:22-23\r
+3 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in _start \\(\\) at .*main.s:27-28\r
+4 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in callA \\(\\) at .*a.s:22-23" "BTR listing at line 30, 1.10"
+
+
+gdb_test "btr /m 1" "
+.*main.s:29\[\[:blank:\]\]*movl *.0, %eax\r
+ *0x\[a-f0-9\]* <_start\\+20>:\[\[:blank:\]\]*mov *.0x0,%eax\r
+\r
+.*main.s:30\[\[:blank:\]\]*leave\r
+=>  *0x\[a-f0-9\]* <_start\\+25>:	leave.*" "BTR of 1, 1.11"
+
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <callB\\+0>:\[\[:blank:\]\]*nop\r
+ *0x\[a-f0-9\]* <callB\\+1>:\[\[:blank:\]\]*ret.*" "BTR of 2, 1.12"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <_start\\+10>:\[\[:blank:\]\]*mov *.0x0,%eax\r
+ *0x\[a-f0-9\]* <_start\\+15>:\[\[:blank:\]\]*call.*<callB>." "BTR of 3, 1.13"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <callA\\+0>:\[\[:blank:\]\]*nop\r
+ *0x\[a-f0-9\]* <callA\\+1>:\[\[:blank:\]\]*ret.*" "BTR of 4, 1.14"
diff --git a/gdb/testsuite/gdb.btrace/main_segv.exp b/gdb/testsuite/gdb.btrace/main_segv.exp
new file mode 100755
index 0000000..402d6d0
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/main_segv.exp
@@ -0,0 +1,84 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Barkha Ahuja <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+###############
+#Test Purpose: The trace shows up when the debugge crashes with SIGSEGV
+# Sourcefiles : main_segv.s, b.s, 
+# Compiled using '-g' option.
+###############
+
+load_lib btrace.exp
+
+set testfile "main"
+
+# start fresh - without an executable
+gdb_exit
+gdb_start
+
+global srcdir
+global objdir
+global subdir
+
+set srcfilemain ${srcdir}/${subdir}/main_segv.s
+set srcfileb ${srcdir}/${subdir}/b.s
+set objfilemain ${objdir}/${subdir}/main_segv.o
+set objfileb ${objdir}/${subdir}/b.o
+set binfile ${objdir}/${subdir}/main_segv.x
+set options " -g "
+#compile
+if {[target_assemble ${srcfilemain} ${objfilemain} ${options}] != ""} { return "" }
+if {[target_assemble ${srcfileb} ${objfileb}  ${options}]!= ""} { return "" }
+
+set objfiles "${objfilemain}  ${objfileb}"
+#link
+if {[target_link ${objfiles} ${binfile} " "] != ""} { return "" }
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+gdb_breakpoint "25" "Breakpoint 1 at .*:.*main_segv.s, line 25." "Breakpoint at line 25, 1.1"
+gdb_breakpoint "28" "Breakpoint 2 at .*:.*main_segv.s, line 28." "Breakpoint at line 28, 1.2"
+
+gdb_test "r" ".*Breakpoint 1, _start .* at.*main_segv.s:25\r
+25.*" "Run to Breakpoint at line 25, 1.3"
+
+# Enable branch trace to trace the startup.
+gdb_test_no_output "btr enable"
+
+gdb_test "stepi" ".*22.*" "Stepping into callB, 1.4"
+
+gdb_test "btr list /lfa" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in callB \\(\\) at .*b.s.*" "BTR listing in b.s, 1.5"
+
+#check that we got SEGV
+gdb_test "c" ".*Program received signal SIGSEGV, Segmentation fault.\r
+_start.*at.*main_segv.s:27.*" "Program received SEGV at line 27, 1.6"
+
+#Check that we do get trace after SEGV too.
+gdb_test "btr list /a" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]*\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]*" "BTR listing at line 29, 1.7"
+
+#Check where we got SEGV
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <_start\\+5>:\[\[:blank:\]\]*mov *.0x0,%eax\r
+=> 0x\[a-f0-9\]* <_start\\+10>:\[\[:blank:\]\]*leave.*" "BTR of 1, 1.8"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <callB\\+0>:\[\[:blank:\]\]*nop\r
+ *0x\[a-f0-9\]* <callB\\+1>:\[\[:blank:\]\]*ret.*" "BTR of 2, 1.9"
diff --git a/gdb/testsuite/gdb.btrace/main_segv.s b/gdb/testsuite/gdb.btrace/main_segv.s
new file mode 100755
index 0000000..f1ca686
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/main_segv.s
@@ -0,0 +1,28 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corp. <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+###################
+# main.s, uses callB from b.s
+###################
+
+	.text
+        .globl  _start
+        .type   _start, @function
+_start:
+        call    callB
+        movl    $0, %eax
+        leave
+        ret
diff --git a/gdb/testsuite/gdb.btrace/sanity_crash.exp b/gdb/testsuite/gdb.btrace/sanity_crash.exp
new file mode 100755
index 0000000..2eaf96f
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/sanity_crash.exp
@@ -0,0 +1,69 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+#Contributed by Intel Corp.  <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+###############
+#Test Purpose: Check that we get SEGV trace, in single source file.
+# see that trace gives the correct addresses.
+# Source file: sanity_crash.s
+###############
+load_lib btrace.exp
+
+set testfile "sanity_crash"
+
+# start fresh - without an executable
+gdb_exit
+gdb_start
+
+global srcdir
+global objdir
+global subdir
+
+set srcfile ${srcdir}/${subdir}/sanity_crash.s
+set objfile ${objdir}/${subdir}/sanity_crash.o
+set binfile ${objdir}/${subdir}/sanity_crash.x
+set options " -g "
+#compile
+if {[target_assemble ${srcfile} ${objfile} ${options}] != ""} { return "" }
+#link
+if {[target_link ${objfile} ${binfile} " "] != ""} { return "" }
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+# At breakpoint on line 20, we reset the trace.
+gdb_breakpoint "40" "Breakpoint 1 at .*:.*sanity_crash.s, line 40." "Breakpoint at line 40, 1.1"
+gdb_breakpoint "47" "Breakpoint 2 at .*:.*sanity_crash.s, line 47." "Breakpoint at line 47, 1.2"
+
+#Reach line 20 and enable trace
+gdb_test "run"
+# Enable branch trace to trace the startup.
+gdb_test_no_output "btr enable"
+
+# we get Segv in between line 24 and 27.
+gdb_test "continue" ".*Program received signal SIGSEGV, Segmentation fault.\r
+_start .* at .*sanity_crash.s:44.*" "Continue, Program received SIGSEGV, 1.3"
+
+# check, we do get Segv for single trace too
+gdb_test "btr list /lf" "
+1 *in _start \\(\\) at.*sanity_crash.s:42-44\r
+2 *in somethingToDo \\(\\) at.*sanity_crash.s:28-36" "BTR listing, 1.4"
+
+#Check where we got SEGV
+gdb_test "btr /m 1" "
+ *0x\[a-f0-9\]* *<_start\\+14>:\[\[:blank:\]\]movl *.0x2,0x20000f.%rip.*\r
+ *0x\[a-f0-9\]* *<_start\\+24>:\[\[:blank:\]\]mov *.0x0,%eax.*\r
+=> 0x\[a-f0-9\]* *<_start\\+29>:\[\[:blank:\]\]movb *.0x0,.%rax." "BTR at 1, 1.5"
diff --git a/gdb/testsuite/gdb.btrace/sanity_crash.s b/gdb/testsuite/gdb.btrace/sanity_crash.s
new file mode 100755
index 0000000..bbfc303
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/sanity_crash.s
@@ -0,0 +1,52 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corp. <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+###################
+# sanity_crash.s
+# Gives segv after calling somethingToDo in _start
+###################
+	.file	"sanity_crash.c"
+	.text
+	.globl _start
+	.type	_start, @function
+	.globl somethingToDo
+	.type	somethingToDo, @function
+somethingToDo:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	movl	x.2043(%rip), %eax
+	movl	%eax, %edx
+	addl	$1, %eax
+	movl	%eax, x.2043(%rip)
+	movl	%edx, %eax
+	popq	%rbp
+	ret
+_start:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	movl	$0, %eax
+	call	somethingToDo
+	movl	$2, jvar.2046(%rip)
+	movl	$0, %eax
+	movb	$0, (%rax)
+	movl	$0, %eax
+	popq	%rbp
+	ret
+.LFE1:
+	.local	jvar.2046
+	.comm	jvar.2046,4,4
+	.local	x.2043
+	.comm	x.2043,4,4
diff --git a/gdb/testsuite/gdb.btrace/thr_callback_32.s b/gdb/testsuite/gdb.btrace/thr_callback_32.s
new file mode 100755
index 0000000..c94285b
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/thr_callback_32.s
@@ -0,0 +1,116 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corp. <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+#
+###############
+# threads.c calls th_a(), th_b(),th_c() and th_d() as callback methods
+# for 4 threads being created.
+###############
+
+
+	.globl th_a
+	.type	th_a, @function
+th_a:
+	pushl	%ebp
+	movl	%esp, %ebp
+	movl	$0, %eax
+	call	call_A
+	movl	$0, %eax
+	call	mybarrier
+	leave
+	ret
+
+	.globl th_b
+	.type	th_b @function
+th_b:
+	pushl	%ebp
+	movl	%esp, %ebp
+	movl	$0, %eax
+	call	call_B
+	movl	$0, %eax
+	call	mybarrier
+	leave
+	ret
+
+	.globl th_c
+	.type	th_c @function
+th_c:
+	pushl	%ebp
+	movl	%esp, %ebp
+	movl	$0, %eax
+	call	call_C
+	movl	$0, %eax
+	call	mybarrier
+	leave
+	ret
+
+	.globl th_d
+	.type	th_d @function
+th_d:
+	pushl	%ebp
+	movl	%esp, %ebp
+	movl	$0, %eax
+	call	call_D
+	movl	$0, %eax
+	call	mybarrier
+	leave
+	ret
+
+	.globl call_A
+	.type	call_A, @function
+call_A:
+	pushl	%ebp
+	movl	%esp, %ebp
+	movl	$0, %eax
+	leave
+	ret
+
+	.globl call_B
+	.type	call_B @function
+call_B:
+	pushl	%ebp
+	movl	%esp, %ebp
+	movl	$0, %eax
+	leave
+	ret
+
+	.globl call_C
+	.type	call_C @function
+call_C:
+	pushl	%ebp
+	movl	%esp, %ebp
+	movl	$0, %eax
+	leave
+	ret
+
+	.globl call_D
+	.type	call_D @function
+call_D:
+	pushl	%ebp
+	movl	%esp, %ebp
+	movl	$0, %eax
+	leave
+	ret
+
+	.globl mybarrier
+	.type	mybarrier @function
+mybarrier:
+	pushl	%ebp
+	movl	%esp, %ebp
+	movl	$0, %eax
+	leave
+	ret
diff --git a/gdb/testsuite/gdb.btrace/thr_callback_64.s b/gdb/testsuite/gdb.btrace/thr_callback_64.s
new file mode 100755
index 0000000..6d4c0bd
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/thr_callback_64.s
@@ -0,0 +1,116 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corp. <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+#
+###############
+# threads.c calls th_a(), th_b(),th_c() and th_d() as callback methods
+# for 4 threads being created.
+###############
+
+
+	.globl th_a
+	.type	th_a, @function
+th_a:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	movl	$0, %eax
+	call	call_A
+	movl	$0, %eax
+	call	mybarrier
+	leave
+	ret
+
+	.globl th_b
+	.type	th_b @function
+th_b:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	movl	$0, %eax
+	call	call_B
+	movl	$0, %eax
+	call	mybarrier
+	leave
+	ret
+
+	.globl th_c
+	.type	th_c @function
+th_c:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	movl	$0, %eax
+	call	call_C
+	movl	$0, %eax
+	call	mybarrier
+	leave
+	ret
+
+	.globl th_d
+	.type	th_d @function
+th_d:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	movl	$0, %eax
+	call	call_D
+	movl	$0, %eax
+	call	mybarrier
+	leave
+	ret
+
+	.globl call_A
+	.type	call_A, @function
+call_A:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	movl	$0, %eax
+	leave
+	ret
+
+	.globl call_B
+	.type	call_B @function
+call_B:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	movl	$0, %eax
+	leave
+	ret
+
+	.globl call_C
+	.type	call_C @function
+call_C:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	movl	$0, %eax
+	leave
+	ret
+
+	.globl call_D
+	.type	call_D @function
+call_D:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	movl	$0, %eax
+	leave
+	ret
+
+	.globl mybarrier
+	.type	mybarrier @function
+mybarrier:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	movl	$0, %eax
+	leave
+	ret
diff --git a/gdb/testsuite/gdb.btrace/threads.c b/gdb/testsuite/gdb.btrace/threads.c
new file mode 100755
index 0000000..2d81715
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/threads.c
@@ -0,0 +1,96 @@
+/*
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corp.  <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+###############
+#This program spawns 4 threads and each thread has a seperate callback function and
+# a diffierent function call from callback function.
+# Purpose: To check the trace functionality of gdb, ("btr auto on" and "btr enable" for individual threads)
+###############
+*/
+#include <pthread.h>
+#include <stdio.h>
+
+
+//function being called by Thread[0],
+int call_A(){ return 0;}
+//function being called by Thread[1]
+int call_B(){ return 0;}
+//function being called by Thread[2]
+int call_C(){ return 0;}
+//function being called by Thread[3]
+int call_D(){ return 0;}
+
+//Callback function for thread[0]
+void* th_a(void* arg){
+	int number = *((int*) arg);
+	call_A();
+	return arg;
+}
+//Callback function for thread[1]
+void* th_b(void* arg){
+	int number = *((int*) arg);
+	call_B();
+	return arg;
+}
+//Callback function for thread[2]
+void* th_c(void* arg){
+	int number = *((int*) arg);
+	call_C();
+	return arg;
+}
+//Callback function for thread[3]
+void* th_d(void* arg){
+	int number = *((int*) arg);
+	call_D();
+	return arg;
+}
+// Terminate the already created thread
+int join_thread(pthread_t *thr)
+{
+	int* resultp;
+	if (pthread_join(*thr, (void**) &resultp)) 
+	{
+		printf("ERROR: pthread_join failed, aborting!\n");
+		return(1);
+	}
+	return(0);
+}
+
+int main(){
+	const int THREADS = 4;
+	pthread_t thread[THREADS];
+	int args[THREADS];
+	args[0]=0;
+	args[1]=1;
+	args[2]=2;
+	args[3]=3;
+
+	// To be deterministic, we have to first terminate the
+	// created thread before creating a new one.
+	pthread_create(&thread[0], 0, th_a ,&args[0]);
+	join_thread(&thread[0]);
+	pthread_create(&thread[1], 0, th_b ,&args[1]);
+	join_thread(&thread[1]);
+	pthread_create(&thread[2], 0, th_c ,&args[2]);
+	join_thread(&thread[2]);
+	pthread_create(&thread[3], 0, th_d ,&args[3]);
+	join_thread(&thread[3]);
+
+	return 1;
+}
diff --git a/gdb/testsuite/gdb.btrace/threads_asm.c b/gdb/testsuite/gdb.btrace/threads_asm.c
new file mode 100755
index 0000000..eb58ecf
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/threads_asm.c
@@ -0,0 +1,78 @@
+/*
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Barkha Ahuja <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+###############
+#This program spawns 4 threads and each thread has a seperate callback function and
+# a different function call from callback function.
+# th_a(), th_b(), th_c() and th_d are called from file th_callback.s
+#
+# Purpose: To check the trace functionality of gdb, ("btr auto on" and "btr enable" for individual threads and "btr enable" in GDb non-stop mode)
+###############
+*/
+#include <pthread.h>
+#include <stdio.h>
+
+pthread_barrier_t bar;
+
+void* th_a(void* arg);
+void* th_b(void* arg);
+void* th_c(void* arg);
+void* th_d(void* arg);
+
+// Terminate the already created thread
+int join_thread(pthread_t *thr)
+{
+	int* resultp;
+	if (pthread_join(*thr, (void**) &resultp))
+	{
+		printf("ERROR: pthread_join failed, aborting!\n");
+		return(1);
+	}
+	return(-1);
+}
+
+int main(){
+	const int THREADS = 4;
+	pthread_t thread[THREADS];
+	int args[THREADS];
+	int i;
+	args[0]=0;
+	args[1]=1;
+	args[2]=2;
+	args[3]=3;
+	pthread_barrier_init(&bar, NULL, 5);
+
+	//create 4 threads having different callback fucntions.
+	pthread_create(&thread[0], 0, th_a ,&args[0]);
+	pthread_create(&thread[1], 0, th_b ,&args[1]);
+	pthread_create(&thread[2], 0, th_c ,&args[2]);
+	pthread_create(&thread[3], 0, th_d ,&args[3]);
+	mybarrier();
+	printf(" All the threads are created by now ");
+	//wait for all the threads to terminate
+
+	for(i=0;i<4;i++) {
+		join_thread(&thread[i]);
+	}
+	//destroy barrier
+	pthread_barrier_destroy(&bar);
+
+	return 1;
+}
+
diff --git a/gdb/testsuite/gdb.btrace/threads_auto.exp b/gdb/testsuite/gdb.btrace/threads_auto.exp
new file mode 100755
index 0000000..d9e85a6
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/threads_auto.exp
@@ -0,0 +1,113 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Barkha Ahuja <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+###############
+#Test Purpose: The trace works for multi-threaded application and the trace is automatically enabled for all the threads created, if we execute the GDB command "btr enable auto".
+# Sourcefiles : threads.c
+# Compiled using '-g -lpthread' option.
+#executed as :
+#                    make check  RUNTESTFLAGS="GDB=<path to gdb> gdb.trace/threads_auto.exp"
+###############
+
+
+
+load_lib btrace.exp
+
+gdb_exit
+gdb_start
+
+global srcdir
+global objdir
+global subdir
+
+set srcfilemain ${srcdir}/${subdir}/threads.c
+set objfilemain ${objdir}/${subdir}/threads.o
+set binfile ${objdir}/${subdir}/threads_auto.x
+set options "{debug}"
+
+#compile
+if {[gdb_compile_pthreads ${srcfilemain} ${objfilemain} "object" ${options}] != ""} {
+	untested threads_auto.exp
+	return -1
+}
+if {[gdb_compile_pthreads ${objfilemain} ${binfile} "executable" ""] != ""} {
+	untested threads_auto.exp
+	return -1
+}
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+# Make sure we don't die when enabling trace for a newly created thread.
+runto main
+#set a breakpoint at the end of each callback function of each thread
+gdb_breakpoint "43" "Breakpoint 2 at .*:.*, line 43." "Breakpoint at line 42, 1.1"
+
+gdb_breakpoint "49" "Breakpoint 3 at .*:.*, line 49." "Breakpoint at line 48, 1.2"
+
+gdb_breakpoint "55" "Breakpoint 4 at .*:.*, line 55." "Breakpoint at line 54, 1.3"
+
+gdb_breakpoint "61" "Breakpoint 5 at .*:.*, line 61." "Breakpoint at line 60, 1.4"
+
+# Reset branch trace on all new threads automatically
+gdb_test_no_output "btr enable auto"
+
+gdb_test "continue" ".*
+Breakpoint 2, th_a.*threads\.c:43\r
+43\[\[:blank:\]\]*return arg.*" "Stopping at breakpoint 2, line 43, 1.5"
+
+#Get the trace listing after it returns from call_A, while ignoring the trace listing of trace pthread libs.
+gdb_test "btr list /fa" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in th_a \\(\\)\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in call_A \\(\\)\r
+3 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in th_a \\(\\)\r
+.*\r" "listing is not correct thread\[0\], 1.6"
+
+
+gdb_test "continue" ".*
+Breakpoint 3, th_b.*threads\.c:49\r
+49\[\[:blank:\]\]*return arg.*" "Stopping at breakpoint 32, line 49, 1.7"
+
+#Get the trace listing after it returns from call_B
+gdb_test "btr list /fa" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in th_b \\(\\)\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in call_B \\(\\)\r
+3 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in th_b \\(\\)\r
+.*\r" "listing is not correct thread\[1\], 1.8"
+
+gdb_test "continue" ".*
+Breakpoint 4, th_c.*threads\.c:55\r
+55\[\[:blank:\]\]*return arg.*" "Stopping at breakpoint 4, line 55, 1.9"
+
+#Get the trace listing after it returns from call_C
+gdb_test "btr list /fa" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in th_c \\(\\)\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in call_C \\(\\)\r
+3 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in th_c \\(\\)\r
+.*\r" "listing is not correct thread\[2\], 1.10"
+
+gdb_test "continue" ".*
+Breakpoint 5, th_d.*threads\.c:61\r
+61\[\[:blank:\]\]*return arg.*" "Stopping at breakpoint 52, line 61, 1.11"
+
+#Get the trace listing after it returns from call_D
+gdb_test "btr list /fa" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in th_d \\(\\)\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in call_D \\(\\)\r
+3 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in th_d \\(\\)\r
+.*\r" "listing is not correct for thread\[3\], 1.12"
diff --git a/gdb/testsuite/gdb.btrace/threads_independent.exp b/gdb/testsuite/gdb.btrace/threads_independent.exp
new file mode 100755
index 0000000..a37be7f
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/threads_independent.exp
@@ -0,0 +1,119 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Barkha Ahuja <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+###############
+#Test Purpose: The trace works for multi-threaded application and the trace is enabled for only the current thread.
+# Sourcefiles : threads.c
+# Compiled using '-g -lpthread' option.
+#executed as :
+#                    make check  RUNTESTFLAGS="GDB=/users/bahuja/work_gdb/gdb_32/gdb --host i686-linux-gnu --target i686-linux-gnu gdb.trace/threads_independent.exp"
+###############
+
+
+load_lib btrace.exp
+
+# start fresh - without an executable
+gdb_exit
+gdb_start
+
+global srcdir
+global objdir
+global subdir
+
+set srcfilemain ${srcdir}/${subdir}/threads.c
+set objfilemain ${objdir}/${subdir}/threads.o
+set binfile ${objdir}/${subdir}/threads_independent.x
+set options "{debug}"
+
+#compile
+if {[gdb_compile_pthreads ${srcfilemain} ${binfile} "executable" ${options}] != ""} {
+	untested threads_independent.exp
+	return -1
+}
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+# Make sure we don't die when enabling trace for a newly created thread.
+runto main
+#set a breakpoint at the end of each callback function of each thread
+gdb_breakpoint "th_a" "Breakpoint 2 at .*:.*, line 41." "Breakpoint at th_a, 1.1"
+
+gdb_breakpoint "th_c" "Breakpoint 4 at .*:.*, line 53." "Breakpoint at th_c, 1.2"
+
+#set a breakpoint at the end of each callback function of each thread
+gdb_breakpoint "43" "Breakpoint 6 at .*:.*, line 43." "Breakpoint at line 43, 1.3"
+
+gdb_breakpoint "49" "Breakpoint 7 at .*:.*, line 49." "Breakpoint at line 49, 1.4"
+
+gdb_breakpoint "55" "Breakpoint 8 at .*:.*, line 55." "Breakpoint at line 55, 1.5"
+
+gdb_breakpoint "61" "Breakpoint 9 at .*:.*, line 61." "Breakpoint at line 61, 1.6"
+
+# move to th_a for thread[0]and enable trace
+gdb_test "continue" ".*
+Breakpoint 2, th_a.*threads\.c:41\r.*" "Stopping at breakpoint 2, th_a, 1.7"
+
+# Reset branch trace
+gdb_test_no_output "btrace enable"
+
+gdb_test "continue" ".*
+Breakpoint 4, th_a.*threads\.c:43\r
+43\[\[:blank:\]\]*return arg.*" "Stopping at breakpoint 4, line 43, 1.8"
+
+#Get the trace listing after it returns from call_A
+gdb_test "btrace list /fa" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in th_a \\(\\)\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in call_A \\(\\)" "listing of thread\[0\], 1.9"
+
+
+# move to th_b for thread[1]and do not enable trace
+gdb_test "continue" ".*
+Breakpoint 5, th_b.*threads\.c:49\r
+49\[\[:blank:\]\]*return arg.*" "Stopping at breakpoint 5, line 49, 1.10"
+
+#Get the trace listing after it returns from call_B
+gdb_test "btr list" "No trace." "No trace for thread\[1\], 1.11"
+
+
+# move to th_c and enable trace
+gdb_test "continue" ".*
+Breakpoint 3, th_c.*threads\.c:53\r
+53.*" "Stopping at breakpoint 3, th_c, 1.12"
+
+
+# Reset branch trace for thread[2]
+gdb_test_no_output "btrace enable"
+
+gdb_test "continue" ".*
+Breakpoint 6, th_c.*threads\.c:55\r
+55\[\[:blank:\]\]*return arg.*" "Stopping at breakpoint 6, line 55, 1.13"
+
+#Get the trace listing after it returns from call_C
+gdb_test "btr list /fa" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in th_c \\(\\)\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in call_C \\(\\)" "listing of  thread\[2\], 1.14"
+
+
+# move to th_d and do not enable trace
+gdb_test "continue" ".*
+Breakpoint 7, th_d.*threads\.c:61\r
+61\[\[:blank:\]\]*return arg.*" "Stopping at breakpoint 7, line 61, 1.15"
+
+#Get the trace listing after it returns from call_D
+gdb_test "btr list" "No trace." "No trace for thread\[3\], 1.16"
diff --git a/gdb/testsuite/gdb.btrace/threads_nonstop.exp b/gdb/testsuite/gdb.btrace/threads_nonstop.exp
new file mode 100755
index 0000000..f22e8f9
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/threads_nonstop.exp
@@ -0,0 +1,182 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Barkha Ahuja <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+###############
+#Test Purpose: In GDB non-stop mode, when btrace is enabled for only one thread (created by pthread_create()), then trace is also generated for only that thread and not for all threads
+# Sourcefiles : threads_asm.c
+# Compiled using '-g -lpthread' option.
+#executed as :
+#                    make check  RUNTESTFLAGS="GDB=/users/bahuja/work_gdb/gdb_32/gdb --host i686-linux-gnu --target i686-linux-gnu gdb.trace/threads_nonstop.exp"
+###############
+
+load_lib btrace.exp
+
+# start fresh - without an executable
+gdb_exit
+gdb_start
+
+global srcdir
+global objdir
+global subdir
+
+set srcfilemain ${srcdir}/${subdir}/threads_asm.c
+set objcallback ${objdir}/${subdir}/thr_callback.o
+set objmain ${objdir}/${subdir}/threads_asm.o
+set binfile ${objdir}/${subdir}/threads_nonstop.x
+set options "{debug}"
+
+# We need to do a seperate listing from here, since the instr lenght is different
+# on different platforms.
+# 32 bit platform
+if {[ishost "i?86-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/thr_callback_32.s
+} elseif {[ishost "x86_64-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/thr_callback_64.s
+} else {
+	warning "host platform not supported "
+	return -1
+}
+
+set objfiles "${objmain}  ${objcallback}"
+
+#compile
+if {[gdb_compile_pthreads ${srcfilemain} ${objmain} "object" ${options}] != ""} { return "" }
+if {[gdb_compile ${srccallback} ${objcallback} "object" ${options}] != ""} { return "" }
+
+if {[gdb_compile_pthreads ${objfiles} ${binfile} "executable" ${options}] != ""} {
+	untested threads_nonstop.exp
+	return -1
+}
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+gdb_test_no_output "set pagination off"
+gdb_test_no_output "set target-async 1"
+gdb_test_no_output "set non-stop 1"
+
+runto main
+
+#set breakpoint at mybarrier to prevent all the pthreads from exiting.
+gdb_breakpoint "mybarrier" "Breakpoint 2 at .*:thr_callback_\[32|64\].s, line .*." "Breakpoint in reach barrier, 1.1"
+
+#set a breakpoint in callback of thread 3, where we enable trace for only thread 3
+gdb_breakpoint "th_b" "Breakpoint 3 at .*:thr_callback_\[32|64\].s.*" "Breakpoint in reach barrier, 1.2"
+
+send_gdb "continue\n"
+gdb_expect 8 {
+      -re "Breakpoint 2.*"
+	{
+	  pass "continuing"
+	}
+      }
+# This "info threads" is needed to get a $gdb_prompt, since gdb seems to get hanged at this particular location.
+set test "info for threads"
+gdb_test_multiple "info threads" $test {
+	-re ".*\n" {
+		pass $test
+	}
+}
+
+# this is added to get the prompt, which is missing after creating new threads in non-stop mode.
+gdb_test "" "" 
+
+# thread 3 reaches its callback th_b(), while all threads wait at mybarrier()
+gdb_test "info threads" "  Id   Target Id         Frame \r
+  5    Thread 0x\[a-f0-9\]*.*mybarrier \\(\\) at.*thr_callback_...s:114\r
+  4    Thread 0x\[a-f0-9\]*.*mybarrier \\(\\) at.*thr_callback_...s:114\r
+  3    Thread 0x\[a-f0-9\]*.*th_b \\(\\) at.*thr_callback_...s:42\r
+  2    Thread 0x\[a-f0-9\]*.*mybarrier \\(\\) at.*thr_callback_...s:114\r
+.* 1    Thread 0x\[a-f0-9\]*.*mybarrier \\(\\) at.*thr_callback_...s:114" "info threads before thread 3 reaches mybarrier(), 1.3"
+
+gdb_test "thread 3" ".*Switching to thread 3.*th_b.*" " Thread 3 is still waiting at th_b(), 1.4"
+#enable trace for only thread 3
+
+gdb_test "btr enable"
+# thread 3 also continues to mybarrier()
+
+gdb_test "continue" ".*Breakpoint 2, mybarrier \\(\\) at .*thr_callback_...s:114.*" " thread 3 also reached at breakpoint 1 at line 53, 1.5"
+# back trace for thread 3.
+
+gdb_test "btr list /lfa" "
+1     0x\[a-f0-9\]* - 0x\[a-f0-9\]* in mybarrier \\(\\) at.*thr_callback_...s:112-114\r
+2     0x\[a-f0-9\]* - 0x\[a-f0-9\]* in th_b \\(\\) at.*thr_callback_...s:44-45\r
+3     0x\[a-f0-9\]* - 0x\[a-f0-9\]* in call_B \\(\\) at.*thr_callback_...s:85-89" "BTR listing at line mybarrier for thread 3, 1.6"
+
+# 32 bit host
+if {[ishost "i?86-*-*"]} {
+
+gdb_test "btr" "
+ *0x\[a-f0-9\]* <mybarrier\\+0>:\[\[:blank:\]\]*push.*\r
+ *0x\[a-f0-9\]* <mybarrier\\+1>:\[\[:blank:\]\]*mov.*\r
+=> 0x\[a-f0-9\]* <mybarrier\\+3>:\[\[:blank:\]\]*mov.*" "btr 0 for thread 3, 1.7"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <th_b\\+13>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <th_b\\+18>:\[\[:blank:\]\]*call.*<mybarrier>" "btr 1 for thread 3, 1.8"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <call_B\\+0>:\[\[:blank:\]\]*push.*\r
+ *0x\[a-f0-9\]* <call_B\\+1>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <call_B\\+3>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <call_B\\+8>:\[\[:blank:\]\]*leave.*\r
+ *0x\[a-f0-9\]* <call_B\\+9>:\[\[:blank:\]\]*ret.*\r" "btr 1 for thread 3, 1.9"
+
+} elseif {[ishost "x86_64-*-*"]} {
+# 64 bit host
+
+gdb_test "btr" "
+ *0x\[a-f0-9\]* <mybarrier\\+0>:\[\[:blank:\]\]*push.*\r
+ *0x\[a-f0-9\]* <mybarrier\\+1>:\[\[:blank:\]\]*mov.*\r
+=> 0x\[a-f0-9\]* <mybarrier\\+4>:\[\[:blank:\]\]*mov.*" "btr 0 for thread 3, 1.7"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <th_b\\+14>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <th_b\\+19>:\[\[:blank:\]\]*call.*<mybarrier>" "btr 1 for thread 3, 1.8"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <call_B\\+0>:\[\[:blank:\]\]*push.*\r
+ *0x\[a-f0-9\]* <call_B\\+1>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <call_B\\+4>:\[\[:blank:\]\]*mov.*\r
+ *0x\[a-f0-9\]* <call_B\\+9>:\[\[:blank:\]\]*leave.*\r
+ *0x\[a-f0-9\]* <call_B\\+10>:\[\[:blank:\]\]*ret.*\r" "btr 1 for thread 3, 1.9"
+
+}
+# All the threads are at mybarrier()
+gdb_test "info threads" "  Id   Target Id         Frame \r
+  5    Thread 0x\[a-f0-9\]*.*mybarrier \\(\\) at.*thr_callback_...s:114\r
+  4    Thread 0x\[a-f0-9\]*.*mybarrier \\(\\) at.*thr_callback_...s:114\r
+.* 3    Thread 0x\[a-f0-9\]*.*mybarrier \\(\\) at.*thr_callback_...s:114\r
+  2    Thread 0x\[a-f0-9\]*.*mybarrier \\(\\) at.*thr_callback_...s:114\r
+  1    Thread 0x\[a-f0-9\]*.*mybarrier \\(\\) at.*thr_callback_...s:114" "Info threads, when all threads reached barrier, 1.10"
+
+# trace was enabled for only thread 3, and none other thread has trace
+gdb_test "thread 2" ".*Switching to thread 2.*mybarrier.*" " switch to thread 2, 1.11"
+
+gdb_test "btr list" "No trace" " no trace for thread 2, 1.12"
+
+gdb_test "thread 4" ".*Switching to thread 4.*mybarrier.*" " swtich to thread 4, 1.13"
+
+gdb_test "btr list" "No trace" " no trace for thread 4, 1.14"
+
+gdb_test "thread 5" ".*Switching to thread 5.*mybarrier.*" " swtich to thread 5, 1.15"
+
+gdb_test "btr list" "No trace" " no trace for thread 5, 1.16"
+
+
+
+
diff --git a/gdb/testsuite/gdb.btrace/trace_iteration.exp b/gdb/testsuite/gdb.btrace/trace_iteration.exp
new file mode 100755
index 0000000..1a63e11
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/trace_iteration.exp
@@ -0,0 +1,264 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# Contributed by Barkha Ahuja <barkha.ahuja@intel.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+###############
+#Test Purpose: Fix a location while linking, where the debuggee will be loaded and then
+# see that trace gives the correct addresses.
+# Iterate over the btrace using the commands "btr", "btr +", "btr -", and check that it gives the correct output.
+# Source file: decrement.s
+###############
+
+load_lib btrace.exp
+
+# start fresh - without an executable
+gdb_exit
+gdb_start
+
+set srcfile ${srcdir}/${subdir}/decrement.s
+set objfile ${objdir}/${subdir}/decrement.o
+set binfile ${objdir}/${subdir}/trace_iteration.x
+set options "{debug}"
+#compile
+if {[target_assemble ${srcfile} ${objfile} ""] != ""} { return -1 }
+#link
+if {[target_link ${objfile} ${binfile} " -Ttext 0x400400 "] != ""} {
+	untested trace_iteration.exp
+	return -1
+}
+
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
+
+
+# Make sure we don't die when enabling trace for a newly created thread.
+runto L1
+
+# Enable branch trace to trace the startup.
+gdb_test_no_output "btr enable"
+
+# Reset branch trace so we get predictable output.
+btrace_reset_trace
+
+gdb_test "next" "0x0*40041a in L1.*" ""
+
+gdb_test "btr list /lfa" "
+1 *0x0*40041a - 0x0*40041a in L1 \\(\\)" "list L1, 1.1"
+
+gdb_continue_to_breakpoint "L1, 1.2"
+
+if {[ishost "x86_64-*-*"]} {
+#64 bit host
+
+#We enter the loop for 5 times from here.
+gdb_test "btr list /af" "
+1 *0x0*40041a - 0x0*40041a in L1 \\(\\)\r
+2 *0x0*40041a - 0x0*400421 in L1 \\(\\)" "list L1 again, 1.3"
+
+#Delete all Breakpoints
+delete_breakpoints
+
+#Set a Breakpoint at L2
+gdb_breakpoint  "L2"
+
+#Continue to L2
+gdb_continue_to_breakpoint "L2"
+
+# BTR listing in method L2, when the loop exits
+gdb_test "btr list /a" "
+1 *0x0*400423 - 0x0*400423\r
+2 *0x0*40041a - 0x0*40041d\r
+3 *0x0*40041a - 0x0*400421\r
+4 *0x0*40041a - 0x0*400421\r
+5 *0x0*40041a - 0x0*400421\r.*" "BTR listing at L2, 1.4"
+
+# Exit the loop
+gdb_test "btr " "
+=> 0x0*400423 *<L2\\+0>:\[\[:blank:\]\]*retq *" "BTR of 0, 1.5"
+
+#BTR of non existing trace
+gdb_test "btr -" "
+No trace." "BTR of non-existing trace, 1.6"
+
+# Comparison, if we are exiting the loop
+gdb_test "btr -" "
+No trace." "BTR of non-existing trace, 1.7"
+
+gdb_test "btr " "
+=> 0x0*400423 *<L2\\+0>:\[\[:blank:\]\]*retq *" "BTR of 1, 1.8"
+
+#in the loop
+gdb_test "btr +" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400423 <L2>\r" "BTR at 2, 1.9"
+
+#in the loop
+gdb_test "btr +" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400423 <L2>\r
+ *0x0*40041f *<L1\\+5>:\[\[:blank:\]\]*dec *%eax\r
+ *0x0*400421 *<L1\\+7>:\[\[:blank:\]\]*jmp *0x40041a <L1>" "BTR at 3, 1.10"
+
+#in the loop
+gdb_test "btr -" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400423 <L2>\r" "BTR at 2 second time, 1.11"
+
+#in the loop
+gdb_test "btr +" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400423 <L2>\r
+ *0x0*40041f *<L1\\+5>:\[\[:blank:\]\]*dec *%eax\r
+ *0x0*400421 *<L1\\+7>:\[\[:blank:\]\]*jmp *0x40041a <L1>" "BTR at 3 second time, 1.12"
+
+#in the loop
+gdb_test "btr -" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400423 <L2>\r" "BTR at 2 third time, 1.13"
+
+#in the loop
+gdb_test "btr -" "
+=> 0x0*400423 *<L2\\+0>:\[\[:blank:\]\]*retq *" "BTR at 1 Again, 1.14"
+ 
+gdb_test "btr 6" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400423 <L2>\r
+ *0x0*40041f *<L1\\+5>:\[\[:blank:\]\]*dec *%eax\r
+ *0x0*400421 *<L1\\+7>:\[\[:blank:\]\]*jmp *0x40041a <L1>" "BTR at 6, 1.15"
+ 
+gdb_test "btr +" "
+No trace." "BTR of non existing at end, 1.16"
+ 
+gdb_test "btr" "
+No trace." "BTR still at 6 , 1.17"
+
+gdb_test "btr -" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400423 <L2>\r
+ *0x0*40041f *<L1\\+5>:\[\[:blank:\]\]*dec *%eax\r
+ *0x0*400421 *<L1\\+7>:\[\[:blank:\]\]*jmp *0x40041a <L1>" "BTR at 6, 1.18"
+  
+} elseif {[ishost "i?86-*-*"]} {
+#32 bit host
+
+#We enter the loop for 5 times from here.
+gdb_test "btr list /af" "
+1 *0x0*40041a - 0x0*40041a in L1 \\(\\)\r
+2 *0x0*40041a - 0x0*400420 in L1 \\(\\)" "list L1 again, 1.3"
+
+#Delete all Breakpoints
+delete_breakpoints
+
+#Set a Breakpoint at L2
+gdb_breakpoint  "L2"
+
+#Continue to L2
+gdb_continue_to_breakpoint "L2"
+
+# BTR listing in method L2, when the loop exits
+gdb_test "btr list /a" "
+1 *0x0*400422 - 0x0*400422\r
+2 *0x0*40041a - 0x0*40041d\r
+3 *0x0*40041a - 0x0*400420\r
+4 *0x0*40041a - 0x0*400420\r
+5 *0x0*40041a - 0x0*400420\r
+6 *0x0*40041a - 0x0*400420\r" "BTR listing at L2, 1.4"
+
+# Exit the loop
+gdb_test "btr " "
+=> 0x0*400422 *<L2\\+0>:\[\[:blank:\]\]*ret *" "BTR of 1, 1.5"
+
+#BTR of non existing trace
+gdb_test "btr -" "
+No trace." "BTR of non-existing trace, 1.6"
+
+#BTR of non existing trace
+gdb_test "btr -" "
+No trace." "BTR of non-existing trace, 1.7"
+
+#BTR of non existing trace
+gdb_test "btr " "
+=> 0x0*400422 *<L2\\+0>:\[\[:blank:\]\]*ret *" "BTR of 1, 1.8"
+
+# Comparison, if we are exiting the loop
+gdb_test "btr +" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400422 *<L2>" "BTR at 2, 1.9"
+
+#in the loop
+gdb_test "btr +" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400422 <L2>\r
+ *0x0*40041f *<L1\\+5>:\[\[:blank:\]\]*dec *%eax\r
+ *0x0*400420 *<L1\\+6>:\[\[:blank:\]\]*jmp *0x40041a <L1>" "BTR at 3, 1.10"
+
+#in the loop
+gdb_test "btr +" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400422 <L2>\r
+ *0x0*40041f *<L1\\+5>:\[\[:blank:\]\]*dec *%eax\r
+ *0x0*400420 *<L1\\+6>:\[\[:blank:\]\]*jmp *0x40041a <L1>" "BTR at 3, 1.11"
+
+#in the loop
+gdb_test "btr -" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400422 <L2>\r
+ *0x0*40041f *<L1\\+5>:\[\[:blank:\]\]*dec *%eax\r
+ *0x0*400420 *<L1\\+6>:\[\[:blank:\]\]*jmp *0x40041a <L1>" "BTR at 2 second time, 1.12"
+
+#in the loop
+gdb_test "btr +" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400422 <L2>\r
+ *0x0*40041f *<L1\\+5>:\[\[:blank:\]\]*dec *%eax\r
+ *0x0*400420 *<L1\\+6>:\[\[:blank:\]\]*jmp *0x40041a <L1>" "BTR at 3 second time, 1.13"
+
+#in the loop
+gdb_test "btr -" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400422 <L2>\r
+ *0x0*40041f *<L1\\+5>:\[\[:blank:\]\]*dec *%eax\r
+ *0x0*400420 *<L1\\+6>:\[\[:blank:\]\]*jmp *0x40041a <L1>" "BTR at 2nd third time, 1.14"
+#in the loop
+gdb_test "btr -" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400422 *<L2>" "BTR at 1 Again, 1.15"
+ 
+gdb_test "btr 6" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400422 <L2>\r
+ *0x0*40041f *<L1\\+5>:\[\[:blank:\]\]*dec *%eax\r
+ *0x0*400420 *<L1\\+6>:\[\[:blank:\]\]*jmp *0x40041a <L1>" "BTR at 6,  1.16"
+ 
+gdb_test "btr +" "" "BTR of non existing at end, 1.17"
+ 
+gdb_test "btr" "" "BTR still at 6 , 1.18"
+
+gdb_test "btr -" "
+ *0x0*40041a *<L1\\+0>:\[\[:blank:\]\]*cmp *.0x0,%eax\r
+ *0x0*40041d *<L1\\+3>:\[\[:blank:\]\]*je *0x400422 <L2>\r
+ *0x0*40041f *<L1\\+5>:\[\[:blank:\]\]*dec *%eax\r
+ *0x0*400420 *<L1\\+6>:\[\[:blank:\]\]*jmp *0x40041a <L1>" "BTR still at 6 , 1.19"
+
+ }  else {
+	warning "host platform not supported "
+}
+
+#reset the trace
+btrace_reset_trace
+
+gdb_test "btr list" "No trace." "No trace should be available now"
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]