Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions p1debuglog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
 gdb a.out
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...done.
(gdb) b main
Breakpoint 1 at 0x7fc: file p1final.c, line 16.
(gdb) r
Starting program: /home/runner/pps-IA1-practice-2/a.out
warning: Error disabling address space randomization: Operation not permitted

Breakpoint 1, main () at p1final.c:16
16 {
(gdb) s
18 input(&a,&b);
(gdb) s
input (a=0x7fff68a0d02c, b=0x7fff68a0d030) at p1final.c:4
4 printf("enter the 2 numbers\n");
(gdb) n
enter the 2 numbers
5 scanf("%d%d",&*a,&*b);
(gdb) n
3
6
6 }
(gdb) p a
$1 = (int *) 0x7fff68a0d02c
(gdb) p b
$2 = (int *) 0x7fff68a0d030
(gdb) n
main () at p1final.c:19
19 add(a,b,&sum);
(gdb) p a
$3 = 3
(gdb) p b
$4 = 6
(gdb) s
add (a=3, b=6, sum=0x7fff68a0d034) at p1final.c:9
9 *sum=a+b;
(gdb) n
10 }
(gdb) n
main () at p1final.c:20
20 output(a,b,sum);
(gdb) p sum
$5 = 9
(gdb) s
output (a=3, b=6, sum=9) at p1final.c:13
13 printf("sum of %d + %d is %d",a,b,sum);
(gdb) n
14 }
(gdb) n
main () at p1final.c:21
21 }
(gdb) c
Continuing.
sum of 3 + 6 is 9[Inferior 1 (process 112) exited normally]
(gdb) q
21 changes: 21 additions & 0 deletions p1final.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdio.h>
void input(int *a,int *b)
{
printf("enter the 2 numbers\n");
scanf("%d%d",&*a,&*b);
}
void add(int a,int b,int *sum)
{
*sum=a+b;
}
void output(int a,int b,int sum)
{
printf("sum of %d + %d is %d",a,b,sum);
}
int main()
{
int a,b,sum;
input(&a,&b);
add(a,b,&sum);
output(a,b,sum);
}
23 changes: 21 additions & 2 deletions p1original.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@

}
#include <stdio.h>
void input(int *a,int *b)
{
printf("enter the 2 numbers\n");
scanf("%d%d",&*a,&*b);
}
void add(int a,int b,int *sum)
{
*sum=a+b;
}
void output(int a,int b,int sum)
{
printf("sum of %d + %d is %d",a,b,sum);
}
int main()
{
int a,b,sum;
input(&a,&b);
add(a,b,&sum);
output(a,b,sum);
}
95 changes: 95 additions & 0 deletions p2debuglog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
 gdb a.out
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...done.
(gdb) b main
Breakpoint 1 at 0x839: file p2final.c, line 19.
(gdb) r
Starting program: /home/runner/pps-IA1-practice-2/a.out
warning: Error disabling address space randomization: Operation not permitted

Breakpoint 1, main () at p2final.c:19
19 int a=input();
(gdb) s
input () at p2final.c:3
3 {
(gdb) n
5 printf("enter the number\n");
(gdb) n
enter the number
6 scanf("%d",&a);
(gdb) n
90
7 return a;
(gdb) n
8 }
(gdb) n
main () at p2final.c:20
20 int b=input();
(gdb) p a
$1 = 90
(gdb) s
input () at p2final.c:3
3 {
(gdb) n
5 printf("enter the number\n");
(gdb) n
enter the number
6 scanf("%d",&a);
(gdb) n
56
7 return a;
(gdb) n
8 }
(gdb) n
main () at p2final.c:21
21 int c=input();
(gdb) s
input () at p2final.c:3
3 {
(gdb) n
5 printf("enter the number\n");
(gdb) n
enter the number
6 scanf("%d",&a);
(gdb) n
10
7 return a;
(gdb) n
8 }
22 int largest=cmp(a,b,c);
(gdb) s
cmp (a=90, b=56, c=10) at p2final.c:11
11 return a>b?a>c?a:c:b>a?b>c?b:c:a;
(gdb) n
12 }
(gdb) n
main () at p2final.c:23
23 output(a,b,c,largest);
(gdb) p largest
$3 = 90
(gdb) s
output (a=90, b=56, c=10, largest=90) at p2final.c:15
15 printf("the largest number of %d %d and %d is %d\n",a,b,c,largest);
(gdb) n
the largest number of 90 56 and 10 is 90
16 }
(gdb) n
main () at p2final.c:24
24 }
(gdb) c
Continuing.
[Inferior 1 (process 185) exited normally]
(gdb) q
24 changes: 24 additions & 0 deletions p2final.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>
int input()
{
int a;
printf("enter the number\n");
scanf("%d",&a);
return a;
}
int cmp(int a,int b,int c)
{
return a>b?a>c?a:c:b>a?b>c?b:c:a;
}
void output(int a,int b,int c,int largest)
{
printf("the largest number of %d %d and %d is %d\n",a,b,c,largest);
}
int main()
{
int a=input();
int b=input();
int c=input();
int largest=cmp(a,b,c);
output(a,b,c,largest);
}
37 changes: 37 additions & 0 deletions p2original.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <stdio.h>
int input()
{
int a;
printf("enter the number\n");
scanf("%d",&a);
return a;
}
int cmp(int a,int b,int c)
{
if(a<b)
{
if(b<c)
return b;
else
return c;
}
else if(b<a)
{
if(a>c)
return a;
else
return c;
}
}
void output(int a,int b,int c,int largest)
{
printf("the largest number of %d %d and %d is %d\n",a,b,c,largest);
}
int main()
{
int a=input();
int b=input();
int c=input();
int largest=cmp(a,b,c);
output(a,b,c,largest);
}
108 changes: 108 additions & 0 deletions p3debuglog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
 gdb a.out
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...done.
(gdb) b main
Breakpoint 1 at 0x83d: file p3final.c, line 23.
(gdb) r
Starting program: /home/runner/pps-IA1-practice-2/a.out
warning: Error disabling address space randomization: Operation not permitted

Breakpoint 1, main () at p3final.c:23
23 printf("enter the limit\n");
(gdb) n
enter the limit
24 int n=input_n();
(gdb) s
input_n () at p3final.c:3
3 {
(gdb) n
5 scanf("%d",&a);
(gdb) 3
Undefined command: "3". Try "help".
(gdb) n
3
6 return a;
(gdb) n
7 }
(gdb) n
main () at p3final.c:25
25 int sum=sum_n(n);
(gdb) p n
$1 = 3
(gdb) s
sum_n (n=3) at p3final.c:10
10 int sum=0;
(gdb) n
11 for(int i=1;i<=n;i++)
(gdb) p i
$2 = 1574748203
(gdb) n
12 sum=sum+i;
(gdb) p i
$3 = 1
(gdb) n
11 for(int i=1;i<=n;i++)
(gdb) p sum
$4 = 1
(gdb) n
12 sum=sum+i;
(gdb) p i
$5 = 2
(gdb) n
11 for(int i=1;i<=n;i++)
(gdb) p sum
$6 = 3
(gdb) n
12 sum=sum+i;
(gdb) p i
$7 = 3
(gdb) n
11 for(int i=1;i<=n;i++)
(gdb) n
13 return sum;
(gdb) p sum
$8 = 6
(gdb) n
14 }
(gdb) n
main () at p3final.c:26
26 output(n,sum);
(gdb) s
output (n=3, sum=6) at p3final.c:17
17 for(int i=1;i<n;i++)
(gdb) n
18 printf("%d+",i);
(gdb) p i
$9 = 1
(gdb) n
17 for(int i=1;i<n;i++)
(gdb) n
18 printf("%d+",i);
(gdb) p i
$10 = 2
(gdb) n
17 for(int i=1;i<n;i++)
(gdb) n
19 printf("%d=%d",n,sum);
(gdb) n
20 }
(gdb) n
main () at p3final.c:27
27 }
(gdb) c
Continuing.
1+2+3=6[Inferior 1 (process 44) exited normally]
(gdb) q
Loading