tools: MimeDump<> can have all static members
[barry.git] / src / m_jvmdebug.cc
blobea8199bdbd73ec65a2563475dc3fc0a27664f042
1 ///
2 /// \file m_jvmdebug.cc
3 /// Mode class for the JVMDebug mode
4 ///
6 /*
7 Copyright (C) 2005-2010, Net Direct Inc. (http://www.netdirect.ca/)
8 Copyright (C) 2008-2009, Nicolas VIVIEN
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
23 #include "m_jvmdebug.h"
24 #include "data.h"
25 #include "protocol.h"
26 #include "protostructs.h"
27 #include "packet.h"
28 #include "endian.h"
29 #include "error.h"
30 #include "usbwrap.h"
31 #include "controller.h"
32 #include "cod.h"
33 #include <stdexcept>
34 #include <sstream>
35 #include <iomanip>
36 #include <vector>
37 #include <string.h>
38 #include <time.h>
39 #include <stdio.h>
41 #include "debug.h"
43 using namespace std;
44 using namespace Barry::Protocol;
46 namespace Barry {
48 ///////////////////////////////////////////////////////////////////////////////
49 // JDModulesList class
51 void JVMModulesList::Parse(const Data &entry_packet)
53 uint16_t count = 0;
55 size_t size = entry_packet.GetSize();
57 while (count < size) {
58 uint16_t len = 0;
60 const unsigned char *ptr = (entry_packet.GetData() + count);
61 Protocol::JVMModulesEntry *e = (Protocol::JVMModulesEntry *) ptr;
63 len = SB_JVMMODULES_ENTRY_HEADER_SIZE + be_btohs(e->sizename);
64 if( (count + len) > size )
65 break;
67 JVMModulesEntry entry;
69 entry.Id = be_btohl(e->id);
70 entry.UniqueID = be_btohl(e->uniqueId);
71 (entry.Name).assign((char *) (ptr + SB_JVMMODULES_ENTRY_HEADER_SIZE), be_btohs(e->sizename));
73 push_back(entry);
75 count += len;
80 void JVMModulesList::Dump(std::ostream &os) const
82 const_iterator i = begin(), e = end();
84 os << " ID " << "|";
85 os << " UniqueID " << "|";
86 os << " Module Name" << endl;
88 os << "------------+";
89 os << "------------+";
90 os << "-------------";
91 os << endl;
93 for( ; i != e; ++i ) {
94 (*i).Dump(os);
99 ///////////////////////////////////////////////////////////////////////////////
100 // JVMModulesEntry class
102 void JVMModulesEntry::Dump(std::ostream &os) const
104 os << " 0x" << setfill('0') << setw(8) << hex << Id << " |";
105 os << " 0x" << setfill('0') << setw(8) << hex << UniqueID << " |";
106 os << " " << Name << endl;
110 ///////////////////////////////////////////////////////////////////////////////
111 // JVMThreadsList class
113 void JVMThreadsList::Parse(const Data &entry_packet)
115 uint16_t count = 0;
117 size_t size = entry_packet.GetSize();
119 while (count < size) {
120 uint16_t len = 0;
122 const unsigned char *ptr = (entry_packet.GetData() + count);
123 uint32_t *e = (uint32_t *) ptr;
125 len = sizeof(uint32_t);
126 if( (count + len) > size )
127 break;
129 JVMThreadsEntry entry;
131 entry.Id = be_btohl(*e);
133 push_back(entry);
135 count += len;
140 void JVMThreadsList::Dump(std::ostream &os) const
142 const_iterator i = begin(), e = end();
144 os << " Thread " << "|";
145 os << " Address " << "|";
146 os << " Byte " << "|";
147 os << " Unknown01 " << "|";
148 os << " Unknown02 " << "|";
149 os << " Unknown03 " << "|";
150 os << " Unknown04 " << "|";
151 os << " Unknown05 " << "|";
152 os << " Unknown06 " << "|";
154 os << "------------+";
155 os << "------------+";
156 os << "------+";
157 os << "------------+";
158 os << "------------+";
159 os << "------------+";
160 os << "------------+";
161 os << "------------+";
162 os << "-------------";
163 os << endl;
165 for(int k=0 ; i != e; ++i, k++ ) {
166 (*i).Dump(os, k);
171 void JVMThreadsEntry::Dump(std::ostream &os, int num) const
173 os << " " << setfill(' ') << setw(8) << dec << num << " |";
174 os << " 0x" << setfill('0') << setw(8) << hex << (Id) << " |";
175 os << " 0x" << setfill('0') << setw(2) << hex << (Byte) << " |";
176 os << " 0x" << setfill('0') << setw(8) << hex << (Address) << " |";
177 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown01) << " |";
178 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown02) << " |";
179 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown03) << " |";
180 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown04) << " |";
181 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown05) << " |";
182 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown06) << endl;
186 namespace Mode {
188 ///////////////////////////////////////////////////////////////////////////////
189 // JVMDebug Mode class
191 JVMDebug::JVMDebug(Controller &con)
192 : Mode(con, Controller::JVMDebug)
193 , m_Attached(false)
197 JVMDebug::~JVMDebug()
199 if( m_Attached )
200 Detach();
203 ///////////////////////////////////////////////////////////////////////////////
204 // protected members
207 ///////////////////////////////////////////////////////////////////////////////
208 // public API
210 void JVMDebug::OnOpen()
212 m_socket->InitSequence();
215 // FIXME - is this necessary? and if it is, wouldn't it be better
216 // in the m_jvmdebug mode class? I'm not convinced that applications
217 // should have to bother with socket-level details.
218 void JVMDebug::Close()
220 if( m_ModeSocket ) {
221 m_socket->Close();
222 m_socket.reset();
223 m_ModeSocket = 0;
228 // Attach
230 /// These commands are sent to prepare the debug communication.
231 /// Must be called at the start of a JVMDebug session.
233 void JVMDebug::Attach()
238 // Detach
240 /// Must be called at the end of a JVMDebug session. The JVM_GOODBYE
241 /// command is sent to the device.
243 void JVMDebug::Detach()
248 void JVMDebug::ThrowJVMError(const std::string &msg, uint8_t cmd)
250 std::ostringstream oss;
251 oss << msg << ": unexpected packet command code: 0x"
252 << std::hex << (unsigned int) cmd;
253 throw Error(oss.str());
258 // Unknown 01 ???
260 void JVMDebug::Unknown01()
262 uint16_t expect = 0;
264 Data command(-1, 8), response;
265 JVMPacket packet(command, response);
267 // Send the command packet
268 packet.Unknown01();
269 m_socket->Packet(packet);
270 expect = packet.Size();
272 if (expect == 0)
273 return;
275 // Read the data stream
276 m_socket->ReceiveData(response);
278 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
280 // Check the size read into the previous packet
281 if( expect != bytereceived ) {
282 ThrowJVMError("JVMDebug::Attach expect", expect);
288 // Unknown 02 ???
290 void JVMDebug::Unknown02()
292 uint16_t expect = 0;
294 Data command(-1, 8), response;
295 JVMPacket packet(command, response);
297 // Send the command packet
298 packet.Unknown02();
299 m_socket->Packet(packet);
300 expect = packet.Size();
302 if (expect == 0)
303 return;
305 // Read the data stream
306 m_socket->ReceiveData(response);
308 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
310 // Check the size read into the previous packet
311 if( expect != bytereceived ) {
312 ThrowJVMError("JVMDebug::Attach expect", expect);
318 // Unknown 03 ???
320 void JVMDebug::Unknown03()
322 uint16_t expect = 0;
324 Data command(-1, 8), response;
325 JVMPacket packet(command, response);
327 // Send the command packet
328 packet.Unknown03();
329 m_socket->Packet(packet);
330 expect = packet.Size();
332 if (expect == 0)
333 return;
335 // Read the data stream
336 m_socket->ReceiveData(response);
338 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
340 // Check the size read into the previous packet
341 if( expect != bytereceived ) {
342 ThrowJVMError("JVMDebug::Attach expect", expect);
348 // Unknown 04 ???
350 void JVMDebug::Unknown04()
352 uint16_t expect = 0;
354 Data command(-1, 8), response;
355 JVMPacket packet(command, response);
357 // Send the command packet
358 packet.Unknown04();
359 m_socket->Packet(packet);
360 expect = packet.Size();
362 if (expect == 0)
363 return;
365 // Read the data stream
366 m_socket->ReceiveData(response);
368 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
370 // Check the size read into the previous packet
371 if( expect != bytereceived ) {
372 ThrowJVMError("JVMDebug::Attach expect", expect);
378 // Unknown 05 ???
380 void JVMDebug::Unknown05()
382 uint16_t expect = 0;
384 Data command(-1, 8), response;
385 JVMPacket packet(command, response);
387 // Send the command packet
388 packet.Unknown05();
389 m_socket->Packet(packet);
390 expect = packet.Size();
392 if (expect == 0)
393 return;
395 // Read the data stream
396 m_socket->ReceiveData(response);
398 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
400 // Check the size read into the previous packet
401 if( expect != bytereceived ) {
402 ThrowJVMError("JVMDebug::Attach expect", expect);
408 // Unknown 06 ???
410 void JVMDebug::Unknown06()
412 uint16_t expect = 0;
414 Data command(-1, 8), response;
415 JVMPacket packet(command, response);
417 // Send the command packet
418 packet.Unknown06();
419 m_socket->Packet(packet);
420 expect = packet.Size();
422 if (expect == 0)
423 return;
425 // Read the data stream
426 m_socket->ReceiveData(response);
428 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
430 // Check the size read into the previous packet
431 if( expect != bytereceived ) {
432 ThrowJVMError("JVMDebug::Attach expect", expect);
438 // Unknown 07 ???
440 void JVMDebug::Unknown07()
442 uint16_t expect = 0;
444 Data command(-1, 8), response;
445 JVMPacket packet(command, response);
447 // Send the command packet
448 packet.Unknown07();
449 m_socket->Packet(packet);
450 expect = packet.Size();
452 if (expect == 0)
453 return;
455 // Read the data stream
456 m_socket->ReceiveData(response);
458 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
460 // Check the size read into the previous packet
461 if( expect != bytereceived ) {
462 ThrowJVMError("JVMDebug::Attach expect", expect);
468 // Unknown 08 ???
470 void JVMDebug::Unknown08()
472 uint16_t expect = 0;
474 Data command(-1, 8), response;
475 JVMPacket packet(command, response);
477 // Send the command packet
478 packet.Unknown08();
479 m_socket->Packet(packet);
480 expect = packet.Size();
482 if (expect == 0)
483 return;
485 // Read the data stream
486 m_socket->ReceiveData(response);
488 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
490 // Check the size read into the previous packet
491 if( expect != bytereceived ) {
492 ThrowJVMError("JVMDebug::Attach expect", expect);
498 // Unknown 09 ???
500 void JVMDebug::Unknown09()
502 uint16_t expect = 0;
504 Data command(-1, 8), response;
505 JVMPacket packet(command, response);
507 // Send the command packet
508 packet.Unknown09();
509 m_socket->Packet(packet);
510 expect = packet.Size();
512 if (expect == 0)
513 return;
515 // Read the data stream
516 m_socket->ReceiveData(response);
518 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
520 // Check the size read into the previous packet
521 if( expect != bytereceived ) {
522 ThrowJVMError("JVMDebug::Attach expect", expect);
528 // Unknown 10 ???
530 void JVMDebug::Unknown10()
532 uint16_t expect = 0;
534 Data command(-1, 8), response;
535 JVMPacket packet(command, response);
537 // Send the command packet
538 packet.Unknown10();
539 m_socket->Packet(packet);
540 expect = packet.Size();
542 if (expect == 0)
543 return;
545 // Read the data stream
546 m_socket->ReceiveData(response);
548 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
550 // Check the size read into the previous packet
551 if( expect != bytereceived ) {
552 ThrowJVMError("JVMDebug::Attach expect", expect);
558 // Get Status
560 bool JVMDebug::GetStatus(int &status)
562 uint16_t expect = 0;
564 Data command(-1, 8), response;
565 JVMPacket packet(command, response);
567 // Send the command packet
568 packet.GetStatus();
570 m_socket->Packet(packet);
572 expect = packet.Size();
574 if (expect == 0)
575 return false;
577 // Read the data stream
578 m_socket->ReceiveData(response);
580 MAKE_JVMPACKET(dpack, response);
582 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
584 // Check the size read into the previous packet
585 if( expect != bytereceived ) {
586 ThrowJVMError("JVMDebug::GetModulesList expect", expect);
589 // Make sure we have a header to read
590 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.status));
592 // Return status
593 status = dpack->u.status;
595 return true;
600 // Wait Status
602 bool JVMDebug::WaitStatus(int &status)
604 uint16_t expect = 0;
606 Data command(-1, 8), response;
607 JVMPacket packet(command, response);
609 // Prepare the command packet
610 packet.GetStatus();
612 try {
613 m_socket->Receive(packet.GetReceive(), 100);
614 } catch (Usb::Timeout &to ) {
615 return false;
618 expect = packet.Size();
620 if (expect == 0)
621 return false;
623 // Read the data stream
624 m_socket->ReceiveData(response);
626 MAKE_JVMPACKET(dpack, response);
628 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
630 // Check the size read into the previous packet
631 if( expect != bytereceived ) {
632 ThrowJVMError("JVMDebug::GetModulesList expect", expect);
635 // Make sure we have a header to read
636 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.status));
638 // Return status
639 status = dpack->u.status;
641 return true;
646 // Get Console Message
647 // Sample, display the output of System.out.println(...) and all JVM messages output
649 // Return the length message or -1 if message doesn't exit or is empty
651 int JVMDebug::GetConsoleMessage(std::string &message)
653 uint16_t expect = 0;
655 Data command(-1, 8), response;
656 JVMPacket packet(command, response);
658 // Send the command packet
659 packet.GetConsoleMessage();
661 m_socket->Packet(packet);
663 expect = packet.Size();
665 if (expect == 0)
666 return -1;
668 // Read the data stream
669 m_socket->ReceiveData(response);
671 MAKE_JVMPACKET(dpack, response);
673 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
675 // Check the size read into the previous packet
676 if( expect != bytereceived ) {
677 ThrowJVMError("JVMDebug::GetModulesList expect", expect);
680 // Make sure we have a header to read
681 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.msglength));
683 // Length of message
684 uint16_t length = be_btohs(dpack->u.msglength);
686 if (length == 0)
687 return -1;
689 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.msglength) + length);
691 // Parse the ID of nextmodules
692 const unsigned char *ptr = (response.GetData() + SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.msglength));
694 message.assign((char *) ptr, length);
696 return length;
701 // Get list of Java modules
703 void JVMDebug::GetModulesList(JVMModulesList &mylist)
705 uint32_t size = 0;
706 uint32_t count = 0;
707 uint32_t offset = 0;
708 uint16_t expect = 0;
710 Data command(-1, 8), response;
711 JVMPacket packet(command, response);
713 do {
714 // Send the command packet
715 packet.GetModulesList(offset);
717 m_socket->Packet(packet);
719 expect = packet.Size();
721 if (expect == 0)
722 break;
724 // Read the data stream
725 m_socket->ReceiveData(response);
727 MAKE_JVMPACKET(dpack, response);
729 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
731 // Check the size read into the previous packet
732 if( expect != bytereceived ) {
733 ThrowJVMError("JVMDebug::GetModulesList expect", expect);
736 // Make sure there's enough for packet header + module list
737 // header + 4 bytes of ID
738 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMMODULES_LIST_HEADER_SIZE + 4);
740 // Number of modules entries in the list
741 count = be_btohl(dpack->u.moduleslist.nbr);
743 // Size of modules list
744 // I remove the header of packet (contains the field 'number of modules')
745 // and 4 bytes (contains the field 'ID of next modules')
746 size = bytereceived - SB_JVMMODULES_LIST_HEADER_SIZE - 4;
748 // Parse the modules list
749 mylist.Parse(Data(response.GetData() + SB_JVMPACKET_HEADER_SIZE + SB_JVMMODULES_LIST_HEADER_SIZE, size));
751 // Parse the ID of nextmodules
752 size_t id_offset = SB_JVMPACKET_HEADER_SIZE + SB_JVMMODULES_LIST_HEADER_SIZE + size;
753 const unsigned char *ptr = (response.GetData() + id_offset);
754 CheckSize(response, id_offset + sizeof(uint32_t));
755 uint32_t *poffset = (uint32_t *) ptr;
757 offset = be_btohl(*poffset);
758 } while (offset != 0); // When the offset != 0, there is some modules
763 // Get list of Java threads
765 void JVMDebug::GetThreadsList(JVMThreadsList &mylist)
767 uint32_t size = 0;
768 uint32_t count = 0;
769 uint16_t expect = 0;
771 Data command(-1, 8), response;
772 JVMPacket packet(command, response);
774 // Send the command packet
775 packet.GetThreadsList();
777 m_socket->Packet(packet);
779 expect = packet.Size();
781 if (expect == 0)
782 return;
784 // Read the data stream
785 m_socket->ReceiveData(response);
787 MAKE_JVMPACKET(dpack, response);
789 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
791 // Check the size read into the previous packet
792 if( expect != bytereceived ) {
793 ThrowJVMError("JVMDebug::GetThreadsList expect", expect);
796 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMTHREADS_LIST_HEADER_SIZE);
798 // Number of threads entries in the list
799 count = be_btohl(dpack->u.threadslist.nbr);
801 // Size of threads list
802 // I remove the header of packet (contains the field 'number of threads')
803 size = bytereceived - SB_JVMTHREADS_LIST_HEADER_SIZE;
805 // Parse the threads list
806 mylist.Parse(Data(response.GetData() + SB_JVMPACKET_HEADER_SIZE + SB_JVMTHREADS_LIST_HEADER_SIZE, size));
808 // Complete threads list
809 JVMThreadsList::iterator b = mylist.begin();
810 for( ; b != mylist.end(); b++ ) {
811 JVMThreadsEntry entry = (*b);
813 // 1°/
814 // Send the command packet
815 packet.Unknown11(entry.Id);
817 m_socket->Packet(packet);
819 expect = packet.Size();
821 if (expect == 0)
822 return;
824 // Read the data stream
825 m_socket->ReceiveData(response);
827 MAKE_JVMPACKET(dpack, response);
829 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
831 // Check the size read into the previous packet
832 if( expect != bytereceived ) {
833 ThrowJVMError("JVMDebug::GetThreadsList (1) expect", expect);
836 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMUNKNOWN01_HEADER_SIZE);
838 // Save values
839 entry.Byte = dpack->u.unknown01.byte;
840 entry.Address = be_btohl(dpack->u.unknown01.address);
842 // 2°/
843 if (entry.Address != 0) {
844 // Send the command packet
845 packet.Unknown12(entry.Address);
847 m_socket->Packet(packet);
849 expect = packet.Size();
851 if (expect == 0)
852 return;
854 // Read the data stream
855 m_socket->ReceiveData(response);
857 MAKE_JVMPACKET(dpack, response);
859 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
861 // Check the size read into the previous packet
862 if( expect != bytereceived ) {
863 ThrowJVMError("JVMDebug::GetThreadsList (2) expect", expect);
867 // Save values
868 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.address));
869 entry.Unknown01 = be_btohl(dpack->u.address);
871 else
872 entry.Unknown01 = 0;
874 // 3°/
875 // Send the command packet
876 packet.Unknown13(entry.Id);
878 m_socket->Packet(packet);
880 expect = packet.Size();
882 if (expect == 0)
883 return;
885 // Read the data stream
886 m_socket->ReceiveData(response);
888 dpack = (const Protocol::JVMPacket *) response.GetData();
890 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
892 // Check the size read into the previous packet
893 if( expect != bytereceived ) {
894 ThrowJVMError("JVMDebug::GetThreadsList (2) expect", expect);
897 // Save values
898 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.address));
899 entry.Unknown02 = be_btohl(dpack->u.address);
901 // 4°/
902 // Send the command packet
903 packet.Unknown14(entry.Id);
905 m_socket->Packet(packet);
907 expect = packet.Size();
909 if (expect == 0)
910 return;
912 // Read the data stream
913 m_socket->ReceiveData(response);
915 dpack = (const Protocol::JVMPacket *) response.GetData();
917 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
919 // Check the size read into the previous packet
920 if( expect != bytereceived ) {
921 ThrowJVMError("JVMDebug::GetThreadsList (2) expect", expect);
924 // Save values
925 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMUNKNOWN02_HEADER_SIZE);
926 entry.Unknown03 = be_btohl(dpack->u.unknown02.address1);
927 entry.Unknown04 = be_btohl(dpack->u.unknown02.address2);
929 // 5°/
930 // Send the command packet
931 packet.Unknown15(entry.Id);
933 m_socket->Packet(packet);
935 expect = packet.Size();
937 if (expect == 0)
938 return;
940 // Read the data stream
941 m_socket->ReceiveData(response);
943 dpack = (const Protocol::JVMPacket *) response.GetData();
945 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
947 // Check the size read into the previous packet
948 if( expect != bytereceived ) {
949 ThrowJVMError("JVMDebug::GetThreadsList (2) expect", expect);
952 // Save values
953 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMUNKNOWN02_HEADER_SIZE);
954 entry.Unknown05 = be_btohl(dpack->u.unknown02.address1);
955 entry.Unknown06 = be_btohl(dpack->u.unknown02.address2);
957 // Save...
958 (*b) = entry;
964 // Go
966 void JVMDebug::Go()
968 uint16_t expect = 0;
970 Data command(-1, 8), response;
971 JVMPacket packet(command, response);
973 // Send the command packet
974 packet.Go();
975 m_socket->Packet(packet);
976 expect = packet.Size();
978 while (expect == 0) {
979 m_socket->Receive(packet.GetReceive());
981 expect = packet.Size();
984 // Read the data stream
985 m_socket->ReceiveData(response);
987 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
989 // Check the size read into the previous packet
990 if( expect != bytereceived ) {
991 ThrowJVMError("JVMDebug::Attach expect", expect);
997 // Stop
999 void JVMDebug::Stop()
1001 uint16_t expect = 0;
1003 Data command(-1, 8), response;
1004 JVMPacket packet(command, response);
1006 // Send the command packet
1007 packet.Stop();
1008 m_socket->Packet(packet);
1009 expect = packet.Size();
1011 while (expect == 0) {
1012 m_socket->Receive(packet.GetReceive());
1014 expect = packet.Size();
1017 // Read the data stream
1018 m_socket->ReceiveData(response);
1020 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
1022 // Check the size read into the previous packet
1023 if( expect != bytereceived ) {
1024 ThrowJVMError("JVMDebug::Attach expect", expect);
1029 }} // namespace Barry::Mode