home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / question / 9268 < prev    next >
Encoding:
Text File  |  1992-07-21  |  11.2 KB  |  521 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!usc!sol.ctr.columbia.edu!cs.columbia.edu!amir
  3. From: amir@cs.columbia.edu (Amiran Eliashvili)
  4. Subject: Memory leaks
  5. Message-ID: <Brrsr6.77J@cs.columbia.edu>
  6. Sender: news@cs.columbia.edu (The Daily News)
  7. Organization: Columbia University Department of Computer Science
  8. References: <Brrsnx.74p@cs.columbia.edu>
  9. Date: Wed, 22 Jul 1992 03:09:06 GMT
  10. Lines: 509
  11.  
  12.  
  13.  
  14. Hi all,
  15.  
  16.  
  17.  
  18. I am having problems running ptrace(2) succesfully. I am trying to get
  19. the first 100 dynamic memory location of a running process.
  20.  
  21.  
  22. What I am trying to do is to fork a process and get its pid and then
  23. exec the executable I am trying to trace. Everything seems to work
  24. except ptrace(). This is my first time using this system call so I am
  25. not quite sure if I am using it correctly. Here is a sample program
  26. that shows my attepmts at using ptrace(2). I'll appreciate greatly any
  27. pointers of how to gp about using ptrace correctly.
  28.  
  29.  
  30.                         Many Thanks In advance
  31.                            --Amiran
  32.  
  33. ---- Sample program -----
  34.  
  35.  
  36.  
  37. /*
  38.  *
  39.  * Design
  40.  * _______
  41.  *
  42.  * The parent forks a child and gets its pid.
  43.  * Then, we set the child to have it traced by the parent
  44.  * at each time we inrement the data segment by four
  45.  * and get all the registers (please reffer to 
  46.  * machine/reg.h to get the name of the registers
  47.  * I am printing Thanks.
  48.  *
  49.  *
  50.  */
  51.  
  52.  
  53. #include <stdio.h>
  54. #include <machine/reg.h>
  55. #include <signal.h>
  56. #include <sys/ptrace.h>
  57. #include <sys/wait.h>
  58.  
  59. main(argc, argv)
  60.      int argc;
  61.      char *argv[];
  62. {
  63.  
  64.   enum ptracereq request;
  65.  
  66.   struct  regs addr;
  67.   int data;
  68.   char *addr2;
  69.   int i=1;
  70.   int pid;
  71.   
  72.   int tmp;
  73.  
  74.  
  75.   if (( pid = fork()) == 0){
  76.     ptrace( PTRACE_TRACEME, 0, 0, 0);
  77.     execl(argv[1],argv[1],0);
  78.     exit(1);
  79.   }
  80.   for(i = 0; i < 100; i++){
  81.     wait((int *)0);
  82.     tmp += sizeof(int); 
  83. /*    if(ptrace(PTRACE_POKEDATA,pid,tmp,i) == -1)
  84.       exit(-1);  */
  85.  
  86.  
  87.  
  88. /*    if(ptrace(PTRACE_ATTACH,pid,0,0) == -1)
  89.       exit(-1);   */                             
  90.     if(ptrace(PTRACE_GETREGS,pid,&addr,i) == -1)
  91.       exit(-1);
  92.  
  93.     printf("addr.r_pc = %d\n",addr.r_pc);
  94.     printf("addr.r_npc = %u\n",addr.r_npc);
  95.     printf("addr.r_psr = %u\n",addr.r_psr);
  96.     printf("addr.r_y = %u\n",addr.r_y);
  97.     printf("addr.r_g1 = %u\n",addr.r_g1); 
  98.     printf("addr.r_g1 = %u\n\n",addr.r_g1); 
  99.  
  100.   }
  101.   /* traced process should resume execution */
  102.   ptrace(PTRACE_CONT, pid, 1, 0);
  103.  
  104. }  /* end */
  105.   
  106.  
  107. Newsgroups: comp.unix.questions, comp.unix.w
  108. Subject: ptrace(2) problems
  109. Summary: 
  110. Expires: 
  111. Sender: 
  112. Followup-To: 
  113. Distribution: 
  114. Organization: Columbia University Department of Computer Science
  115. Keywords: 
  116.  
  117. Hi all,
  118.  
  119.  
  120.  
  121. I am having problems running ptrace(2) succesfully. I am trying to get
  122. the first 100 dynamic memory location of a running process.
  123.  
  124.  
  125. What I am trying to do is to fork a process and get its pid and then
  126. exec the executable I am trying to trace. Everything seems to work
  127. except ptrace(). This is my first time using this system call so I am
  128. not quite sure if I am using it correctly. Here is a sample program
  129. that shows my attepmts at using ptrace(2). I'll appreciate greatly any
  130. pointers of how to gp about using ptrace correctly.
  131.  
  132.  
  133.                         Many Thanks In advance
  134.                            --Amiran
  135.  
  136. ---- Sample program -----
  137.  
  138.  
  139.  
  140. /*
  141.  *
  142.  * Design
  143.  * _______
  144.  *
  145.  * The parent forks a child and gets its pid.
  146.  * Then, we set the child to have it traced by the parent
  147.  * at each time we inrement the data segment by four
  148.  * and get all the registers (please reffer to 
  149.  * machine/reg.h to get the name of the registers
  150.  * I am printing Thanks.
  151.  *
  152.  *
  153.  */
  154.  
  155.  
  156. #include <stdio.h>
  157. #include <machine/reg.h>
  158. #include <signal.h>
  159. #include <sys/ptrace.h>
  160. #include <sys/wait.h>
  161.  
  162. main(argc, argv)
  163.      int argc;
  164.      char *argv[];
  165. {
  166.  
  167.   enum ptracereq request;
  168.  
  169.   struct  regs addr;
  170.   int data;
  171.   char *addr2;
  172.   int i=1;
  173.   int pid;
  174.   
  175.   int tmp;
  176.  
  177.  
  178.   if (( pid = fork()) == 0){
  179.     ptrace( PTRACE_TRACEME, 0, 0, 0);
  180.     execl(argv[1],argv[1],0);
  181.     exit(1);
  182.   }
  183.   for(i = 0; i < 100; i++){
  184.     wait((int *)0);
  185.     tmp += sizeof(int); 
  186. /*    if(ptrace(PTRACE_POKEDATA,pid,tmp,i) == -1)
  187.       exit(-1);  */
  188.  
  189.  
  190.  
  191. /*    if(ptrace(PTRACE_ATTACH,pid,0,0) == -1)
  192.       exit(-1);   */                             
  193.     if(ptrace(PTRACE_GETREGS,pid,&addr,i) == -1)
  194.       exit(-1);
  195.  
  196.     printf("addr.r_pc = %d\n",addr.r_pc);
  197.     printf("addr.r_npc = %u\n",addr.r_npc);
  198.     printf("addr.r_psr = %u\n",addr.r_psr);
  199.     printf("addr.r_y = %u\n",addr.r_y);
  200.     printf("addr.r_g1 = %u\n",addr.r_g1); 
  201.     printf("addr.r_g1 = %u\n\n",addr.r_g1); 
  202.  
  203.   }
  204.   /* traced process should resume execution */
  205.   ptrace(PTRACE_CONT, pid, 1, 0);
  206.  
  207. }  /* end */
  208.   
  209.  
  210. Newsgroups: comp.unix.questions,comp.unix.admin,comp.unix.wizards,comp.unix.ultrix
  211. Subject: ptrace(2) problems
  212. Summary: 
  213. Expires: 
  214. Sender: 
  215. Followup-To: 
  216. Distribution: 
  217. Organization: Columbia University Department of Computer Science
  218. Keywords: 
  219.  
  220.  
  221.  
  222. Hi all,
  223.  
  224.  
  225.  
  226. I am having problems running ptrace(2) succesfully. I am trying to get
  227. the first 100 dynamic memory location of a running process.
  228.  
  229.  
  230. What I am trying to do is to fork a process and get its pid and then
  231. exec the executable I am trying to trace. Everything seems to work
  232. except ptrace(). This is my first time using this system call so I am
  233. not quite sure if I am using it correctly. Here is a sample program
  234. that shows my attepmts at using ptrace(2). I'll appreciate greatly any
  235. pointers of how to gp about using ptrace correctly.
  236.  
  237.  
  238.                         Many Thanks In advance
  239.                            --Amiran
  240.  
  241. ---- Sample program -----
  242.  
  243.  
  244.  
  245. /*
  246.  *
  247.  * Design
  248.  * _______
  249.  *
  250.  * The parent forks a child and gets its pid.
  251.  * Then, we set the child to have it traced by the parent
  252.  * at each time we inrement the data segment by four
  253.  * and get all the registers (please reffer to 
  254.  * machine/reg.h to get the name of the registers
  255.  * I am printing Thanks.
  256.  *
  257.  *
  258.  */
  259.  
  260.  
  261. #include <stdio.h>
  262. #include <machine/reg.h>
  263. #include <signal.h>
  264. #include <sys/ptrace.h>
  265. #include <sys/wait.h>
  266.  
  267. main(argc, argv)
  268.      int argc;
  269.      char *argv[];
  270. {
  271.  
  272.   enum ptracereq request;
  273.  
  274.   struct  regs addr;
  275.   int data;
  276.   char *addr2;
  277.   int i=1;
  278.   int pid;
  279.   
  280.   int tmp;
  281.  
  282.  
  283.   if (( pid = fork()) == 0){
  284.     ptrace( PTRACE_TRACEME, 0, 0, 0);
  285.     execl(argv[1],argv[1],0);
  286.     exit(1);
  287.   }
  288.   for(i = 0; i < 100; i++){
  289.     wait((int *)0);
  290.     tmp += sizeof(int); 
  291. /*    if(ptrace(PTRACE_POKEDATA,pid,tmp,i) == -1)
  292.       exit(-1);  */
  293.  
  294.  
  295.  
  296. /*    if(ptrace(PTRACE_ATTACH,pid,0,0) == -1)
  297.       exit(-1);   */                             
  298.     if(ptrace(PTRACE_GETREGS,pid,&addr,i) == -1)
  299.       exit(-1);
  300.  
  301.     printf("addr.r_pc = %d\n",addr.r_pc);
  302.     printf("addr.r_npc = %u\n",addr.r_npc);
  303.     printf("addr.r_psr = %u\n",addr.r_psr);
  304.     printf("addr.r_y = %u\n",addr.r_y);
  305.     printf("addr.r_g1 = %u\n",addr.r_g1); 
  306.     printf("addr.r_g1 = %u\n\n",addr.r_g1); 
  307.  
  308.   }
  309.   /* traced process should resume execution */
  310.   ptrace(PTRACE_CONT, pid, 1, 0);
  311.  
  312. }  /* end */
  313.   
  314.  
  315. Newsgroups: comp.unix.wizards
  316. Subject: ptrace(2) problems
  317. Summary: 
  318. Expires: 
  319. Sender: 
  320. Followup-To: 
  321. Distribution: 
  322. Organization: Columbia University Department of Computer Science
  323. Keywords: 
  324.  
  325.  
  326.  
  327. Hi all,
  328.  
  329.  
  330.  
  331. I am having problems running ptrace(2) succesfully. I am trying to get
  332. the first 100 dynamic memory location of a running process.
  333.  
  334.  
  335. What I am trying to do is to fork a process and get its pid and then
  336. exec the executable I am trying to trace. Everything seems to work
  337. except ptrace(). This is my first time using this system call so I am
  338. not quite sure if I am using it correctly. Here is a sample program
  339. that shows my attepmts at using ptrace(2). I'll appreciate greatly any
  340. pointers of how to gp about using ptrace correctly.
  341.  
  342.  
  343.                         Many Thanks In advance
  344.                            --Amiran
  345. Please respond via e-mail
  346.  
  347. ---- Sample program -----
  348.  
  349.  
  350.  
  351. /*
  352.  *
  353.  * Design
  354.  * _______
  355.  *
  356.  * The parent forks a child and gets its pid.
  357.  * Then, we set the child to have it traced by the parent
  358.  * at each time we inrement the data segment by four
  359.  * and get all the registers (please reffer to 
  360.  * machine/reg.h to get the name of the registers
  361.  * I am printing Thanks.
  362.  *
  363.  *
  364.  */
  365.  
  366.  
  367. #include <stdio.h>
  368. #include <machine/reg.h>
  369. #include <signal.h>
  370. #include <sys/ptrace.h>
  371. #include <sys/wait.h>
  372.  
  373. main(argc, argv)
  374.      int argc;
  375.      char *argv[];
  376. {
  377.  
  378.   enum ptracereq request;
  379.  
  380.   struct  regs addr;
  381.   int data;
  382.   char *addr2;
  383.   int i=1;
  384.   int pid;
  385.   
  386.   int tmp;
  387.  
  388.  
  389.   if (( pid = fork()) == 0){
  390.     ptrace( PTRACE_TRACEME, 0, 0, 0);
  391.     execl(argv[1],argv[1],0);
  392.     exit(1);
  393.   }
  394.   for(i = 0; i < 100; i++){
  395.     wait((int *)0);
  396.     tmp += sizeof(int); 
  397. /*    if(ptrace(PTRACE_POKEDATA,pid,tmp,i) == -1)
  398.       exit(-1);  */
  399.  
  400.  
  401.  
  402. /*    if(ptrace(PTRACE_ATTACH,pid,0,0) == -1)
  403.       exit(-1);   */                             
  404.     if(ptrace(PTRACE_GETREGS,pid,&addr,i) == -1)
  405.       exit(-1);
  406.  
  407.     printf("addr.r_pc = %d\n",addr.r_pc);
  408.     printf("addr.r_npc = %u\n",addr.r_npc);
  409.     printf("addr.r_psr = %u\n",addr.r_psr);
  410.     printf("addr.r_y = %u\n",addr.r_y);
  411.     printf("addr.r_g1 = %u\n",addr.r_g1); 
  412.     printf("addr.r_g1 = %u\n\n",addr.r_g1); 
  413.  
  414.   }
  415.   /* traced process should resume execution */
  416.   ptrace(PTRACE_CONT, pid, 1, 0);
  417.  
  418. }  /* end */
  419.   
  420.  
  421. Newsgroups: comp.protocols.tcp-ip
  422. Subject: 10BASE-F
  423. Summary: 
  424. Expires: 
  425. Sender: 
  426. Followup-To: 
  427. Distribution: 
  428. Organization: Columbia University Department of Computer Science
  429. Keywords: 
  430.  
  431.  
  432. I am looking for documentations or any litrature on the following
  433. subject:
  434.  
  435.     FIBER OPTIC-BASED HIGH-SPEED LOCAL AREA NETWORK.
  436.  
  437. Are there any good books or articles on the subject?
  438. Hwo does one go about finding more about the subject?
  439.  
  440.  
  441. Please reply by e-mail  to amir@cs.columbia.edu. Thanks
  442.  
  443. /amiran
  444.  
  445. Newsgroups: comp.unix.programmer
  446. Subject: Ramdisk
  447. Summary: 
  448. Expires: 
  449. Sender: 
  450. Followup-To: 
  451. Distribution: 
  452. Organization: Columbia University Department of Computer Science
  453. Keywords: 
  454.  
  455.  
  456. Hi all:
  457.  
  458.     Does anyone out there has any experience, good or bad, reading
  459. and writing to ramdisks. I am trying to speed up the reading from
  460. files and I heard that ramdisk might be the way to go about this. I
  461. would appreciate more details on this scheme -- why it might be
  462. faster, what are the big disadvantage, ... . Also, is it true that one
  463. can only use fopen(), fwrite(), and fread() with ramdisks?
  464.  
  465.  
  466. All relevant comments are welcomed.
  467.  
  468. Pleases respond via e-mail to: amir@cs.columbia.edu
  469.  
  470. Thanks
  471. /amiran
  472. Newsgroups: sci.math.num-analysis
  473. Subject: An efficient way of finding the the delta of two numbers
  474. Summary: 
  475. Expires: 
  476. Sender: 
  477. Followup-To: 
  478. Distribution: 
  479. Organization: Columbia University Department of Computer Science
  480. Keywords: 
  481.  
  482.  
  483. Hi all:
  484.  
  485.     I am trying to come up with an efficient way (fewest number of
  486. iteration ) to find in a list of numbers (not sorted) two numbers
  487. whose delta (x - y) is the least. So far I could see O(n^2) and
  488. possibly n*log(n). Are there any kind souls out there that know of a
  489. better methods that will improve on the above number of iterations?
  490.  
  491.     I am not quite sure that this is the most appropriate place to
  492. post this so I apologize head of time for those who resent the question.
  493.  
  494.  
  495. Please reply to amir@cs.columbia.edu 
  496. Thanks.
  497. /amiran
  498. Newsgroups: comp.unix.questions
  499. Subject: Memory leaks
  500. Summary: 
  501. Expires: 
  502. Sender: 
  503. Followup-To: 
  504. Distribution: 
  505. Organization: Columbia University Department of Computer Science
  506. Keywords: 
  507.  
  508.  
  509.  
  510. Hi all:
  511.  
  512.  
  513.     I was wondering if there are any utilities in PD that will
  514. check for memory leaks. Has anyone used such utilities before? If so,
  515. how helpful were they?
  516.  
  517. Please reply to amir@cs.columbia.edu
  518.  
  519. Thanks
  520. /amiran
  521.