Skip to content

Commit

Permalink
test: Add a test case for variable watchpoints
Browse files Browse the repository at this point in the history
    $ uftrace -W var:mydata tests/t-watch-global
    # DURATION     TID     FUNCTION
                [238314] | __monstartup() {
                [238314] |   /* watch:var (mydata=0) */
       1.375 us [238314] | } /* __monstartup */
       0.384 us [238314] | __cxa_atexit();
                [238314] | main() {
                [238314] |   foo() {
                [238314] |     /* watch:var (mydata=1) */
       0.202 us [238314] |     bar();
                [238314] |     /* watch:var (mydata=2) */
       0.638 us [238314] |   } /* foo */
       0.902 us [238314] | } /* main */

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
  • Loading branch information
namhyung committed May 28, 2024
1 parent 32b0755 commit 9d2f25b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/s-watch-global.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <stdlib.h>

volatile int mydata;

void bar(int n)
{
if (n)
mydata = -1;
}

void foo(int n)
{
mydata = 1;
bar(n);
mydata = 2;
}

int main(int argc, char *argv[])
{
int n = 0;

if (argc > 1)
n = atoi(argv[1]);

foo(n);
return 0;
}
25 changes: 25 additions & 0 deletions tests/t290_watch_global.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3

import re

from runtest import TestBase

class TestCase(TestBase):
def __init__(self):
TestBase.__init__(self, 'watch-global', result="""
# DURATION TID FUNCTION
[243156] | __monstartup() {
[243156] | /* watch:var (mydata=0) */
2.803 us [243156] | } /* __monstartup */
0.621 us [243156] | __cxa_atexit();
[243156] | main() {
[243156] | foo() {
[243156] | /* watch:var (mydata=1) */
0.117 us [243156] | bar();
[243156] | /* watch:var (mydata=2) */
0.643 us [243156] | } /* foo */
0.938 us [243156] | } /* main */
""")

def setup(self):
self.option = '-W var:mydata'

0 comments on commit 9d2f25b

Please sign in to comment.