internals

How does gdb set software breakpoints in shared library functions?

元气小坏坏 提交于 2021-02-08 13:21:41
问题 I know that software breakpoints in an executable file can work through replacing some assembler instruction at the desired place with another one, which cause interrupt. So debugger can stop execution exactly at this place and replace this instruction with original one and ask user about what to do the next or call some commands and etc. But code of such executable file is not used by another programs and has only one copy in memory. How can software breakpoints work with a shared libraries?

How does the virtual inheritance table work in g++?

北战南征 提交于 2021-01-28 08:25:38
问题 I'm trying to get a better understanding how virtual inheritance works in practice (that is, not according to the standard, but in an actual implementation like g++ ). The actual question is at the bottom, in bold face. So, I built myself a inheritance graph, which has among other things, these simple types: struct A { unsigned a; unsigned long long u; A() : a(0xAAAAAAAA), u(0x1111111111111111ull) {} virtual ~A() {} }; struct B : virtual A { unsigned b; B() : b(0xBBBBBBBB) { a = 0xABABABAB; }

In Bash regular expressions do `^` and `$` refer to lines, or to the entire string?

夙愿已清 提交于 2021-01-27 14:11:38
问题 In The Linux Documentation Project (I didn't find details about the regex metacharacters in the Bash manual), the metachars ^ and $ are defined as matching lines: ^ : Matches the empty string at the beginning of a line [...] $ : Matches the empty string at the end of a line however, when I try, this is not correct: $ string="a > b > c" $ [[ $string =~ ^a ]] && echo BOS match BOS match $ [[ $string =~ ^b ]] && echo BOL match # nothing Are the manuals really wrong, or I am missing something?

How to hide visibility of Kotlin internal class in Java from different modules?

拜拜、爱过 提交于 2020-08-06 05:53:07
问题 I was working on the Android library which I'm developing in Kotlin. I kept access modifier of some classes as internal . Internal classes are only visible in that library module in Kotlin. If I implement that library in the app then it's not visible at all. But the problem comes when accessing that library from Java code. If I create .java file and type name of that internal class of library then IDE is suggesting name and it's resolved and compiled without any error. For e.g. Library Module

When to use ExtSlice node in Python's AST?

僤鯓⒐⒋嵵緔 提交于 2020-04-11 06:40:10
问题 Green Tree Snakes gives an example of using ExtSlice : >>> parseprint("l[1:2, 3]") Module(body=[ Expr(value=Subscript(value=Name(id='l', ctx=Load()), slice=ExtSlice(dims=[ Slice(lower=Num(n=1), upper=Num(n=2), step=None), Index(value=Num(n=3)), ]), ctx=Load())), ]) However this syntax won't work in interactive python shell: >>> foo = range(10) >>> foo[1:2,3] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: list indices must be integers, not tuple Anyone got an

When to use ExtSlice node in Python's AST?

£可爱£侵袭症+ 提交于 2020-04-11 06:40:07
问题 Green Tree Snakes gives an example of using ExtSlice : >>> parseprint("l[1:2, 3]") Module(body=[ Expr(value=Subscript(value=Name(id='l', ctx=Load()), slice=ExtSlice(dims=[ Slice(lower=Num(n=1), upper=Num(n=2), step=None), Index(value=Num(n=3)), ]), ctx=Load())), ]) However this syntax won't work in interactive python shell: >>> foo = range(10) >>> foo[1:2,3] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: list indices must be integers, not tuple Anyone got an

Why does a numpy array have 96 bytes of overhead?

倖福魔咒の 提交于 2020-03-21 15:41:49
问题 If I take a simply and empty numpy array i can see it has 96 bytes of overhead, >>> sys.getsizeof( np.array([]) ) 96 What is that 96 bytes storing? Where in the C source for numpy or Python 3 (cpython) is this set up? 回答1: Array is present in C sources in numpy/core/include/numpy/ndarraytypes.h See: https://github.com/numpy/numpy/blob/master/numpy/core/include/numpy/ndarraytypes.h Looks like it has several pointers, number of dimensions and PyObject_HEAD, which all may in total count to

Initialization-on-demand holder idiom - When are classes loaded?

人走茶凉 提交于 2020-02-22 14:49:13
问题 I have been looking at: https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom to understand a little bit more about Singletons. My question is when exactly does the static inner class get Loaded and when does it get Initialised? My understanding is that classes can be loaded but remain uninitialised until initialisation is absolutely necessary. If the class is not loaded, how is the private static inner class specified within the JVM? 回答1: The exact time when a class is

Initialization-on-demand holder idiom - When are classes loaded?

旧时模样 提交于 2020-02-22 14:45:37
问题 I have been looking at: https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom to understand a little bit more about Singletons. My question is when exactly does the static inner class get Loaded and when does it get Initialised? My understanding is that classes can be loaded but remain uninitialised until initialisation is absolutely necessary. If the class is not loaded, how is the private static inner class specified within the JVM? 回答1: The exact time when a class is

STL internals: deque implementation

你离开我真会死。 提交于 2020-01-27 23:54:55
问题 I am using a std::deque for storing a large collection of items. I know that deques is implemented as a list of vectors. The size of those vectors cannot be set but I wander what is the algorithm for choosing that size. 回答1: deque is implemented as a vector of vectors (a list of vectors would impede the constant time random access). The size of the secondary vectors is implementation dependent, a common algorithm is to use a constant size in bytes. 回答2: My deque implementation, the one from