]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add a test for helgrind --history-backtrace-size
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Thu, 29 Dec 2022 14:56:36 +0000 (15:56 +0100)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Thu, 29 Dec 2022 15:19:24 +0000 (16:19 +0100)
Extend hg04_race to have more entries in the conflicting stacktrace,
and make another test hg04_race_h9 to test with one more entry than
the default of 8.

helgrind/tests/Makefile.am
helgrind/tests/hg04_race.c
helgrind/tests/hg04_race.stderr.exp
helgrind/tests/hg04_race_h9.stderr.exp [new file with mode: 0644]
helgrind/tests/hg04_race_h9.stdout.exp [new file with mode: 0644]
helgrind/tests/hg04_race_h9.vgtest [new file with mode: 0644]

index 2286e220f1ed236f466cc6c17d103bd4531092d0..28f4c61912fbe818128b5e9b4a22029676694d30 100755 (executable)
@@ -34,6 +34,7 @@ EXTRA_DIST = \
        hg02_deadlock.vgtest hg02_deadlock.stdout.exp hg02_deadlock.stderr.exp \
        hg03_inherit.vgtest hg03_inherit.stdout.exp hg03_inherit.stderr.exp \
        hg04_race.vgtest hg04_race.stdout.exp hg04_race.stderr.exp \
+       hg04_race_h9.vgtest hg04_race_h9.stdout.exp hg04_race_h9.stderr.exp \
        hg05_race2.vgtest hg05_race2.stdout.exp hg05_race2.stderr.exp \
        hg06_readshared.vgtest hg06_readshared.stdout.exp \
                hg06_readshared.stderr.exp \
index 111195bf903f8d6ba91194bfc8be60d7b12215e7..760caf88601d7dcc87c6271d324416caba3e6d40 100644 (file)
@@ -5,18 +5,79 @@
 
 static int shared;
 
+__attribute__((noinline))
+static void th10(void)
+{
+   shared++;
+}
+
+__attribute__((noinline))
+static void th9(void)
+{
+   th10();
+}
+
+__attribute__((noinline))
+static void th8(void)
+{
+   th9();
+}
+
+__attribute__((noinline))
+static void th7(void)
+{
+   th8();
+}
+
+__attribute__((noinline))
+static void th6(void)
+{
+   th7();
+}
+
+__attribute__((noinline))
+static void th5(void)
+{
+   th6();
+}
+
+__attribute__((noinline))
+static void th4(void)
+{
+   th5();
+}
+
+__attribute__((noinline))
+static void th3(void)
+{
+   th4();
+}
+
+__attribute__((noinline))
+static void th2(void)
+{
+   th3();
+}
+
+
+__attribute__((noinline))
+static void th1(void)
+{
+   th2();
+}
+
 static void *th(void *v)
 {
-       shared++;
+   th1();
 
-       return 0;
+   return 0;
 }
 
 int main()
 {
        pthread_t a, b;
 
-       pthread_create(&a, NULL, th, NULL);     
+       pthread_create(&a, NULL, th, NULL);
        sleep(1);               /* force ordering */
        pthread_create(&b, NULL, th, NULL);
 
index 67f6573963afa36ee713afece563d8e3ada33142..f66394bd1303eef2163dbde13155dab9c52d3e33 100644 (file)
@@ -4,28 +4,42 @@
 Thread #x was created
    ...
    by 0x........: pthread_create@* (hg_intercepts.c:...)
-   by 0x........: main (hg04_race.c:21)
+   by 0x........: main (hg04_race.c:82)
 
 ---Thread-Announcement------------------------------------------
 
 Thread #x was created
    ...
    by 0x........: pthread_create@* (hg_intercepts.c:...)
-   by 0x........: main (hg04_race.c:19)
+   by 0x........: main (hg04_race.c:80)
 
 ----------------------------------------------------------------
 
 Possible data race during read of size 4 at 0x........ by thread #x
 Locks held: none
-   at 0x........: th (hg04_race.c:10)
+   at 0x........: th10 (hg04_race.c:11)
+   by 0x........: th9 (hg04_race.c:17)
+   by 0x........: th8 (hg04_race.c:23)
+   by 0x........: th7 (hg04_race.c:29)
+   by 0x........: th6 (hg04_race.c:35)
+   by 0x........: th5 (hg04_race.c:41)
+   by 0x........: th4 (hg04_race.c:47)
+   by 0x........: th3 (hg04_race.c:53)
+   by 0x........: th2 (hg04_race.c:59)
+   by 0x........: th1 (hg04_race.c:66)
+   by 0x........: th (hg04_race.c:71)
    by 0x........: mythread_wrapper (hg_intercepts.c:...)
-   ...
 
 This conflicts with a previous write of size 4 by thread #x
 Locks held: none
-   at 0x........: th (hg04_race.c:10)
-   by 0x........: mythread_wrapper (hg_intercepts.c:...)
-   ...
+   at 0x........: th10 (hg04_race.c:11)
+   by 0x........: th9 (hg04_race.c:17)
+   by 0x........: th8 (hg04_race.c:23)
+   by 0x........: th7 (hg04_race.c:29)
+   by 0x........: th6 (hg04_race.c:35)
+   by 0x........: th5 (hg04_race.c:41)
+   by 0x........: th4 (hg04_race.c:47)
+   by 0x........: th3 (hg04_race.c:53)
  Location 0x........ is 0 bytes inside global var "shared"
  declared at hg04_race.c:6
 
@@ -33,15 +47,29 @@ Locks held: none
 
 Possible data race during write of size 4 at 0x........ by thread #x
 Locks held: none
-   at 0x........: th (hg04_race.c:10)
+   at 0x........: th10 (hg04_race.c:11)
+   by 0x........: th9 (hg04_race.c:17)
+   by 0x........: th8 (hg04_race.c:23)
+   by 0x........: th7 (hg04_race.c:29)
+   by 0x........: th6 (hg04_race.c:35)
+   by 0x........: th5 (hg04_race.c:41)
+   by 0x........: th4 (hg04_race.c:47)
+   by 0x........: th3 (hg04_race.c:53)
+   by 0x........: th2 (hg04_race.c:59)
+   by 0x........: th1 (hg04_race.c:66)
+   by 0x........: th (hg04_race.c:71)
    by 0x........: mythread_wrapper (hg_intercepts.c:...)
-   ...
 
 This conflicts with a previous write of size 4 by thread #x
 Locks held: none
-   at 0x........: th (hg04_race.c:10)
-   by 0x........: mythread_wrapper (hg_intercepts.c:...)
-   ...
+   at 0x........: th10 (hg04_race.c:11)
+   by 0x........: th9 (hg04_race.c:17)
+   by 0x........: th8 (hg04_race.c:23)
+   by 0x........: th7 (hg04_race.c:29)
+   by 0x........: th6 (hg04_race.c:35)
+   by 0x........: th5 (hg04_race.c:41)
+   by 0x........: th4 (hg04_race.c:47)
+   by 0x........: th3 (hg04_race.c:53)
  Location 0x........ is 0 bytes inside global var "shared"
  declared at hg04_race.c:6
 
diff --git a/helgrind/tests/hg04_race_h9.stderr.exp b/helgrind/tests/hg04_race_h9.stderr.exp
new file mode 100644 (file)
index 0000000..6e692e7
--- /dev/null
@@ -0,0 +1,79 @@
+
+---Thread-Announcement------------------------------------------
+
+Thread #x was created
+   ...
+   by 0x........: pthread_create@* (hg_intercepts.c:...)
+   by 0x........: main (hg04_race.c:82)
+
+---Thread-Announcement------------------------------------------
+
+Thread #x was created
+   ...
+   by 0x........: pthread_create@* (hg_intercepts.c:...)
+   by 0x........: main (hg04_race.c:80)
+
+----------------------------------------------------------------
+
+Possible data race during read of size 4 at 0x........ by thread #x
+Locks held: none
+   at 0x........: th10 (hg04_race.c:11)
+   by 0x........: th9 (hg04_race.c:17)
+   by 0x........: th8 (hg04_race.c:23)
+   by 0x........: th7 (hg04_race.c:29)
+   by 0x........: th6 (hg04_race.c:35)
+   by 0x........: th5 (hg04_race.c:41)
+   by 0x........: th4 (hg04_race.c:47)
+   by 0x........: th3 (hg04_race.c:53)
+   by 0x........: th2 (hg04_race.c:59)
+   by 0x........: th1 (hg04_race.c:66)
+   by 0x........: th (hg04_race.c:71)
+   by 0x........: mythread_wrapper (hg_intercepts.c:...)
+
+This conflicts with a previous write of size 4 by thread #x
+Locks held: none
+   at 0x........: th10 (hg04_race.c:11)
+   by 0x........: th9 (hg04_race.c:17)
+   by 0x........: th8 (hg04_race.c:23)
+   by 0x........: th7 (hg04_race.c:29)
+   by 0x........: th6 (hg04_race.c:35)
+   by 0x........: th5 (hg04_race.c:41)
+   by 0x........: th4 (hg04_race.c:47)
+   by 0x........: th3 (hg04_race.c:53)
+   by 0x........: th2 (hg04_race.c:59)
+ Location 0x........ is 0 bytes inside global var "shared"
+ declared at hg04_race.c:6
+
+----------------------------------------------------------------
+
+Possible data race during write of size 4 at 0x........ by thread #x
+Locks held: none
+   at 0x........: th10 (hg04_race.c:11)
+   by 0x........: th9 (hg04_race.c:17)
+   by 0x........: th8 (hg04_race.c:23)
+   by 0x........: th7 (hg04_race.c:29)
+   by 0x........: th6 (hg04_race.c:35)
+   by 0x........: th5 (hg04_race.c:41)
+   by 0x........: th4 (hg04_race.c:47)
+   by 0x........: th3 (hg04_race.c:53)
+   by 0x........: th2 (hg04_race.c:59)
+   by 0x........: th1 (hg04_race.c:66)
+   by 0x........: th (hg04_race.c:71)
+   by 0x........: mythread_wrapper (hg_intercepts.c:...)
+
+This conflicts with a previous write of size 4 by thread #x
+Locks held: none
+   at 0x........: th10 (hg04_race.c:11)
+   by 0x........: th9 (hg04_race.c:17)
+   by 0x........: th8 (hg04_race.c:23)
+   by 0x........: th7 (hg04_race.c:29)
+   by 0x........: th6 (hg04_race.c:35)
+   by 0x........: th5 (hg04_race.c:41)
+   by 0x........: th4 (hg04_race.c:47)
+   by 0x........: th3 (hg04_race.c:53)
+   by 0x........: th2 (hg04_race.c:59)
+ Location 0x........ is 0 bytes inside global var "shared"
+ declared at hg04_race.c:6
+
+
+ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
diff --git a/helgrind/tests/hg04_race_h9.stdout.exp b/helgrind/tests/hg04_race_h9.stdout.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/helgrind/tests/hg04_race_h9.vgtest b/helgrind/tests/hg04_race_h9.vgtest
new file mode 100644 (file)
index 0000000..528d7a1
--- /dev/null
@@ -0,0 +1,3 @@
+prog: hg04_race
+vgopts: --read-var-info=yes --history-backtrace-size=9
+stderr_filter_args: hg04_race.c