Ddd Cheat Sheet



  • DDD is an approach to data modeling
  • Separating the quick-changing to ever-stable data
  • 4 Layers
    • Infrastructure Layer = almost never change
    • Domain Layer = hardly change
    • Application Layer = could change frequently
    • Presentation Layer = changes all the time
  1. Ddd Cheat Sheet Pdf
  2. Ddd Cheat Sheet Pdf
  3. Cheat Sheet Recipes
  4. Ddd Cheat Sheet Printable

Layers

Ddd Octal value ddd, where ddd is 1 to 3 digits between 0 and 7 c Any other character literally (e.g., for backslash, ” for “,. for., and so on) Operator Meaning = Greater than or equal to Greater than Matched by (used when comparing strings). DDD - The 3D Essentials (Download, 9 MB) DDD - a patient & staff perspective (Download, 417 KB) DDD - Managing the day (Download, 673 KB) DDD - Our approach (Download, 506 KB) DDD- Cheat sheet (Download, 140 KB) DDD - Task Sheet (example 1) (Download, 43 KB) DDD - Task sheet (example 2) (Download, 16 KB) DDD - One page guide (Download, 533 KB). December, 2016 Page 3 of 11 About this Guide Oregon uses Medicaid dollars to provide supports for people with disabilities. Progress notes are one way to be sure funds are used appropriately to meet the needs of people served.

  • DDD mostly focus on crafting the domain layer
  • Domain layer encapsulates all the domain logic

Domain vs. Application Layer

  • Domain logic = logical part of the business, i.e. the syntax of the business
  • Application logic = the configurable part of the business, i.e. the semantics of the business
  • The domain model is there to ensure the domain is legitimate, or, is syntactically correct
    • Example 1: When we put some goods to a spot in a warehouse, the spot should be empty; after we put the item in, the spot should be occupied; if someone else try to put another item in the same spot, it should not be denied
    • Example 2: In the domain of car plate registration, the plate number must always be unique, if someone try to register a plate that was already assigned to another car, the system should not allow it
    • Example 3: If I want to buy a ticket, the ticketing system should only issue a ticket after receiving the money
  • Domain logic should look very simple and intuitive and should be the same for most people familiar or unfamiliar with it, because it is based on basic logic that rarely changes
  • It should only cares about syntax but not semantics, as the latter could vary amongst different instances of the domain
    • Syntax error: two car plates had the same number; the balance between two parties in a successful transaction do not equal to zero; a ticket is issues without transaction attached to it; system shows that 100 items are at the exact same spot of a warehouse; price for an item is negative 5 dollars
    • Semantics error: a supermarket casher decide the shutdown the shop for half day; a visitor of a website can view the earnings of the site admin; someone won lottery 5 consecutive times
  • In short, if a syntax error happens, something illogical / unphysical / impossible happens; if a semantics error happens, we may feel strange but still the business plays by rules
  • Another example
    • There is a flight / business trip booking system
    • In Big Company A, only the boss can view where other people are going
    • In Startup B, everyone can see where everyone is going
    • They have very different semantics, people from one company with feel very strange about the other company, but the syntax stays the same
  • As domain logic rarely changes, so when the syntax stays the same, we are in the same domain
  • When the domain logic really change, it is highly possible that we have entered into a completely different domain
  • Each company, organization, application could have different semantics, as how the domain model is manipulated, but the domain model stays the same
  • More examples
    • HR service provides salary reports, one company allows only an employee to see his/her own salary report, another allows the employee and the boss, yet another allows everyone to see everyone; all in the same domain, same business logic, but different semantics
    • A car production line can be stopped by a button, in Toyota, everyone working on the line has the power to push the button, in Ford, only the boss has the authority; same syntax (push button > stop line), different semantics (who can do it)
    • In shop A, when you buy something, you get 1 credit for each dollar you spend, in shop B, you get 100 credit for each dollar you spend; same syntax, different semantics
  • When we have different set of semantics, we basically have a different application
  • That is the core difference between application and domain
  • This makes domain very stable and reusable across applications sharing the same syntax

Other Layers

  • Infrastructure = database, tables, message queues, basic components that could be reused in any domain and any application
  • Presentation = how the data is displayed (presented), like Web page, themes, apps, etc.

Other Ideas

  • Ubiquitous Language = When any members of the domain / on the team say “order”, we want to make sure everyone is referring to the exact same thing, so we clearly define a set of terms and use them throughout our data modeling
  • Bounding Context = There are situations when different players in the same domain must use the same name for slightly different things, then we bound a term to a context
    • For example, when referring to a “customer”, a sales is thinking about the customer’s business problem, revenue, etc.; a technician is thinking about the customer’s architecture, software stack, engineer team structure; a support personnel is thinking about the support plan, last support situation, customer contact name, etc.
    • They all use “customer” and it is difficult to give a different name for each slight variation or perspective they have, so we bound the customer to SalesContext, EngineerContext and SupportContext and create models corresponding to those contexts.

Starting GDB:

  • gdb name-of-executable
  • gdb -e name-of-executable -c name-of-core-file
  • gdb name-of-executable --pid=process-id
    Use ps -auxw to list process id's:

    Attach to a process already running:

Command line options: (version 6. Older versions use a single '-')

OptionDescription
--help
-h
List command line arguments
--exec=file-name
-e file-name
Identify executable associated with core file.
--core=name-of-core-file
-c name-of-core-file
Specify core file.
--command=command-file
-x command-file
File listing GDB commands to perform. Good for automating set-up.
--directory=directory
-d directory
Add directory to the path to search for source files.
--cd=directoryRun GDB using specified directory as the current working directory.
--nx
-n
Do not execute commands from ~/.gdbinit initialization file. Default is to look at this file and execute the list of commands.
--batch -x command-fileRun in batch (not interactive) mode. Execute commands from file. Requires -x option.
--symbols=file-name
-s file-name
Read symbol table from file file.
--se=file-nameUse FILE as symbol file and executable file.
--writeEnable writing into executable and core files.
--quiet
-q
Do not print the introductory and copyright messages.
--tty=deviceSpecify device for running program's standard input and output.
--tuiUse a terminal user interface. Console curses based GUI interface for GDB. Generates a source and debug console area.
--pid=process-id
-p process-id
Specify process ID number to attach to.
--versionPrint version information and then exit.
GDB Commands:

Commands used within GDB:

Ddd Cheat Sheet
CommandDescription
helpList gdb command topics.
help topic-classesList gdb command within class.
help commandCommand description.
eg help show to list the show commands
apropos search-wordSearch for commands and command topics containing search-word.
info args
i args
List program command line arguments
info breakpointsList breakpoints
info breakList breakpoint numbers.
info break breakpoint-numberList info about specific breakpoint.
info watchpointsList breakpoints
info registersList registers in use
info threadsList threads in use
info setList set-able option
Break and Watch
break funtion-name
break line-number
break ClassName::functionName
Suspend program at specified function of line number.
break +offset
break -offset
Set a breakpoint specified number of lines forward or back from the position at which execution stopped.
break filename:functionDon't specify path, just the file name and function name.
break filename:line-numberDon't specify path, just the file name and line number.
break Directory/Path/filename.cpp:62
break *addressSuspend processing at an instruction address. Used when you do not have source.
break line-number if conditionWhere condition is an expression. i.e. x > 5
Suspend when boolean expression is true.
break line thread thread-numberBreak in thread at specified line number. Use info threads to display thread numbers.
tbreakTemporary break. Break once only. Break is then removed. See 'break' above for options.
watch conditionSuspend processing when condition is met. i.e. x > 5
clear
clear function
clear line-number
Delete breakpoints as identified by command option.
Delete all breakpoints in function
Delete breakpoints at a given line
delete
d
Delete all breakpoints, watchpoints, or catchpoints.
delete breakpoint-number
delete range
Delete the breakpoints, watchpoints, or catchpoints of the breakpoint ranges specified as arguments.
disable breakpoint-number-or-range
enable breakpoint-number-or-range
Does not delete breakpoints. Just enables/disables them.
Example:
Show breakpoints: info break
Disable: disable 2-9
enable breakpoint-number onceEnables once
continue
c
Continue executing until next break point/watchpoint.
continue numberContinue but ignore current breakpoint number times. Usefull for breakpoints within a loop.
finishContinue to end of function.
Line Execution
step
s
step number-of-steps-to-perform
Step to next line of code. Will step into a function.
next
n
next number
Execute next line of code. Will not enter functions.
until
until line-number
Continue processing until you reach aspecified line number. Also: function name, address, filename:function or filename:line-number.
info signals
info handle
handle SIGNAL-NAMEoption
Perform the following option when signal recieved: nostop, stop, print, noprint, pass/noignore or nopass/ignore
whereShows current line number and which function you are in.
Stack
backtrace
bt
bt inner-function-nesting-depth
bt -outer-function-nesting-depth
Show trace of where you are currently. Which functions you are in. Prints stack backtrace.
backtrace fullPrint values of local variables.
frame
frame number
f number
Show current stack frame (function where you are stopped)
Select frame number. (can also user up/down to navigate frames)
up
down
up number
down number
Move up a single frame (element in the call stack)
Move down a single frame
Move up/down the specified number of frames in the stack.
info frameList address, language, address of arguments/local variables and which registers were saved in frame.
info args
info locals
info catch
Info arguments of selected frame, local variables and exception handlers.
Source Code
list
l
list line-number
list function
list -
list start#,end#
list filename:function
List source code.
set listsize count
show listsize
Number of lines listed when list command given.
directory directory-name
dir directory-name
show directories
Add specified directory to front of source code path.
directoryClear sourcepath when nothing specified.
Machine Language
info line
info line number
Displays the start and end position in object code for the current line in source.
Display position in object code for a specified line in source.
disassemble 0xstart 0xendDisplays machine code for positions in object code specified (can use start and end hex memory values given by the info line command.
stepi
si
nexti
ni
step/next assembly/processor instruction.
x 0xaddress
x/nfu 0xaddress
Examine the contents of memory.
Examine the contents of memory and specify formatting.
  • n: number of display items to print
  • f: specify the format for the output
  • u: specify the size of the data unit (eg. byte, word, ...)
Example: x/4dw var
Examine Variables
print variable-name
p variable-name
p file-name::variable-name
p 'file-name'::variable-name
Print value stored in variable.
p *array-variable@lengthPrint first # values of array specified by length. Good for pointers to dynamicaly allocated memory.
p/x variablePrint as integer variable in hex.
p/d variablePrint variable as a signed integer.
p/u variablePrint variable as a un-signed integer.
p/o variablePrint variable as a octal.
p/t variable
x/b address
x/b &variable
Print as integer value in binary. (1 byte/8bits)
p/c variablePrint integer as character.
p/f variablePrint variable as floating point number.
p/a variablePrint as a hex address.
x/w address
x/4b &variable
Print binary representation of 4 bytes (1 32 bit word) of memory pointed to by address.
ptype variable
ptype data-type
Prints type definition of the variable or declared variable type. Helpful for viewing class or struct definitions while debugging.
GDB Modes
set gdb-optionvalueSet a GDB option
set logging on
set logging off
show logging
set logging file log-file
Turn on/off logging. Default name of file is gdb.txt
set print array on
set print array off
show print array
Default is off. Convient readable format for arrays turned on/off.
set print array-indexes on
set print array-indexes off
show print array-indexes
Default off. Print index of array elements.
set print pretty on
set print pretty off
show print pretty
Format printing of C structures.
set print union on
set print union off
show print union
Default is on. Print C unions.
set print demangle on
set print demangle off
show print demangle
Default on. Controls printing of C++ names.
Start and Stop
run
r
run command-line-arguments
run < infile > outfile
Start program execution from the beginning of the program. The command break main will get you started. Also allows basic I/O redirection.
continue
c
Continue execution to next break point.
killStop program execution.
quit
q
Exit GDB debugger.
  • Compile with the '-g' option (for most GNU and Intel compilers) which generates added information in the object code so the debugger can match a line of source code with the step of execution.
  • Do not use compiler optimization directive such as '-O' or '-O2' which rearrange computing operations to gain speed as this reordering will not match the order of execution in the source code and it may be impossible to follow.
  • control+c: Stop execution. It can stop program anywhere, in your source or a C library or anywhere.
  • To execute a shell command: ! command
    or shell command
  • GDB command completion: Use TAB key
    info bre + TAB will complete the command resulting in info breakpoints
    Press TAB twice to see all available options if more than one option is available or type 'M-?' + RETURN.
  • GDB command abreviation:
    info bre + RETURN will work as bre is a valid abreviation for breakpoints
De-Referencing STL Containers:

Displaying STL container classes using the GDB 'p variable-name'results in an cryptic display of template definitions and pointers.Use the following ~/.gdbinit file (V1.03 09/15/08). Now works with GDB 4.3+.
(Archived versions: [V1.01 GDB 6.4+ only])
Thanks to Dr. Eng. Dan C. Marinescu for permission to post this script.

Ddd

Use the following commands provided by the script:

Data typeGDB command
std::vector<T>pvector stl_variable
std::list<T>plist stl_variable T
std::map<T,T>pmap stl_variable
std::multimap<T,T>pmap stl_variable
std::set<T>pset stl_variable T
std::multiset<T>pset stl_variable
std::deque<T>pdequeue stl_variable
std::stack<T>pstack stl_variable
std::queue<T>pqueue stl_variable
std::priority_queue<T>ppqueue stl_variable
std::bitset<n>td>pbitset stl_variable
std::stringpstring stl_variable
std::widestringpwstring stl_variable
Where T refers to native C++ data types. While classes and other STL data types will work with the STL container classes, this de-reference tool may not handle non-native types.

Also see the YoLinux.com STL string class tutorial and debugging with GDB.

Example: STL_vector_int.cpp

Compile: g++ -g STL_vector_int.cpp

Debug in GDB: gdb a.out

Notice the native GDB print 'p' results in an cryptic display while the 'pvector'routine from the GDB script provided a human decipherable display of your data.

Example: STL_vector_int_2.cpp

Compile: g++ -g STL_vector_int_2.cppDdd

Debug in GDB: gdb a.out

Ddd Cheat Sheet Pdf

Note 'pvector' does not de-reference the entire vector of vectors all at once but returns vectors $1, $2 and $3. The 'pvector' command then helps us traverse the information by examining the contents of each element in the individual 'terminal' vectors.Note that the native gdb 'p vI2Matrix' (last command) was much less informative.

GDB has a console GUI option available with the command line option --tui

Text console User Interface: gdb --tui
Command just like regular GDB with a source screen showing source code and break points.

My favorite gdb GUI is ddd.

Awesome variable and memory interrogation. Can interactively follow a linked list by clicking on its pointer in the display graph window. Highlight variable and right click for menu to interrogate variables in source.
Source code line numbers: Source + Display Line Numbers.
Set break points by right clicking just left of the line number.

Installation:
  • Ubuntu installation: apt-get install ddd
  • Red Hat/Fedora/CentOS RPMs available from EPEL (Extra Packages for Enterprise Linux)

GNU ddd: GUI for gdb, dbx, bashdb, pydb, etc

Man Pages:

Ddd Cheat Sheet Pdf

  • gdb - GNU debugger
  • ld - Linker
  • gcc/g++ - GNU project C and C++ compiler
Books:

Cheat Sheet Recipes

'Debugging with GDB: The GNU Source-Level Debugger'
by Richard Stallman, Roland H. Pesch, Stan Shebs
ISBN # 1882114884, Free Software Foundation; 9th edition (January 1, 2002)

'GDB Pocket Reference'
by Arnold Robbins
ISBN # 0596100272, O'Reilly

'Advanced Linux Programming'
by Mark Mitchell, Jeffrey Oldham, Alex Samuel, Jeffery Oldham
ISBN # 0735710430, New Riders

Good book for programmers who already know how to program and just need to know the Linux specifics. Covers a variety of Linux tools, libraries, API's and techniques. If you don't know how to program, start with a book on C.


Ddd Cheat Sheet Printable

Please enable JavaScript to view the comments powered by Disqus.