Skip to content

Commit bd6b903

Browse files
authoredAug 30, 2017
Remove DSTACK support (#6346)
Debugstacks is not useful, we don't really use it, the DebugStack is not pertinent, gdb and lldb are better if we really want to debug.
1 parent 43f9e94 commit bd6b903

22 files changed

+1
-327
lines changed
 

‎src/client.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,6 @@ Client::~Client()
252252

253253
void Client::connect(Address address, bool is_local_server)
254254
{
255-
DSTACK(FUNCTION_NAME);
256-
257255
initLocalMapSaving(address, m_address_name, is_local_server);
258256

259257
m_con->SetTimeoutMs(0);
@@ -262,8 +260,6 @@ void Client::connect(Address address, bool is_local_server)
262260

263261
void Client::step(float dtime)
264262
{
265-
DSTACK(FUNCTION_NAME);
266-
267263
// Limit a bit
268264
if(dtime > 2.0)
269265
dtime = 2.0;
@@ -773,7 +769,6 @@ void Client::initLocalMapSaving(const Address &address,
773769

774770
void Client::ReceiveAll()
775771
{
776-
DSTACK(FUNCTION_NAME);
777772
u64 start_ms = porting::getTimeMs();
778773
for(;;)
779774
{
@@ -799,7 +794,6 @@ void Client::ReceiveAll()
799794

800795
void Client::Receive()
801796
{
802-
DSTACK(FUNCTION_NAME);
803797
NetworkPacket pkt;
804798
m_con->Receive(&pkt);
805799
ProcessData(&pkt);
@@ -816,8 +810,6 @@ inline void Client::handleCommand(NetworkPacket* pkt)
816810
*/
817811
void Client::ProcessData(NetworkPacket *pkt)
818812
{
819-
DSTACK(FUNCTION_NAME);
820-
821813
ToClientCommand command = (ToClientCommand) pkt->getCommand();
822814
u32 sender_peer_id = pkt->getPeerId();
823815

@@ -1235,17 +1227,13 @@ void Client::sendChangePassword(const std::string &oldpassword,
12351227

12361228
void Client::sendDamage(u8 damage)
12371229
{
1238-
DSTACK(FUNCTION_NAME);
1239-
12401230
NetworkPacket pkt(TOSERVER_DAMAGE, sizeof(u8));
12411231
pkt << damage;
12421232
Send(&pkt);
12431233
}
12441234

12451235
void Client::sendBreath(u16 breath)
12461236
{
1247-
DSTACK(FUNCTION_NAME);
1248-
12491237
// Protocol v29 make this obsolete
12501238
if (m_proto_ver >= 29)
12511239
return;
@@ -1257,16 +1245,12 @@ void Client::sendBreath(u16 breath)
12571245

12581246
void Client::sendRespawn()
12591247
{
1260-
DSTACK(FUNCTION_NAME);
1261-
12621248
NetworkPacket pkt(TOSERVER_RESPAWN, 0);
12631249
Send(&pkt);
12641250
}
12651251

12661252
void Client::sendReady()
12671253
{
1268-
DSTACK(FUNCTION_NAME);
1269-
12701254
NetworkPacket pkt(TOSERVER_CLIENT_READY,
12711255
1 + 1 + 1 + 1 + 2 + sizeof(char) * strlen(g_version_hash));
12721256

‎src/client/keys.h

-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ class KeyType
7373
QUICKTUNE_INC,
7474
QUICKTUNE_DEC,
7575

76-
DEBUG_STACKS,
77-
7876
// hotbar
7977
SLOT_1,
8078
SLOT_2,

‎src/clientenvironment.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ ClientMap & ClientEnvironment::getClientMap()
7979

8080
void ClientEnvironment::setLocalPlayer(LocalPlayer *player)
8181
{
82-
DSTACK(FUNCTION_NAME);
8382
/*
8483
It is a failure if already is a local player
8584
*/
@@ -91,8 +90,6 @@ void ClientEnvironment::setLocalPlayer(LocalPlayer *player)
9190

9291
void ClientEnvironment::step(float dtime)
9392
{
94-
DSTACK(FUNCTION_NAME);
95-
9693
/* Step time of day */
9794
stepTimeOfDay(dtime);
9895

‎src/clientiface.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ void RemoteClient::GetNextBlocks (
6666
float dtime,
6767
std::vector<PrioritySortedBlockTransfer> &dest)
6868
{
69-
DSTACK(FUNCTION_NAME);
70-
71-
7269
// Increment timers
7370
m_nothing_to_send_pause_timer -= dtime;
7471
m_nearest_unsent_reset_timer += dtime;

‎src/clientmap.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ ClientMap::ClientMap(
6262

6363
MapSector * ClientMap::emergeSector(v2s16 p2d)
6464
{
65-
DSTACK(FUNCTION_NAME);
6665
// Check that it doesn't exist already
6766
try {
6867
return getSectorNoGenerate(p2d);
@@ -303,8 +302,6 @@ struct MeshBufListList
303302

304303
void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
305304
{
306-
DSTACK(FUNCTION_NAME);
307-
308305
bool is_transparent_pass = pass == scene::ESNRP_TRANSPARENT;
309306

310307
std::string prefix;

‎src/debug.cpp

-133
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ void sanity_check_fn(const char *assertion, const char *file,
5656
errorstream << file << ":" << line << ": " << function
5757
<< ": An engine assumption '" << assertion << "' failed." << std::endl;
5858

59-
debug_stacks_print_to(errorstream);
60-
6159
abort();
6260
}
6361

@@ -73,140 +71,9 @@ void fatal_error_fn(const char *msg, const char *file,
7371
errorstream << file << ":" << line << ": " << function
7472
<< ": A fatal error occured: " << msg << std::endl;
7573

76-
debug_stacks_print_to(errorstream);
77-
7874
abort();
7975
}
8076

81-
/*
82-
DebugStack
83-
*/
84-
85-
struct DebugStack
86-
{
87-
DebugStack(std::thread::id id);
88-
void print(FILE *file, bool everything);
89-
void print(std::ostream &os, bool everything);
90-
91-
std::thread::id thread_id;
92-
char stack[DEBUG_STACK_SIZE][DEBUG_STACK_TEXT_SIZE];
93-
int stack_i; // Points to the lowest empty position
94-
int stack_max_i; // Highest i that was seen
95-
};
96-
97-
DebugStack::DebugStack(std::thread::id id)
98-
{
99-
thread_id = id;
100-
stack_i = 0;
101-
stack_max_i = 0;
102-
memset(stack, 0, DEBUG_STACK_SIZE*DEBUG_STACK_TEXT_SIZE);
103-
}
104-
105-
void DebugStack::print(FILE *file, bool everything)
106-
{
107-
std::ostringstream os;
108-
os << thread_id;
109-
fprintf(file, "DEBUG STACK FOR THREAD %s:\n",
110-
os.str().c_str());
111-
112-
for (int i = 0; i < stack_max_i; i++) {
113-
if (i == stack_i && !everything)
114-
break;
115-
116-
if (i < stack_i)
117-
fprintf(file, "#%d %s\n", i, stack[i]);
118-
else
119-
fprintf(file, "(Leftover data: #%d %s)\n", i, stack[i]);
120-
}
121-
122-
if (stack_i == DEBUG_STACK_SIZE)
123-
fprintf(file, "Probably overflown.\n");
124-
}
125-
126-
void DebugStack::print(std::ostream &os, bool everything)
127-
{
128-
os<<"DEBUG STACK FOR THREAD "<<thread_id<<": "<<std::endl;
129-
130-
for(int i = 0; i < stack_max_i; i++) {
131-
if(i == stack_i && !everything)
132-
break;
133-
134-
if (i < stack_i)
135-
os<<"#"<<i<<" "<<stack[i]<<std::endl;
136-
else
137-
os<<"(Leftover data: #"<<i<<" "<<stack[i]<<")"<<std::endl;
138-
}
139-
140-
if (stack_i == DEBUG_STACK_SIZE)
141-
os<<"Probably overflown."<<std::endl;
142-
}
143-
144-
std::map<std::thread::id, DebugStack*> g_debug_stacks;
145-
std::mutex g_debug_stacks_mutex;
146-
147-
void debug_stacks_print_to(std::ostream &os)
148-
{
149-
MutexAutoLock lock(g_debug_stacks_mutex);
150-
151-
os<<"Debug stacks:"<<std::endl;
152-
153-
for (auto it : g_debug_stacks) {
154-
it.second->print(os, false);
155-
}
156-
}
157-
158-
void debug_stacks_print()
159-
{
160-
debug_stacks_print_to(errorstream);
161-
}
162-
163-
DebugStacker::DebugStacker(const char *text)
164-
{
165-
std::thread::id thread_id = std::this_thread::get_id();
166-
167-
MutexAutoLock lock(g_debug_stacks_mutex);
168-
169-
auto n = g_debug_stacks.find(thread_id);
170-
if (n != g_debug_stacks.end()) {
171-
m_stack = n->second;
172-
} else {
173-
/*DEBUGPRINT("Creating new debug stack for thread %x\n",
174-
(unsigned int)thread_id);*/
175-
m_stack = new DebugStack(thread_id);
176-
g_debug_stacks[thread_id] = m_stack;
177-
}
178-
179-
if (m_stack->stack_i >= DEBUG_STACK_SIZE) {
180-
m_overflowed = true;
181-
} else {
182-
m_overflowed = false;
183-
184-
snprintf(m_stack->stack[m_stack->stack_i],
185-
DEBUG_STACK_TEXT_SIZE, "%s", text);
186-
m_stack->stack_i++;
187-
if (m_stack->stack_i > m_stack->stack_max_i)
188-
m_stack->stack_max_i = m_stack->stack_i;
189-
}
190-
}
191-
192-
DebugStacker::~DebugStacker()
193-
{
194-
MutexAutoLock lock(g_debug_stacks_mutex);
195-
196-
if (m_overflowed)
197-
return;
198-
199-
m_stack->stack_i--;
200-
201-
if (m_stack->stack_i == 0) {
202-
std::thread::id thread_id = m_stack->thread_id;
203-
/*DEBUGPRINT("Deleting debug stack for thread %x\n",
204-
(unsigned int)thread_id);*/
205-
delete m_stack;
206-
g_debug_stacks.erase(thread_id);
207-
}
208-
}
209-
21077
#ifdef _MSC_VER
21178

21279
const char *Win32ExceptionCodeToString(DWORD exception_code)

‎src/debug.h

-30
Original file line numberDiff line numberDiff line change
@@ -83,36 +83,6 @@ NORETURN extern void sanity_check_fn(
8383

8484
void debug_set_exception_handler();
8585

86-
/*
87-
DebugStack
88-
*/
89-
90-
#define DEBUG_STACK_SIZE 50
91-
#define DEBUG_STACK_TEXT_SIZE 300
92-
93-
extern void debug_stacks_print_to(std::ostream &os);
94-
extern void debug_stacks_print();
95-
96-
struct DebugStack;
97-
class DebugStacker
98-
{
99-
public:
100-
DebugStacker(const char *text);
101-
~DebugStacker();
102-
103-
private:
104-
DebugStack *m_stack;
105-
bool m_overflowed;
106-
};
107-
108-
#define DSTACK(msg) \
109-
DebugStacker __debug_stacker(msg);
110-
111-
#define DSTACKF(...) \
112-
char __buf[DEBUG_STACK_TEXT_SIZE]; \
113-
snprintf(__buf, DEBUG_STACK_TEXT_SIZE, __VA_ARGS__); \
114-
DebugStacker __debug_stacker(__buf);
115-
11686
/*
11787
These should be put into every thread
11888
*/

‎src/emerge.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,6 @@ MapBlock *EmergeThread::finishGen(v3s16 pos, BlockMakeData *bmdata,
598598

599599
void *EmergeThread::run()
600600
{
601-
DSTACK(FUNCTION_NAME);
602601
BEGIN_DEBUG_EXCEPTION_HANDLER
603602

604603
v3s16 pos;

‎src/game.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,6 @@ void KeyCache::populate()
10991099
key[KeyType::QUICKTUNE_INC] = getKeySetting("keymap_quicktune_inc");
11001100
key[KeyType::QUICKTUNE_DEC] = getKeySetting("keymap_quicktune_dec");
11011101

1102-
key[KeyType::DEBUG_STACKS] = getKeySetting("keymap_print_debug_stacks");
1103-
11041102
for (int i = 0; i < 23; i++) {
11051103
std::string slot_key_name = "keymap_slot" + std::to_string(i + 1);
11061104
key[KeyType::SLOT_1 + i] = getKeySetting(slot_key_name.c_str());
@@ -2609,14 +2607,6 @@ void Game::processKeyInput()
26092607
quicktune->inc();
26102608
} else if (wasKeyDown(KeyType::QUICKTUNE_DEC)) {
26112609
quicktune->dec();
2612-
} else if (wasKeyDown(KeyType::DEBUG_STACKS)) {
2613-
// Print debug stacks
2614-
dstream << "-----------------------------------------"
2615-
<< std::endl;
2616-
dstream << "Printing debug stacks:" << std::endl;
2617-
dstream << "-----------------------------------------"
2618-
<< std::endl;
2619-
debug_stacks_print();
26202610
}
26212611

26222612
if (!isKeyDown(KeyType::JUMP) && runData.reset_jump_timer) {

‎src/guiKeyChangeMenu.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ enum
6363
GUI_ID_KEY_MUTE_BUTTON,
6464
GUI_ID_KEY_DEC_VOLUME_BUTTON,
6565
GUI_ID_KEY_INC_VOLUME_BUTTON,
66-
GUI_ID_KEY_DUMP_BUTTON,
6766
GUI_ID_KEY_RANGE_BUTTON,
6867
GUI_ID_KEY_ZOOM_BUTTON,
6968
GUI_ID_KEY_CAMERA_BUTTON,
@@ -433,6 +432,5 @@ void GUIKeyChangeMenu::init_keys()
433432
this->add_key(GUI_ID_KEY_HUD_BUTTON, wgettext("Toggle HUD"), "keymap_toggle_hud");
434433
this->add_key(GUI_ID_KEY_CHATLOG_BUTTON, wgettext("Toggle chat log"), "keymap_toggle_chat");
435434
this->add_key(GUI_ID_KEY_FOG_BUTTON, wgettext("Toggle fog"), "keymap_toggle_force_fog_off");
436-
this->add_key(GUI_ID_KEY_DUMP_BUTTON, wgettext("Print stacks"), "keymap_print_debug_stacks");
437435
}
438436

‎src/httpfetch.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,6 @@ class CurlFetchThread : public Thread
642642

643643
void *run()
644644
{
645-
DSTACK(FUNCTION_NAME);
646-
647645
CurlHandlePool pool;
648646

649647
m_multi = curl_multi_init();

‎src/inventory.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ ItemStack::ItemStack(const std::string &name_, u16 count_,
5757

5858
void ItemStack::serialize(std::ostream &os) const
5959
{
60-
DSTACK(FUNCTION_NAME);
61-
62-
if(empty())
60+
if (empty())
6361
return;
6462

6563
// Check how many parts of the itemstring are needed
@@ -84,8 +82,6 @@ void ItemStack::serialize(std::ostream &os) const
8482

8583
void ItemStack::deSerialize(std::istream &is, IItemDefManager *itemdef)
8684
{
87-
DSTACK(FUNCTION_NAME);
88-
8985
clear();
9086

9187
// Read name

0 commit comments

Comments
 (0)
Please sign in to comment.