Let a laziest linked list like:
#include <assert.h>
[...]
struct value {
int i_;
};
struct values {
struct value * first;
struct values * next;
};
[...]
struct values values_;
[...]
assert(values_ != NULL);
assert(values_->first != NULL);
assert(values_->first->i_ == 4);
assert(values_->next != NULL);
assert(values_->next->first != NULL);
assert(values_->next->first->i_ == 8);
assert(values_->next->next == NULL);
I read in https://stackoverflow.com/a/46289993 that print *values_
is an improvement over print values_
, then print values_->first
and print values_->next
.
But I don't know how to end up with something like $i = {first = 0x?????? {i_ = 4}, next = 0x?????? {first = 0x?????? {i_ = 8}, next = 0x0}}
using a single gdb
command.
There is https://stackoverflow.com/a/16493871/1737973 and https://sourceware.org/gdb/current/onlinedocs/gdb/Pretty-Printing.html. Is there any laziest way than those?