[patch v5 11/12] test, btrace: more branch tracing tests

markus.t.metzger@intel.com markus.t.metzger@intel.com
Fri Dec 7 10:39:00 GMT 2012


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

Non-stop tests are failing with gdbserver and are thus skipped.

2012-12-07 Barkha Ahuja <barkha.ahuja@intel.com>

testsuite/
 	* gdb.btrace/a.S: New file
	* gdb.btrace/allthreads_trace.exp: New file
	* gdb.btrace/b.S: New file
	* gdb.btrace/decrement.exp: New file
	* gdb.btrace/decrement.S: New file
	* gdb.btrace/disable_all.exp: New file
	* gdb.btrace/enable_all.exp: New file
	* gdb.btrace/enable_range.exp: New file
	* gdb.btrace/list_options.exp: New file
	* gdb.btrace/main.S: New file
	* gdb.btrace/main_asm.exp: New file
	* gdb.btrace/main_segv.exp: New file
	* gdb.btrace/main_segv.S: New file
	* gdb.btrace/sanity_crash.exp: New file
	* gdb.btrace/sanity_crash.S: New file
	* gdb.btrace/amd64-thr-callback.S: New file
	* gdb.btrace/i386-thr-callback.S: New file
	* gdb.btrace/threads.c: New file
	* gdb.btrace/threads_asm.c: New file
	* gdb.btrace/threads_auto.exp: New file
	* gdb.btrace/threads_independent.exp: New file
	* gdb.btrace/threads_nonstop.exp: New file
	* gdb.btrace/trace_iteration.exp: New file


---
 gdb/testsuite/gdb.btrace/a.S                     |   23 ++
 gdb/testsuite/gdb.btrace/allthreads_trace.exp    |  345 ++++++++++++++++++++++
 gdb/testsuite/gdb.btrace/amd64-thr-callback.S    |  116 ++++++++
 gdb/testsuite/gdb.btrace/b.S                     |   23 ++
 gdb/testsuite/gdb.btrace/decrement.S             |   32 ++
 gdb/testsuite/gdb.btrace/decrement.exp           |  141 +++++++++
 gdb/testsuite/gdb.btrace/disable_all.exp         |  279 +++++++++++++++++
 gdb/testsuite/gdb.btrace/enable_all.exp          |  282 ++++++++++++++++++
 gdb/testsuite/gdb.btrace/enable_range.exp        |  281 ++++++++++++++++++
 gdb/testsuite/gdb.btrace/i386-thr-callback.S     |  116 ++++++++
 gdb/testsuite/gdb.btrace/list_options.exp        |  107 +++++++
 gdb/testsuite/gdb.btrace/main.S                  |   36 +++
 gdb/testsuite/gdb.btrace/main_asm.exp            |  109 +++++++
 gdb/testsuite/gdb.btrace/main_segv.S             |   32 ++
 gdb/testsuite/gdb.btrace/main_segv.exp           |   84 ++++++
 gdb/testsuite/gdb.btrace/threads.c               |   96 ++++++
 gdb/testsuite/gdb.btrace/threads_asm.c           |   78 +++++
 gdb/testsuite/gdb.btrace/threads_auto.exp        |  123 ++++++++
 gdb/testsuite/gdb.btrace/threads_independent.exp |  125 ++++++++
 gdb/testsuite/gdb.btrace/threads_nonstop.exp     |  231 +++++++++++++++
 gdb/testsuite/gdb.btrace/trace_iteration.exp     |  265 +++++++++++++++++
 21 files changed, 2924 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/amd64-thr-callback.S
 create mode 100755 gdb/testsuite/gdb.btrace/b.S
 create mode 100755 gdb/testsuite/gdb.btrace/decrement.S
 create mode 100755 gdb/testsuite/gdb.btrace/decrement.exp
 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/i386-thr-callback.S
 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.S
 create mode 100755 gdb/testsuite/gdb.btrace/main_segv.exp
 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..b457975
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/a.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  callA
+        .type   callA, @function
+callA:
+	nop
+	ret
diff --git a/gdb/testsuite/gdb.btrace/allthreads_trace.exp b/gdb/testsuite/gdb.btrace/allthreads_trace.exp
new file mode 100755
index 0000000..8af544c
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/allthreads_trace.exp
@@ -0,0 +1,345 @@
+# 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, i386-thr-callback.S, amd64-thr-callback.S
+# Compiled using '-g -lpthread' option.
+#executed as :
+#                    make check  RUNTESTFLAGS="GDB=<path to gdb>  gdb.trace/allthreads_trace.exp"
+###############
+
+load_lib btrace.exp
+
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+# the tests do currently not work with gdbserver
+if [is_remote target] {
+	untested "allthreads_trace.exp"
+	return -1
+}
+
+# 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}"
+
+if { ![support_displaced_stepping] } {
+    unsupported "displaced stepping"
+    return -1
+}
+
+#Load different callback files for 32 and 64 bit.
+# 32 bit platform
+if {[istarget "i?86-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/i386-thr-callback.S
+} elseif {[istarget "x86_64-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/amd64-thr-callback.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"
+
+if ![runto_main] then {
+   fail "Can't run to main"
+   return 0
+}
+# 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"
+
+set test "continue running..."
+gdb_test_multiple "continue" $test {
+      -re "Breakpoint 3, mybarrier \\(\\) at.*thr-callback.S:114.*"
+	{
+	  pass "continuing"
+	}
+	timeout {fail "(timeout) continue into program"}
+}
+# this is added to get the prompt, which is missing.
+gdb_test "" ""
+
+# 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_multiple "thread 2" "switching to thread 2" {
+    -re ".*Switching to thread 2.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 2, 1.3"
+    }
+    timeout {
+	fail "switching to thread 2 (timeout), 1.3"
+    }
+}
+
+# 64 bit platform
+if {[istarget "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_multiple "thread 3" "switching to thread 3" {
+    -re ".*Switching to thread 3.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 3, 1.7"
+    }
+    timeout {
+	fail "switching to thread 3 (timeout), 1.7"
+    }
+}
+
+gdb_test "btr list /la" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*amd64-thr-callback.S:112-114\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*amd64-thr-callback.S:44-45\r
+3 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*amd64-thr-callback.S:85-89\r
+4 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*amd64-thr-callback.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_multiple "thread 4" "switching to thread 4" {
+    -re ".*Switching to thread 4.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 4, 1.11"
+    }
+    timeout {
+	fail "switching to thread 4 (timeout), 1.11"
+    }
+}
+
+gdb_test "btr list /lf" "
+1 *in mybarrier at.*amd64-thr-callback.S:112-114\r
+2 *in th_c at.*amd64-thr-callback.S:56-57\r
+3 *in call_C at.*amd64-thr-callback.S:94-98\r
+4 *in th_c at.*amd64-thr-callback.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_multiple "thread 5" "switching to thread 5" {
+    -re ".*Switching to thread 5.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 5, 1.15"
+    }
+    timeout {
+	fail "switching to thread 5 (timeout), 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 {[istarget "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"
+
+#switch to thread 3
+gdb_test_multiple "thread 3" "switching to thread 3" {
+    -re ".*Switching to thread 3.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 3, 1.7"
+    }
+    timeout {
+	fail "switching to thread 3 (timeout), 1.7"
+    }
+}
+
+#trace for thread 3
+gdb_test "btr list /la" "
+1 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*i386-thr-callback.S:112-114\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*i386-thr-callback.S:44-45\r
+3 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*i386-thr-callback.S:85-89\r
+4 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* at .*i386-thr-callback.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"
+
+#switch to thread 4
+gdb_test_multiple "thread 4" "switching to thread 4" {
+    -re ".*Switching to thread 4.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 4, 1.11"
+    }
+    timeout {
+	fail "switching to thread 4 (timeout), 1.11"
+    }
+}
+
+#trace for thread 4
+gdb_test "btr list /lf" "
+1 *in mybarrier at.*i386-thr-callback.S:112-114\r
+2 *in th_c at.*i386-thr-callback.S:56-57\r
+3 *in call_C at.*i386-thr-callback.S:94-98\r
+4 *in th_c at.*i386-thr-callback.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"
+
+#switch to thread 5
+gdb_test_multiple "thread 5" "switching to thread 5" {
+    -re ".*Switching to thread 5.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 5, 1.15"
+    }
+    timeout {
+	fail "switching to thread 5 (timeout), 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
+}
diff --git a/gdb/testsuite/gdb.btrace/amd64-thr-callback.S b/gdb/testsuite/gdb.btrace/amd64-thr-callback.S
new file mode 100755
index 0000000..871f76d
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/amd64-thr-callback.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/b.S b/gdb/testsuite/gdb.btrace/b.S
new file mode 100755
index 0000000..09d376d
--- /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.S b/gdb/testsuite/gdb.btrace/decrement.S
new file mode 100755
index 0000000..38bb254
--- /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/decrement.exp b/gdb/testsuite/gdb.btrace/decrement.exp
new file mode 100755
index 0000000..45e4ee1
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/decrement.exp
@@ -0,0 +1,141 @@
+# 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
+
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+# 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
+
+if ![runto L1] then {
+   fail "Can't run to test L1"
+   return 0
+}
+
+#Enable tracing
+gdb_test_no_output "btr enable"
+
+gdb_continue_to_breakpoint "L1"
+
+gdb_test "btr list /lfa" "
+1 *0x0*40041a - 0x0*40041a in L1" "list L1, 1.1"
+
+gdb_continue_to_breakpoint "L1"
+
+if {[istarget "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 {[istarget "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 {[istarget "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 {[istarget "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/disable_all.exp b/gdb/testsuite/gdb.btrace/disable_all.exp
new file mode 100755
index 0000000..48eb07d
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/disable_all.exp
@@ -0,0 +1,279 @@
+# 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, i386-thr-callback.S, amd64-thr-callback.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
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+# the tests do currently not work with gdbserver
+if [is_remote target] {
+	untested "disable_all.exp"
+	return -1
+}
+
+# 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}"
+
+if { ![support_displaced_stepping] } {
+    unsupported "displaced stepping"
+    return -1
+}
+
+#Load different callback files for 32 and 64 bit.
+# 32 bit platform
+if {[istarget "i?86-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/i386-thr-callback.S
+} elseif {[istarget "x86_64-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/amd64-thr-callback.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"
+
+if ![runto_main] then {
+   fail "Can't run to main"
+   return 0
+}
+# 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"
+
+set test "continue running..."
+gdb_test_multiple "continue" $test {
+      -re "Breakpoint 3, mybarrier \\(\\) at.*thr-callback.S:114.*"
+	{
+	  pass "continuing"
+	}
+	timeout {fail "(timeout) continue into program"}
+}
+# this is added to get the prompt, which is missing.
+gdb_test "" ""
+
+# 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.
+# switch to thread 2
+gdb_test_multiple "thread 2" "switching to thread 2" {
+    -re ".*Switching to thread 2.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 2, 1.7"
+    }
+    timeout {
+	fail "switching to thread 2 (timeout), 1.7"
+    }
+}
+
+# 64 bit platform
+if {[istarget "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" "
+No trace." " BTR of thread 2, 1.9"
+
+# trace for thread 3
+# switch to thread 3
+gdb_test_multiple "thread 3" "switching to thread 3" {
+    -re ".*Switching to thread 3.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 3, 1.10"
+    }
+    timeout {
+	fail "switching to thread 3 (timeout), 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"
+#switch to thread 4
+gdb_test_multiple "thread 4" "switching to thread 4" {
+    -re ".*Switching to thread 4.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 4, 1.13"
+    }
+    timeout {
+	fail "switching to thread 4 (timeout), 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
+# switch to thread 5
+gdb_test_multiple "thread 5" "switching to thread 5" {
+    -re ".*Switching to thread 5.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 5, 1.16"
+    }
+    timeout {
+	fail "switching to thread 5 (timeout), 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 {[istarget "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" "
+No trace." " BTR of thread 2, 1.9"
+
+# trace for thread 3
+# switch to thread 3
+gdb_test_multiple "thread 3" "switching to thread 3" {
+    -re ".*Switching to thread 3.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 3, 1.10"
+    }
+    timeout {
+	fail "switching to thread 3 (timeout), 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
+# switch to thread 4
+gdb_test_multiple "thread 4" "switching to thread 4" {
+    -re ".*Switching to thread 4.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 4, 1.13"
+    }
+    timeout {
+	fail "switching to thread 4 (timeout), 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
+# switch to thread 5
+gdb_test_multiple "thread 5" "switching to thread 5" {
+    -re ".*Switching to thread 5.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 5, 1.16"
+    }
+    timeout {
+	fail "switching to thread 5 (timeout), 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"
+}
diff --git a/gdb/testsuite/gdb.btrace/enable_all.exp b/gdb/testsuite/gdb.btrace/enable_all.exp
new file mode 100755
index 0000000..53a28ed
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/enable_all.exp
@@ -0,0 +1,282 @@
+# 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,  i386-thr-callback.S, amd64-thr-callback.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
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+# the tests do currently not work with gdbserver
+if [is_remote target] {
+	untested "enable_all.exp"
+	return -1
+}
+
+# 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}"
+
+if { ![support_displaced_stepping] } {
+    unsupported "displaced stepping"
+    return -1
+}
+
+#Load different callback files for 32 and 64 bit.
+# 32 bit platform
+if {[istarget "i?86-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/i386-thr-callback.S
+} elseif {[istarget "x86_64-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/amd64-thr-callback.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"
+
+if ![runto_main] then {
+   fail "Can't run to main"
+   return 0
+}
+# 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.
+set test "continue running..."
+gdb_test_multiple "continue" $test {
+      -re "Breakpoint 3, mybarrier \\(\\) at.*-thr-callback.S:114.*"
+	{
+	  pass "continuing"
+	}
+	timeout {fail "(timeout) continue into program"}
+}
+# this is added to get the prompt, which is missing.
+gdb_test "" ""
+
+# 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$gdb_prompt $" {
+		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.
+#switch to thread 2
+gdb_test_multiple "thread 2" "switching to thread 2" {
+    -re ".*Switching to thread 2.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 2, 1.7"
+    }
+    timeout {
+	fail "switching to thread 2 (timeout), 1.7"
+    }
+}
+
+# 64 bit platform
+if {[istarget "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
+# switch to thread 3
+gdb_test_multiple "thread 3" "switching to thread 3" {
+    -re ".*Switching to thread 3.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 3, 1.10"
+    }
+    timeout {
+	fail "switching to thread 3 (timeout), 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
+# switch to thread 4
+gdb_test_multiple "thread 4" "switching to thread 4" {
+    -re ".*Switching to thread 4.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 4, 1.13"
+    }
+    timeout {
+	fail "switching to thread 4 (timeout), 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
+# switch to thread 5
+gdb_test_multiple "thread 5" "switching to thread 5" {
+    -re ".*Switching to thread 5.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 5, 1.16"
+    }
+    timeout {
+	fail "switching to thread 5 (timeout), 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 {[istarget "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
+# switch to thread 3
+gdb_test_multiple "thread 3" "switching to thread 3" {
+    -re ".*Switching to thread 3.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 3, 1.10"
+    }
+    timeout {
+	fail "switching to thread 3 (timeout), 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
+# switch to thread 4
+gdb_test_multiple "thread 4" "switching to thread 4" {
+    -re ".*Switching to thread 4.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 4, 1.13"
+    }
+    timeout {
+	fail "switching to thread 4 (timeout), 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
+# switch to thread 5
+gdb_test_multiple "thread 5" "switching to thread 5" {
+    -re ".*Switching to thread 5.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 5, 1.16"
+    }
+    timeout {
+	fail "switching to thread 5 (timeout), 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
+}
diff --git a/gdb/testsuite/gdb.btrace/enable_range.exp b/gdb/testsuite/gdb.btrace/enable_range.exp
new file mode 100755
index 0000000..ee21246
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/enable_range.exp
@@ -0,0 +1,281 @@
+# 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,  i386-thr-callback.S, amd64-thr-callback.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
+
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+# the tests do currently not work with gdbserver
+if [is_remote target] {
+	untested "enable_range.exp"
+	return -1
+}
+
+# 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}"
+
+if { ![support_displaced_stepping] } {
+    unsupported "displaced stepping"
+    return -1
+}
+
+#Load different callback files for 32 and 64 bit.
+# 32 bit platform
+if {[istarget "i?86-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/i386-thr-callback.S
+} elseif {[istarget "x86_64-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/amd64-thr-callback.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"
+
+if ![runto main] {
+    fail "could not run to main."
+    return -1
+}
+
+# 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"
+
+set test "continue running..."
+gdb_test_multiple "continue" $test {
+      -re "Breakpoint 3, mybarrier \\(\\) at.*thr-callback.S:114.*"
+	{
+	  pass $test
+	}
+	timeout {fail "(timeout) continue into program"}
+      }
+# this is added to get the prompt, which is missing.
+gdb_test "" ""
+
+# 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$gdb_prompt $" {
+		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.
+#switch to thread 2
+gdb_test_multiple "thread 2" "switching to thread 2" {
+    -re ".*Switching to thread 2.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 2, 1.7"
+    }
+    timeout {
+	fail "switching to thread 2 (timeout), 1.7"
+    }
+}
+
+# 64 bit platform
+if {[istarget "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
+#switch to thread 3
+gdb_test_multiple "thread 3" "switching to thread 3" {
+    -re ".*Switching to thread 3.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 3, 1.10"
+    }
+    timeout {
+	fail "switching to thread 3 (timeout), 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
+#switch to thread 4
+gdb_test_multiple "thread 4" "switching to thread 4" {
+    -re ".*Switching to thread 4.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 4, 1.13"
+    }
+    timeout {
+	fail "switching to thread 4 (timeout), 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
+#switch to thread 5
+gdb_test_multiple "thread 5" "switching to thread 5" {
+    -re ".*Switching to thread 5.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 5, 1.16"
+    }
+    timeout {
+	fail "switching to thread 5 (timeout), 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 {[istarget "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
+#switch to thread 3
+gdb_test_multiple "thread 3" "switching to thread 3" {
+    -re ".*Switching to thread 3.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 3, 1.10"
+    }
+    timeout {
+	fail "switching to thread 3 (timeout), 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
+#switch to thread 4
+gdb_test_multiple "thread 4" "switching to thread 4" {
+    -re ".*Switching to thread 4.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 4, 1.13"
+    }
+    timeout {
+	fail "switching to thread 4 (timeout), 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
+#switch to thread 5
+gdb_test_multiple "thread 5" "switching to thread 5" {
+    -re ".*Switching to thread 5.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 5, 1.16"
+    }
+    timeout {
+	fail "switching to thread 5 (timeout), 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
+}
diff --git a/gdb/testsuite/gdb.btrace/i386-thr-callback.S b/gdb/testsuite/gdb.btrace/i386-thr-callback.S
new file mode 100755
index 0000000..0356aa4
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/i386-thr-callback.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/list_options.exp b/gdb/testsuite/gdb.btrace/list_options.exp
new file mode 100755
index 0000000..3faf347
--- /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
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+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
+
+if ![runto main] { return -1 }
+
+gdb_breakpoint "35" "Breakpoint 3 at .*:.*main\.S, line 35\." "Breakpoint at line 35, 1.2"
+
+# Enable branch trace to trace the startup.
+gdb_test_no_output "btr enable"
+
+gdb_test "c" "Continuing.*Breakpoint.*main\.S:35.*" "continue to end, 1.3"
+
+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 main\r
+2 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in callB\r
+3 *0x\[a-f0-9\]* - 0x\[a-f0-9\]* in main\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 main at .*main\\.S:34-35\r
+2 *in callB at .*b\.S:22-23\r
+3 *in main at .*main\\.S:32-33\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 main at .*main\.S:32-33\r
+4 *in callA at .*a\.S:22-23\r" "Listing at return, 1.7"
+
+gdb_test "btrace /m 3"  "
+.*main\.S:32\[\[:blank:\]\]*movl *.0, %eax\r
+ *0x\[a-f0-9\]* <main\\+10>:\[\[:blank:\]\]*mov *.0x0,%eax\r
+\r
+.*main\.S:33\[\[:blank:\]\]*call\[\[:blank:\]\]*callB\r
+ *0x\[a-f0-9\]* <main\\+15>:\[\[:blank:\]\]*call. *0x\[a-f0-9\]* *<callB>"  "btrace for 1 to 3, 1.8"
+
+gdb_test "btrace /r 3" "
+ *0x\[a-f0-9\]* <main\\+10>:.*mov *.0x0,%eax\r
+ *0x\[a-f0-9\]* <main\\+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..916a7f6
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/main.S
@@ -0,0 +1,36 @@
+# 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
+        .globl  _main
+        .type   _start, @function
+        .type   _main, @function
+_start:
+        call main
+        hlt
+main:
+        movl    $0, %eax
+        call    callA
+        movl    $0, %eax
+        call    callB
+        movl    $0, %eax
+        leave
+        ret
diff --git a/gdb/testsuite/gdb.btrace/main_asm.exp b/gdb/testsuite/gdb.btrace/main_asm.exp
new file mode 100755
index 0000000..9d79a73
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/main_asm.exp
@@ -0,0 +1,109 @@
+# 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
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+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
+
+if ![runto_main] {
+	return -1
+}
+
+# Set the breakpoints we'll need later on.
+gdb_breakpoint "33" "Breakpoint \[0-9\]+ at .*:.*main.S, line 33." "Breakpoint at line 33, 1.1"
+gdb_breakpoint "34" "Breakpoint \[0-9\]+ at .*:.*main.S, line 34." "Breakpoint at line 34, 1.2"
+
+# Enable branch trace to trace the startup.
+gdb_test_no_output "btr enable"
+
+# run to callB
+gdb_test "c" ".*Breakpoint \[0-9\]+, main .* at.*main.S:33\r
+33.*call.*callB" "Run to Breakpoint at line 33, 1.3"
+
+#get BTR listing in CallB
+gdb_test "btr list /f" "
+1 * in main\r
+2 * in callA\r" "BTR listing at line 28, 1.4"
+
+#return to main
+gdb_test "c" ".*Breakpoint \[0-9\]+, main .* at.*main.S:34\r
+34.*movl.*" "Run to Breakpoint at line 30, 1.5"
+
+# we do get trace for main, callB, main, callA here
+gdb_test "btr list /f" "
+1 *in main\r
+2 *in callB\r
+3 *in main\r
+4 *in callA\r" "BTR listing at line 30, 1.6"
+
+
+gdb_test "btr /m 1" "
+.*main.S:34\[\[:blank:\]\]*movl *.0, %eax\r
+=>  *0x\[a-f0-9\]* <main\\+20>:\[\[:blank:\]\]*mov *.0x0,%eax" "BTR of 1, 1.7"
+
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <callB\\+0>:\[\[:blank:\]\]*nop\r
+ *0x\[a-f0-9\]* <callB\\+1>:\[\[:blank:\]\]*ret.*" "BTR of 2, 1.8"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <main\\+10>:\[\[:blank:\]\]*mov *.0x0,%eax\r
+ *0x\[a-f0-9\]* <main\\+15>:\[\[:blank:\]\]*call.*<callB>." "BTR of 3, 1.9"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <callA\\+0>:\[\[:blank:\]\]*nop\r
+ *0x\[a-f0-9\]* <callA\\+1>:\[\[:blank:\]\]*ret.*" "BTR of 4, 1.10"
diff --git a/gdb/testsuite/gdb.btrace/main_segv.S b/gdb/testsuite/gdb.btrace/main_segv.S
new file mode 100755
index 0000000..1d3df2e
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/main_segv.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 callB from b.s
+###################
+
+	.text
+        .globl  _start
+        .type   _start, @function
+        .type   _main, @function
+_start:
+        call main
+        hlt
+main:
+        call    callB
+        movl    $0, %eax
+        leave
+        ret
diff --git a/gdb/testsuite/gdb.btrace/main_segv.exp b/gdb/testsuite/gdb.btrace/main_segv.exp
new file mode 100755
index 0000000..be15a69
--- /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
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+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
+
+if ![runto_main] {
+	return -1
+}
+
+# Enable branch trace to trace the startup.
+gdb_test_no_output "btr enable"
+
+gdb_test "stepi" ".*22.*" "Stepping into callB, 1.1"
+
+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.2"
+
+#check that we got SEGV
+gdb_test "c" ".*Program received signal SIGSEGV, Segmentation fault.\r
+main.*at.*main_segv.S:31.*" "Program received SEGV at line 31, 1.3"
+
+#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 of 1, 1.4"
+
+#Check where we got SEGV
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <main\\+5>:\[\[:blank:\]\]*mov *.0x0,%eax\r
+=> 0x\[a-f0-9\]* <main\\+10>:\[\[:blank:\]\]*leave.*" "BTR of 2, 1.5"
+
+gdb_test "btr +" "
+ *0x\[a-f0-9\]* <callB\\+0>:\[\[:blank:\]\]*nop\r
+ *0x\[a-f0-9\]* <callB\\+1>:\[\[:blank:\]\]*ret.*" "BTR of 3, 1.6"
diff --git a/gdb/testsuite/gdb.btrace/threads.c b/gdb/testsuite/gdb.btrace/threads.c
new file mode 100755
index 0000000..9c49563
--- /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..20474c2
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/threads_auto.exp
@@ -0,0 +1,123 @@
+# 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
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+# the tests do currently not work with gdbserver
+if [is_remote target] {
+	untested "threads_auto.exp"
+	return -1
+}
+
+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 running to main
+if ![runto_main] then {
+   fail "Can't run to main"
+   return 0
+}
+
+#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..ff930f1
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/threads_independent.exp
@@ -0,0 +1,125 @@
+# 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
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+# 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 running to main
+if ![runto_main] then {
+   fail "Can't run to main"
+   return 0
+}
+
+#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..82dcf2d
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/threads_nonstop.exp
@@ -0,0 +1,231 @@
+# 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,  i386-thr-callback.S, amd64-thr-callback.S
+# 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
+
+#check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+# the tests do currently not work with gdbserver
+if [is_remote target] {
+	untested "threads_nonstop.exp"
+	return -1
+}
+
+# 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}"
+
+if { ![support_displaced_stepping] } {
+    unsupported "displaced stepping"
+    return -1
+}
+
+# We need to do a seperate listing from here, since the instr lenght is different
+# on different platforms.
+# 32 bit platform
+if {[istarget "i?86-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/i386-thr-callback.S
+} elseif {[istarget "x86_64-*-*"]} {
+	set srccallback ${srcdir}/${subdir}/amd64-thr-callback.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"
+
+# Make sure we don't die when running to main
+if ![runto_main] then {
+   fail "Can't run to main"
+   return 0
+}
+#set breakpoint at mybarrier to prevent all the pthreads from exiting.
+gdb_breakpoint "mybarrier" "Breakpoint 2 at .*:\[i386|amd64\]-thr-callback.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 .*:\[i386|amd64\]-thr-callback.S.*" "Breakpoint in reach barrier, 1.2"
+
+set test "continue running..."
+gdb_test_multiple "continue" $test {
+      -re "Breakpoint 2.*"
+	{
+	  pass "continuing"
+	}
+}
+# this is added to get the prompt, which is missing.
+gdb_test "" ""
+
+# 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$gdb_prompt $" {
+		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"
+
+#switch to thread 3
+gdb_test_multiple "thread 3" "switching to thread 3" {
+    -re ".*Switching to thread 3.*th_b.*$gdb_prompt $" {
+	pass  "switch to thread 3, 1.4"
+    }
+    timeout {
+	fail "switching to thread 3 (timeout), 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 {[istarget "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 {[istarget "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
+#switch to thread 2
+gdb_test_multiple "thread 2" "switching to thread 2" {
+    -re ".*Switching to thread 2.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 2, 1.11"
+    }
+    timeout {
+	fail "switching to thread 2 (timeout), 1.11"
+    }
+}
+
+gdb_test "btr list" "No trace\." " no trace for thread 2, 1.12"
+
+#switch to thread 4
+gdb_test_multiple "thread 4" "switching to thread 4" {
+    -re ".*Switching to thread 4.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 4, 1.13"
+    }
+    timeout {
+	fail "switching to thread 4 (timeout), 1.13"
+    }
+}
+
+gdb_test "btr list" "No trace\." " no trace for thread 4, 1.14"
+
+#switch to thread 5
+gdb_test_multiple "thread 5" "switching to thread 5" {
+    -re ".*Switching to thread 5.*mybarrier.*$gdb_prompt $" {
+	pass  "switch to thread 5, 1.15"
+    }
+    timeout {
+	fail "switching to thread 5 (timeout), 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..7c4e408
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/trace_iteration.exp
@@ -0,0 +1,265 @@
+# 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
+# check for btrace support
+if { [skip_btrace_tests] } { return -1 }
+
+# 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
+
+if ![runto L1] then {
+    fail "Can't run to L1"
+    return 0
+}
+
+
+# Enable branch trace.
+gdb_test_no_output "btr enable"
+
+gdb_continue_to_breakpoint "L1, 1.2"
+
+gdb_test "btr list /lfa" "
+1 *0x0*40041a - 0x0*40041a in L1" "list L1, 1.1"
+
+gdb_continue_to_breakpoint "L1, 1.2"
+
+if {[istarget "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 {[istarget "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



More information about the Gdb-patches mailing list