DOC PREVIEW
CMU CS 15213 - How to dBug your (threaded) proxy

This preview shows page 1-2-19-20 out of 20 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

15 213 How to dBug your threaded proxy Ji im a PARALLEL DATA LABORATORY Carnegie Mellon University Motivation Concurrency is a good servant but a bad master Today we will cover good programming practices good debugging practices tips for designing and testing your proxy a tool for testing your multi threaded proxy http www pdl cmu edu 2 Jiri Simsa October 10 Before We Start Go to http www virtualbox org and download and install VirtualBox on your laptop Go to http www cs cmu edu 213 resources html and start downloading the dbug 213 vdi http www pdl cmu edu 3 Jiri Simsa October 10 GOOD PROGRAMMING PRACTICES http www pdl cmu edu 4 Jiri Simsa October 10 1 Know Your Library Calls pthread mutex lock mutex if cache empty pthread mutex unlock mutex pthread mutex unlock mutex Spending time reading a man page will dispel your misconceptions and save you hours of frustration http www pdl cmu edu 5 Jiri Simsa October 10 2 Check Return Values ret accept sockfd addr addrlen if ret 1 perror Accept failed n else assert pthread mutex lock mutex 0 Handling error cases correctly will facilitate identification of program failure root cause http www pdl cmu edu 6 Jiri Simsa October 10 3 Use Conditional Compilation void request handler void args ifdef DEBUG printf Entering s FUNCTION endif gcc DDEBUG http www pdl cmu edu Spending time including informative messages will greatly improve your debugging efficiency 7 Jiri Simsa October 10 4 Learn and Use Makefiles CC gcc CFLAGS g Wall Werror LDFLAGS lpthread all proxy proxy test proxy proxy c csapp c CC o CFLAGS O3 LDFLAGS proxy test CC o http www pdl cmu edu Spending time learning howcsapp c to use a Makefile will proxy c CFLAGS DDEBUG LDFLAGS save you hours of repetitive and dull work 8 Jiri Simsa October 10 5 Keep It Simple Silly int main int argc char argv init proxy while 1 if ret accept sockfd addr addrlen 0 setup args sockfd addr addrlen args ret pthread create tid 0 handler args assert ret 0 else perror Accept failed n Start with the simplest approach possible Often getting the simplest design right will be enough http www pdl cmu edu 9 Jiri Simsa October 10 6 Avoid Premature Optimizations All cache operations take O 1 time Sick fancy cache t cache inline void lookup cache entry struct cache entry entry 100 lines of code Start with the simplest approach possible Often getting the simplest design right will be enough http www pdl cmu edu 10 Jiri Simsa October 10 7 Learn and Use gdb ulimit c unlimited proxy 1234 Segmentation fault core dumped gdb proxy core gdb bt 3 0x08049865 in doit fd 4 at proxy c 179 4 0x080496c5 in thread handler connfdp 0x9920008 at proxy c 136 5 0x00da7cc9 in start thread arg 0xb78adb70 at pthread create c 304 Learning how to control and inspect execution of a program is instrumental to efficient debugging http www pdl cmu edu 11 Jiri Simsa October 10 Summary of Good Practices 1 2 3 4 5 6 7 Know Your Library Calls Check Return Values Use Conditional Compilation Learn and Use a Makefile Keep it Simple Avoid Premature Optimization Learn and Use gdb http www pdl cmu edu 12 Jiri Simsa October 10 TESTING YOUR PROXY http www pdl cmu edu 13 Jiri Simsa October 10 Sequential Proxy Test Case Open three terminal windows 1 cd TINY make sudo tiny 80 2 cd PROXY make proxy 1234 3 curl x localhost 1234 http localhost html head title test title head body img align middle src godzilla gif Dave O Hallaron body html http www pdl cmu edu 14 Jiri Simsa October 10 Case Proxy Test Case Open three terminal windows 1 cd TINY make sudo tiny 80 2 cd PROXY make proxy 1234 3 curl x localhost 1234 HTTP LoCaLhOst html head title test title head body img align middle src godzilla gif Dave O Hallaron body html http www pdl cmu edu 15 Jiri Simsa October 10 Port Proxy Test Case Open three terminal windows 1 cd TINY make tiny 8080 2 cd PROXY make proxy 1234 3 curl x localhost 1234 http localhost 8080 html head title test title head body img align middle src godzilla gif Dave O Hallaron body html http www pdl cmu edu 16 Jiri Simsa October 10 Cache Proxy Test Case Open three terminal windows 1 2 3 3 3 cd TINY make sudo tiny 80 cd PROXY make proxy 1234 curl x localhost 1234 http localhost killall 9 tiny curl x localhost 1234 http localhost html head title test title head body img align middle src godzilla gif http www pdl cmu edu 17 Jiri Simsa October 10 Concurrent Proxy Test Case Open three terminal windows 1 2 3 3 cd TINY make sudo tiny 80 cd PROXY make proxy 1234 export CMD curl x localhost 1234 http localhost CMD CMD Which request will get serviced 1st Will the 2nd request be serviced from cache Will a non reentrant function be called concurrently How to try out all possible cases http www pdl cmu edu 18 Jiri Simsa October 10 USING DBUG http www pdl cmu edu 19 Jiri Simsa October 10 dBug Concurrent gdb and more Systematic Testing of Concurrent Systems Given a concurrent system and a test dBug systematically explores all possible ways in which the test could have executed dBug searches for deadlocks data races and assertion violations http www pdl cmu edu 20 Jiri Simsa October 10


View Full Document

CMU CS 15213 - How to dBug your (threaded) proxy

Documents in this Course
lecture

lecture

14 pages

lecture

lecture

46 pages

Caches

Caches

9 pages

lecture

lecture

39 pages

Lecture

Lecture

36 pages

Lecture

Lecture

45 pages

Lecture

Lecture

56 pages

lecture

lecture

11 pages

lecture

lecture

9 pages

Lecture

Lecture

36 pages

Lecture

Lecture

37 pages

Exam

Exam

16 pages

Lecture

Lecture

10 pages

Lecture

Lecture

43 pages

Lecture

Lecture

8 pages

Lecture

Lecture

8 pages

Lecture

Lecture

36 pages

Lecture

Lecture

43 pages

Lecture

Lecture

12 pages

Lecture

Lecture

37 pages

Lecture

Lecture

6 pages

Lecture

Lecture

40 pages

coding

coding

2 pages

Exam

Exam

17 pages

Exam

Exam

14 pages

Lecture

Lecture

29 pages

Lecture

Lecture

34 pages

Exam

Exam

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

37 pages

Lecture

Lecture

36 pages

lecture

lecture

46 pages

Lecture

Lecture

33 pages

Lecture

Lecture

57 pages

Lecture

Lecture

32 pages

Lecture

Lecture

46 pages

Lecture

Lecture

40 pages

Lecture

Lecture

11 pages

Lecture

Lecture

6 pages

Lecture

Lecture

43 pages

Lecture

Lecture

12 pages

Lecture

Lecture

18 pages

Exam

Exam

10 pages

Lecture

Lecture

45 pages

Lecture

Lecture

37 pages

Exam

Exam

24 pages

class09

class09

21 pages

class22

class22

37 pages

class20

class20

30 pages

class27

class27

33 pages

class25

class25

21 pages

class04

class04

31 pages

Lecture

Lecture

59 pages

class01a

class01a

14 pages

class12

class12

45 pages

class29

class29

33 pages

Lecture

Lecture

39 pages

Lecture

Lecture

6 pages

class03

class03

34 pages

lecture

lecture

42 pages

Lecture

Lecture

40 pages

Lecture

Lecture

47 pages

Exam

Exam

19 pages

R06-B

R06-B

25 pages

class17

class17

37 pages

class25

class25

31 pages

Lecture

Lecture

15 pages

final-f06

final-f06

17 pages

Lecture

Lecture

9 pages

lecture

lecture

9 pages

Exam

Exam

15 pages

Lecture

Lecture

22 pages

class11

class11

45 pages

lecture

lecture

50 pages

Linking

Linking

37 pages

Lecture

Lecture

64 pages

Integers

Integers

40 pages

Exam

Exam

11 pages

Lecture

Lecture

37 pages

Lecture

Lecture

44 pages

Lecture

Lecture

37 pages

Lecture

Lecture

9 pages

Lecture

Lecture

37 pages

Lecture

Lecture

45 pages

Final

Final

25 pages

lecture

lecture

9 pages

Lecture

Lecture

30 pages

Lecture

Lecture

16 pages

Final

Final

17 pages

Lecture

Lecture

8 pages

Exam

Exam

11 pages

Lecture

Lecture

47 pages

Lecture

Lecture

9 pages

lecture

lecture

39 pages

Exam

Exam

11 pages

lecture

lecture

41 pages

lecture

lecture

37 pages

Lecture

Lecture

59 pages

Lecture

Lecture

45 pages

Exam 1

Exam 1

18 pages

Lecture

Lecture

41 pages

Lecture

Lecture

32 pages

Lecture

Lecture

30 pages

Lecture

Lecture

9 pages

Lecture

Lecture

9 pages

Lecture

Lecture

15 pages

Lecture

Lecture

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

34 pages

Lecture

Lecture

40 pages

Lecture

Lecture

4 pages

Lecture

Lecture

46 pages

Lecture

Lecture

8 pages

Lecture

Lecture

65 pages

Lecture

Lecture

38 pages

Lecture

Lecture

35 pages

Lecture

Lecture

8 pages

Lecture

Lecture

34 pages

Lecture

Lecture

8 pages

Exam

Exam

13 pages

Lecture

Lecture

43 pages

Lecture

Lecture

9 pages

Lecture

Lecture

12 pages

Lecture

Lecture

9 pages

Lecture

Lecture

34 pages

Lecture

Lecture

43 pages

Lecture

Lecture

7 pages

Lecture

Lecture

45 pages

Lecture

Lecture

24 pages

Lecture

Lecture

47 pages

Lecture

Lecture

12 pages

Lecture

Lecture

20 pages

Lecture

Lecture

9 pages

Exam

Exam

11 pages

Lecture

Lecture

52 pages

Lecture

Lecture

20 pages

Exam

Exam

11 pages

Lecture

Lecture

35 pages

Lecture

Lecture

47 pages

Lecture

Lecture

18 pages

Lecture

Lecture

30 pages

Lecture

Lecture

59 pages

Lecture

Lecture

37 pages

Lecture

Lecture

22 pages

Lecture

Lecture

35 pages

Exam

Exam

23 pages

Lecture

Lecture

9 pages

Lecture

Lecture

22 pages

class12

class12

32 pages

Lecture

Lecture

8 pages

Lecture

Lecture

39 pages

Lecture

Lecture

44 pages

Lecture

Lecture

38 pages

Lecture

Lecture

69 pages

Lecture

Lecture

41 pages

Lecture

Lecture

12 pages

Lecture

Lecture

52 pages

Lecture

Lecture

59 pages

Lecture

Lecture

39 pages

Lecture

Lecture

83 pages

Lecture

Lecture

59 pages

class01b

class01b

17 pages

Exam

Exam

21 pages

class07

class07

47 pages

Lecture

Lecture

11 pages

Odyssey

Odyssey

18 pages

multicore

multicore

66 pages

Lecture

Lecture

6 pages

lecture

lecture

41 pages

lecture

lecture

55 pages

lecture

lecture

52 pages

lecture

lecture

33 pages

lecture

lecture

46 pages

lecture

lecture

55 pages

lecture

lecture

17 pages

lecture

lecture

49 pages

Exam

Exam

17 pages

lecture

lecture

56 pages

Exam 2

Exam 2

16 pages

Exam 2

Exam 2

16 pages

Notes

Notes

37 pages

Lecture

Lecture

40 pages

Lecture

Lecture

36 pages

Lecture

Lecture

43 pages

Lecture

Lecture

25 pages

Exam

Exam

13 pages

Lecture

Lecture

32 pages

Lecture

Lecture

12 pages

Lecture

Lecture

58 pages

Lecture

Lecture

29 pages

Lecture

Lecture

59 pages

Lecture

Lecture

41 pages

Lecture

Lecture

50 pages

Exam

Exam

17 pages

Lecture

Lecture

29 pages

Lecture

Lecture

44 pages

Lecture

Lecture

41 pages

Lecture

Lecture

52 pages

Lecture

Lecture

40 pages

Lecture

Lecture

33 pages

lecture

lecture

10 pages

Lecture

Lecture

27 pages

Lecture

Lecture

29 pages

Lecture

Lecture

39 pages

Lecture

Lecture

9 pages

Lecture

Lecture

29 pages

Lecture

Lecture

8 pages

Lecture

Lecture

43 pages

Lecture

Lecture

43 pages

Lecture

Lecture

75 pages

Lecture

Lecture

55 pages

Exam

Exam

12 pages

Lecture

Lecture

43 pages

Lecture

Lecture

35 pages

lecture

lecture

36 pages

Exam

Exam

33 pages

lecture

lecture

56 pages

lecture

lecture

64 pages

lecture

lecture

8 pages

Exam

Exam

14 pages

Lecture

Lecture

43 pages

Lecture

Lecture

36 pages

lecture

lecture

56 pages

lecture

lecture

75 pages

lecture

lecture

36 pages

Lecture

Lecture

50 pages

Lecture

Lecture

45 pages

Lecture

Lecture

13 pages

Exam

Exam

23 pages

Lecture

Lecture

10 pages

Lecture

Lecture

48 pages

Lecture

Lecture

83 pages

lecture

lecture

57 pages

Lecture

Lecture

33 pages

Lecture

Lecture

39 pages

Lecture

Lecture

33 pages

lecture

lecture

54 pages

Lecture

Lecture

30 pages

Exam

Exam

13 pages

Lecture

Lecture

36 pages

Lecture

Lecture

40 pages

Exam

Exam

17 pages

Lecture

Lecture

9 pages

Exam

Exam

15 pages

Lecture

Lecture

44 pages

Lecture

Lecture

34 pages

Lecture

Lecture

24 pages

Lecture

Lecture

29 pages

class12

class12

43 pages

lecture

lecture

43 pages

class22

class22

22 pages

R06-B

R06-B

25 pages

class01b

class01b

19 pages

lecture

lecture

29 pages

lab1

lab1

8 pages

Caches

Caches

36 pages

lecture

lecture

55 pages

Lecture,

Lecture,

37 pages

Integers

Integers

40 pages

Linking

Linking

38 pages

lecture

lecture

45 pages

Lecture

Lecture

61 pages

Linking

Linking

33 pages

lecture

lecture

40 pages

lecture

lecture

40 pages

Lecture

Lecture

32 pages

lecture

lecture

48 pages

lecture

lecture

44 pages

Exam

Exam

11 pages

Lecture

Lecture

31 pages

Lecture

Lecture

46 pages

Lecture

Lecture

40 pages

Lecture

Lecture

40 pages

Exam

Exam

12 pages

Lecture

Lecture

42 pages

Lecture

Lecture

36 pages

Lecture

Lecture

45 pages

Lecture

Lecture

41 pages

Lecture

Lecture

13 pages

Lecture

Lecture

35 pages

Lecture

Lecture

20 pages

Final

Final

19 pages

Lecture

Lecture

33 pages

Lecture

Lecture

50 pages

Lecture

Lecture

33 pages

Lecture

Lecture

27 pages

Lecture

Lecture

6 pages

Exam

Exam

15 pages

Lecture

Lecture

24 pages

Lecture

Lecture

23 pages

Lecture

Lecture

43 pages

Lecture

Lecture

32 pages

Lecture

Lecture

52 pages

Lecture

Lecture

37 pages

Lecture

Lecture

36 pages

Lecture

Lecture

34 pages

Lecture

Lecture

40 pages

Lecture

Lecture

15 pages

lecture

lecture

21 pages

Lecture

Lecture

58 pages

Lecture

Lecture

49 pages

Lecture

Lecture

36 pages

Lecture

Lecture

11 pages

Lecture

Lecture

12 pages

Lecture

Lecture

58 pages

Lecture

Lecture

33 pages

Exam

Exam

15 pages

Lecture

Lecture

35 pages

Lecture

Lecture

10 pages

Lecture

Lecture

25 pages

Lecture

Lecture

31 pages

Lecture

Lecture

24 pages

Lecture

Lecture

34 pages

Lecture

Lecture

50 pages

lecture

lecture

35 pages

Lecture

Lecture

11 pages

Lecture

Lecture

39 pages

Lecture

Lecture

45 pages

Lecture

Lecture

41 pages

exam1-f05

exam1-f05

11 pages

Lecture

Lecture

4 pages

Lecture

Lecture

17 pages

Exam

Exam

17 pages

malloc()

malloc()

12 pages

Lecture

Lecture

57 pages

Lecture

Lecture

30 pages

Lecture

Lecture

30 pages

Lecture

Lecture

47 pages

Lecture

Lecture

33 pages

Exam

Exam

12 pages

Lecture

Lecture

43 pages

Lectures

Lectures

33 pages

Lecture

Lecture

36 pages

lecture

lecture

33 pages

Exam

Exam

14 pages

Lecture

Lecture

43 pages

Lecture

Lecture

25 pages

Load more
Download How to dBug your (threaded) proxy
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view How to dBug your (threaded) proxy and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view How to dBug your (threaded) proxy and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?