added more code
This commit is contained in:
8
CPE455/lab07/Makefile
Normal file
8
CPE455/lab07/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
CC := afl-gcc
|
||||
CFLAGS := -Wno-unused-result
|
||||
|
||||
all: crashy.c
|
||||
$(CC) $(CFLAGS) -o crashy crashy.c
|
||||
|
||||
clean:
|
||||
rm crashy
|
BIN
CPE455/lab07/crashy
Executable file
BIN
CPE455/lab07/crashy
Executable file
Binary file not shown.
83
CPE455/lab07/crashy.c
Normal file
83
CPE455/lab07/crashy.c
Normal file
@ -0,0 +1,83 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
FILE *fp;
|
||||
unsigned int sz, len, ptr;
|
||||
char *buffer;
|
||||
char type;
|
||||
char tmp_char;
|
||||
int tmp_int;
|
||||
char *tmp_string;
|
||||
|
||||
if(argc != 2) {
|
||||
fprintf(stderr, "Usage: %s <inputfile>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fp = fopen(argv[1], "r");
|
||||
if(!fp) {
|
||||
fprintf(stderr, "Failed to open '%s'\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
sz = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
buffer = malloc(sz);
|
||||
if(!buffer) {
|
||||
fprintf(stderr, "Failed to allocate %d bytes of memory\n", sz);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fread(buffer, sizeof(char), sz, fp);
|
||||
|
||||
ptr = 0;
|
||||
while(ptr < sz) {
|
||||
|
||||
type = buffer[ptr++];
|
||||
switch(type) {
|
||||
|
||||
case '\x01': // integer
|
||||
tmp_int = *(int *)(buffer + ptr);
|
||||
ptr += sizeof(int);
|
||||
printf("i: 0x%08x\n", tmp_int);
|
||||
break;
|
||||
|
||||
case '\x02': // char
|
||||
tmp_char = buffer[ptr++];
|
||||
printf("c: 0x%02x\n", (unsigned char)tmp_char);
|
||||
break;
|
||||
|
||||
case '\x03': // string
|
||||
len = *(int *)(buffer + ptr);
|
||||
ptr += sizeof(int);
|
||||
tmp_string = malloc(len);
|
||||
if(!tmp_string) {
|
||||
fprintf(stderr, "Failed to allocate %d bytes of memory\n", len);
|
||||
return 1;
|
||||
}
|
||||
strcpy(tmp_string, (buffer + ptr));
|
||||
printf("s: %s\n", tmp_string);
|
||||
ptr += len;
|
||||
break;
|
||||
|
||||
case '\x04': // comment
|
||||
printf("#: %s\n", (buffer + ptr));
|
||||
while(*(buffer + ptr++) != '\x00');
|
||||
break;
|
||||
|
||||
case '\xff': // END
|
||||
return 0;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Unknown data type '%c'\n", type);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
88
CPE455/lab07/crashy.c.gcov
Normal file
88
CPE455/lab07/crashy.c.gcov
Normal file
@ -0,0 +1,88 @@
|
||||
-: 0:Source:crashy.c
|
||||
-: 0:Graph:crashy.gcno
|
||||
-: 0:Data:crashy.gcda
|
||||
-: 0:Runs:9
|
||||
-: 0:Programs:1
|
||||
-: 1:#include <stdio.h>
|
||||
-: 2:#include <stdlib.h>
|
||||
-: 3:#include <string.h>
|
||||
-: 4:
|
||||
9: 5:int main(int argc, char *argv[]) {
|
||||
-: 6:
|
||||
-: 7: FILE *fp;
|
||||
-: 8: unsigned int sz, len, ptr;
|
||||
-: 9: char *buffer;
|
||||
-: 10: char type;
|
||||
-: 11: char tmp_char;
|
||||
-: 12: int tmp_int;
|
||||
-: 13: char *tmp_string;
|
||||
-: 14:
|
||||
9: 15: if(argc != 2) {
|
||||
1: 16: fprintf(stderr, "Usage: %s <inputfile>\n", argv[0]);
|
||||
1: 17: return 1;
|
||||
-: 18: }
|
||||
-: 19:
|
||||
8: 20: fp = fopen(argv[1], "r");
|
||||
8: 21: if(!fp) {
|
||||
1: 22: fprintf(stderr, "Failed to open '%s'\n", argv[1]);
|
||||
1: 23: return 1;
|
||||
-: 24: }
|
||||
-: 25:
|
||||
7: 26: fseek(fp, 0, SEEK_END);
|
||||
7: 27: sz = ftell(fp);
|
||||
7: 28: fseek(fp, 0, SEEK_SET);
|
||||
-: 29:
|
||||
7: 30: buffer = malloc(sz);
|
||||
7: 31: if(!buffer) {
|
||||
1: 32: fprintf(stderr, "Failed to allocate %d bytes of memory\n", sz);
|
||||
1: 33: return 1;
|
||||
-: 34: }
|
||||
-: 35:
|
||||
6: 36: fread(buffer, sizeof(char), sz, fp);
|
||||
-: 37:
|
||||
6: 38: ptr = 0;
|
||||
31: 39: while(ptr < sz) {
|
||||
-: 40:
|
||||
25: 41: type = buffer[ptr++];
|
||||
25: 42: switch(type) {
|
||||
-: 43:
|
||||
-: 44: case '\x01': // integer
|
||||
8: 45: tmp_int = *(int *)(buffer + ptr);
|
||||
8: 46: ptr += sizeof(int);
|
||||
8: 47: printf("i: 0x%08x\n", tmp_int);
|
||||
8: 48: break;
|
||||
-: 49:
|
||||
-: 50: case '\x02': // char
|
||||
5: 51: tmp_char = buffer[ptr++];
|
||||
5: 52: printf("c: 0x%02x\n", (unsigned char)tmp_char);
|
||||
5: 53: break;
|
||||
-: 54:
|
||||
-: 55: case '\x03': // string
|
||||
6: 56: len = *(int *)(buffer + ptr);
|
||||
6: 57: ptr += sizeof(int);
|
||||
6: 58: tmp_string = malloc(len);
|
||||
6: 59: if(!tmp_string) {
|
||||
1: 60: fprintf(stderr, "Failed to allocate %d bytes of memory\n", len);
|
||||
1: 61: return 1;
|
||||
-: 62: }
|
||||
5: 63: strcpy(tmp_string, (buffer + ptr));
|
||||
5: 64: printf("s: %s\n", tmp_string);
|
||||
5: 65: ptr += len;
|
||||
5: 66: break;
|
||||
-: 67:
|
||||
-: 68: case '\x04': // comment
|
||||
1: 69: printf("#: %s\n", (buffer + ptr));
|
||||
1: 70: while(*(buffer + ptr++) != '\x00');
|
||||
1: 71: break;
|
||||
-: 72:
|
||||
-: 73: case '\xff': // END
|
||||
5: 74: return 0;
|
||||
-: 75:
|
||||
-: 76: default:
|
||||
#####: 77: fprintf(stderr, "Unknown data type '%c'\n", type);
|
||||
-: 78:
|
||||
-: 79: }
|
||||
-: 80:
|
||||
-: 81: }
|
||||
-: 82:
|
||||
#####: 83:}
|
BIN
CPE455/lab07/crashy.gcda
Normal file
BIN
CPE455/lab07/crashy.gcda
Normal file
Binary file not shown.
BIN
CPE455/lab07/crashy.gcno
Normal file
BIN
CPE455/lab07/crashy.gcno
Normal file
Binary file not shown.
BIN
CPE455/lab07/crashy.zip
Normal file
BIN
CPE455/lab07/crashy.zip
Normal file
Binary file not shown.
BIN
CPE455/lab07/example1
Normal file
BIN
CPE455/lab07/example1
Normal file
Binary file not shown.
BIN
CPE455/lab07/example2
Normal file
BIN
CPE455/lab07/example2
Normal file
Binary file not shown.
BIN
CPE455/lab07/example3
Normal file
BIN
CPE455/lab07/example3
Normal file
Binary file not shown.
1
CPE455/lab07/example4
Normal file
1
CPE455/lab07/example4
Normal file
@ -0,0 +1 @@
|
||||
ABC<>
|
BIN
CPE455/lab07/example5
Normal file
BIN
CPE455/lab07/example5
Normal file
Binary file not shown.
409
CPE455/lab07/lab07.txt
Normal file
409
CPE455/lab07/lab07.txt
Normal file
@ -0,0 +1,409 @@
|
||||
Script started on Tue 29 Mar 2022 09:53:31 AM CDT
|
||||
[?1034hbash-4.2$ gcc -g --coverage crashy.c -o crashy
|
||||
bash-4.2$ ./v[Kcrashy
|
||||
Usage: ./crashy <inputfile>
|
||||
bash-4.2$ gcov crashy.c
|
||||
File 'crashy.c'
|
||||
Lines executed:9.30% of 43
|
||||
Creating 'crashy.c.gcov'
|
||||
|
||||
bash-4.2$ ./crashy example1
|
||||
i: 0x78563412
|
||||
c: 0xcc
|
||||
s: hello
|
||||
bash-4.2$ ./crashy example1
|
||||
[C[C[C[C[C[C[C[C[C[C[5Pgcov crashy.c
|
||||
File 'crashy.c'
|
||||
Lines executed:74.42% of 43
|
||||
Creating 'crashy.c.gcov'
|
||||
|
||||
bash-4.2$ gcov crashy.c
|
||||
[C[C[C[C[C[C[C[C[C[C ./crashy example1[K2
|
||||
i: 0x00000001
|
||||
i: 0x00000002
|
||||
i: 0x00000003
|
||||
i: 0x00000004
|
||||
i: 0x00000005
|
||||
bash-4.2$ ./crashy example2
|
||||
[C[C[C[C[C[C[C[C[C[C[5Pgcov crashy.c
|
||||
File 'crashy.c'
|
||||
Lines executed:74.42% of 43
|
||||
Creating 'crashy.c.gcov'
|
||||
|
||||
bash-4.2$ gcov crashy.c
|
||||
[C[C[C[C[C[C[C[C[C[C ./crashy example2[K3
|
||||
s: this
|
||||
s: is
|
||||
s: an
|
||||
s: example
|
||||
bash-4.2$ ./crashy example3
|
||||
[C[C[C[C[C[C[C[C[C[C[5Pgcov crashy.c
|
||||
File 'crashy.c'
|
||||
Lines executed:74.42% of 43
|
||||
Creating 'crashy.c.gcov'
|
||||
|
||||
bash-4.2$ gcov crashy.c
|
||||
[C[C[C[C[C[C[C[C[C[C ./crashy example3[K4
|
||||
c: 0x41
|
||||
c: 0x42
|
||||
c: 0x43
|
||||
bash-4.2$ ./crashy example4
|
||||
[C[C[C[C[C[C[C[C[C[C[5Pgcov crashy.c
|
||||
File 'crashy.c'
|
||||
Lines executed:74.42% of 43
|
||||
Creating 'crashy.c.gcov'
|
||||
|
||||
bash-4.2$ gcov crashy.c
|
||||
[C[C[C[C[C[C[C[C[C[C ./crashy example4[K5
|
||||
i: 0x00001337
|
||||
#: ELITE
|
||||
bash-4.2$ ./crashy example5
|
||||
[C[C[C[C[C[C[C[C[C[C[5Pgcov crashy.c
|
||||
File 'crashy.c'
|
||||
Lines executed:81.40% of 43
|
||||
Creating 'crashy.c.gcov'
|
||||
|
||||
bash-4.2$ more crashy
|
||||
crashy crashy.c crashy.c.gcov crashy.gcda crashy.gcno crashy.zip
|
||||
bash-4.2$ more crashy.c.gcov
|
||||
-: 0:Source:crashy.c
|
||||
-: 0:Graph:crashy.gcno
|
||||
-: 0:Data:crashy.gcda
|
||||
-: 0:Runs:6
|
||||
-: 0:Programs:1
|
||||
-: 1:#include <stdio.h>
|
||||
-: 2:#include <stdlib.h>
|
||||
-: 3:#include <string.h>
|
||||
-: 4:
|
||||
6: 5:int main(int argc, char *argv[]) {
|
||||
-: 6:
|
||||
-: 7: FILE *fp;
|
||||
-: 8: unsigned int sz, len, ptr;
|
||||
-: 9: char *buffer;
|
||||
-: 10: char type;
|
||||
-: 11: char tmp_char;
|
||||
-: 12: int tmp_int;
|
||||
-: 13: char *tmp_string;
|
||||
-: 14:
|
||||
6: 15: if(argc != 2) {
|
||||
1: 16: fprintf(stderr, "Usage: %s <inputfile>\n", argv[0]);
|
||||
1: 17: return 1;
|
||||
-: 18: }
|
||||
-: 19:
|
||||
5: 20: fp = fopen(argv[1], "r");
|
||||
5: 21: if(!fp) {
|
||||
#####: 22: fprintf(stderr, "Failed to open '%s'\n", argv[1]);
|
||||
#####: 23: return 1;
|
||||
-: 24: }
|
||||
-: 25:
|
||||
5: 26: fseek(fp, 0, SEEK_END);
|
||||
5: 27: sz = ftell(fp);
|
||||
5: 28: fseek(fp, 0, SEEK_SET);
|
||||
-: 29:
|
||||
5: 30: buffer = malloc(sz);
|
||||
5: 31: if(!buffer) {
|
||||
#####: 32: fprintf(stderr, "Failed to allocate %d bytes of memory\n", sz);
|
||||
#####: 33: return 1;
|
||||
-: 34: }
|
||||
-: 35:
|
||||
5: 36: fread(buffer, sizeof(char), sz, fp);
|
||||
-: 37:
|
||||
5: 38: ptr = 0;
|
||||
27: 39: while(ptr < sz) {
|
||||
-: 40:
|
||||
22: 41: type = buffer[ptr++];
|
||||
22: 42: switch(type) {
|
||||
-: 43:
|
||||
-: 44: case '\x01': // integer
|
||||
7: 45: tmp_int = *(int *)(buffer + ptr);
|
||||
7: 46: ptr += sizeof(int);
|
||||
[7m--More--(55%)[27m
|
||||
7: 47: printf("i: 0x%08x\n", tmp_int);
|
||||
[7m--More--(57%)[27m
|
||||
7: 48: break;
|
||||
[7m--More--(58%)[27m
|
||||
-: 49:
|
||||
[7m--More--(59%)[27m
|
||||
-: 50: case '\x02': // char
|
||||
[7m--More--(60%)[27m
|
||||
4: 51: tmp_char = buffer[ptr++];
|
||||
[7m--More--(61%)[27m
|
||||
4: 52: printf("c: 0x%02x\n", (unsigned char)tmp_char);
|
||||
[7m--More--(64%)[27m
|
||||
4: 53: break;
|
||||
[7m--More--(65%)[27m
|
||||
-: 54:
|
||||
[7m--More--(65%)[27m
|
||||
-: 55: case '\x03': // string
|
||||
[7m--More--(67%)[27m
|
||||
5: 56: len = *(int *)(buffer + ptr);
|
||||
[7m--More--(68%)[27m
|
||||
5: 57: ptr += sizeof(int);
|
||||
[7m--More--(70%)[27m
|
||||
5: 58: tmp_string = malloc(len);
|
||||
[7m--More--(71%)[27m
|
||||
5: 59: if(!tmp_string) {
|
||||
[7m--More--(72%)[27m
|
||||
#####: 60: fprintf(stderr, "Failed to allocate %d bytes of m
|
||||
[7m--More--(75%)[27m
|
||||
emory\n", len);
|
||||
[7m--More--(75%)[27m
|
||||
#####: 61: return 1;
|
||||
[7m--More--(76%)[27m
|
||||
-: 62: }
|
||||
[7m--More--(77%)[27m
|
||||
5: 63: strcpy(tmp_string, (buffer + ptr));
|
||||
[7m--More--(79%)[27m
|
||||
5: 64: printf("s: %s\n", tmp_string);
|
||||
[7m--More--(81%)[27m
|
||||
5: 65: ptr += len;
|
||||
[7m--More--(82%)[27m
|
||||
5: 66: break;
|
||||
[7m--More--(83%)[27m
|
||||
-: 67:
|
||||
[7m--More--(83%)[27m
|
||||
-: 68: case '\x04': // comment
|
||||
[7m--More--(85%)[27m
|
||||
1: 69: printf("#: %s\n", (buffer + ptr));
|
||||
[7m--More--(86%)[27m
|
||||
1: 70: while(*(buffer + ptr++) != '\x00');
|
||||
[7m--More--(88%)[27m
|
||||
1: 71: break;
|
||||
[7m--More--(89%)[27m
|
||||
-: 72:
|
||||
[7m--More--(90%)[27m
|
||||
-: 73: case '\xff': // END
|
||||
[7m--More--(91%)[27m
|
||||
5: 74: return 0;
|
||||
[7m--More--(92%)[27m
|
||||
-: 75:
|
||||
[7m--More--(93%)[27m
|
||||
-: 76: default:
|
||||
[7m--More--(94%)[27m
|
||||
#####: 77: fprintf(stderr, "Unknown data type '%c'\n", type);
|
||||
[7m--More--(96%)[27m
|
||||
[Kbash-4.2$ more crashy.c.gcov
|
||||
-: 0:Source:crashy.c
|
||||
-: 0:Graph:crashy.gcno
|
||||
-: 0:Data:crashy.gcda
|
||||
-: 0:Runs:6
|
||||
-: 0:Programs:1
|
||||
-: 1:#include <stdio.h>
|
||||
-: 2:#include <stdlib.h>
|
||||
-: 3:#include <string.h>
|
||||
-: 4:
|
||||
6: 5:int main(int argc, char *argv[]) {
|
||||
-: 6:
|
||||
-: 7: FILE *fp;
|
||||
-: 8: unsigned int sz, len, ptr;
|
||||
-: 9: char *buffer;
|
||||
-: 10: char type;
|
||||
-: 11: char tmp_char;
|
||||
-: 12: int tmp_int;
|
||||
-: 13: char *tmp_string;
|
||||
-: 14:
|
||||
6: 15: if(argc != 2) {
|
||||
1: 16: fprintf(stderr, "Usage: %s <inputfile>\n", argv[0]);
|
||||
1: 17: return 1;
|
||||
-: 18: }
|
||||
-: 19:
|
||||
5: 20: fp = fopen(argv[1], "r");
|
||||
5: 21: if(!fp) {
|
||||
#####: 22: fprintf(stderr, "Failed to open '%s'\n", argv[1]);
|
||||
#####: 23: return 1;
|
||||
-: 24: }
|
||||
-: 25:
|
||||
5: 26: fseek(fp, 0, SEEK_END);
|
||||
5: 27: sz = ftell(fp);
|
||||
5: 28: fseek(fp, 0, SEEK_SET);
|
||||
-: 29:
|
||||
5: 30: buffer = malloc(sz);
|
||||
5: 31: if(!buffer) {
|
||||
#####: 32: fprintf(stderr, "Failed to allocate %d bytes of memory\n", sz);
|
||||
#####: 33: return 1;
|
||||
-: 34: }
|
||||
-: 35:
|
||||
5: 36: fread(buffer, sizeof(char), sz, fp);
|
||||
-: 37:
|
||||
5: 38: ptr = 0;
|
||||
27: 39: while(ptr < sz) {
|
||||
-: 40:
|
||||
22: 41: type = buffer[ptr++];
|
||||
22: 42: switch(type) {
|
||||
-: 43:
|
||||
-: 44: case '\x01': // integer
|
||||
7: 45: tmp_int = *(int *)(buffer + ptr);
|
||||
7: 46: ptr += sizeof(int);
|
||||
[7m--More--(55%)[27m
|
||||
7: 47: printf("i: 0x%08x\n", tmp_int);
|
||||
[7m--More--(57%)[27m
|
||||
7: 48: break;
|
||||
[7m--More--(58%)[27m
|
||||
-: 49:
|
||||
[7m--More--(59%)[27m
|
||||
-: 50: case '\x02': // char
|
||||
[7m--More--(60%)[27m
|
||||
4: 51: tmp_char = buffer[ptr++];
|
||||
[7m--More--(61%)[27m
|
||||
4: 52: printf("c: 0x%02x\n", (unsigned char)tmp_char);
|
||||
[7m--More--(64%)[27m
|
||||
4: 53: break;
|
||||
[7m--More--(65%)[27m
|
||||
-: 54:
|
||||
[7m--More--(65%)[27m
|
||||
-: 55: case '\x03': // string
|
||||
[7m--More--(67%)[27m
|
||||
5: 56: len = *(int *)(buffer + ptr);
|
||||
[7m--More--(68%)[27m
|
||||
5: 57: ptr += sizeof(int);
|
||||
[7m--More--(70%)[27m
|
||||
5: 58: tmp_string = malloc(len);
|
||||
[7m--More--(71%)[27m
|
||||
5: 59: if(!tmp_string) {
|
||||
[7m--More--(72%)[27m
|
||||
#####: 60: fprintf(stderr, "Failed to allocate %d bytes of memory\n", len);
|
||||
[7m--More--(75%)[27m
|
||||
#####: 61: return 1;
|
||||
[7m--More--(76%)[27m
|
||||
-: 62: }
|
||||
[7m--More--(77%)[27m
|
||||
5: 63: strcpy(tmp_string, (buffer + ptr));
|
||||
[7m--More--(79%)[27m
|
||||
5: 64: printf("s: %s\n", tmp_string);
|
||||
[7m--More--(81%)[27m
|
||||
5: 65: ptr += len;
|
||||
[7m--More--(82%)[27m
|
||||
5: 66: break;
|
||||
[7m--More--(83%)[27m
|
||||
-: 67:
|
||||
[7m--More--(83%)[27m
|
||||
-: 68: case '\x04': // comment
|
||||
[7m--More--(85%)[27m
|
||||
1: 69: printf("#: %s\n", (buffer + ptr));
|
||||
[7m--More--(86%)[27m
|
||||
1: 70: while(*(buffer + ptr++) != '\x00');
|
||||
[7m--More--(88%)[27m
|
||||
1: 71: break;
|
||||
[7m--More--(89%)[27m
|
||||
-: 72:
|
||||
[7m--More--(90%)[27m
|
||||
-: 73: case '\xff': // END
|
||||
[7m--More--(91%)[27m
|
||||
5: 74: return 0;
|
||||
[7m--More--(92%)[27m
|
||||
-: 75:
|
||||
[7m--More--(93%)[27m
|
||||
-: 76: default:
|
||||
[7m--More--(94%)[27m
|
||||
#####: 77: fprintf(stderr, "Unknown data type '%c'\n", type);
|
||||
[7m--More--(96%)[27m
|
||||
-: 78:
|
||||
[7m--More--(96%)[27m
|
||||
-: 79: }
|
||||
[7m--More--(97%)[27m
|
||||
-: 80:
|
||||
[7m--More--(98%)[27m
|
||||
-: 81: }
|
||||
[7m--More--(98%)[27m
|
||||
-: 82:
|
||||
[7m--More--(99%)[27m
|
||||
#####: 83:}
|
||||
bash-4.2$
|
||||
bash-4.2$
|
||||
bash-4.2$
|
||||
bash-4.2$
|
||||
bash-4.2$
|
||||
bash-4.2$
|
||||
bash-4.2$
|
||||
bash-4.2$
|
||||
bash-4.2$
|
||||
bash-4.2$
|
||||
bash-4.2$
|
||||
bash-4.2$
|
||||
bash-4.2$
|
||||
bash-4.2$ ./crashy example6
|
||||
Failed to open 'example6'
|
||||
bash-4.2$ ./crashy example6
|
||||
[C[C[C[C[C[C[C[C[C[Cmore crashy.c.gcov
|
||||
[C[C[C[C[C[C[C[C[C[C[5Pgcov crashy.c
|
||||
File 'crashy.c'
|
||||
Lines executed:86.05% of 43
|
||||
Creating 'crashy.c.gcov'
|
||||
|
||||
bash-4.2$ gdb ./crashy
|
||||
[?1034hGNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7
|
||||
Copyright (C) 2013 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-redhat-linux-gnu".
|
||||
For bug reporting instructions, please see:
|
||||
<http://www.gnu.org/software/gdb/bugs/>...
|
||||
Reading symbols from /home/student/anw0044/CPE455/lab07/crashy...done.
|
||||
(gdb)
|
||||
[K(gdb) break main
|
||||
Breakpoint 1 at 0x400e4c: file crashy.c, line 15.
|
||||
(gdb) break 31
|
||||
Breakpoint 2 at 0x400fa7: file crashy.c, line 31.
|
||||
(gdb) break 31[K[K59
|
||||
Breakpoint 3 at 0x401153: file crashy.c, line 59.
|
||||
(gdb) break 5931main[2P3159
|
||||
[C[C[C[C[C[C[Krun example1
|
||||
Starting program: /home/student/anw0044/CPE455/lab07/./crashy example1
|
||||
|
||||
Breakpoint 1, main (argc=2, argv=0x7fffffffe438) at crashy.c:15
|
||||
15 if(argc != 2) {
|
||||
Missing separate debuginfos, use: debuginfo-install glibc-2.17-325.el7_9.x86_64
|
||||
(gdb) continue
|
||||
Continuing.
|
||||
|
||||
Breakpoint 2, main (argc=2, argv=0x7fffffffe438) at crashy.c:31
|
||||
31 if(!buffer) {
|
||||
(gdb) print buffer=0
|
||||
$1 = 0x0
|
||||
(gdb) cony[Ktinue
|
||||
Continuing.
|
||||
Failed to allocate 19 bytes of memory
|
||||
[Inferior 1 (process 1861) exited with code 01]
|
||||
(gdb) continue
|
||||
[C[C[C[C[C[Cprint buffer=0
|
||||
[C[C[C[C[C[C[6Pcontinue
|
||||
[C[C[C[C[C[Crun example1
|
||||
Starting program: /home/student/anw0044/CPE455/lab07/./crashy example1
|
||||
|
||||
Breakpoint 1, main (argc=2, argv=0x7fffffffe438) at crashy.c:15
|
||||
15 if(argc != 2) {
|
||||
(gdb) print tmp_string=0
|
||||
$2 = 0x0
|
||||
(gdb) continue
|
||||
Continuing.
|
||||
|
||||
Breakpoint 2, main (argc=2, argv=0x7fffffffe438) at crashy.c:31
|
||||
31 if(!buffer) {
|
||||
(gdb) continue
|
||||
Continuing.
|
||||
i: 0x78563412
|
||||
c: 0xcc
|
||||
|
||||
Breakpoint 3, main (argc=2, argv=0x7fffffffe438) at crashy.c:59
|
||||
59 if(!tmp_string) {
|
||||
(gdb) continue
|
||||
[C[C[C[C[C[Cprint tmp_string=0
|
||||
$3 = 0x0
|
||||
(gdb) continue
|
||||
Continuing.
|
||||
Failed to allocate 6 bytes of memory
|
||||
[Inferior 1 (process 1910) exited with code 01]
|
||||
(gdb) quit
|
||||
bash-4.2$ gdb ./crashycov crashy.c
|
||||
[C[C[C[C[C[C[C[C[C[C./crashy example6
|
||||
[C[C[C[C[C[C[C[C[C[C[4Pgcov crashy.c
|
||||
File 'crashy.c'
|
||||
Lines executed:95.35% of 43
|
||||
Creating 'crashy.c.gcov'
|
||||
|
||||
bash-4.2$ cat crashy.c.gcov
|
||||
-: 0:Source:crashy.c
|
||||
-: 0:Graph:crashy.gcno
|
||||
-: 0:Data:crashy.gcda
|
Reference in New Issue
Block a user