Skip to main content
added 2 characters in body
Source Link
Yves
  • 12.6k
  • 21
  • 106
  • 217

I'm trying to use GDB to debug my C++ program.

I'm thinking is itif it's possible to pass arguments to a function while using GDB?.

For example, I have such a program as below:

#include <iostream>

void func(int a)
{
    std::cout << a << std::endl;
}

int main(int argc, char **argv)
{
    func(2222);

    return EXIT_SUCCESS;
}

I set a breakpoint at the line func(2222) in the function main. My question is: is it possible to set another argument to the function func, instead of 2222, while using GDB on this program?

I'm trying to use GDB to debug my C++ program.

I'm thinking is it possible to pass arguments to a function while using GDB?

For example, I have such a program as below:

#include <iostream>

void func(int a)
{
    std::cout << a << std::endl;
}

int main(int argc, char **argv)
{
    func(2222);

    return EXIT_SUCCESS;
}

I set a breakpoint at the line func(2222) in the function main. My question is: is it possible to set another argument to the function func, instead of 2222, while using GDB on this program?

I'm trying to use GDB to debug my C++ program.

I'm thinking if it's possible to pass arguments to a function while using GDB.

For example, I have such a program as below:

#include <iostream>

void func(int a)
{
    std::cout << a << std::endl;
}

int main(int argc, char **argv)
{
    func(2222);

    return EXIT_SUCCESS;
}

I set a breakpoint at the line func(2222) in the function main. My question is: is it possible to set another argument to the function func, instead of 2222, while using GDB on this program?

Source Link
Yves
  • 12.6k
  • 21
  • 106
  • 217

How to pass arguments to a function while GDB

I'm trying to use GDB to debug my C++ program.

I'm thinking is it possible to pass arguments to a function while using GDB?

For example, I have such a program as below:

#include <iostream>

void func(int a)
{
    std::cout << a << std::endl;
}

int main(int argc, char **argv)
{
    func(2222);

    return EXIT_SUCCESS;
}

I set a breakpoint at the line func(2222) in the function main. My question is: is it possible to set another argument to the function func, instead of 2222, while using GDB on this program?