Table of Contents....4
Preface....16
About the Author....17
Introduction....18
Original Training Course Name....18
Prerequisites....19
Training Goals....20
Training Principles....21
Schedule....22
Training Idea....23
General C & C++ Aspects....24
What We Do Not Cover....26
Linux C & C++ Aspects....27
Why C & C++?....28
Which C & C++?....30
My History of C & C++....31
C and C++ Mastery Process....33
Thought Process....34
Philosophy of Pointers....35
Pointer....36
Pointer Dereference....37
Many to One....38
Many to One Dereference....39
Invalid Pointer....40
Invalid Pointer Dereference....41
Wild (Dangling) Pointer....42
Pointer to Pointer....43
Pointer to Pointer Dereference....44
Naming Pointers and Entities....45
Names as Pointer Content....46
Pointers as Entities....47
Memory and Pointers....48
Mental Exercise....49
Debugger Memory Layout....50
Memory Dereference Layout....51
Names as Addresses....52
Addresses and Entities....53
Addresses and Structures....54
Pointers to Structures....55
Arrays....56
Arrays and Pointers to Arrays....57
Strings and Pointers to Strings....58
Basic Types....59
ASCII Characters and Pointers....60
Bytes and Pointers....61
Wide Characters and Pointers....62
Integers....63
Little-Endian System....64
Short Integers....65
Long and Long Long Integers....66
Signed and Unsigned Integers....67
Fixed Size Integers....68
Booleans....69
Bytes....70
Size....71
Alignment....72
LP64....73
Nothing and Anything....74
Automatic Type Inference....75
Entity Conversion....76
Pointer Conversion (C-Style)....77
Numeric Promotion/Conversion....78
Numeric Conversion....79
Incompatible Types....80
Forcing....81
Structures, Classes, and Objects....83
Structures....84
Access Level....85
Classes and Objects....86
Structures and Classes....87
Pointer to Structure....88
Pointer to Structure Dereference....89
Many Pointers to One Structure....90
Many to One Dereference....91
Invalid Pointer to Structure....92
Invalid Pointer Dereference....93
Wild (Dangling) Pointer....94
Pointer to Pointer to Structure....95
Pointer to Pointer Dereference....96
Memory and Structures....97
Addresses and Structures....98
Structure Field Access....99
Pointers to Structures....100
Pointers to Structure Fields....101
Structure Inheritance....102
Structure Slicing....103
Inheritance Access Level....105
Structures and Classes II....106
Internal Structure Alignment....107
Static Structure Fields....108
Uniform Initialization....109
Old Initialization Ways....110
New Way {}....111
Uniform Structure Initialization....112
Static Field Initialization....113
Macros, Types, and Synonyms....114
Macros....115
Old Way....116
New Way....117
Memory Storage....118
Overview....119
Thread Stack Frames....120
Local Variable Value Lifecycle....121
Stack Allocation Pitfalls....123
Explicit Local Allocation....125
Dynamic Allocation (C-style)....126
Dynamic Allocation (C++)....127
Memory Operators....128
Memory Expressions....129
Local Pointers (Manual)....130
In-place Allocation....132
Source Code Organisation....133
Logical Layer (Translation Units)....134
Physical Layer (Source Files)....135
Inter-TU Sharing....136
Classic Static TU Isolation....137
Namespace TU Isolation....138
Declaration and Definition....139
TU Definition Conflicts....140
Fine-grained TU Scope Isolation....141
Conceptual Layer (Design)....142
Incomplete Types....143
References....144
Type& vs. Type*....145
Values....146
Value Categories....147
Constant Values....148
Constant Expressions....149
Functions....150
Pointers to Functions....151
Function Pointer Types....153
Reading Declarations....154
Structure Function Fields....155
Structure Methods....156
Structure Methods (Inlined)....157
Structure Methods (Inheritance)....158
Structure Virtual Methods....160
Structure Pure Virtual Methods....162
Structure as Interface....163
Function Structure....164
Structure Constructors....165
Structure Copy Constructor....166
Structure Copy Assignment....167
Structure Destructor....168
Structure Destructor Hierarchy....169
Structure Virtual Destructor....170
Destructor as a Method....171
Conversion Operators....172
Parameters by Value....174
Parameters by Pointer/Reference....175
Parameters by Ptr/Ref to Const....176
Possible Mistake....177
Function Overloading....178
Immutable Objects....179
Static Structure Functions....180
Lambdas....181
x64 CPU Registers....182
x64 Instructions and Registers....183
x64 Memory and Stack Addressing....184
x64 Memory Load Instructions....185
x64 Memory Store Instructions....186
x64 Flow Instructions....187
x64 Function Parameters....188
x64 Struct Function Parameters....189
A64 CPU Registers....190
A64 Instructions and Registers....191
A64 Memory and Stack Addressing....192
A64 Memory Load Instructions....193
A64 Memory Store Instructions....194
A64 Flow Instructions....195
A64 Function Parameters....196
A64 Struct Function Parameters....197
this....198
Function Objects vs. Lambdas....199
A64 Lambda Example....201
Captures and Closures....202
A64 Captures Example....204
Lambdas as Parameters....205
A64 Lambda Parameter Example....207
Lambda Parameter Optimization....208
A64 Optimization Example....210
Lambdas as Unnamed Functions....211
std::function Lambda Parameters....213
auto Lambda Parameters....215
Lambdas as Return Values....217
Virtual Function Call....219
VTBL Memory Layout....220
VPTR and Struct Memory Layout....221
Templates: A Planck-length Introduction....222
Why Templates?....223
Reusability....224
Types of Templates....226
Types of Template Parameters....227
Type Safety....229
Flexibility....231
Metafunctions....232
Iterators as Pointers....233
Containers....234
Iterators....235
Constant Iterators....236
Pointers as Iterators....237
Algorithms....238
Memory Ownership....239
Pointers as Owners....240
Problems with Pointer Owners....241
Smart Pointers....242
Basic Design....243
Unique Pointers....244
Descriptors as Unique Pointers....245
Shared Pointers....246
RAII....247
RAII Definition....248
RAII Advantages....249
File Descriptor RAII....250
Threads and Synchronization....251
Threads in C/C++....252
Threads in C++ Proper....253
Synchronization Problems....254
Synchronization Solution....255
Resources....256
C and C++....257
Training (Linux C and C++)....258
Solid C and C++ knowledge is a must to fully understand Linux diagnostic artifacts such as core memory dumps and do diagnostic, forensic, and root cause analysis beyond listing backtraces. This full-color reference book is a part of the Accelerated C & C++ for Linux Diagnostics training course organized by Software Diagnostics Services. The text contains slides, brief notes highlighting particular points, and replicated source code fragments that are easy to copy into your favorite IDE. The book's detailed Table of Contents makes the usual Index redundant. We hope this reference is helpful for the following audiences: