KLab Expert Camp 5 - Day1やってみた

初っ端でつまずきました。。

「step1 デバイス管理」のところ

test@ubuntu:~/tcp-programing/microps$ ./test/step1.exe 
20:34:03.613 [I] net_init: initialized (net.c:151)
Segmentation fault
test@ubuntu:~/tcp-programing/microps$ 

セグメンテーションフォルトでちゃって直せない。core dumpはくように設定した。

test@ubuntu:~/tcp-programing/microps/test$ ./step1.exe 
20:41:36.392 [I] net_init: initialized (net.c:151)
Segmentation fault (core dumped)
test@ubuntu:~/tcp-programing/microps/test$ 
test@ubuntu:~/tcp-programing/microps/test$ ls
core        step0.c    step0.o  step1.exe  test.h
net.h.save  step0.exe  step1.c  step1.o

dumpの中身は以下

test@ubuntu:~/tcp-programing/microps/test$ gdb step1.exe core
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 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 step1.exe...
[New LWP 2164]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./step1.exe'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055a6d1967687 in dummy_init () at driver/dummy.c:33
33    dev->type = NET_DEVICE_TYPE_DUMMY;

dev->type = NET_DEVICE_TYPE_DUMMY

ここでエラーになったっぽい。「driver/dummy.c」に設定されてた。

net.hで定義?してるっぽいので確認。ちゃんと書いてある。。

 

よくわからず、、make cleanしてみました。そしたらちゃんと動いた!

test@ubuntu:~/tcp-programing/microps/test$ ./step1.exe 
21:13:04.018 [I] net_init: initialized (net.c:151)
21:13:04.018 [I] net_device_register: registered, dev=net0, type=0x0000 (net.c:39)
21:13:04.018 [D] dummy_init: initialized, dev=net0 (driver/dummy.c:42)
21:13:04.018 [D] net_run: open all devices... (net.c:128)
21:13:04.018 [I] net_device_open: dev=net0, state=up (net.c:59)
21:13:04.018 [D] net_run: running... (net.c:132)
21:13:04.018 [E] net_device_output: already opened, dev=net0 (net.c:88)
21:13:04.018 [E] main: net_device_output() failure (test/step1.c:43)
21:13:04.018 [D] net_shutdown: close all devices... (net.c:141)
21:13:04.018 [E] net_device_close: already opened, dev=net0 (net.c:69)
21:13:04.018 [D] net_shutdown: shutting down (net.c:145)
test@ubuntu:~/tcp-programing/microps/test$