-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add pyda attach tests, fix bin/pyda
- Loading branch information
Showing
4 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
|
||
ROOT=$(dirname "$0")/../ | ||
ASAN_OPTIONS=$ASAN_OPTIONS:detect_leaks=0 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PYTHONHOME/lib/ PYDA_SCRIPT=$1 exec $DYNAMORIO_HOME/bin64/drrun -stack_size 1024K -c $ROOT/build/pyda_core/libtool.so ${@:2} | ||
PYDA_NO_ATTACH=1 ASAN_OPTIONS=$ASAN_OPTIONS:detect_leaks=0 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PYTHONHOME/lib/ PYDA_SCRIPT=$1 exec $DYNAMORIO_HOME/bin64/drrun -stack_size 1024K -c $ROOT/build/pyda_core/libtool.so ${@:2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
#include <unistd.h> | ||
#include <sys/time.h> | ||
|
||
unsigned long timems() { | ||
struct timeval start; | ||
gettimeofday(&start, NULL); | ||
return (start.tv_sec * 1000000 + start.tv_usec) / 1000; | ||
} | ||
int main() { | ||
printf("Hello from long running test\n"); | ||
|
||
unsigned long start = timems(); | ||
while (timems() - start < 10000) { | ||
sleep(1); | ||
} | ||
|
||
char *buf = malloc(100); | ||
snprintf(buf, 100, "Finished longrunning test\n"); | ||
printf("%s", buf); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <sys/time.h> | ||
#include <stdint.h> | ||
#include <pthread.h> | ||
|
||
unsigned long timems() { | ||
struct timeval start; | ||
gettimeofday(&start, NULL); | ||
return (start.tv_sec * 1000000 + start.tv_usec) / 1000; | ||
} | ||
|
||
void* thread(void *tid) { | ||
unsigned int t = (unsigned int)(unsigned long)tid; | ||
printf("Hello from long running test %u\n", t); | ||
unsigned long start = timems(); | ||
while (timems() - start < 10000) { | ||
sleep(1); | ||
} | ||
char *buf = malloc(100); | ||
snprintf(buf, 100, "Finished longrunning test %u\n", t); | ||
printf("%s", buf); | ||
return NULL; | ||
} | ||
|
||
int main() { | ||
pthread_t threads[10]; | ||
for (int i=0; i<10; i++) { | ||
pthread_create(&threads[i], 0, thread, (void*)(uintptr_t)i); | ||
} | ||
|
||
for (int i=0; i<10; i++) { | ||
void *ret; | ||
pthread_join(threads[i], &ret); | ||
} | ||
|
||
|
||
} |