好吧,所以基本上我想知道如何打印一个存储器地址的值,该地址与存储在GDB寄存器中的地址相差一点.例如,拿这个装配线:
mov 0x34(%esp),%edx
Run Code Online (Sandbox Code Playgroud)
根据我的理解,它在堆栈指针指向的地址之后取值52个字节,并将该值存储在edx寄存器中.在这种情况下,值是一个字符串,因此它将存储char*.在edx寄存器中使用GDB内部的examine命令时:
x/s $edx
Run Code Online (Sandbox Code Playgroud)
它按照预期打印出字符串.但是,当我尝试通过直接检查使用此命令复制的位置来打印字符串时:
x/s $esp + 0x34
Run Code Online (Sandbox Code Playgroud)
它打印出垃圾.为什么是这样?我误解了GDB命令的语法,还是其他的东西?
以下代码无法编译并显示以下错误template template argument has different template parameters than its corresponding template template parameter
:
#include <tuple>
#include <vector>
#include <string>
#include <iostream>
template<template<typename, typename> class Blah, typename KeyType, typename ValueType>
void print_tuploid(const Blah<KeyType, ValueType>& tup) {
std::cout << "first value: " << std::get<0>(tup) << " second value: " << std::get<1>(tup) << std::endl;
}
int main() {
auto stuff = std::make_tuple(1, 2);
print_tuploid(stuff);
}
Run Code Online (Sandbox Code Playgroud)
该代码背后的初衷无关紧要,在这一点上,我只是想了解为什么认为这是无效的。
如果将调用更改std::make_tuple
为std::make_pair
,则代码会正确编译并运行,这使我相信特定于的事情很奇怪std::tuple
。
我最初以为std::tuple
可能会有一些我不知道的额外的默认模板参数,因为如果我将以下定义更改为print_tuploid
,则代码会同时为std::make_tuple
和编译std::make_pair …