Add 'PracticingC/' from commit 'ef128a996fc826339bbc3d9deea376932caf6981'
git-subtree-dir: PracticingC git-subtree-mainline:fd87ec8fe9
git-subtree-split:ef128a996f
This commit is contained in:
14
PracticingC/gdbtut/Makefile
Normal file
14
PracticingC/gdbtut/Makefile
Normal file
@@ -0,0 +1,14 @@
|
||||
# tutorial exercises from http://www.unknownroad.com/rtfm/gdbtut/
|
||||
|
||||
BINDIR := $(PWD)/bin
|
||||
export BINDIR
|
||||
|
||||
|
||||
all:
|
||||
$(CD) src && $(MAKE)
|
||||
|
||||
clean:
|
||||
$(RM) $(BINDIR)/*
|
||||
|
||||
|
||||
.PHONY: all clean
|
0
PracticingC/gdbtut/bin/.keep
Normal file
0
PracticingC/gdbtut/bin/.keep
Normal file
12
PracticingC/gdbtut/src/Makefile
Normal file
12
PracticingC/gdbtut/src/Makefile
Normal file
@@ -0,0 +1,12 @@
|
||||
# tutorial exercises from http://www.unknownroad.com/rtfm/gdbtut/
|
||||
|
||||
ALL_BIN := $(patsubst %.c,$(BINDIR)/%,$(wildcard *.c))
|
||||
|
||||
|
||||
$(BINDIR)/%: %.c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
all: $(ALL_BIN)
|
||||
|
||||
|
||||
.PHONY: all
|
28
PracticingC/gdbtut/src/segfault.c
Normal file
28
PracticingC/gdbtut/src/segfault.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* :author: Dan Buch (daniel.buch@gmail.com)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *buf;
|
||||
long long huge = 8000000000000000000;
|
||||
/* Okay, so this is *not* going to segfault because
|
||||
* the way memory is allocated has changed since
|
||||
* the tutorial was written. The segfault is supposed
|
||||
* to happen when more memory is allocated than is
|
||||
* available on the machine. So much for that exercise.
|
||||
*/
|
||||
|
||||
buf = malloc(huge);
|
||||
|
||||
fgets(buf, 1024, stdin);
|
||||
printf("%s\n", buf);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* vim:filetype=c:fileencoding=utf-8
|
||||
*/
|
Reference in New Issue
Block a user