Skip to content

Instantly share code, notes, and snippets.

View KevinKu's full-sized avatar

proof.K KevinKu

View GitHub Profile
所以只好用malloc額外一個object來處理
echo 'set logging file '$2>>_tmp.gdb
這邊跟swap不同的是
我搞懂set logging file怎麼用了 所以測試的result不會有很多無用的資訊了
set logging file 決定當set logging on 執行完的時候 gdb的output要輸出到哪個檔案
(gdb) set $head=(List*)0
(gdb) create_list $head 2
$1 = 0
$2 = (List *) 0x602010
$3 = 0
$4 = (struct List_node *) 0x0
$5 = (List *) 0x602010
$6 = (List *) 0x602010
$7 = 1
$8 = (List *) 0x602030
#!/bin/bash
echo 'b main'>>_tmp.gdb
echo 'r'>>_tmp.gdb
echo 'source create_list.gdb'>>_tmp.gdb
echo 'source print_list.gdb'>>_tmp.gdb
echo 'source free_list.gdb'>>_tmp.gdb
def printf_list
/*
printf_list需要一個參數
就是要print的list 的head address
*/
p $_head = $arg0
def create_list
/*
這個command用來製造測試用的list 需要二個參數
第一個用來存放head的address
第二個表示要有多少個node
*/
當初寫command時 以為他運作起來像是函數
結果寫了一些測試的command 不是
在gdb中 def XXX XXX為定義的command
XXX後接的參數 分別為 arg0 arg1 ...
使用的方法為在gdb界面下
XXX ooo ooo
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 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/>.
./Unit_swap_test.bs test_simple_data result
第一個參數是給測試資料的pathname
第二個參數是用作保留測試結果的pathname
~
#!/bin/bash
echo b main >> _tmp.gdb
echo r >> _tmp.gdb
echo source create__list.gdb>> _tmp.gdb
echo source printf_list.gdb>> _tmp.gdb
第一行是用來給list的長度 例如6 就會去create一個有6個node的list
然後測試資料是每三行讀一組
第一行空格