Jul 16, 2014

Clewn

Clewn provides Gdb support within Vim - Clewn is a standalone program controlling Vim through a NetBeans interface.


List of default key mappings:

        CTRL-Z  send an interrupt to GDB and the program it is running
        B       info breakpoints
        L       info locals
        A       info args
        S       step
        I       stepi
        CTRL-N  next: next source line, skipping all function calls
        X       nexti
        F       finish
        R       run
        Q       quit
        C       continue
        W       where
        CTRL-U  up: go up one frame
        CTRL-D  down: go down one frame

cursor position: ~
        CTRL-B  set a breakpoint on the line where the cursor is located
        CTRL-E  clear all breakpoints on the line where the cursor is located

mouse pointer position: ~
        CTRL-P  print the value of the variable defined by the mouse pointer
                position
        CTRL-X  print the value that is referenced by the address whose
                value is that of the variable defined by the mouse pointer
                position
        CTRL-K  set a breakpoint at assembly address shown by mouse position
        CTRL-H  clear a breakpoint at assembly address shown by mouse position
        CTRL-J  add the selected variable at mouse position to the watched
                variables window

Note: You can tune Vim behavior when using netBeans keys with the mouse
pointer position, by setting Vim balloondelay to a smaller value than its
default. The following setting has been reported to give better results:

    :set balloondelay=100 ~

Note: After browsing your code, you can always return rapidly to the line of
code where GDB is currently stopped, by using CTRL-U and CTRL-D.

Jul 15, 2014

изобретатель шахмат запросил у правителя в качестве награды одно зерно на первое поле шахматной доски, два на второе и т.д., т.е. вдвое больше на каждое следующее. когда правитель понял что ему придется раскошелиться на 2 в 64й степени зерен пшеницы, он приказал отрубить голову изобретателю и таким образом стал первым, кто применил метод отсечения в качестве меры контроля комбинаторного взрыва : )

Jun 25, 2014

Read auxv

LD_SHOW_AUXV=1 /bin/true
or

Jun 24, 2014

Elfutils

https://access.redhat.com/site/documentation/en-US/Red_Hat_Developer_Toolset/1/html/User_Guide/chap-elfutils.html
sudo apt-get install elfutils
eu-readelf --all /lib/x86_64-linux-gnu/libc.so.6

gcc dumpspecs

gcc -dumpspecs
# ...
# *startfile:
# %{!mandroid|tno-android-ld:%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}    crti.o%s # %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s};:%{shared: crtbegin_so%O%s;:  %{static: crtbegin_static%O%s;: crtbegin_dynamic%O%s}}}
# ...
http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Spec-Files.html#Spec-Files

ld --verbose
#...
# OUTPUT_ARCH(i386:x86-64)
# ENTRY(_start)
# SEARCH_DIR("/usr/x86_64-linux-gnu/lib64"); SEARCH_DIR("=/usr/local/lib/x86_64-linux-gnu"); SEARCH_DIR("=/usr/local/lib64"); SEARCH_DIR("=/lib/x86_64-linux-gnu"); SEARCH_DIR("=/lib64"); SEARCH_DIR("=/usr/lib/x86_64-linux-gnu"); SEARCH_DIR("=/usr/lib64"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); # SEARCH_DIR("=/usr/lib");
SECTIONS
# ...
https://sourceware.org/binutils/docs/ld/

Core dump

Allow core dump
Permanent:
sudo vi /etc/security/limits.conf
#add line
#YOUR_USERNAME     soft    core            1000000
Temporary:
ulimit -c unlimited
Core dump
sleep 30
# Type Control-\
Quit (core dumped)
kill -ABRT <PID>
# 11602 abort (core dumped)
In C
abort()
Core dump misc
cat /proc/sys/kernel/core_pattern
man 5 core
cat /proc/PID/coredump_filter

Jun 13, 2014

Software architecture design principles

GRASP - General Responsibility Assignment Software Patterns (or Principles) consists of guidelines for assigning responsibility to classes and objects in object-oriented design. The different patterns and principles used in GRASP are: Controller, Creator, Indirection, Information Expert, High Cohesion, Low Coupling, Polymorphism, Protected Variations, and Pure Fabrication.
SOLID (ru)
KISS Keep it simple, stupid
DRY Don't repeat yourself
YAGNI You aren't gonna need it
Worse is better
Law of Demeter, LoD Each unit should have only limited knowledge about other units: only units "closely" related to the current unit. Each unit should only talk to its friends; don't talk to strangers. Only talk to your immediate friends.